import Api from "@/api/system/log";
import type { IContentConfig } from "@/components/CURD/types";
import dayjs from "dayjs";
import { returnOptions } from './config'
const contentConfig: IContentConfig = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  pagination: {
    background: true,
    layout: "prev,pager,next,jumper,total,sizes",
    pageSize: 20,
    pageSizes: [10, 20, 30, 50],
  },
  indexAction: function (params) {
    let [startTime, endTime] = params.createTime || []
    if (startTime && endTime) {
      delete params.createTime;
      return Api.getList({ ...params, startTime: dayjs(startTime).format('YYYY-MM-DD'), endTime: dayjs(endTime).format('YYYY-MM-DD') });
    }
    return Api.getList(params);
  },
  pk: "id",
  toolbar: [
    {
      auth: '',
      text: '清空',
      name: 'clear',
      icon: 'delete',
      type: 'danger'
    },

  ],
  defaultToolbar: ["refresh", "filter", "search"],
  cols: [
    // { type: "selection", width: 50, align: "center" },
    {
      label: "用户名",
      align: "center",
      prop: "createUserName",
    },
    {
      label: "IP来源",
      align: "center",
      prop: "location",
    },
    {
      label: "用户操作",
      align: "center",
      prop: "operation",
    },
    // {
    //   label: "请求Url",
    //   align: "center",
    //   prop: "requestUri",
    // },
    {
      label: "请求耗时",
      align: "center",
      prop: "time",
      templet: 'custom',
      slotName: 'time'
    },
    {
      label: "创建时间",
      align: "center",
      prop: "createTime",
    },
    // {
    //   label: "异常信息",
    //   align: "center",
    //   prop: "errorInfo",
    // }
    // , {
    //   label: "日志类型",
    //   align: "center",
    //   prop: "type",
    //   templet: 'custom',
    //   slotName: 'options'
    // },

  ],
};

export default contentConfig;
