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

import { h } from "vue";
import { ElTag } from "element-plus";
import { hasAccountOptions, orderTypeCgOptions, purchPayStatusOptions } from "/@/utils/status";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";

const columns = [
  {
    label: "对账付款编码",
    prop: "dzNo",
    width: 150,
    align: "left"
  },
  {
    label: "对账编码",
    prop: "payNo",
    width: 150
  },
  {
    label: "供应商端",
    prop: "has_account",
    width: 80,
    ...renderProp(hasAccountOptions, "has_account")
  },
  {
    label: "状态",
    prop: "dstatus",
    width: 140,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            purchPayStatusOptions.find(s => String(row.dstatus) === s.value)
              ?.label
        }
      )
  },
  {
    label: '业务类型',
    width: 95,
    ...renderProp(orderTypeCgOptions, 'is_comon')
  },
  {
    label: "对账总金额",
    prop: "total_fee",
    width: 110
  },
  {
    label: "本次付款金额",
    prop: "dpay_fee",
    width: 110,
    align: "left"
  },
  // {
  //   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"
  },
  {
    label: "操作",
    fixed: "right",
    width: 60,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "采购付款",
  columns,
  deleteProp: "dzNo",
  transformCompany: true,
  companyProp: 'supplierNo',
  showDelete: ({ dstatus }) => Number(dstatus) === 1,
  apis: {
    httpList: (data) => httpOldList({ ...data, noRela: true }),
  }
};

export default contentConfig;
