From e37e45cfe1123928dba5d9c5a427b0ee497b7ad6 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 23 八月 2022 03:21:32 +0800
Subject: [PATCH] 修复算法配置的字段内容

---
 src/views/equipmentManagement/equipmentList/components/AddBox.vue |  380 +++++++++++++++++++++--------------------------------
 1 files changed, 151 insertions(+), 229 deletions(-)

diff --git a/src/views/equipmentManagement/equipmentList/components/AddBox.vue b/src/views/equipmentManagement/equipmentList/components/AddBox.vue
index 86a3bdb..dc7f034 100644
--- a/src/views/equipmentManagement/equipmentList/components/AddBox.vue
+++ b/src/views/equipmentManagement/equipmentList/components/AddBox.vue
@@ -1,121 +1,73 @@
 <template>
   <div class="addBox">
-    <div class="title">鍔犲叆闆嗙兢</div>
+    <div class="title">娣诲姞璁惧</div>
 
     <div class="close iconfont" @click="close()">&#xe60f;</div>
 
     <div class="search">
-      <el-input
-        v-model="searchContent"
-        placeholder="璇疯緭鍏ラ泦缇P/闆嗙兢鍚嶇О/璁惧IP/璁惧鍚嶇О"
-      ></el-input>
-      <div class="button" @click="listType = 'cluster'">鎼滅储闆嗙兢</div>
-      <div class="button" @click="listType = 'equipment'">鎼滅储璁惧</div>
+      <el-input v-model="searchContent" placeholder="璇疯緭鍏ラ泦缇P/闆嗙兢鍚嶇О/璁惧IP/璁惧鍚嶇О"></el-input>
+      <div class="button" @click="searchCluster">鎼滅储闆嗙兢</div>
+      <div class="button" @click="searchDevice">鎼滅储璁惧</div>
     </div>
 
     <div class="clusterList">
       <div class="tableList" v-if="listType == 'cluster'">
         <div class="header">
-          <div
-            class="label"
-            v-for="(item, index) in clusterHeader"
-            :key="index"
-          >
+          <div class="label" v-for="(item, index) in clusterHeader" :key="index">
             {{ item }}
           </div>
         </div>
         <div class="body" v-if="listType == 'cluster'">
-          <div class="row" v-for="(item, index) in clusterList" :key="index">
-            <div class="content">
-              <div class="rowItem index">{{ index + 1 }}</div>
-              <div class="rowItem name">{{ item.name }}</div>
-              <div class="rowItem ip">{{ item.ip }}</div>
-              <div class="rowItem status">
-                <div v-if="item.status == 1" class="status green">宸叉坊鍔�</div>
-                <div v-else class="status">鏈坊鍔�</div>
+          <template v-if="clusterList.length > 0">
+            <div class="row" v-for="(item, index) in clusterList" :key="index">
+              <div class="content">
+                <div class="rowItem index">{{ index + 1 }}</div>
+                <div class="rowItem name">{{ item.clusterName }}</div>
+                <div class="rowItem ip">{{ item.virtualIp }}</div>
+                <div class="rowItem status">
+                  <div v-if="!item.canAdd" class="status green">宸叉坊鍔�</div>
+                  <div v-else class="status">鏈坊鍔�</div>
+                </div>
+                <div class="rowItem options">
+                  <!-- 娣诲姞 -->
+                  <span v-if="!item.canAdd">-</span>
+                  <template v-else>
+                    <span class="iconfont option" @click="showBox('cluster', item.clusterId)">&#xe63f;</span>
+                    <!-- 闆嗙兢璇︽儏  -->
+                    <span class="iconfont option" @click="showChildrenLIst(index, item.clusterId)">&#xe63e;</span>
+                  </template>
+                </div>
               </div>
-              <div class="rowItem options">
-                <!-- 娣诲姞 -->
-                <span class="iconfont option" @click="showPasswordBox = true"
-                  >&#xe63f;</span
-                >
-                <!-- 闆嗙兢璇︽儏  -->
-                <span class="iconfont option" @click="showChildrenLIst(index)"
-                  >&#xe63e;</span
-                >
+
+              <div class="overList" :class="{ isShow: showClusterChild == index }">
+                <el-table :data="overList" :fit="true" header-row-class-name="overList-head">
+                  <el-table-column label="搴忓彿" type="index" width="146" class-name="index "> </el-table-column>
+                  <el-table-column prop="dev_id" label="璁惧ID"></el-table-column>
+
+                  <el-table-column prop="dev_ip" label="璁惧IP" width="146"></el-table-column>
+
+                  <el-table-column prop="dev_name" label="璁惧鍚嶇О" width="240"></el-table-column>
+                </el-table>
+
+                <div class="iconfont" @click="showClusterChild = null">
+                  &#xe63d;
+                </div>
               </div>
             </div>
