import { ContentConfig } from "/@/components/PageContent";

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";

import {
  httpAdd,
  httpList,
  httpUpdate,
  httpDelete,
  httpStatus
} from "/@/api/parameter/setProcess";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center",
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "ID",
    prop: "id"
  },
  {
    label: "流程名称",
    prop: "process_name"
  },
  {
    label: "流程值",
    prop: "process_type"
  },
  {
    label: "状态",
    prop: "status",
    cellRenderer({ row }) {
      return h(
        ElTag,
        {
          type: row.status === "0" ? "danger" : "success"
        },
        {
          default: () => (row.status === "0" ? "禁用" : "启用")
        }
      );
    }
  },
  {
    label: "创建人",
    prop: "creater"
  },
  {
    label: "创建时间",
    prop: "addtime",
    formatter: ({ createTime }) =>
      dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 150,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "流程设置",
  notNeedCompanyFilter: true,
  columns,
  apis: {
    httpAdd,
    httpList,
    httpUpdate,
    httpStatus,
    httpDelete
  }
};

export default contentConfig;
