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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import { capital_status } from "./configs";
import { CAPITAL_STATUS } from "/@/utils/details/tragelog";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    type: "expand",
    slot: "expand"
  },
  {
    label: "资金编号",
    prop: "tradNo",
    width: 160
  },
  {
    label: "状态",
    prop: "status",
    width: 100,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size
        },
        {
          default: () => {
            const status = row.logNo ? CAPITAL_STATUS : capital_status;
            return status.find(s => row.status === s.value)?.label || "--";
          }
        }
      )
  },
  {
    label: "付款单位账号",
    prop: "trade_account",
    width: 160
  },
  {
    label: "付款银行单位名称",
    prop: "trade_out",
    width: 160
  },
  {
    label: "交易时间",
    prop: "trade_time",
    width: 120,
    cellRenderer: ({ row }) => dayjs(row.trade_time).format("YYYY-MM-DD")
  },
  {
    label: "交易金额",
    prop: "total_fee",
    width: 110
  },
  {
    label: "交易银行",
    prop: "trade_bank",
    width: 130
  },
  {
    label: "收款单位名称",
    prop: "trade_in"
  },
  {
    label: "未认领",
    prop: "balance",
    width: 80
  },
  {
    label: "已认领",
    prop: "used_fee",
    width: 80
  },
  {
    label: "操作",
    fixed: "right",
    width: 60,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "资金认领管理",
  columns,
  apis: {
    httpList
  },
  showExpand: row => row.child.length > 0,
  isTree: true,
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"]
};

export default contentConfig;
