import { listDictModel } from '/@/api/common';
import { DescItem } from '/@/components/Description';
import { BasicColumn, FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '操作名称',
    dataIndex: 'opName',
  },
  {
    title: '用户IP',
    dataIndex: 'userIp',
  },
  {
    title: '用户地址',
    dataIndex: 'loginLocation',
  },
  // {
  //   title: '类名称',
  //   dataIndex: 'javaClass',
  // },
  // {
  //   title: '方法名称',
  //   dataIndex: 'javaMethod',
  // },
  {
    title: '操作日志类型',
    dataIndex: 'type',
  },
  {
    title: '操作时间',
    dataIndex: 'opTime',
  },
  {
    title: '执行时长',
    dataIndex: 'duration',
  },
  {
    title: '操作用户',
    dataIndex: 'opUser',
  },
  // {
  //   title: '请求参数',
  //   dataIndex: 'requestArgs',
  // },
  {
    title: '浏览器UserAgent',
    dataIndex: 'userAgent',
  },
  // {
  //   title: '响应结果',
  //   dataIndex: 'resultJson',
  // },
];

// 表单列定义
export const searchFormSchema: FormSchema[] = [
  {
    label: '',
    field: 'type',
    component: 'ApiRadioGroup',
    componentProps: ({ tableAction }) => {
      return {
        api: listDictModel,
        isBtn: true,
        params: {
          dictCode: 'sys_log_type',
        },
        onchange: (e: any) => {
          console.log('e:::::::::', e);
          const { reload } = tableAction;
          reload();
        },
      };
    },
    defaultValue: 'oper',
  },
  {
    label: '操作名称',
    field: 'opName',
    component: 'Input',
    componentProps: {
      placeholder: '请输入操作名称',
    },
  },
  // {
  //   label: '更新时间',
  //   field: 'updateTime',
  //   component: 'Input',
  //   componentProps: {
  //     placeholder: '请输入更新时间',
  //   },
  // },
];
// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '操作名称',
    field: 'opName',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入操作名称',
    },
  },
  {
    label: '用户IP',
    field: 'userIp',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入用户IP',
    },
  },
  {
    label: '用户地址',
    field: 'loginLocation',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入用户地址',
    },
  },
  {
    label: '类名称',
    field: 'javaClass',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入类名称',
    },
  },
  {
    label: '方法名称',
    field: 'javaMethod',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入方法名称',
    },
  },
  {
    label: '操作日志类型',
    field: 'type',
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'sys_log_type',
      },
    },
  },
  {
    label: '操作时间',
    field: 'opTime',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入操作时间',
    },
  },
  {
    label: '执行时长',
    field: 'duration',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入执行时长',
    },
  },
  {
    label: '操作用户',
    field: 'opUser',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入操作用户',
    },
  },
  {
    label: '请求参数',
    field: 'requestArgs',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入请求参数',
    },
  },
  {
    label: '浏览器UserAgent',
    field: 'userAgent',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入浏览器UserAgent',
    },
  },
  {
    label: '响应结果',
    field: 'resultJson',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入响应结果',
    },
  },
];
// 表单详情查看
export const viewSchema: DescItem[] = [
  {
    label: '操作名称',
    field: 'opName',
  },
  {
    label: '用户IP',
    field: 'userIp',
  },
  {
    label: '用户地址',
    field: 'loginLocation',
  },
  {
    label: '类名称',
    field: 'javaClass',
  },
  {
    label: '方法名称',
    field: 'javaMethod',
  },
  {
    label: '日志类型',
    field: 'type',
  },
  {
    label: '操作时间',
    field: 'opTime',
  },
  {
    label: '执行时长',
    field: 'duration',
  },
  {
    label: '操作用户',
    field: 'opUser',
  },
  {
    label: '请求参数',
    field: 'requestArgs',
  },
  {
    label: '浏览器UserAgent',
    field: 'userAgent',
  },
  {
    label: '响应结果',
    field: 'resultJson',
  },
  {
    label: '创建时间',
    field: 'createTime',
  },
  {
    label: '更新时间',
    field: 'updateTime',
  },
];
