mirror of
https://github.com/certd/certd.git
synced 2026-04-25 05:07:25 +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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user