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

import { statusOptions } from "./_options";
import { ContentConfig } from "/@/components/PageContent";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";
import { hasAccountOptions } from "/@/utils/status";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center"
  },
  // {
  //   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,
    transform: status =>
      statusOptions.find(s => status === s.value)?.label || "--",
    ...renderProp(statusOptions)
  },
  {
    label: "供应商端",
    prop: "has_account",
    width: 80,
    ...renderProp(hasAccountOptions, "has_account")
  },
  // {
  //   label: "卖出方公司编码",
  //   prop: "supplierNo",
  //   width: 150,
  //   align: "left",
  // },
  {
    label: "卖出方公司",
    prop: "supplierName",
    minWidth: 160,
    align: "left",
    ...renderIconLabelLeft('supplierNo','supplierName','卖出方公司:')
  },
  // {
  //   label: "买入方公司编码",
  //   prop: "companyNo",
  //   width: 150,
  //   align: "left"
  // },
  {
    label: "买入方公司",
    prop: "companyName",
    minWidth: 180,
    align: "left",
      ...renderIconLabelLeft('companyNo','companyName','买入方公司:')
  },

  {
    label: "申请人",
    prop: "apply_name",
    width: 70,
    align: "left"
  },
  {
    label: "申请时间",
    width: 140,
    prop: "addtime"
  },
  {
    label: "操作",
    fixed: "right",
    width: 135,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "订单对账",
  columns,
  apis: {
    httpList,
    httpAdd: true,
    httpDelete: httpDel
  },
  superUserNoAction: true,
  showDelete: () => false,
  payProps: {
    prop: "payNo",
    type: "1"
  },
  returnProps: {
    prop: "payNo",
    type: "2"
  },
  // { code: "013", name: "添加采购对账付款标签" },
  // { code: "014", name: "添加采购对账回票标签" },
  showPayTagFn: ({ status }, permissions) =>
    String(status) === "2" && permissions.includes("013"),
  showReturnTagFn: ({ status }, permissions) =>
    String(status) === "2" && permissions.includes("014")
};

export default contentConfig;
