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

import {
  httpList,
  httpAdd,
  httpUpdate,
  httpDelete,
  httpStatus
} from "/@/api/parameter/tagManage";

import { h } from "vue";
import dayjs from "dayjs";
import { ElTag } from "element-plus";
import { tag_type } from "./_options";
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: "companyNo",
  //   width: "150px"
  // },
  {
    label: "业务公司",
    prop: "companyName",
    width: "160px",
    ...renderIconLabelLeft('companyNo','companyName','业务公司编码:','companyNo')
  },
  {
    label: "标签类型",
    prop: "type",
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () => tag_type.find(s => String(row.type) === s.value)?.label
        }
      )
  },
  {
    label: "状态",
    prop: "status",
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size,
          type: String(row.status) === "1" ? "success" : "danger"
        },
        {
          default: () => (String(row.status) === "1" ? "启用" : "禁用")
        }
      )
  },
  {
    label: "标签名称",
    prop: "tag_name"
  },
  {
    label: "申请人",
    prop: "apply_name"
  },
  {
    label: "创建时间",
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 150,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "公司标签管理",
  superUserNoAction: true,
  columns,
  apis: {
    httpList,
    httpAdd,
    httpUpdate,
    httpStatus,
    httpDelete
  }
};

export default contentConfig;
