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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import {
  hasAccountOptions,
  orderTypeCgOptions,
  ticketReturnReliveStatusOptions
} from "/@/utils/status";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";

const columns = [
  {
    label: "回票解除编码",
    prop: "returnCode",
    width: 150
  },
  {
    label: "对账回票编码",
    prop: "orderCode",
    width: 150
  },
  {
    label: "发票编码",
    prop: "payNo",
    width: 150
  },
  {
    label: '发票号码',
    prop: 'invoice_number',
    width: 150
  },
  {
    label: "状态",
    prop: "status",
    width: 120,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            ticketReturnReliveStatusOptions.find(
              s => String(row.status) === s.value
            )?.label
        }
      )
  },
  {
    label: "卖出方公司",
    prop: "supplierName",
    minWidth: 160,
    ...renderIconLabelLeft('supplierNo','supplierName','卖出方公司编码:')
  },
  {
    label: "买入方公司",
    prop: "companyNo",
    minWidth: 160,
    ...renderIconLabelLeft('companyNo','companyName','买入方公司编码:')
  },
  {
    label: "退票理由",
    prop: "reason",
    minWidth: 160,
  },
  {
    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: "采购回票",
  companyProp: "supplierNo",
  columns,
  apis: {
    httpList,
    httpDelete,
    httpAdd: true
  },
  deleteProp: "hpNo",
  delTooltip: "是否撤回采购回票申请",
  showDelete: ({ status }) => Number(status) !== 6
};

export default contentConfig;
