import { ContentConfig } from "/@/components/PageContent";
import { httpList, httpDel } from "/@/api/purchase/orderRecord";

import { h } from "vue";
import dayjs from "dayjs";
import { ElTag } from "element-plus";
import { statusOptions } 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: "apply_name",
    minWidth: 180,
    align: "left"
  },
  {
    label: "总额款",
    prop: "total_fee",
    minWidth: 180,
    align: "total_fee"
  },
  {
    label: "已付款金额",
    prop: "apay_fee",
    minWidth: 180,
    align: "left"
  },
  {
    label: "付款中金额",
    prop: "pay_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: "status",
    minWidth: 120,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () => statusOptions.find(s => row.status === s.value)?.label
        }
      )
  },
  {
    label: "申请时间",
    minWidth: 180,
    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,
  deleteProp: "payNo",
  apis: {
    httpList,
    httpDelete: httpDel
  },
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"]
};

export default contentConfig;
