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

import { h } from "vue";
import { ElTag } from "element-plus";
import { RETRUN_STATUS } from "/@/utils/details/refund";
import { refund_type } from "./search.config";
import {
  xs_order_source_options,
  xs_order_type_options
} from "/@/utils/status";
import { renderIconLabelLeft } from "/@/utils/columnRenderHelper";


const typeOptions = [
  { value: 0, label: '手动创建', type: 'info' },
  { value: 1, label: '系统同步' }
]

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: "150px"
  },

  {
    label: "资金认领编码",
    prop: "logNo",
    width: 150
  },

  {
    label: "销售订单编码",
    prop: "orderCode",
    width: "150px"
  },
  {
    label: "资金编码",
    prop: "tradNo",
    width: 150
  },
  {
    label: "退款金额",
    width: "110px",
    prop: "cancel_fee"
  },
  {
    label: '操作来源',
    width: 120,
    cellRenderer: ({ row }) => {
      return h(ElTag, {
        type: row.tag_type == '1' ? 'info' : ''
      }, {
        default: () =>
          typeOptions.find(s => s.value == row.tag_type)?.label || "--"
      });
    }
  },
  {
    label: '关联资金认领编号',
    width: 120,
    prop: 'relaNo'
  },
  {
    label: "状态",
    prop: "status",
    width: 100,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () =>
          RETRUN_STATUS.find(s => s.value === String(row.status))?.label || "--"
      });
    }
  },
  {
    label: "订单来源",
    prop: "qrdSource",
    width: "100px",
    cellRenderer({ row }) {
      return h(ElTag, null, {
        default: () =>
          xs_order_source_options.find(s => s.value == row.qrdSource)?.label
      });
    }
  },
  {
    label: "商品类型",
    prop: "qrdType",
    width: "100px",
    cellRenderer({ row }) {
      return h(ElTag, null, {
        default: () =>
          xs_order_type_options.find(s => s.value == row.qrdType)?.label
      });
    }
  },
  {
    label: "商品名称",
    prop: "goodName",
    minWidth: "160px",
    ...renderIconLabelLeft('goodNo','goodName','商品编码:')
  },
  {
    label: "平台名称",
    prop: "platName",
    width: "100px"
  },
  {
    label: "客户名称",
    width: "180px",
    prop: "customerName",
    // _slot_:'customer'
    ...renderIconLabelLeft('customerNo','customerName','客户编码:')
  },

  {
    label: "申请人",
    prop: "apply_name",
    width: "80px"
  },
  {
    label: "添加时间",
    prop: "addtime",
    width: "140px"
  },
  {
    label: "操作",
    fixed: "right",
    width: 50,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "退款申请管理",
  superUserNoAction: true,
  columns,
  apis: {
    httpList,
    httpAdd
  }
};

export default contentConfig;
