import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/purchase/ticketReturn";

import dayjs from "dayjs";
import { invType_options, status_options } from "./configs";
import { h } from "vue";
import { ElTag } from "element-plus";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "id",
    prop: "id"
  },
  {
    label: "发票类型",
    prop: "invoiceType_cn"
  },
  {
    label: "发票状态",
    prop: "invStatus_cn"
  },
  {
    label: "发票号码",
    prop: "invoiceNumber"
  },
  {
    label: "录入方式",
    prop: "invType",
    formatter: ({ invType }) =>
      invType_options.find(item => item.value === invType)?.label
  },
  {
    label: "录入人",
    prop: "apply_name"
  },
  {
    label: "状态",
    prop: "status",
    width: 160,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () => status_options.find(s => row.status === s.value)?.label
        }
      )
  },
  {
    label: "开票日期",
    prop: "open_time",
    formatter: ({ open_time }) =>
      open_time ? dayjs(open_time).format("YYYY-MM-DD HH:mm:ss") : ""
  },
  {
    label: "创建时间",
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 60,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "企业客户",
  columns,
  apis: {
    httpList
  },
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"]
};

export default contentConfig;
