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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";

import { hasAccountOptions, orderTypeCgOptions, purchPayReliveStatusOptions } from "/@/utils/status";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";

const columns = [
  // {
  //   type: "selection",
  //   width: 40,
  // align: "center",
  //   hide: ({ checkList }) => !checkList.includes("勾选列")
  // },
  // {
  //   label: "序号",
  //   type: "index",
  //   minWidth: 60,
  //   align: "left",
  //   hide: ({ checkList }) => !checkList.includes("序号列")
  // },
  {
    label: "付款解除编码",
    prop: "returnCode",
    width: 150,
    align: "left"
  },
  {
    label: "对账付款编码",
    prop: "orderCode",
    width: 150,
    align: "left"
  },

  {
    label: "对账编码",
    prop: "payNo",
    width: 150,
    align: "left"
  },
  {
    label: "状态",
    prop: "status",
    width: 140,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            purchPayReliveStatusOptions.find(
              s => String(row.status) === s.value
            )?.label
        }
      )
  },
  {
    label: '业务类型',
    width: 95,
    ...renderProp(orderTypeCgOptions, 'is_comon')
  },
  {
    label: "供应商端",
    prop: "has_account",
    width: 80,
    ...renderProp(hasAccountOptions, "has_account")
  },
  // {
  //   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: 80,
    align: "left"
  },
  {
    label: "申请时间",
    width: 140,
    prop: "addtime",
    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",
  showDelete: ({ dstatus }) => Number(dstatus) !== 3,
  superUserNoAction: true,
  apis: {
    httpList,
    httpDelete,
    httpAdd: true
  }
};

export default contentConfig;
