chore: FormDialog

This commit is contained in:
xiaojunnuo
2026-01-19 11:01:48 +08:00
parent be1a70299f
commit 5ec9916817
2 changed files with 67 additions and 0 deletions

View File

@@ -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,
};
}

View File

@@ -0,0 +1,29 @@
import * as api from "./api";
import { useFormDialog } from "/@/use/use-dialog";
export function useDomainImport() {
const { openFormDialog } = useFormDialog();
const columns = {
dnsProviderType: {
title: "域名提供商",
type: "select",
},
dnsProviderAccessId: {
title: "域名提供商访问ID",
type: "input",
},
};
return function openDomainImportDialog() {
openFormDialog({
title: "从域名提供商导入域名",
columns: columns,
onSubmit: async (form: any) => {
await api.Save({
title: form.title,
});
},
});
};
}