mirror of
https://github.com/certd/certd.git
synced 2026-04-15 21:40:53 +08:00
chore: FormDialog
This commit is contained in:
38
packages/ui/certd-client/src/use/use-dialog.ts
Normal file
38
packages/ui/certd-client/src/use/use-dialog.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
29
packages/ui/certd-client/src/views/certd/cert/domain/use.tsx
Normal file
29
packages/ui/certd-client/src/views/certd/cert/domain/use.tsx
Normal 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,
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user