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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import { hasAccountOptions, orderTypeCgOptions, sendPurchPayStatusOptions } from "/@/utils/status";
import { renderIconLabelLeft, renderProp } 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: "dzNo",
    width: 150,
    align: "left"
  },
  {
    label: "对账编码",
    prop: "payNo",
    width: 150
  },
  {
    label: "状态",
    prop: "dstatus",
    width: 130,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            sendPurchPayStatusOptions.find(s => String(row.dstatus) === s.value)
              ?.label
        }
      )
  },
  {
    label: "本次付款金额",
    prop: "dpay_fee",
    width: 110,
    align: "left"
  },
  {
    label: "总额款",
    prop: "total_fee",
    width: 110
  },
  // {
  //   label: "卖方公司编码",
  //   prop: "supplierNo",
  //   width: 150,
  //   align: "left"
  // },
  {
    label: "物流供应商",
    prop: "supplierName",
    minWidth: 180,
    ...renderIconLabelLeft("supplierNo", "supplierName", "物流供应商编码:")
  },
  // {
  //   label: "买方公司编码",
  //   prop: "companyNo",
  //   width: 150
  // },
  {
    label: "业务公司",
    prop: "companyName",
    minWidth: 180,
    ...renderIconLabelLeft("companyNo", "companyName", "业务公司名称:")
  },
  {
    label: "申请人",
    prop: "apply_name",
    width: 90,
    align: "left"
  },
  {
    label: "回执时间",
    width: 140,
    prop: "return_time"
  },
  {
    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,
  superUserNoAction: true,
  listNoRelation: true,
  companyProp: 'supplierNo',
  apis: {
    httpList: (data) => httpList({ ...data, pay_type: "2" }),
    httpAdd: true,
    httpDelete
  }
};

export default contentConfig;
