import { ContentConfig } from "/@/components/PageContent";

import { httpList, httpAdd, httpStatus } from "/@/api/reportForm/reportApply";
import { h } from "vue";
import dayjs from "dayjs";
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",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "报表名称",
    prop: "name"
  },
  {
    label: "状态",
    prop: "status",
    width: "80px",
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size,
          type: String(row.status) === "1" ? "success" : "danger"
        },
        {
          default: () => (String(row.status) === "1" ? "启用" : "禁用")
        }
      )
  },
  // {
  //   label: "业务公司编码",
  //   prop: "companyNo",
  //   width: "150px"
  // },
  {
    label: "业务公司",
    prop: "companyName",
    minWidth: '180px',
    ...renderIconLabelLeft('companyNo','companyName','业务公司编码')
  },

  {
    label: "创建人",
    prop: "apply_name",
    width: "80px"
  },
  {
    label: "创建时间",
    prop: "addtime",
    width: "140px",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 100,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "可申请报表",
  superUserNoAction: false,
  showCreate: isSuperUser => isSuperUser,
  showStatus: isSuperUser => isSuperUser,
  columns,
  apis: {
    httpList,
    httpAdd,
    httpStatus
  }
};

export default contentConfig;
