import { ContentConfig } from "/@/components/PageContent";
import {
  httpList,
  httpDelete,
  httpStatus,
  httpAdd,
  httpEdit as httpUpdate
} from "/@/api/system/setBtn";
import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";

const columns = [
  {
    type: "selection",
    width: 40,
    align: "center",
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    minWidth: 60,
    align: "left",
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "按钮名称",
    prop: "action_name",
    minWidth: 180,
    align: "left"
  },
  {
    label: "状态",
    prop: "status",
    minWidth: 80,
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size,
          type: String(row.status) === "1" ? "success" : "danger"
        },
        {
          default: () => (row.status + "" === "0" ? "禁用" : "启用")
        }
      )
  },
  {
    label: "创建时间",
    minWidth: 180,
    prop: "addtime"
  },
  {
    label: "操作",
    fixed: "right",
    minWidth: 140,
    slot: "operation"
  }
];

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

export default contentConfig;
