mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
282f8b4e02
chore: chore: chore: editRequest 判断form.id不为空 chore:
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import * as api from "./api";
|
|
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, 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
|
|
}
|
|
},
|
|
icon: {
|
|
title: "icon",
|
|
search: { show: true },
|
|
type: "text",
|
|
column: {
|
|
component: {
|
|
name: "fs-icon",
|
|
vModel: "icon",
|
|
style: "font-size:18px"
|
|
}
|
|
},
|
|
form: {
|
|
helper: {
|
|
render() {
|
|
return (
|
|
<a target={"_blank"} href={"https://iconify.design/icon-sets/ion/"}>
|
|
点击此处选择图标名称
|
|
</a>
|
|
);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
svg: {
|
|
title: "svg",
|
|
search: { show: true },
|
|
type: "text",
|
|
column: {
|
|
component: {
|
|
name: "fs-icon",
|
|
vModel: "icon",
|
|
style: "font-size:18px"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|