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

import dayjs from "dayjs";
import { ElTag } from "element-plus";
import { h } from "vue";
import { RETURN_STATUS } from "/@/utils/details/inv-return";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "退票编号",
    prop: "returnCode"
  },
  {
    label: "付款单位名称",
    prop: "buyer_title"
  },
  {
    label: "付款银行名称",
    prop: "buyer_bank"
  },
  {
    label: "付款账号",
    prop: "inv_value"
  },
  {
    label: "收款单位名称",
    prop: "inv_in"
  },
  {
    label: "申请时间",
    prop: "addtime",
    formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "状态",
    prop: "status",
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () => RETURN_STATUS.find(s => s.value === row.status)?.label
      });
    }
  },
  {
    label: "操作",
    fixed: "right",
    width: 80,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "退票申请管理",
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"],
  columns,
  apis: {
    httpList,
    httpAdd
  }
};

export default contentConfig;
