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 {
  hasAccountOptions,
  orderTypeCgOptions,
  sendTicketReturnReliveStatusOptions
} from "/@/utils/status";
import { renderIconLabelLeft, renderProp } from "/@/utils/columnRenderHelper";

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: "has_account",
    width: 80,
    ...renderProp(hasAccountOptions, "has_account")
  },
  {
    label: "状态",
    prop: "status",
    width: 120,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () =>
            sendTicketReturnReliveStatusOptions.find(
              s => String(row.status) === s.value
            )?.label
        }
      )
  },
  // {
  //   label: "卖方公司编码",
  //   prop: "supplierNo",
  //   width: 150
  // },
  {
    label: "物流供应商",
    prop: "supplierName",
    minWidth: 160,
    ...renderIconLabelLeft('supplierNo', 'supplierName', '物流供应商编码:')
  },
  {
    label: "业务公司",
    prop: "companyNo",
    minWidth: 160,
    ...renderIconLabelLeft('companyNo', 'companyName', '业务公司编码:')
  },
  // {
  //   label: "买方公司名称",
  //   prop: "companyName",
  //   minWidth: 160
  // },

  {
    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: "采购回票",
  statusProp: "companyNo",
  columns,
  apis: {
    httpList: (data) => httpList({ ...data, pay_type: '2' }),
    httpDelete,
    httpAdd: true
  },
  deleteProp: "hpNo",
  superUserNoAction: true,
  delTooltip: "是否撤回采购回票申请",
  showDelete: ({ status }) => Number(status) !== 6
};

export default contentConfig;
