123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- import * as api from './api';
- import { UserPageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
- export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
- const pageRequest = async (query: UserPageQuery) => {
- const { search, ...otherParams } = query;
- const newQueryParams = {
- request_modular: search,
- ...otherParams
- };
- return await api.GetList(newQueryParams);
- };
- const editRequest = async ({ form, row }: EditReq) => {
- form.id = row.id;
- return await api.UpdateObj(form);
- };
- const delRequest = async ({ row }: DelReq) => {
- return await api.DelObj(row.id);
- };
- const addRequest = async ({ form }: AddReq) => {
- return await api.AddObj(form);
- };
- return {
- crudOptions: {
- request: {
- pageRequest,
- addRequest,
- editRequest,
- delRequest,
- },
- actionbar: {
- buttons: {
- add: {
- show: false,
- },
- },
- },
- rowHandle: {
- fixed:'right',
- width: 100,
- buttons: {
- view: {
- type: 'text',
- },
- edit: {
- show: false,
- },
- remove: {
- show: false,
- },
- },
- },
- columns: {
- _index: {
- title: '序号',
- form: { show: false },
- column: {
- //type: 'index',
- align: 'center',
- width: '70px',
- columnSetDisabled: true, //禁止在列设置中选择
- formatter: (context) => {
- //计算序号,你可以自定义计算规则,此处为翻页累加
- let index = context.index ?? 1;
- let pagination = crudExpose!.crudBinding.value.pagination;
- return ((pagination!.currentPage ?? 1) - 1) * pagination!.pageSize + index + 1;
- },
- },
- },
- search: {
- title: '请求模块搜索',
- column: {
- show: false,
- },
- search: {
- autoSearchTrigger: false,
- show: true,
- component: {
- props: {
- clearable: true,
- },
- placeholder: '请输入请求模块',
- },
- },
- //form: {
- // show: false,
- // component: {
- // props: {
- // clearable: true,
- // },
- // },
- //},
- },
- request_modular: {
- title: '请求模块',
- search: {
- disabled: false,
- },
- type: 'input',
- column:{
- minWidth: 100,
- },
- form: {
- disabled: true,
- component: {
- placeholder: '请输入请求模块',
- },
- },
- },
- request_path: {
- title: '请求地址',
- search: {
- disabled: false,
- },
- type: 'input',
- column:{
- minWidth: 200,
- },
- form: {
- disabled: true,
- component: {
- placeholder: '请输入请求地址',
- },
- },
- },
- request_body: {
- column: {
- showOverflowTooltip: true,
- width: 200, //列宽
- minWidth: 100, //最小列宽
- },
- title: '请求参数',
- search: {
- disabled: true,
- },
- disabled: true,
- type: 'textarea',
- form: {
- component: {
- props: {
- type: 'textarea',
- },
- autosize: {
- minRows: 2,
- maxRows: 8,
- },
- placeholder: '请输入关键词',
- },
- },
- },
- request_method: {
- title: '请求方法',
- type: 'input',
- search: {
- disabled: false,
- },
- column:{
- minWidth: 100,
- },
- form: {
- disabled: true,
- component: {
- placeholder: '请输入请求方法',
- },
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- request_msg: {
- title: '操作说明',
- disabled: true,
- form: {
- component: {
- span: 12,
- },
- },
- },
- request_ip: {
- title: 'IP地址',
- search: {
- disabled: false,
- },
- type: 'input',
- column:{
- minWidth: 115,
- },
- form: {
- disabled: true,
- component: {
- placeholder: '请输入IP地址',
- },
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- create_datetime: {
- title: '操作时间',
- column: {
- minWidth: 100,
- }
- },
- request_browser: {
- title: '请求浏览器',
- type: 'input',
- column:{
- minWidth: 120,
- },
- form: {
- disabled: true,
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- response_code: {
- title: '响应码',
- search: {
- disabled: true,
- },
- type: 'input',
- column:{
- minWidth: 100,
- },
- form: {
- disabled: true,
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- request_os: {
- title: '操作系统',
- disabled: true,
- search: {
- disabled: true,
- },
- type: 'input',
- column:{
- minWidth: 120,
- },
- form: {
- disabled: true,
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- json_result: {
- title: '返回信息',
- search: {
- disabled: true,
- },
- type: 'input',
- column:{
- minWidth: 150,
- },
- form: {
- disabled: true,
- },
- component: { props: { color: 'auto' } }, // 自动染色
- },
- creator_name: {
- title: '操作人',
- column:{
- minWidth: 100,
- },
- form: {
- disabled: true,
- },
- },
- },
- },
- };
- };
|