From 0a8a22894bfc4650539f31221b81d49f92806f4a Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Wed, 29 May 2024 16:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=85=B3=E5=85=B3=E8=81=94=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E8=AE=BE=E7=BD=AEv0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DesignForm/assembly/index.ts | 14 ++- src/components/DesignForm/formControlAttr.vue | 76 ++++++++++++++++- .../DesignForm/public/form/form.vue | 85 ++++++++++++++++--- src/types/components.d.ts | 8 ++ 4 files changed, 168 insertions(+), 15 deletions(-) diff --git a/src/components/DesignForm/assembly/index.ts b/src/components/DesignForm/assembly/index.ts index 7d739262f..30f0412d7 100644 --- a/src/components/DesignForm/assembly/index.ts +++ b/src/components/DesignForm/assembly/index.ts @@ -164,7 +164,19 @@ const selectOption: any = [ icon: 'switch', iconFont: 'fa-toggle-on', control: { - modelValue: false + modelValue: "", + glxxszSwitch:[ + { + conditionField:'', + openValue:"", + showFields:[] + }, + { + conditionField:'', + offValue:"", + showFields:[] + }, + ] }, config: {}, styles:{ diff --git a/src/components/DesignForm/formControlAttr.vue b/src/components/DesignForm/formControlAttr.vue index d7e815205..63faee8de 100644 --- a/src/components/DesignForm/formControlAttr.vue +++ b/src/components/DesignForm/formControlAttr.vue @@ -2222,6 +2222,14 @@ function delRole(id:String){ const glxxszDialogFlag = ref(false) const glxxszDialogFlagCheckBox = ref(false) +const glxxszDialogFlagSwitch = ref(false) +function handelGlxxszDialogSwitch(){ + if(controlData.value.control.activeValue==undefined||controlData.value.control.inactiveValue==undefined){ + alert("请先设置开关状态打开/关闭时的值") + }else{ + glxxszDialogFlagSwitch.value = true + } +} function handelGlxxszDialog(){ if(controlData.value.options.length===0){ alert("无可配置选项,请先添加。") @@ -2237,9 +2245,27 @@ function handelGlxxszDialogCheckbox(){ function handleDetermineGlxxszDialog(){ glxxszDialogFlag.value = false } +function handleDetermineGlxxszDialogSwitch(){ + glxxszDialogFlagSwitch.value = false +} function handleDetermineGlxxszDialogCheckBox(){ glxxszDialogFlagCheckBox.value = false } +//同步开关的设置值和开关关联选项设置的值 +watch(()=>controlData.value.control,(newVal) => { + if(typeof(newVal)!="undefined"){ + if(typeof(newVal.glxxszSwitch)!="undefined"){ + if(typeof(controlData.value.control.activeValue)!="undefined"){ + controlData.value.control.glxxszSwitch[0].openValue = controlData.value.control.activeValue + controlData.value.control.glxxszSwitch[0].conditionField = controlData.value.name + } + if(typeof(controlData.value.control.inactiveValue)!="undefined"){ + controlData.value.control.glxxszSwitch[1].offValue = controlData.value.control.inactiveValue + controlData.value.control.glxxszSwitch[1].conditionField = controlData.value.name + } + } + } +},{ deep: true }) @@ -2295,8 +2321,8 @@ function createRowForGlxxsz(){ function deleteRowForGlxxsz(row: { id: any }){ controlData.value.control.glxxszForCheckBox = controlData.value.control.glxxszForCheckBox.filter((item: { id: any }) => item.id!=row.id) } +/* */ -//修复bug:当字段标识改变时,关联选项设置的字段标识未同步更改 //liwenxuan20240426 单选多选下拉 关联选项设置 end @@ -2920,6 +2946,9 @@ const loadNextPage = () => { +
+ 关联选项设置 +
关联选项设置
@@ -3831,6 +3860,51 @@ const loadNextPage = () => { + + + + + + + + + + + + diff --git a/src/components/DesignForm/public/form/form.vue b/src/components/DesignForm/public/form/form.vue index 8774d306e..a91fd0381 100644 --- a/src/components/DesignForm/public/form/form.vue +++ b/src/components/DesignForm/public/form/form.vue @@ -164,7 +164,9 @@ const forEachGetFormModel = (list: FormList[], obj: any) => { }) } else if (['card', 'div'].includes(item.type)) { forEachGetFormModel(item.list, obj) - } else { + } /* else if(['switch'].includes(item.type)){ + console.log(item) + } */else { const excludeType = ['title', 'divider', 'txt', 'button'] if (excludeType.indexOf(item.type) === -1) { obj[item.name] = jsonParseStringify(item.control.modelValue) @@ -219,6 +221,9 @@ const recursionToGetFinallyHideFields = (hideFieldArr: any[],radioSelectArr3: st /* console.log("所有字段modelKeyArr^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^") console.log(modelKeyArr) */ + //console.log("当前表单的值-------------------") + //console.log(model.value) + //当前处于显示状态的默认隐藏的字段 @@ -295,7 +300,7 @@ const recursionToGetFinallyHideFields = (hideFieldArr: any[],radioSelectArr3: st console.log(conditionFieldValue) */ for(let n = 0; n< modelKeyArr.length;n++){ if(modelKeyArr[n]==conditionField){ - let count_1 = 0; + //let count_1 = 0; let trueValue = model.value[modelKeyArr[n]] if(trueValue.length>0&&arrayEqual(trueValue,conditionFieldValueArr)){ //此时满足了条件,但是必须看一下conditionField有没有被隐藏.如果被隐藏了,则x不能增加. @@ -304,7 +309,7 @@ const recursionToGetFinallyHideFields = (hideFieldArr: any[],radioSelectArr3: st console.log(toshow) */ let flag = false//其依赖的选项的父字段是否被隐藏.默认没被隐藏, //如果此时的conditionField有可能被隐藏且已被隐藏,x不能++ - for(let a = 0;a1说明时多选,=1说明是单选. for(let b = 0;b0){ for(let i = 0;i0){ + for(let i = 0;i0){ + for(let j = 0; j0){ + for(let n = 0; n0){ + for(let i = 0;i0){ + for(let j = 0;j0){ + const optionValueJArr = typeof(jArr.openValue)=="undefined"?jArr.offValue:jArr.openValue + let arr1 = [] + for(let n = 0;n