Browse Source

取消绑定

Signed-off-by: hsshuxian <3049816743@qq.com>
hsshuxian 5 tháng trước cách đây
mục cha
commit
0f8b6033f0
1 tập tin đã thay đổi với 27 bổ sung27 xóa
  1. 27 27
      ems-ui-cloud/src/views/basecfg/boundaryRel/index.vue

+ 27 - 27
ems-ui-cloud/src/views/basecfg/boundaryRel/index.vue

@@ -975,16 +975,22 @@ export default {
         const index = this[`${tabType}Bound`].indexOf(row);
         if (index !== -1) {
           this[`${tabType}Bound`].splice(index, 1);
+          this[`${tabType}Unbound`].push(row);
+
+          const objType = row.objType;
+          const boundaryObj = row.boundaryObj;
+          const meterCls = row.meterCls || (this.activeDeviceTab === 'electricMeter' ? 45 : 70);
+
+          delete row.boundaryObj;
+          delete row.meterDevice;
+          delete row.objType;
+
+          this.saveByObj(tabType, objType, boundaryObj, meterCls);
         }
-        this[`${tabType}Unbound`].push(row);
-        delete row.boundaryObj;
-        delete row.meterDevice;
-        delete row.objType;
-        this.saveByObj(tabType);
-      }).catch(() => {});
+      })
     },
-    /**保存绑定的设备*/
-    saveByObj(tabType) {
+    /**绑定保存*/
+    saveByObj(tabType, objType = null, boundaryObj = null, meterCls = null) {
       const dataToSave = this[`${tabType}Bound`].map(item => {
         return {
           boundaryObj: item.boundaryObj,
@@ -994,31 +1000,25 @@ export default {
           objType: item.objType
         };
       });
-      const RequestQueryParams = this[`${tabType}Bound`].map(item => {
-        return {
-          objType: item.objType,
-          boundaryObj: item.boundaryObj,
-          meterCls: item.meterCls || (this.activeDeviceTab === 'electricMeter' ? 45 : 70),
-        };
-      });
-      const objType = RequestQueryParams.length > 0 ? RequestQueryParams[0].objType : null;
-      const boundaryObj = RequestQueryParams.length > 0 ? RequestQueryParams[0].boundaryObj : null;
-      const meterCls = RequestQueryParams.length > 0 ? RequestQueryParams[0].meterCls : null;
+
+      if (dataToSave.length === 0) {
+        objType = objType || this.queryParams.objType;
+        boundaryObj = boundaryObj || this.queryParams.areaCode;
+        meterCls = meterCls || (this.activeDeviceTab === 'electricMeter' ? 45 : 70);
+      } else {
+        objType = dataToSave[0].objType;
+        boundaryObj = dataToSave[0].boundaryObj;
+        meterCls = dataToSave[0].meterCls;
+      }
       addAllByObj(objType, meterCls, boundaryObj, dataToSave)
         .then(response => {
           if (response.code === 200) {
             this.$message.success('保存成功');
             this.getMeterData(tabType);
-          } else {
-            this.$message.error('保存失败');
           }
         })
-        .catch(error => {
-          console.error('保存失败:', error);
-          this.$message.error('保存失败');
-        });
-    },
 
+    },
     // 设施下拉框选项
     getFacsOptions() {
       const getFacsParams = {
@@ -1163,11 +1163,11 @@ export default {
   flex: 1;
   display: flex;
   align-items: center;
-  justify-content: flex-start; /* 调整为 flex-start */
+  justify-content: flex-start;
 }
 
 .custom-tree-node .el-button {
-  margin-left: 8px; /* 添加一些左边距 */
+  margin-left: 8px;
 }
 .topology-chart-container {
   overflow-x: auto;