2026-01-19 11:01:48 +08:00
|
|
|
import { useFormWrapper } from "@fast-crud/fast-crud";
|
|
|
|
|
|
|
|
|
|
export type FormOptionReq = {
|
|
|
|
|
title: string;
|
2026-01-25 00:50:36 +08:00
|
|
|
columns?: any;
|
2026-01-19 11:01:48 +08:00
|
|
|
onSubmit?: any;
|
2026-01-25 00:50:36 +08:00
|
|
|
body?: any;
|
2026-01-25 13:01:12 +08:00
|
|
|
initialForm?: any;
|
2026-01-19 11:01:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function useFormDialog() {
|
|
|
|
|
const { openCrudFormDialog } = useFormWrapper();
|
|
|
|
|
|
|
|
|
|
async function openFormDialog(req: FormOptionReq) {
|
|
|
|
|
function createCrudOptions() {
|
|
|
|
|
return {
|
|
|
|
|
crudOptions: {
|
|
|
|
|
columns: req.columns,
|
|
|
|
|
form: {
|
2026-01-25 13:01:12 +08:00
|
|
|
initialForm: req.initialForm,
|
2026-01-19 11:01:48 +08:00
|
|
|
wrapper: {
|
|
|
|
|
title: req.title,
|
|
|
|
|
saveRemind: false,
|
2026-01-25 00:50:36 +08:00
|
|
|
slots: {
|
|
|
|
|
"form-body-top": req.body,
|
|
|
|
|
},
|
2026-01-19 11:01:48 +08:00
|
|
|
},
|
|
|
|
|
async afterSubmit() {},
|
|
|
|
|
async doSubmit({ form }: any) {
|
|
|
|
|
if (req.onSubmit) {
|
|
|
|
|
await req.onSubmit(form);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const { crudOptions } = createCrudOptions();
|
|
|
|
|
await openCrudFormDialog({ crudOptions });
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
openFormDialog,
|
|
|
|
|
};
|
|
|
|
|
}
|