/* eslint-disable prettier/prettier */
import { BeforeRequestType, ContentConfig } from "/@/components/PageContent";
import apis from "./apis";
import { h } from "vue";
import { ElTag } from "element-plus";

const statusOptions = [
  { value: 1, label: '待执行', type: "info" },
  { value: 2, label: '执行完成', type: "success" },
  { value: 3, label: '执行失败', type: 'danger' },
]

const exceTypeOptions = [
  { value: 1, label: '立即执行', type: "" },
  { value: 2, label: '延迟执行', type: "warning" },
]

const columns = [
  {
    prop: "exec_name",
    label: "业务表名称",
    minWidth: "115px"
  },
  {
    prop: "start",
    label: "数据开始时间",
    minWidth: "155px"
  },
  {
    prop: "end",
    label: "数据结束时间",
    minWidth: "155px"
  },
  {
    prop: "updatetime",
    label: "状态更新时间",
    minWidth: "155px"
  },

  {
    prop: "createtime",
    label: "创建时间",
    minWidth: "115px"
  },
  {
    prop: 'exce_type',
    label: '执行类型',
    cellRenderer({ row }) {
      const s = exceTypeOptions.find(({ value }) => String(value) === String(row.exec_type))
      return h(ElTag, {
        type: s.type || ''
      }, {
        default: () => s.label || '--'
      })
    }
  },
  {
    prop: 'status',
    label: '状态',
    cellRenderer({ row }) {
      const s = statusOptions.find(({ value }) => String(value) === String(row.status))
      return h(ElTag, {
        type: s.type || ''
      }, {
        default: () => s.label || '--'
      })
    }
  },
  // {
  //   prop: "departName",
  //   label: "部门名称",
  //   minWidth: "155px"
  // },
  // {
  //   prop: "companyName",
  //   label: "业务公司名称",
  //   minWidth: "155px"
  // },
  {
    prop: "apply_name",
    label: "申请人",
    minWidth: "80px"
  },
  {
    label: "操作",
    fixed: "right",
    width: 90,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  columns,
  showTitle: false,
  superUserNoAction: false,
  apis: {
    httpList: (params = {}) => apis.list({ ...params, companyNo: 'GS2302231125079621' })
  }
};

export default contentConfig;
