diff --git a/src/scripts/cmdPlugin/newValidateHandler.js b/src/scripts/cmdPlugin/newValidateHandler.js index c4ce288c8..771198b74 100644 --- a/src/scripts/cmdPlugin/newValidateHandler.js +++ b/src/scripts/cmdPlugin/newValidateHandler.js @@ -1,4 +1,4 @@ -import { objectIsEqual } from '@/utils/date'; +import { objectIsEqualSp } from '@/utils/date'; import Handler from './newHandler.js'; import { ScriptMode } from '@/scripts/ConstDic'; import store from '@/store/index'; @@ -50,9 +50,9 @@ class ValidateHandler { } } if (linkDataFlag) { - return objectIsEqual(param1, param2) || objectIsEqual(linkParam, param2); + return objectIsEqualSp(param1, param2) || objectIsEqualSp(linkParam, param2); } else { - return objectIsEqual(param1, param2); + return objectIsEqualSp(param1, param2); } } // 判断实训操作正确性 diff --git a/src/utils/date.js b/src/utils/date.js index 729d7adc9..711ed54af 100644 --- a/src/utils/date.js +++ b/src/utils/date.js @@ -121,3 +121,44 @@ export function objectIsEqual(obj1, obj2) { } return true; } +export function checkUndefinedOrNull(key) { + if (key === '' || key === undefined || key === null) { + return false; + } + return true; +} +export function checkTwo(k1, k2) { + console.log(checkUndefinedOrNull(k1), checkUndefinedOrNull(k2), '----', k1, k2); + return checkUndefinedOrNull(k1) || checkUndefinedOrNull(k2); +} +/* 对象是否相等(undefined和空字符串空对象空数组认为相同) */ +export function objectIsEqualSp(obj1, obj2) { + if (!(obj1 instanceof Object)) { + return false; + } else if (!(obj2 instanceof Object)) { + return false; + } + // 仅过滤值为null的项 + const arr1 = Object.keys(obj1).filter(key => { return obj1[key] != null; }); + const arr2 = Object.keys(obj2).filter(key => { return obj2[key] != null; }); + // if (arr1.length !== arr2.length) { + // return false; + // } + for (const key of arr1) { + const index = arr2.findIndex(item => item === key); + arr2.splice(index, 1); + if (obj1[key] instanceof Object && obj2[key] instanceof Object) { + if (!objectIsEqualSp(obj1[key], obj2[key])) { + return false; + } + } else if (obj1[key] !== obj2[key] && checkTwo(obj1[key], obj2[key])) { + return false; + } + } + for (const key of arr2) { + if (obj1[key] !== obj2[key] && checkTwo(obj1[key], obj2[key])) { + return false; + } + } + return true; +} diff --git a/src/views/newMap/display/terminals/terminalMenu.vue b/src/views/newMap/display/terminals/terminalMenu.vue index 893169003..11c855165 100644 --- a/src/views/newMap/display/terminals/terminalMenu.vue +++ b/src/views/newMap/display/terminals/terminalMenu.vue @@ -69,7 +69,7 @@ export default { } else { this.initPictureShow(); } - } else if (clientIdList.length) { + } else if (clientIdList && clientIdList.length) { this.initTerminalList(clientIdList); if (this.$store.state.trainingNew.trainingDetail && this.$store.state.trainingNew.trainingDetail.client) { const client = this.findTerminalFromMap(this.$store.state.trainingNew.trainingDetail.client); @@ -83,7 +83,11 @@ export default { } } else if (!this.terminalList.length) { this.initTerminalList([]); - this.changeQueryClient(); + if (this.$route.query.client && !this.nowTerminal.id) { + this.changeQueryClient(); + } else { + this.initPictureShow(); + } } } },