mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
282f8b4e02
chore: chore: chore: editRequest 判断form.id不为空 chore:
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import * as api from "./api";
|
|
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
|
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
|
return await api.GetList(query);
|
|
};
|
|
const editRequest = async ({ form, row }: EditReq) => {
|
|
if (form.id == null) {
|
|
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
|
|
},
|
|
columns: {
|
|
id: {
|
|
title: "ID",
|
|
key: "id",
|
|
type: "number",
|
|
column: {
|
|
width: 50
|
|
},
|
|
form: {
|
|
show: false
|
|
}
|
|
},
|
|
radio: {
|
|
title: "状态",
|
|
search: { show: true },
|
|
type: "dict-radio",
|
|
dict: dict({
|
|
url: "/mock/dicts/OpenStatusEnum?single"
|
|
})
|
|
},
|
|
button: {
|
|
title: "按钮样式",
|
|
search: { show: true },
|
|
type: "dict-radio",
|
|
dict: dict({
|
|
url: "/mock/dicts/OpenStatusEnum?single"
|
|
}),
|
|
form: {
|
|
component: {
|
|
optionName: "a-radio-button"
|
|
}
|
|
}
|
|
},
|
|
bool: {
|
|
title: "布尔类型",
|
|
search: { show: true },
|
|
type: "dict-radio",
|
|
dict: dict({
|
|
data: [
|
|
{ value: true, label: "TRUE" },
|
|
{ value: false, label: "FALSE" }
|
|
]
|
|
})
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|