import { h } from "vue";

import {
  httpList,
  httpDelete,
  httpStatus,
  httpUpdate
} from "/@/api/supplierManage/supplierAccoutQuery";

import dayjs from "dayjs";
import { ContentConfig } from "/@/components/PageContent";
import { ElTag } from "element-plus";
import { renderIconLabelLeft } from "/@/utils/columnRenderHelper";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center",
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    minWidth: 60,
    align: "left",
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "手机号",
    prop: "mobile",
    width: 120,
    align: "left"
  },
  {
    label: "真实姓名",
    prop: "nickname",
    minWidth: 150
  },
  {
    label: "状态",
    prop: "status",
    width: 120,
    cellRenderer: ({ row }) => {
      return h(
        ElTag,
        {
          type: String(row.status) === "1" ? "success" : "danger"
        },
        {
          default: () => (String(row.status) === "1" ? "启用" : "禁用")
        }
      );
    }
  },
  {
    label: "角色",
    prop: "role_name",
    minWidth: 150,
    align: "left"
  },
  // {
  //   label: "公司编码",
  //   prop: "companyCode",
  //   width: 150,
  //   align: "left"
  // },
  {
    label: "公司名称",
    prop: "companyName",
    minWidth: 180,
    align: "left",
    ...renderIconLabelLeft('companyCode','companyName','公司编码:')
  },
  {
    label: "创建时间",
    width: 140,
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 80,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "公司账号角色查询",
  columns,
  deleteProp: "payNo",
  notNeedCompanyFilter: true,
  statusRowProp: ({ companyCode: companyNo }) => ({ companyNo }),
  apis: {
    httpAdd: true,
    httpDelete,
    // httpStatus,
    httpUpdate,
    httpList
  }
};

export default contentConfig;
