From 9105d4d14a14ff5d50b1b1bb360e53fac5e07192 Mon Sep 17 00:00:00 2001 From: JyQAQ <45193678+jyqwq@users.noreply.github.com> Date: Wed, 3 Dec 2025 10:03:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(api-component):=20api-component=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84options=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9Adi?= =?UTF-8?q?sabled=E5=80=BC=20(#6991)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api-component/api-component.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/effects/common-ui/src/components/api-component/api-component.vue b/packages/effects/common-ui/src/components/api-component/api-component.vue index 70e86e0ea..38419a7d7 100644 --- a/packages/effects/common-ui/src/components/api-component/api-component.vue +++ b/packages/effects/common-ui/src/components/api-component/api-component.vue @@ -36,6 +36,8 @@ interface Props { childrenField?: string; /** value字段名 */ valueField?: string; + /** disabled字段名 */ + disabledField?: string; /** 组件接收options数据的属性名 */ optionsPropName?: string; /** 是否立即调用api */ @@ -75,6 +77,7 @@ defineOptions({ name: 'ApiComponent', inheritAttrs: false }); const props = withDefaults(defineProps(), { labelField: 'label', valueField: 'value', + disabledField: 'disabled', childrenField: '', optionsPropName: 'options', resultField: '', @@ -108,17 +111,25 @@ const isFirstLoaded = ref(false); const hasPendingRequest = ref(false); const getOptions = computed(() => { - const { labelField, valueField, childrenField, numberToString } = props; + const { + labelField, + valueField, + disabledField, + childrenField, + numberToString, + } = props; const refOptionsData = unref(refOptions); function transformData(data: OptionsItem[]): OptionsItem[] { return data.map((item) => { const value = get(item, valueField); + const disabled = get(item, disabledField); return { - ...objectOmit(item, [labelField, valueField, childrenField]), + ...objectOmit(item, [labelField, valueField, disabled, childrenField]), label: get(item, labelField), value: numberToString ? `${value}` : value, + disabled: get(item, disabledField), ...(childrenField && item[childrenField] ? { children: transformData(item[childrenField]) } : {}),