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

const statusOptions = [
  { value: 0, label: '禁用', type: "danger" },
  { value: 1, label: '启用', type: "success" },
]

const columns = [
  {
    prop: "id",
    label: "ID",
    minWidth: "40px"
  },
  {
    prop: "exec_name",
    label: "脚本名称",
    minWidth: "115px"
  },
  {
    prop: "updatetime",
    label: "状态更新时间",
    minWidth: "155px"
  },

  {
    prop: "createtime",
    label: "创建时间",
    minWidth: "115px"
  },
  {
    prop: 'status',
    label: '状态',
    cellRenderer({ row }) {
      const s = statusOptions.find(({ value }) => String(value) === String(row.status))
      return h(ElTag, {
        type: s.type || ''
      }, {
        default: () => s.label || '--'
      })
    }
  },
  {
    label: "操作",
    fixed: "right",
    width: 90,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  columns,
  showTitle: false,
  superUserNoAction: false,
  apis: { httpList: apis.list }
};

export default contentConfig;
