From b8303b7e36ce946b566efeadce185e3058173c91 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Tue, 3 Mar 2026 23:20:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][che?= =?UTF-8?q?ckbox-tree]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/HandleFormItem.vue | 51 +++++++----------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 7106a92..34bcf4a 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -67,7 +67,7 @@
-
@@ -224,10 +224,8 @@ import Question from "./icons/Question.vue"; import DecimalInput from "./DecimalInput.vue"; import { EventBus } from "@/utils/eventBus"; import moment from "moment"; -import { deepClone } from "@/utils/index"; -import { getuuid } from "@/utils/index.js"; +import { getuuid,isEqual ,deepClone,getDefaultValueByOptions,isValueEmpty} from "@/utils/index.js"; import { getToken } from "@/utils/auth" -import { isValueEmpty, getDefaultValueByOptions } from '@/utils/index.js'; export default { inject: ['templateData', 'templateFillType', "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"], @@ -339,6 +337,7 @@ export default { currentHandleType: '',//当前操作的类型 currentOtherCode: '',//当前操作的otherCode currentCheckboxTreeValue: '',//当前操作的checkboxTree值 + } }, watch: { @@ -1169,32 +1168,32 @@ export default { // 如果是checkboxList类型,需要同时比较otherValues if (this.type === 'checkboxList') { const current = this.getCheckboxListInfo(); - isSame = this.isEqual(current.oldValue, current.newValue); + isSame = isEqual(current.oldValue, current.newValue); isOldValueEmpty = isValueEmpty(current.oldValue); } else if (this.type === "checkboxTag") { // checkboxTag类型,只比较当前tagIndex的数据 const currentTag = this.checkboxTagList[this.currentTagIndex]; const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {}; - isSame = this.isEqual(oldTag.checked, currentTag.checked); - isOldValueEmpty = isValueEmpty(oldTag.checked); + isSame = isEqual(oldTag.checked, currentTag.checked); + isOldValueEmpty = oldTag.checked===undefined; } else if (this.type === "fqyq") { const current = this.getFqyqInfo(); - isSame = this.isEqual(current.oldValue, current.newValue); + isSame = isEqual(current.oldValue, current.newValue); isOldValueEmpty = isValueEmpty(current.oldValue); } else if (this.type === "checkboxTree") { const current = this.getCheckboxTreeInfo(); const { oldValue, newValue } = current; if (currentHandleType === "checkboxTreeCheckbox") { - isSame = this.isEqual(oldValue.checked, newValue.checked); - isOldValueEmpty = isValueEmpty(oldValue.checked); + isSame = isEqual(oldValue.checked, newValue.checked); + isOldValueEmpty = oldValue.checked===undefined; } else { - isSame = this.isEqual(current.oldValue, current.newValue); + isSame = isEqual(current.oldValue, current.newValue); isOldValueEmpty = isValueEmpty(current.oldValue); } } else { - isSame = this.isEqual(this.oldValue, this.inputValue) + isSame = isEqual(this.oldValue, this.inputValue) isOldValueEmpty = isValueEmpty(this.oldValue); } console.log(isSame, isOldValueEmpty, this.currentCheckboxTreeValue, this.oldValue, this.inputValue, "isSame") @@ -1352,17 +1351,6 @@ export default { }) }, - //判断两个值是否相等 - isEqual(oldValue, nowValue) { - if (oldValue === null || nowValue === null) { - return oldValue === nowValue; - } - if (typeof oldValue === 'object' && typeof nowValue === 'object') { - return JSON.stringify(oldValue) === JSON.stringify(nowValue); - } - return oldValue === nowValue; - }, - //获取公共记录信息 getCommonRecordInfo() { const { nickName, name } = this.$store.getters; @@ -1385,23 +1373,6 @@ export default { } return commonInfo; }, - - // 判断值是否为空 - isValueEmpty(value) { - if (value === null || value === undefined || value === '') { - return true; - } - if (typeof value === 'string' && value.trim() === '') { - return true; - } - if (Array.isArray(value) && value.length === 0) { - return true; - } - if (Object.keys(value).length === 0) { - return true; - } - return false; - }, // 判断checkboxList中特定otherCode输入框是否有错误 isOtherInputError(otherCode) { if (!this.error) {