From 986ead9c0ba1de832e5265a806d9c30f79f0688b Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期五, 15 七月 2022 20:27:37 +0800
Subject: [PATCH] 下载
---
src/views/equipmentManagement/equipmentList/components/AddBox.vue | 360 +++++++++++++++++++++++++++++------------------------------
1 files changed, 179 insertions(+), 181 deletions(-)
diff --git a/src/views/equipmentManagement/equipmentList/components/AddBox.vue b/src/views/equipmentManagement/equipmentList/components/AddBox.vue
index 86a3bdb..c4091d4 100644
--- a/src/views/equipmentManagement/equipmentList/components/AddBox.vue
+++ b/src/views/equipmentManagement/equipmentList/components/AddBox.vue
@@ -1,6 +1,6 @@
<template>
<div class="addBox">
- <div class="title">鍔犲叆闆嗙兢</div>
+ <div class="title">娣诲姞璁惧</div>
<div class="close iconfont" @click="close()"></div>
@@ -9,8 +9,8 @@
v-model="searchContent"
placeholder="璇疯緭鍏ラ泦缇P/闆嗙兢鍚嶇О/璁惧IP/璁惧鍚嶇О"
></el-input>
- <div class="button" @click="listType = 'cluster'">鎼滅储闆嗙兢</div>
- <div class="button" @click="listType = 'equipment'">鎼滅储璁惧</div>
+ <div class="button" @click="searchCluster">鎼滅储闆嗙兢</div>
+ <div class="button" @click="searchDevice">鎼滅储璁惧</div>
</div>
<div class="clusterList">
@@ -25,67 +25,77 @@
</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)"
+ ></span
+ >
+ <!-- 闆嗙兢璇︽儏 -->
+ <span
+ class="iconfont option"
+ @click="showChildrenLIst(index, item.clusterId)"
+ ></span
+ >
+ </template>
+ </div>
</div>
- <div class="rowItem options">
- <!-- 娣诲姞 -->
- <span class="iconfont option" @click="showPasswordBox = true"
- ></span
- >
- <!-- 闆嗙兢璇︽儏 -->
- <span class="iconfont option" @click="showChildrenLIst(index)"
- ></span
- >
- </div>
- </div>
- <div
- class="overList"
- :class="{ isShow: showClusterChild == index }"
- >
- <el-table
- :data="overList"
- :fit="true"
- header-row-class-name="overList-head"
+ <div
+ class="overList"
+ :class="{ isShow: showClusterChild == index }"
>
- <el-table-column
- label="搴忓彿"
- type="index"
- width="146"
- class-name="index "
+ <el-table
+ :data="overList"
+ :fit="true"
+ header-row-class-name="overList-head"
>
- </el-table-column>
- <el-table-column
- prop="id"
- label="璁惧ID"
- width="146"
- ></el-table-column>
+ <el-table-column
+ label="搴忓彿"
+ type="index"
+ width="146"
+ class-name="index "
+ >
+ </el-table-column>
+ <el-table-column
+ prop="dev_id"
+ label="璁惧ID"
+ width="146"
+ ></el-table-column>
- <el-table-column
- prop="ip"
- label="璁惧IP"
- width="146"
- ></el-table-column>
+ <el-table-column
+ prop="dev_ip"
+ label="璁惧IP"
+ width="146"
+ ></el-table-column>
- <el-table-column
- prop="name"
- label="璁惧鍚嶇О"
- width="240"
- ></el-table-column>
- </el-table>
+ <el-table-column
+ prop="dev_name"
+ label="璁惧鍚嶇О"
+ width="240"
+ ></el-table-column>
+ </el-table>
- <div class="iconfont" @click="showClusterChild = null">
- 
+ <div class="iconfont" @click="showClusterChild = null">
+ 
+ </div>
</div>
</div>
- </div>
+ </template>
+ <div class="empty" v-else>鏆傛棤鏁版嵁</div>
</div>
</div>
@@ -101,21 +111,29 @@
class-name="index"
>
</el-table-column>
- <el-table-column prop="id" label="璁惧ID" width="107"></el-table-column>
<el-table-column
- prop="name"
+ prop="devId"
+ label="璁惧ID"
+ width="107"
+ ></el-table-column>
+ <el-table-column
+ prop="devName"
label="璁惧鍚嶇О"
width="107"
></el-table-column>
- <el-table-column prop="ip" label="璁惧IP" width="107"></el-table-column>
<el-table-column
- prop="cluster"
+ 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 +142,11 @@
<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)"
></span
>
</div>
@@ -144,13 +166,21 @@
<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,131 +189,19 @@
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");
},
- showChildrenLIst(index) {
+ async showChildrenLIst(index, id) {
if (this.showClusterChild === index) {
this.showClusterChild = null;
return;
@@ -294,6 +212,77 @@
setTimeout(() => {
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,
+ };
},
},
};
@@ -360,6 +349,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 +569,7 @@
.btns {
margin-top: 40px;
display: flex;
- justify-content: end;
+ justify-content: flex-end;
text-align: center;
line-height: 32px;
font-size: 14px;
--
Gitblit v1.8.0