| | |
| | | <div class="cluster"> |
| | | 所属集群 |
| | | <el-select v-model="cluster" placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in clusterArr" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | <el-option v-for="item in clusterArr" :key="item.value" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | |
| | | </div> |
| | | |
| | | <div class="btns"> |
| | | <div class="button add" @click="isShowAdd = true"> |
| | | <span>+</span>添加设备 |
| | | </div> |
| | | <div class="button export" @click="exportFile"> |
| | | <span class="iconfont"></span>导出 |
| | | </div> |
| | | <div class="button add" @click="isShowAdd = true"><span>+</span>添加设备</div> |
| | | <div class="button export" @click="exportFile"><span class="iconfont"></span>导出</div> |
| | | </div> |
| | | |
| | | <div class="table-area"> |
| | |
| | | :stripe="true" |
| | | > |
| | | <el-table-column label="序号" width="80" class-name="index"> |
| | | <template slot-scope="scope">{{ |
| | | scope.$index + 1 + (page - 1) * size |
| | | }}</template> |
| | | <template slot-scope="scope">{{ scope.$index + 1 + (page - 1) * size }}</template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="devId" |
| | | label="设备ID" |
| | | min-width="140" |
| | | show-overflow-tooltip |
| | | ></el-table-column> |
| | | <el-table-column |
| | | prop="devName" |
| | | label="设备名称" |
| | | min-width="140" |
| | | show-overflow-tooltip |
| | | ></el-table-column> |
| | | <el-table-column |
| | | prop="devIp" |
| | | label="IP地址" |
| | | min-width="150" |
| | | ></el-table-column> |
| | | <el-table-column prop="devId" label="设备ID" min-width="185" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="devName" label="设备名称" min-width="140" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="devIp" label="IP地址" min-width="150"></el-table-column> |
| | | <el-table-column label="安装时间" min-width="159"> |
| | | <template slot-scope="scope"> |
| | | <div v-if="scope.row.installTime.length > 1"> |
| | |
| | | <el-table-column label="操作" min-width="180"> |
| | | <template slot-scope="scope"> |
| | | <!-- 加入 --> |
| | | <el-tooltip |
| | | content="加入集群" |
| | | placement="top" |
| | | v-if="!scope.row.clusterId" |
| | | > |
| | | <el-tooltip content="加入集群" placement="top" v-if="!scope.row.clusterId"> |
| | | <span |
| | | class="iconfont option" |
| | | @click="joinCluster(scope.row)" |
| | |
| | | </el-tooltip> |
| | | <!-- 解绑 --> |
| | | <el-tooltip content="解除绑定" placement="top"> |
| | | <span |
| | | class="iconfont option" |
| | | @click="Untying(scope.row)" |
| | | :class="{ disable: scope.row.isOnline != 1 }" |
| | | <span class="iconfont option" @click="Untying(scope.row)" :class="{ disable: scope.row.isOnline != 1 }" |
| | | ></span |
| | | > |
| | | </el-tooltip> |
| | |
| | | </div> |
| | | |
| | | <!-- 解绑弹窗 --> |
| | | <UnbindBox |
| | | @close="closeUnbindBox" |
| | | v-if="isShowUnbind" |
| | | :id="unbindId" |
| | | @reflash="reflash" |
| | | ></UnbindBox> |
| | | <UnbindBox @close="closeUnbindBox" v-if="isShowUnbind" :id="unbindId" @reflash="reflash"></UnbindBox> |
| | | |
| | | <!-- 添加设备弹窗 --> |
| | | <AddBox @close="closeAddBox" v-if="isShowAdd"></AddBox> |
| | | |
| | | <!-- 退出集群弹窗 --> |
| | | <QuitClusterBox |
| | | :equipment="activeEquipment" |
| | | v-if="showQuit" |
| | | @close="showQuit = false" |
| | | ></QuitClusterBox> |
| | | <QuitClusterBox :equipment="activeEquipment" v-if="showQuit" @close="showQuit = false"></QuitClusterBox> |
| | | |
| | | <!-- 加入集群弹窗 --> |
| | | <JoinClusterBox |
| | | :equipment="activeEquipment" |
| | | v-if="showJoin" |
| | | @close="showJoin = false" |
| | | ></JoinClusterBox> |
| | | <JoinClusterBox :equipment="activeEquipment" v-if="showJoin" @close="showJoin = false"></JoinClusterBox> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | findDevList, |
| | | findClustersBySearch, |
| | | exportDevListExcel, |
| | | } from "@/api/device"; |
| | | import AddBox from "@/views/equipmentManagement/equipmentList/components/AddBox"; |
| | | import UnbindBox from "@/views/equipmentManagement/equipmentDetail/components/UnbindBox"; |
| | | import QuitClusterBox from "@/views/equipmentManagement/equipmentList/components/QuitClusterBox"; |
| | | import JoinClusterBox from "@/views/equipmentManagement/equipmentList/components/JoinClusterBox"; |
| | | import { findDevList, findClustersBySearch, exportDevListExcel } from "@/api/device" |
| | | import AddBox from "@/views/equipmentManagement/equipmentList/components/AddBox" |
| | | import UnbindBox from "@/views/equipmentManagement/equipmentDetail/components/UnbindBox" |
| | | import QuitClusterBox from "@/views/equipmentManagement/equipmentList/components/QuitClusterBox" |
| | | import JoinClusterBox from "@/views/equipmentManagement/equipmentList/components/JoinClusterBox" |
| | | |
| | | import bus from "@/plugin/bus"; |
| | | import bus from "@/plugin/bus" |
| | | |
| | | export default { |
| | | components: { |
| | | AddBox, |
| | | UnbindBox, |
| | | QuitClusterBox, |
| | | JoinClusterBox, |
| | | JoinClusterBox |
| | | }, |
| | | created() { |
| | | this.getCluster(); |
| | | this.getCluster() |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | cluster: null, //选中的集群类型 |
| | | showQuit: false, //展示退出集群的弹窗 |
| | | showJoin: false, //展示加入集群的弹窗 |
| | | activeEquipment: null, //处理中的设备 |
| | | }; |
| | | activeEquipment: null //处理中的设备 |
| | | } |
| | | }, |
| | | methods: { |
| | | async getCluster() { |
| | |
| | | InputText: "", |
| | | Page: 1, |
| | | Size: 10000, |
| | | userId: JSON.parse(sessionStorage.getItem("userInfo")).id, |
| | | }); |
| | | userId: JSON.parse(sessionStorage.getItem("userInfo")).id |
| | | }) |
| | | if (res && res.success) { |
| | | res.data.list.forEach((item) => { |
| | | this.clusterArr.push({ |
| | | label: item.clusterName, |
| | | value: item.clusterId, |
| | | }); |
| | | }); |
| | | value: item.clusterId |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 跳到设备详情 |
| | | checkDetail(row) { |
| | | if (row.isOnline != 1) { |
| | | return; |
| | | return |
| | | } |
| | | this.$router.push({ |
| | | path: "/equipmentDetail", |
| | | query: { |
| | | id: row.devId, |
| | | }, |
| | | }); |
| | | id: row.devId |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 跳到算法详情 |
| | | algorithmDetail(row) { |
| | | if (row.isOnline != 1) { |
| | | return; |
| | | return |
| | | } |
| | | this.$router.push({ |
| | | path: "/algorithmDetail", |
| | | query: { |
| | | id: row.devId, |
| | | }, |
| | | }); |
| | | id: row.devId |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 查询列表 |
| | | searchingBtn() { |
| | | let param = {}; |
| | | let param = {} |
| | | |
| | | if (!this.searchTime) { |
| | | param = { |
| | |
| | | startTime: "", |
| | | endTime: "", |
| | | clusterId: this.cluster, |
| | | inputText: this.inputText, |
| | | }; |
| | | inputText: this.inputText |
| | | } |
| | | } else { |
| | | param = { |
| | | page: this.page, |
| | |
| | | startTime: this.searchTime[0], |
| | | endTime: this.searchTime[1], |
| | | clusterId: this.cluster, |
| | | inputText: this.inputText, |
| | | }; |
| | | inputText: this.inputText |
| | | } |
| | | } |
| | | |
| | | findDevList(param) |
| | | .then((res) => { |
| | | this.dataList = res.data.list; |
| | | this.dataList = res.data.list |
| | | //时间分行显示 |
| | | this.dataList.forEach((item) => { |
| | | item.installTime = item.installTime.split(" "); |
| | | item.firstUseTime = item.firstUseTime.split(" "); |
| | | }); |
| | | this.total = res.data.total; |
| | | item.installTime = item.installTime.split(" ") |
| | | item.firstUseTime = item.firstUseTime.split(" ") |
| | | }) |
| | | this.total = res.data.total |
| | | if (res.data.total <= this.size) { |
| | | this.page = 1; |
| | | this.page = 1 |
| | | } |
| | | |
| | | bus.$emit("refleshNode", this.dataList); |
| | | bus.$emit("refleshNode", this.dataList) |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err); |
| | | }); |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | |
| | | //分页功能 |
| | | handleSizeChange(size) { |
| | | this.size = size; |
| | | this.searchingBtn(); |
| | | this.size = size |
| | | this.searchingBtn() |
| | | }, |
| | | //分页功能 |
| | | refrash(page) { |
| | | this.page = page; |
| | | this.searchingBtn(); |
| | | this.page = page |
| | | this.searchingBtn() |
| | | }, |
| | | |
| | | //解绑按钮 |
| | | Untying(row) { |
| | | if (row.isOnline != 1) { |
| | | return; |
| | | return |
| | | } |
| | | this.unbindId = row.devId; |
| | | this.isShowUnbind = true; |
| | | this.unbindId = row.devId |
| | | this.isShowUnbind = true |
| | | }, |
| | | |
| | | //获得默认时间 |
| | | getDateInit() { |
| | | // 要求 默认一个月 |
| | | const end = new Date(); |
| | | const start = new Date(); |
| | | const nowDate = new Date(); |
| | | nowDate.setHours(0); |
| | | nowDate.setMinutes(0); |
| | | nowDate.setSeconds(0); |
| | | nowDate.setMilliseconds(0); |
| | | start.setTime(nowDate.getTime() - 3600 * 1000 * 24 * 30); |
| | | end.setTime(nowDate.getTime() + 3600 * 1000 * 24 - 1); |
| | | return [ |
| | | this.$moment(start).format("YYYY-MM-DD HH:mm:ss"), |
| | | this.$moment(end).format("YYYY-MM-DD HH:mm:ss"), |
| | | ]; |
| | | const end = new Date() |
| | | const start = new Date() |
| | | const nowDate = new Date() |
| | | nowDate.setHours(0) |
| | | nowDate.setMinutes(0) |
| | | nowDate.setSeconds(0) |
| | | nowDate.setMilliseconds(0) |
| | | start.setTime(nowDate.getTime() - 3600 * 1000 * 24 * 30) |
| | | end.setTime(nowDate.getTime() + 3600 * 1000 * 24 - 1) |
| | | return [this.$moment(start).format("YYYY-MM-DD HH:mm:ss"), this.$moment(end).format("YYYY-MM-DD HH:mm:ss")] |
| | | }, |
| | | |
| | | //关闭新增弹窗 |
| | | closeAddBox() { |
| | | this.isShowAdd = false; |
| | | this.searchingBtn(); |
| | | this.isShowAdd = false |
| | | this.searchingBtn() |
| | | }, |
| | | // 关闭解绑弹窗 |
| | | closeUnbindBox() { |
| | | this.isShowUnbind = false; |
| | | this.isShowUnbind = false |
| | | }, |
| | | |
| | | //解绑成功回调 |
| | | reflash() { |
| | | this.isShowUnbind = false; |
| | | this.searchingBtn(); |
| | | this.isShowUnbind = false |
| | | this.searchingBtn() |
| | | }, |
| | | |
| | | clearSearch() { |
| | | this.searchTime = this.getDateInit(); |
| | | this.inputText = ""; |
| | | this.cluster = ""; |
| | | this.searchingBtn(); |
| | | this.searchTime = this.getDateInit() |
| | | this.inputText = "" |
| | | this.cluster = "" |
| | | this.searchingBtn() |
| | | }, |
| | | |
| | | //退出集群 |
| | | quitCluster(equipment) { |
| | | if (equipment.isOnline != 1) { |
| | | return; |
| | | return |
| | | } |
| | | this.activeEquipment = equipment; |
| | | this.showQuit = true; |
| | | this.activeEquipment = equipment |
| | | this.showQuit = true |
| | | }, |
| | | |
| | | //加入集群 |
| | | joinCluster(equipment) { |
| | | if (equipment.isOnline != 1) { |
| | | return; |
| | | return |
| | | } |
| | | this.activeEquipment = equipment; |
| | | this.showJoin = true; |
| | | this.activeEquipment = equipment |
| | | this.showJoin = true |
| | | }, |
| | | |
| | | //导出列表文件 |
| | | async exportFile() { |
| | | let param = {}; |
| | | let param = {} |
| | | |
| | | if (!this.searchTime) { |
| | | param = { |
| | |
| | | startTime: "", |
| | | endTime: "", |
| | | clusterId: this.cluster, |
| | | inputText: this.inputText, |
| | | }; |
| | | inputText: this.inputText |
| | | } |
| | | } else { |
| | | param = { |
| | | page: this.page, |
| | |
| | | startTime: this.searchTime[0], |
| | | endTime: this.searchTime[1], |
| | | clusterId: this.cluster, |
| | | inputText: this.inputText, |
| | | }; |
| | | inputText: this.inputText |
| | | } |
| | | } |
| | | const result = await exportDevListExcel(param); |
| | | const result = await exportDevListExcel(param) |
| | | |
| | | var blob = new Blob([result.body.data], { |
| | | type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8", |
| | | type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8" |
| | | }), |
| | | Temp = document.createElement("a"); |
| | | Temp = document.createElement("a") |
| | | |
| | | Temp.href = window.URL.createObjectURL(blob); |
| | | Temp.href = window.URL.createObjectURL(blob) |
| | | |
| | | console.log(result); |
| | | console.log(result.fileName); |
| | | console.log(result) |
| | | console.log(result.fileName) |
| | | |
| | | Temp.download = window.decodeURI(result.fileName); |
| | | Temp.download = window.decodeURI(result.fileName) |
| | | |
| | | Temp.setAttribute("download", result.fileName); |
| | | Temp.setAttribute("download", result.fileName) |
| | | |
| | | document.body.appendChild(Temp); |
| | | document.body.appendChild(Temp) |
| | | |
| | | Temp.click(); |
| | | Temp.click() |
| | | |
| | | document.body.removeChild(Temp); |
| | | document.body.removeChild(Temp) |
| | | |
| | | window.URL.revokeObjectURL(Temp); |
| | | }, |
| | | window.URL.revokeObjectURL(Temp) |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.searchingBtn(); |
| | | }, |
| | | }; |
| | | this.searchingBtn() |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | } |
| | | </style> |
| | | |
| | | <style > |
| | | <style> |
| | | .el-date-table td.start-date span, |
| | | .el-date-table td.end-date span { |
| | | background-color: #0065ff; |
| | |
| | | color: #0065ff; |
| | | border-color: #0065ff; |
| | | } |
| | | </style> |
| | | </style> |