-
-            <div
-              class="overList"
-              :class="{ isShow: showClusterChild == index }"
-            >
-              <el-table
-                :data="overList"
-                :fit="true"
-                header-row-class-name="overList-head"
-              >
-                <el-table-column
-                  label="搴忓彿"
-                  type="index"
-                  width="146"
-                  class-name="index "
-                >
-                </el-table-column>
-                <el-table-column
-                  prop="id"
-                  label="璁惧ID"
-                  width="146"
-                ></el-table-column>
-
-                <el-table-column
-                  prop="ip"
-                  label="璁惧IP"
-                  width="146"
-                ></el-table-column>
-
-                <el-table-column
-                  prop="name"
-                  label="璁惧鍚嶇О"
-                  width="240"
-                ></el-table-column>
-              </el-table>
-
-              <div class="iconfont" @click="showClusterChild = null">
-                &#xe63d;
-              </div>
-            </div>
-          </div>
+          </template>
+          <div class="empty" v-else>鏆傛棤鏁版嵁</div>
         </div>
       </div>
 
-      <el-table
-        :data="equipmentList"
-        :fit="true"
-        v-if="listType == 'equipment'"
-      >
-        <el-table-column
-          label="搴忓彿"
-          type="index"
-          width="72"
-          class-name="index"
-        >
-        </el-table-column>
-        <el-table-column prop="id" label="璁惧ID" width="107"></el-table-column>
-        <el-table-column
-          prop="name"
-          label="璁惧鍚嶇О"
-          width="107"
-        ></el-table-column>
-        <el-table-column prop="ip" label="璁惧IP" width="107"></el-table-column>
-        <el-table-column
-          prop="cluster"
-          label="鎵�灞為泦缇�"
-          width="107"
-        ></el-table-column>
+      <el-table :data="equipmentList" :fit="true" v-if="listType == 'equipment'">
+        <el-table-column label="搴忓彿" type="index" width="72" class-name="index"> </el-table-column>
+        <el-table-column prop="devId" label="璁惧ID"></el-table-column>
+        <el-table-column prop="devName" label="璁惧鍚嶇О" width="107"></el-table-column>
+        <el-table-column prop="devIp" label="璁惧IP" width="107"></el-table-column>
+        <el-table-column prop="clusterName" label="鎵�灞為泦缇�" width="107"></el-table-column>
         <el-table-column label="鐘舵��" width="107">
           <template slot-scope="scope">
-            <div v-if="scope.row.status == 1" class="status green">宸叉坊鍔�</div>
+            <div v-if="!scope.row.canAdd" class="status green">宸叉坊鍔�</div>
             <div v-else class="status">鏈坊鍔�</div>
           </template>
         </el-table-column>
@@ -124,7 +76,8 @@
           <template slot-scope="scope">
             <div class="options" v-if="scope">
               <!-- 娣诲姞 -->
-              <span class="iconfont option" @click="showPasswordBox = true"
+              <span v-if="!scope.row.canAdd">-</span>
+              <span v-else class="iconfont option" @click="showBox('dev', scope.row.devId, scope.row.clusterId)"
                 >&#xe63f;</span
               >
             </div>
@@ -137,20 +90,21 @@
       <div class="title">鐢宠娣诲姞璁惧</div>
       <div class="des">
         <span class="iconfont">&#xe601;</span>
-        濡傝澶囧凡鍔犲叆闆嗙兢锛屾坊鍔犵鐞嗗悗闆嗙兢涓嬫墍鏈夎澶囧皢鍦ㄨ澶囩鐞�
-        椤甸潰鏄剧ず锛屽苟鏀寔淇℃伅鏌ョ湅鍙婄鐞嗐��
+        濡傝澶囧凡鍔犲叆闆嗙兢锛屾坊鍔犵鐞嗗悗闆嗙兢涓嬫墍鏈夎澶囧皢鍦ㄨ澶囩鐞� 椤甸潰鏄剧ず锛屽苟鏀寔淇℃伅鏌ョ湅鍙婄鐞嗐��
       </div>
       <div class="ask">瀵嗛挜淇℃伅璇疯闂澶囩鐞嗕汉鍛�</div>
       <el-input v-model="auth_password"></el-input>
       <div class="btns">
         <div class="cancel button" @click="showPasswordBox = false">鍙栨秷</div>
