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

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

const columns = [
  {
    type: "selection",
    minWidth: 55,
    align: "left",
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    minWidth: 60,
    align: "left",
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "对账编号",
    prop: "payNo",
    minWidth: 180,
    align: "left"
  },
  {
    label: "供应商编号",
    prop: "supplierNo",
    minWidth: 180,
    align: "left"
  },
  // {
  //   label: "供应商名称",
  //   prop: "supplierName",
  //   minWidth: 180,
  //   align: "left"
  // },
  {
    label: "业务公司名称",
    prop: "companyName",
    minWidth: 180
  },
  {
    label: "总额款",
    prop: "total_fee",
    minWidth: 180
  },
  {
    label: "本次付款金额",
    prop: "dpay_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "已付款金额",
    prop: "apay_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "待付款金额",
    prop: "wpay_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "已回票金额",
    prop: "ainv_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "未回票金额",
    prop: "winv_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "状态",
    prop: "dstatus",
    minWidth: 120,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            paymentOptions.find(s => row.dstatus === s.value)?.label
        }
      )
  },
  {
    label: "申请时间",
    minWidth: 180,
    prop: "createTime",
    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",
  apis: {
    httpList,
    httpDelete
  },
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"]
};

export default contentConfig;
