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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import { ticketReturnReliveStatusOptions } from "/@/utils/status";
// import { statusOptions } from "./_opitons";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center",
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "退票申请编码",
    prop: "returnCode",
    width: 150
  },
  {
    label: "对账回票编码",
    prop: "orderCode",
    width: 150
  },
  {
    label: "对账编码",
    prop: "payNo",
    width: 150
  },
  {
    label: '发票号码',
    prop: 'inv_number',
    width: 150
  },
  {
    label: "卖方公司名称",
    prop: "supplierName",
    minWidth: 150
  },
  {
    label: "卖方公司编码",
    prop: "supplierNo",
    width: 150
  },
  {
    label: "买方公司名称",
    prop: "companyName",
    minWidth: 150
  },
  {
    label: "买方公司编码",
    prop: "companyNo",
    width: 150
  },
  {
    label: "状态",
    prop: "status",
    width: 160,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            ticketReturnReliveStatusOptions.find(
              s => String(row.status) === s.value
            )?.label
        }
      )
  },
  {
    label: "退票理由",
    prop: "reason"
  },
  {
    label: "申请人",
    prop: "apply_name",
    width: 80
  },
  {
    label: "创建时间",
    prop: "addtime",
    width: 140,
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    slot: "operation",
    width: 110
  }
];

const contentConfig: ContentConfig = {
  title: "采购回票",
  statusProp: "companyNo",
  columns,
  apis: {
    httpList,
    httpDelete,
    httpAdd: true
  },
  deleteProp: "hpNo",
  superUserNoAction: true,
  delTooltip: "是否撤回采购回票申请",
  companyProp: "supplierNo",
  listNoRelation: true,
  showDelete: ({ status }) => Number(status) !== 6
};

export default contentConfig;
