From 92ea2fc6eb9a624fd51282f3ef99b4fb8c60ebb7 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 23 Dec 2024 13:57:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BF=85=E5=A1=AB=E9=A1=B9=E6=98=AF=E5=90=A6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1017498 --user=刘瑞斌 【高级编排应用】用户输入参数默认值增加显示设置优化 https://www.tapd.cn/57709429/s/1635457 --- .../components/dynamics-form/constructor/index.vue | 1 + .../constructor/items/DatePickerConstructor.vue | 12 ++++++++++-- .../constructor/items/JsonInputConstructor.vue | 12 ++++++++++-- .../constructor/items/MultiSelectConstructor.vue | 10 +++++++++- .../constructor/items/RadioCardConstructor.vue | 10 +++++++++- .../constructor/items/SingleSelectConstructor.vue | 9 ++++++++- .../constructor/items/TextInputConstructor.vue | 9 ++++++++- ui/src/components/dynamics-form/index.vue | 6 ++++++ ui/src/components/dynamics-form/type.ts | 4 ++++ 9 files changed, 65 insertions(+), 8 deletions(-) diff --git a/ui/src/components/dynamics-form/constructor/index.vue b/ui/src/components/dynamics-form/constructor/index.vue index 8c3297b415d..76521fe3b2b 100644 --- a/ui/src/components/dynamics-form/constructor/index.vue +++ b/ui/src/components/dynamics-form/constructor/index.vue @@ -100,6 +100,7 @@ const getData = () => { required: form_data.value.required, field: form_data.value.field, default_value: form_data.value.default_value, + show_default_value: form_data.value.show_default_value, ...componentFormRef.value.getData() } } diff --git a/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue b/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue index e370dd6a564..c22d38e5507 100644 --- a/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue @@ -26,11 +26,16 @@ + { format: formValue.value.format, 'value-format': formValue.value.format }, - default_value: formValue.value.default_value + default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, } } const rander = (form_data: any) => { formValue.value.type = form_data.attrs.type formValue.value.format = form_data.attrs?.format formValue.value.default_value = form_data.default_value || '' + formValue.value.show_default_value = form_data.show_default_value } defineExpose({ getData, rander }) onBeforeMount(() => { formValue.value.type = 'datetime' formValue.value.format = 'YYYY-MM-DD HH:mm:ss' formValue.value.default_value = '' + formValue.value.show_default_value = true }) diff --git a/ui/src/components/dynamics-form/constructor/items/JsonInputConstructor.vue b/ui/src/components/dynamics-form/constructor/items/JsonInputConstructor.vue index 5121bd020b1..210ebc860e1 100644 --- a/ui/src/components/dynamics-form/constructor/items/JsonInputConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/JsonInputConstructor.vue @@ -1,10 +1,15 @@ @@ -40,7 +45,8 @@ const getData = () => { } ] }, - default_value: formValue.value.default_value + default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, } } @@ -55,10 +61,12 @@ const default_value_rule = { const rander = (form_data: any) => { formValue.value.default_value = form_data.default_value + formValue.value.show_default_value = form_data.show_default_value } defineExpose({ getData, rander }) onMounted(() => { formValue.value.default_value = {} + formValue.value.show_default_value = true }) diff --git a/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue b/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue index 04fbbe9d492..5e202ba8281 100644 --- a/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/MultiSelectConstructor.vue @@ -46,11 +46,16 @@ + { input_type: 'MultiSelect', attrs: {}, default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, text_field: 'label', value_field: 'value', option_list: formValue.value.option_list @@ -111,12 +117,14 @@ const getData = () => { const rander = (form_data: any) => { formValue.value.option_list = form_data.option_list || [] formValue.value.default_value = form_data.default_value + formValue.value.show_default_value = form_data.show_default_value } defineExpose({ getData, rander }) onMounted(() => { formValue.value.option_list = [] formValue.value.default_value = '' + formValue.value.show_default_value = true addOption() }) diff --git a/ui/src/components/dynamics-form/constructor/items/RadioCardConstructor.vue b/ui/src/components/dynamics-form/constructor/items/RadioCardConstructor.vue index 1347a7a2d3f..dcf9b0f0a44 100644 --- a/ui/src/components/dynamics-form/constructor/items/RadioCardConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/RadioCardConstructor.vue @@ -47,11 +47,16 @@ + { input_type: 'RadioCard', attrs: {}, default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, text_field: 'label', value_field: 'value', option_list: formValue.value.option_list @@ -104,12 +110,14 @@ const getData = () => { const rander = (form_data: any) => { formValue.value.option_list = form_data.option_list || [] formValue.value.default_value = form_data.default_value + formValue.value.show_default_value = form_data.show_default_value } defineExpose({ getData, rander }) onMounted(() => { formValue.value.option_list = [] formValue.value.default_value = '' + formValue.value.show_default_value = true addOption() }) diff --git a/ui/src/components/dynamics-form/constructor/items/SingleSelectConstructor.vue b/ui/src/components/dynamics-form/constructor/items/SingleSelectConstructor.vue index fb7693f56dc..6089b7b86e4 100644 --- a/ui/src/components/dynamics-form/constructor/items/SingleSelectConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/SingleSelectConstructor.vue @@ -47,11 +47,16 @@ + { input_type: 'SingleSelect', attrs: {}, default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, text_field: 'label', value_field: 'value', option_list: formValue.value.option_list @@ -109,6 +115,7 @@ defineExpose({ getData, rander }) onMounted(() => { formValue.value.option_list = [] formValue.value.default_value = '' + formValue.value.show_default_value = true addOption() }) diff --git a/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue b/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue index 553cb448352..0540a95e80a 100644 --- a/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue +++ b/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue @@ -47,13 +47,18 @@ + { 'show-word-limit': true }, default_value: formValue.value.default_value, + show_default_value: formValue.value.show_default_value, props_info: { rules: formValue.value.required ? [ @@ -153,6 +159,7 @@ onMounted(() => { formValue.value.minlength = 0 formValue.value.maxlength = 20 formValue.value.default_value = '' + formValue.value.show_default_value = true }) diff --git a/ui/src/components/dynamics-form/index.vue b/ui/src/components/dynamics-form/index.vue index b618652b205..bd493f4a00b 100644 --- a/ui/src/components/dynamics-form/index.vue +++ b/ui/src/components/dynamics-form/index.vue @@ -151,6 +151,12 @@ const initDefaultData = (formField: FormField) => { ) { formValue.value[formField.field] = formField.default_value } + + // 配置不展示默认值 + if (!formField.show_default_value) { + formValue.value[formField.field] = undefined + console.log(formField.show_default_value, formValue.value[formField.field]) + } } onBeforeMount(() => { diff --git a/ui/src/components/dynamics-form/type.ts b/ui/src/components/dynamics-form/type.ts index 20bb29dba25..e0da49be2f4 100644 --- a/ui/src/components/dynamics-form/type.ts +++ b/ui/src/components/dynamics-form/type.ts @@ -126,6 +126,10 @@ interface FormField { * 默认值 */ default_value?: any + /** + * 是否显示默认值 + */ + show_default_value?: boolean /** * {field:field_value_list} 表示在 field有值 ,并且值在field_value_list中才显示 */