diff --git a/packages/ui/certd-client/src/components/plugins/common/remote-auto-complete.vue b/packages/ui/certd-client/src/components/plugins/common/remote-auto-complete.vue index a46c3d66b..114e7705c 100644 --- a/packages/ui/certd-client/src/components/plugins/common/remote-auto-complete.vue +++ b/packages/ui/certd-client/src/components/plugins/common/remote-auto-complete.vue @@ -23,7 +23,7 @@ defineOptions({ const props = defineProps< { - watches: string[]; + watches?: string[]; } & ComponentPropsType >(); @@ -48,6 +48,18 @@ const message = ref(""); const hasError = ref(false); const loading = ref(false); +function getInputFromForm(form: any, pluginType: string) { + let input: any = {}; + if (pluginType === "plugin") { + input = form?.input || {}; + } else if (pluginType === "access") { + input = form?.access || {}; + } else { + input = form || {}; + } + return input; +} + const getOptions = async () => { if (loading.value) { return; @@ -63,15 +75,14 @@ const getOptions = async () => { } const pluginType = getPluginType(); const { form } = getScope(); - const input = (pluginType === "plugin" ? form?.input : form) || {}; - + const input = getInputFromForm(form, pluginType); for (let key in define.input) { const inWatches = props.watches?.includes(key); const inputDefine = define.input[key]; if (inWatches && inputDefine.required) { const value = input[key]; if (value == null || value === "") { - console.log("remote-select required", key); + console.log("remote-auto-complete required", key); return; } } @@ -129,12 +140,14 @@ watch( () => { const pluginType = getPluginType(); const { form, key } = getScope(); - const input = (pluginType === "plugin" ? form?.input : form) || {}; - const watches = {}; - for (const key of props.watches) { - //@ts-ignore - watches[key] = input[key]; + const input = getInputFromForm(form, pluginType); + const watches: any = {}; + if (props.watches && props.watches.length > 0) { + for (const key of props.watches) { + watches[key] = input[key]; + } } + return { form: watches, key, @@ -144,6 +157,9 @@ watch( const { form } = value; const oldForm: any = oldValue?.form; let changed = oldForm == null || optionsRef.value.length == 0; + if (!props.watches || props.watches.length === 0) { + return; + } for (const key of props.watches) { //@ts-ignore if (oldForm && form[key] != oldForm[key]) { diff --git a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue index e951b4d54..15b315a1e 100644 --- a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue +++ b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue @@ -57,7 +57,7 @@ const VNodes = defineComponent({ const props = defineProps< { - watches: string[]; + watches?: string[]; search?: boolean; pager?: boolean; } & ComponentPropsType @@ -201,11 +201,13 @@ watch( const pluginType = getPluginType(); const { form, key } = getScope(); const input = (pluginType === "plugin" ? form?.input : form) || {}; - const watches = {}; - for (const key of props.watches) { - //@ts-ignore - watches[key] = input[key]; + const watches: any = {}; + if (props.watches && props.watches.length > 0) { + for (const key of props.watches) { + watches[key] = input[key]; + } } + return { form: watches, key, @@ -215,11 +217,12 @@ watch( const { form } = value; const oldForm: any = oldValue?.form; let changed = oldForm == null || optionsRef.value.length == 0; - for (const key of props.watches) { - //@ts-ignore - if (oldForm && form[key] != oldForm[key]) { - changed = true; - break; + if (props.watches && props.watches.length > 0) { + for (const key of props.watches) { + if (oldForm && form[key] != oldForm[key]) { + changed = true; + break; + } } } if (changed) { diff --git a/packages/ui/certd-server/src/controller/user/pipeline/handle-controller.ts b/packages/ui/certd-server/src/controller/user/pipeline/handle-controller.ts index 534f2effe..2c4eaab53 100644 --- a/packages/ui/certd-server/src/controller/user/pipeline/handle-controller.ts +++ b/packages/ui/certd-server/src/controller/user/pipeline/handle-controller.ts @@ -53,6 +53,7 @@ export class HandleController extends BaseController { const accessGetter = new AccessGetter(userId, this.accessService.getById.bind(this.accessService)); const access = await newAccess(body.typeName, inputAccess,accessGetter); + mergeUtils.merge(access, body.input); const res = await access.onRequest(body); return this.ok(res);