mirror of
https://github.com/certd/certd.git
synced 2026-05-16 13:17:29 +08:00
chore: FormDialog
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user