-        <div class="submit button" @click="showPasswordBox = false">鎻愪氦</div>
+        <div class="submit button" @click="submit">鎻愪氦</div>
       </div>
     </div>
   </div>
 </template>
 
 <script>
+import { findDeviceListAll, findClustersBySearch, getDevicesByCluster, addCluster, addDeviceToUser } from "@/api/device"
+
 export default {
   data() {
     return {
@@ -159,144 +113,103 @@
       showClusterChild: null, //灞曠ず闆嗙兢鍒楄〃涓嬫媺鍒楄〃
       clusterHeader: ["搴忓彿", "闆嗙兢鍚嶇О", "IP鍦板潃", "鐘舵��", "鎿嶄綔"], //闆嗙兢鍒楄〃琛ㄥご
       showPasswordBox: false,
-      clusterList: [
-        {
-          name: "闆嗙兢1",
-          ip: "192.168.7.45",
-          status: "1",
-        },
-        {
-          name: "闆嗙兢1",
-          ip: "192.168.7.45",
-          status: "1",
-        },
-        {
-          name: "闆嗙兢1",
-          ip: "192.168.7.45",
-          status: "0",
-        },
-        {
-          name: "闆嗙兢1",
-          ip: "192.168.7.45",
-          status: "0",
-        },
-      ],
-      equipmentList: [
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-      ],
-      overList: [
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-        {
-          id: "BJS23123132",
-          name: "鏈嶅姟鍣�20.10",
-          ip: "192.168.7.45",
-          cluster: "闆嗙兢1",
-          status: "1",
-        },
-      ],
+      clusterList: [],
+      equipmentList: [],
+      overList: [],
       auth_password: "", //鎺堟潈绉橀挜
-    };
+      addObj: {}
+    }
   },
+
   methods: {
     close() {
-      this.$emit("close");
+      this.$emit("close")
     },
-    showChildrenLIst(index) {
+    async showChildrenLIst(index, id) {
       if (this.showClusterChild === index) {
-        this.showClusterChild = null;
-        return;
+        this.showClusterChild = null
+        return
       } else if (!index) {
-        this.showClusterChild = index;
+        this.showClusterChild = index
       }
-      this.showClusterChild = null;
+      this.showClusterChild = null
       setTimeout(() => {
-        this.showClusterChild = index;
-      }, 400);
+        this.showClusterChild = index
+      }, 400)
+
+      const res = await getDevicesByCluster({
+        clusterId: id
+      })
+      if (res && res.success) {
+        this.overList = res.data.list
+      }
     },
-  },
-};
+    async getCluster() {
+      const res = await findClustersBySearch({
+        InputText: this.searchContent,
+        Page: 1,
+        Size: 10000
+      })
+      if (res && res.success) {
+        this.clusterList = res.data.list
+      }
+    },
+
+    async getDevice() {
+      const res = await findDeviceListAll({
+        InputText: this.searchContent,
+        Page: 1,
+        Size: 10000
+      })
+      if (res && res.success) {
+        this.equipmentList = res.data.list
+      }
+    },
+
+    searchCluster() {
+      this.getCluster()
+      this.listType = "cluster"
+    },
+
+    searchDevice() {
+      this.getDevice()
+      this.listType = "equipment"
+    },
+
+    async submit() {
+      let res = {}
+      if (this.addObj.type == "cluster") {
+        res = await addCluster({
+          authPwd: this.auth_password,
+          clusterId: this.addObj.id
+        })
+      } else {
+        res = await addDeviceToUser({
+          authPwd: this.auth_password,
+          deviceId: this.addObj.id,
+          clusterId: this.addObj.cid
+        })
+      }
+
+      if (res && res.success) {
+        this.$notify({
+          type: "success",
+          message: "娣诲姞鎴愬姛"
+        })
+        this.close()
+      }
+    },
+    showBox(type, id, cid) {
+      this.auth_password = ""
+      this.showPasswordBox = true
+      this.addObj = {
+        type,
+        id,
+        cid
+      }
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -360,6 +273,15 @@
   .clusterList {
     max-height: 507px;
     overflow-y: overlay;
+
+    .empty {
+      height: 60px;
+      background-color: rgb(233, 235, 238);
+      line-height: 60px;
+      color: #909399;
+      font-size: 14px;
+      text-align: center;
+    }
   }
 
   .tableList {
@@ -571,7 +493,7 @@
     .btns {
       margin-top: 40px;
       display: flex;
-      justify-content: end;
+      justify-content: flex-end;
       text-align: center;
       line-height: 32px;
       font-size: 14px;
@@ -595,4 +517,4 @@
     }
   }
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0