diff --git a/src/components/formTable/index.vue b/src/components/formTable/index.vue index af69e2b..593d201 100644 --- a/src/components/formTable/index.vue +++ b/src/components/formTable/index.vue @@ -620,6 +620,7 @@ onMounted(() => { nextTick(() => { appendRemoveStyle(true) }) + getAsfs() }) onUnmounted(() => { if (eventName) { @@ -1826,6 +1827,137 @@ function arrayEqual(a: string[], b: any[]) { } //liwenxuan 241209 关联选项设置 显示隐藏效果 end +//liwenxuan 241217 数据范围动态 start +let asfRangeDoubleCondiChangeObj = ref(); +provide("asfRangeDoubleCondiChangeObj", asfRangeDoubleCondiChangeObj); +const asfs: any[] = []; +const tables: any[] = []; +let oldModelStr = ""; +watch( + () => model.value, + (newVal) => { + //console.log(1) + let currentChangeKey = ""; + const newModelStr = JSON.stringify(newVal); + let oldModelStr1 = oldModelStr; + if (newModelStr !== oldModelStr1 && oldModelStr1 != "") { + let oldVal = JSON.parse(oldModelStr1); + /* console.log(oldVal) + console.log(newVal) */ + for (const key in newVal) { + if (JSON.stringify(newVal[key]) !== JSON.stringify(oldVal[key])) { + currentChangeKey = key; + } + } + } + let rangeFormulaArr = []; + + if (asfs.length > 0) { + /* console.log(currentChangeKey) + console.log(asfs) */ + asfs.forEach((element: any) => { + let asfName = element.name; + + if ( + element.control.dataRangeGongShi && + element.control.dataRangeGongShi.mathsFormula && + element.control.dataRangeGongShi.mathsFormula.length > 0 + ) { + let asfRangeDoubleCondi = element.control.dataRangeGongShi.mathsFormula; + + if (currentChangeKey != "") { + let a = asfRangeDoubleCondi.split(":"); + let field = a[a.length - 1]; + if (currentChangeKey == field) { + let toShowDoubleCondiValVal = model.value[currentChangeKey]; + //console.log("关联表单"+asfName+"应该更新其选项,只显示doubleCondiVal为"+toShowDoubleCondiValVal+"的选项") + let obj = { + asfName: asfName, + toShowDoubleCondiValVal: toShowDoubleCondiValVal, + }; + asfRangeDoubleCondiChangeObj.value = obj; + } + } + } + }); + } + oldModelStr = newModelStr; + }, + { deep: true } +); + +function getAsfs() { + setTimeout(() => { + let dataList = ref({}); + dataList.value = props.formData.list; + + if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { + for (let i = 0; i < dataList.value.length; i++) { + if (dataList.value[i].type == "associatedForms") { + asfs.push(dataList.value[i]); + } else if ( + dataList.value[i].type == "card" || + dataList.value[i].type == "flex" || + dataList.value[i].type == "div" || + dataList.value[i].type == "table" + ) { + if (dataList.value[i].type == "table") { + tables.push(dataList.value[i]); + } + + dataList.value[i].list.forEach((element: any) => { + if (element.type == "associatedForms") { + asfs.push(element); + } + }); + } else if (dataList.value[i].type == "grid") { + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } + } + } + } + } else if (dataList.value[i].type == "tabs") { + //tabs标签页有可能再嵌套一层flex或者table + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if (a.type == "flex" || a.type == "table") { + if (a.type == "table") { + tables.push(dataList.value[i]); + } + + if (a.list.length > 0) { + for (let m = 0; m < a.list.length; m++) { + let q = JSON.parse(JSON.stringify(a.list[m])); + + if (q.type == "associatedForms") { + asfs.push(q); + } + } + } + } + } + } + } + } + } + } + }, 500); +} +//liwenxuan 241217 数据范围动态 end