import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/InvoiceSales/updateInvoice";

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

const columns = [
  {
    label: "开票申请编号",
    prop: "invNo",
    width: 150
  },
  {
    prop: "KPLX",
    width: 90,
    label: "开票类型",
    cellRenderer({ row }) {
      return h(ElTag, {}, {
        default: () => ([{ value: "0", label: "蓝字发票" }, { value: "1", label: '红字发票' }]).find(({ value }) => value === String(row.KPLX))?.label || '--'
      })
    }
  },
  {
    prop: "KPFS",
    width: 80,
    label: "开票方式",
    cellRenderer({ row }) {
      return h(ElTag, {}, {
        default: () => ([{ value: "0", label: "自动" }, { value: "1", label: '手动' }]).find(({ value }) => value === String(row.KPFS))?.label || '--'
      })
    }
  },
  {
    label: "状态",
    prop: "status",
    width: "140px",
    cellRenderer({ row }) {
      return h(ElTag, {}, {
        default: () => ([
          { value: "0", label: "待开票" },
          { value: "1", label: '待返回开票结果' },
          { value: '2', label: "开票成功" },
          { value: "3", label: "数据有误" },
          { value: "4", label: "开票失败" }]).find(({ value }) => value === String(row.status))?.label || '--'
      })
    }
  },
  {
    label: "销售方名称",
    prop: "XHFMC",
    width: 110
  },
  {
    label: "销售方识别号",
    prop: "XHFSBH",
    width: 160,
  },
  {
    label: "购买方识别号",
    prop: "GMFSBH",
    width: 130
  },
  {
    label: "购买方名称",
    prop: "GMFMC",
    width: 100
  },
  {
    label: "开票人",
    prop: "KPR",
    width: 80,
  },
  {
    label: "收款人",
    prop: "SKR",
    width: 80
  },
  {
    label: "复核人",
    prop: "FHR"
  },
  {
    label: "红冲原票代码",
    prop: "YFPDM",
    width: 100
  },
  {
    label: "红冲原票号码",
    prop: "YFPHM",
    width: 100
  },
  {
    label: "红冲原票类型",
    prop: "YFPLX",
    width: 100
  },
  {
    label: "红冲原票开票日期",
    prop: "YFPKPRQ",
    width: 120
  },
  {
    label: "价税合计",
    prop: "JSHJ"
  },
  {
    label: "合计金额",
    prop: "HJJE"
  },
  {
    label: "开票备注",
    prop: "remark",
    width: 120
  },
  {
    label: "添加时间",
    prop: "addtime",
    width: 120
  },
  {
    label: "操作",
    fixed: "right",
    width: 55,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "发票公海池",
  inv: true,
  companyProp: 'companyNo',
  columns,
  apis: {
    httpList
  }
};

export default contentConfig;
