diff --git a/src/views/profile/DeviceDetailsView/childDevice.vue b/src/views/profile/DeviceDetailsView/childDevice.vue index e67ad635..8db82a8b 100644 --- a/src/views/profile/DeviceDetailsView/childDevice.vue +++ b/src/views/profile/DeviceDetailsView/childDevice.vue @@ -382,7 +382,7 @@ export default { }, created() { this.getDeviceTypeList(); - this.getList(); + this.getList(false); }, methods: { relationSubmit() { @@ -404,7 +404,6 @@ export default { this.msgSuccess("子设备绑定操作成功!"); this.selectTableBoxShow = false; this.getList(); - this.$emit("EventUpload"); }); }, chenking_deviceKey(rule, value, callback) { @@ -725,11 +724,21 @@ export default { val + 1 + (this.queryParams.pageNum - 1) * this.queryParams.pageSize ); }, + // 判断两个数组是否 + compareName(arr = [], arr2 = [], keys){ + if (!arr || !arr2) return false; + if (arr.length !== arr2.length) return false; + + return arr.every(obj => arr2.find(v => v[keys] === obj[keys])); + }, /** 查询设备列表 */ - getList() { + getList(upload = true) { this.loading = true; this.queryParams.parentId = this.sourceId; listDevice(this.queryParams).then((response) => { + if (upload && !this.compareName([...this.deviceList], [...response.rows], 'deviceKey')) { + this.$emit("EventUpload"); + } this.deviceList = response.rows; this.total = response.total; this.loading = false; @@ -763,7 +772,6 @@ export default { .then(() => { this.getList(); this.msgSuccess("取消成功"); - this.$emit("EventUpload"); }); }, /** 删除按钮操作 */ @@ -779,7 +787,6 @@ export default { .then(() => { this.getList(); this.msgSuccess("删除成功"); - this.$emit("EventUpload"); }); }, /** 提交按钮 */ @@ -802,7 +809,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - this.$emit("EventUpload"); }); } }