mirror of
https://github.com/certd/certd.git
synced 2026-05-18 06:17:31 +08:00
39 lines
871 B
TypeScript
39 lines
871 B
TypeScript
|
|
import { useFormWrapper } from "@fast-crud/fast-crud";
|
||
|
|
|
||
|
|
export type FormOptionReq = {
|
||
|
|
title: string;
|
||
|
|
columns: any;
|
||
|
|
onSubmit?: any;
|
||
|
|
};
|
||
|
|
|
||
|
|
export function useFormDialog() {
|
||
|
|
const { openCrudFormDialog } = useFormWrapper();
|
||
|
|
|
||
|
|
async function openFormDialog(req: FormOptionReq) {
|
||
|
|
function createCrudOptions() {
|
||
|
|
return {
|
||
|
|
crudOptions: {
|
||
|
|
columns: req.columns,
|
||
|
|
form: {
|
||
|
|
wrapper: {
|
||
|
|
title: req.title,
|
||
|
|
saveRemind: false,
|
||
|
|
},
|
||
|
|
async afterSubmit() {},
|
||
|
|
async doSubmit({ form }: any) {
|
||
|
|
if (req.onSubmit) {
|
||
|
|
await req.onSubmit(form);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
};
|
||
|
|
}
|
||
|
|
const { crudOptions } = createCrudOptions();
|
||
|
|
await openCrudFormDialog({ crudOptions });
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
openFormDialog,
|
||
|
|
};
|
||
|
|
}
|