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

import dayjs from "dayjs";
import { payStatusOptions, invStatusOptions } from "./_options";
import { ContentConfig } from "/@/components/PageContent";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";
import { orderRecordStatusOptions, orderTypeCgOptions } from "/@/utils/status";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center",
    fixed: 'left'
  },
  {
    label: "序号",
    type: "index",
    minWidth: 60,
    align: "left", 
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "对账编码",
    prop: "payNo",
    width: 150,
    align: "left"
  },
  {
    label: "总额款",
    prop: "total_fee",
    width: 110,
    align: "total_fee"
  },
  {
    label: "状态",
    prop: "status",
    width: 140,
    ...renderProp(orderRecordStatusOptions)
  },
  {
    label: '业务类型',
    width: 95,
    ...renderProp(orderTypeCgOptions, 'is_comon')
  },
  {
    label: '付款状态',
    prop: 'pay_status',
    width: 80,
    transform: pay_status =>
      payStatusOptions.find(s => pay_status === s.value)?.label || "--",
    ...renderProp(payStatusOptions, 'pay_status')
  },
  {
    label: '付款标签金额',
    prop: 'pay_tag_fee',
    width: '100px'
  },
  {
    label: '回票状态',
    prop: 'inv_status',
    width: 80,
    transform: inv_status =>
      payStatusOptions.find(s => inv_status === s.value)?.label || "--",
    ...renderProp(invStatusOptions, 'inv_status')
  },
  {
    label: '回票标签金额',
    prop: 'inv_tag_fee',
    width: '100px'
  },
  // {
  //   label: "卖方公司编码",
  //   prop: "supplierNo",
  //   width: 150,
  //   align: "left"
  // },
  {
    label: "卖出方公司",
    prop: "supplierName",
    minWidth: 180,
    align: "left",
    ...renderIconLabelLeft('supplierNo','supplierName','卖出方公司编码:')
  },
  {
    label: "买入方公司",
    prop: "companyNo",
    minWidth: 180,
    align: "left",
      ...renderIconLabelLeft('companyNo','companyName','买入方公司:')
  },
  // {
  //   label: "买方公司名称",
  //   prop: "companyName",
  //   minWidth: 180,
  //   align: "left"
  // },
  {
    label: "申请人",
    prop: "apply_name",
    width: 70,
    align: "left"
  },
  {
    label: "申请时间",
    width: 140,
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 140,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "订单对账",
  columns,
  deleteProp: "payNo",
  apis: {
    httpList,
    httpDelete: httpDel,
    httpAdd: true
  },
  companyProp: "supplierNo",
  superUserNoAction: true,
  listNoRelation: true,
  showDelete: ({ status }) => false,
};

export default contentConfig;
