import { ContentConfig } from "/@/components/PageContent";
import { httpList, httpDelete } from "/@/api/purchase/purchPayRelive";

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import { purchPayReliveStatusOptions } from "/@/utils/status";

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: "returnCode",
    width: 150,
    align: "left"
  },
  {
    label: "对账编码",
    prop: "payNo",
    width: 150,
    align: "left"
  },
  {
    label: "卖方公司编码",
    prop: "supplierNo",
    width: 150,
    align: "left"
  },
  {
    label: "买方公司名称",
    prop: "companyName",
    minWidth: 180
  },
  {
    label: "买方公司编码",
    prop: "companyNo",
    width: 150
  },
  {
    label: "买方公司名称",
    prop: "companyNo",
    minWidth: 180
  },
  {
    label: "状态",
    prop: "status",
    minWidth: 130,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            purchPayReliveStatusOptions.find(
              s => String(row.status) === s.value
            )?.label
        }
      )
  },
  {
    label: "申请人",
    prop: "apply_name",
    width: 90,
    align: "left"
  },
  {
    label: "申请时间",
    width: 140,
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 100,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "采购付款",
  columns,
  deleteProp: "dzNo",
  showDelete: ({ dstatus }) => Number(dstatus) !== 3,
  companyProp: "supplierNo",
  superUserNoAction: true,
  listNoRelation: true,
  apis: {
    httpList,
    httpDelete,
    httpAdd: true
  }
};

export default contentConfig;
