Browse Source

创建盒子,单机增加设备uuid

kukuasir@vip.qq.com 1 year ago
parent
commit
f71cd9a1f0
1 changed files with 35 additions and 14 deletions
  1. 35 14
      src/views/equip-management/add-box/index.vue

+ 35 - 14
src/views/equip-management/add-box/index.vue

@@ -4012,6 +4012,8 @@ import HexAdvPannel from "./hex-adv-pannel";
 import customInputNumber from "@/components/CustomInputNumber";
 import {duplicatesEnd, duplicatesHex, duplicatesHost, duplicatesNewTrend} from "@/utils/format";
 
+import { v4 as uuidv4 } from 'uuid';
+
 const standaloneDefault = {};
 /* 命令常量 */
 const commandsConstTemp = {
@@ -6511,6 +6513,10 @@ export default {
         switch (Object.keys(item)[0]) {
           case "host":
             item.host.standalone.map(ele => {
+              // uuid
+              if (!ele.uuid) {
+                ele.uuid = this.genUuid();
+              }
               //品牌
               if (ele.hpBrand === 0) {
                 ele.hpBrand = null
@@ -6527,6 +6533,9 @@ export default {
             break;
           case "newtrend":
             item.newtrend.standalone.map(ele => {
+              if (!ele.uuid) {
+                ele.uuid = this.genUuid();
+              }
               if (ele.dhBrand === 0) {
                 ele.dhBrand = null
               }
@@ -6540,6 +6549,9 @@ export default {
             break;
           case "heatexchange":
             item.heatexchange.standalone.map(ele => {
+              if (!ele.uuid) {
+                ele.uuid = this.genUuid();
+              }
               if (ele.hexBrand === 0) {
                 ele.hexBrand = null
               }
@@ -6553,6 +6565,9 @@ export default {
             break;
           case "end":
             item.end.standalone.map(ele => {
+              if (!ele.uuid) {
+                ele.uuid = this.genUuid();
+              }
               if (ele.cbBrand === 0) {
                 ele.cbBrand = null
               }
@@ -8320,9 +8335,10 @@ export default {
     /* 确认新增 */
     makeSureAddNew () {
       this.standaloneList.push({
-        hpName: this.addNewStandName,
-        hpOrder: ++this.templateAddIndex,
         id: this.templateAddIndex,
+        uuid: this.genUuid(),
+        hpOrder: ++this.templateAddIndex,
+        hpName: this.addNewStandName,
         hpType: "水机", //类型
         hpOpenDelay: 0, //开启延迟
         hpCloseDelay: 0, //关闭延迟
@@ -8442,9 +8458,10 @@ export default {
     /* 确认新增 */
     makeSureAddNewCopy () {
       this.standaloneList.push({
-        hpName: "主机",
-        hpOrder: ++this.templateAddIndex,
         id: this.templateAddIndex,
+        uuid: this.genUuid(),
+        hpOrder: ++this.templateAddIndex,
+        hpName: "主机",
         hpType: "水机", //类型
         hpOpenDelay: 0, //开启延迟
         hpCloseDelay: 0, //关闭延迟
@@ -8565,9 +8582,10 @@ export default {
     /* 确定新增新风机 */
     makeSureAddNewDh () {
       this.standaloneDhList.push({
-        dhName: this.addNewStandNameDh,
-        dhOrder: ++this.templateAddDhIndex,
         id: this.templateAddDhIndex,
+        uuid: this.genUuid(),
+        dhOrder: ++this.templateAddDhIndex,
+        dhName: this.addNewStandNameDh,
         dhType: "双冷源", //类型
         dhModeAvail: [
           {
@@ -8818,9 +8836,10 @@ export default {
     /* 确定新增换热站 */
     makeSureAddNewHex () {
       this.standaloneHexList.push({
-        hexName: this.addNewStandNameHex,
-        hexOrder: ++this.templateAddExIndex,
         id: this.templateAddExIndex,
+        uuid: this.genUuid(),
+        hexOrder: ++this.templateAddExIndex,
+        hexName: this.addNewStandNameHex,
         hexType: "板换", //类型
         hexModeAvail: [
           {
@@ -9067,7 +9086,10 @@ export default {
       });
       this.activeOperateHexIndex = this.standaloneHexList.length - 1;
     },
-    /* 确定新增 */
+    /* 生成唯一码 */
+    genUuid() {
+      return uuidv4();
+    },
     /* 删除某个主机 */
     deleteStandaloneRow (index) {
       this.$confirm("确定删除该主机吗?", "警告", {
@@ -9461,7 +9483,6 @@ export default {
           if (ele.id > 0) {
             sourceArr.push(ele.id)
           }
-
           if (ele.cbOrder > 0) {
             sourceArrOrder.push(ele.cbOrder)
           }
@@ -9470,12 +9491,13 @@ export default {
 
       let maxId = Math.max(...sourceArr)
       let maxOrder = Math.max(...sourceArrOrder)
-
-      console.log(maxId, maxOrder)
+      // console.log(maxId, maxOrder)
       this.regionalStructTopList[this.activeAddOperateAreaIndex].listRooms.push(
         {
-          cbOrder: maxOrder + 1,
+          
           id: maxId + 1,
+          uuid: this.genUuid(),
+          cbOrder: maxOrder + 1,
           cbType: "",
           cbIcon: "",
           cbModeAvail: [
@@ -9597,7 +9619,6 @@ export default {
           if (ele.id > 0) {
             sourceArr.push(ele.id)
           }
-
           if (ele.cbOrder > 0) {
             sourceArrOrder.push(ele.cbOrder)
           }