feat(完成附件管理基本功能): 完成附件管理crud菜单

This commit is contained in:
H0nGzA1
2023-02-11 16:25:09 +08:00
parent d6bd3c6310
commit c5e5767572
3 changed files with 177 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';
import { dictionary } from '/@/utils/dictionary';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes {
const pageRequest = async (query: PageQuery) => {
return await api.GetList(query);
};
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: {
actionbar: {
buttons: {
add: {
show: false,
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
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: {
show: true,
component: {
props: {
clearable: true,
},
placeholder: '请输入关键词',
},
},
form: {
show: false,
component: {
props: {
clearable: true,
},
},
},
},
name: {
title: '文件名称',
search: {
show: true,
},
type: 'input',
form: {
component: {
placeholder: '请输入文件名称',
},
},
},
url: {
title: '文件地址',
type: 'file-uploader',
search: {
disabled: true,
},
},
md5sum: {
title: '文件MD5',
width: 200,
search: {
disabled: true,
},
form: {
disabled: false,
},
},
},
},
};
};