From 98a4ce701cac233cb7938e741c57274ffee5afc8 Mon Sep 17 00:00:00 2001
From: CGD <3030332422@qq.com>
Date: Mon, 14 Apr 2025 16:10:46 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D"=E8=AE=BE=E5=A4=87?=
=?UTF-8?q?=E7=AE=A1=E7=90=86"=E9=A1=B5=E9=9D=A2=E8=A7=A3=E7=BB=91?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=97=B6=E5=87=BA=E7=8E=B0=E7=9A=84=E5=BC=82?=
=?UTF-8?q?=E5=B8=B8=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F=E8=A7=A3?=
=?UTF-8?q?=E7=BB=91=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=AE=8C=E5=96=84=E6=90=9C?=
=?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/DeviceManagement.vue | 78 ++++++++++++++++---
.../src/views/ParamsManagement.vue | 1 -
2 files changed, 68 insertions(+), 11 deletions(-)
diff --git a/main/manager-web/src/views/DeviceManagement.vue b/main/manager-web/src/views/DeviceManagement.vue
index 913ee0cc..9e362edb 100644
--- a/main/manager-web/src/views/DeviceManagement.vue
+++ b/main/manager-web/src/views/DeviceManagement.vue
@@ -26,9 +26,9 @@
-
-
-
+
+
+
@@ -40,15 +40,15 @@
-
+
-
+
-
+
解绑
@@ -86,7 +86,6 @@
-
@@ -105,17 +104,19 @@ export default {
selectedDevices: [],
isAllSelected: false,
searchKeyword: "",
+ activeSearchKeyword: "",
currentAgentId: this.$route.query.agentId || '',
currentPage: 1,
pageSize: 5,
deviceList: [],
loading: false,
userApi: null,
+
};
},
computed: {
filteredDeviceList() {
- const keyword = this.searchKeyword.toLowerCase();
+ const keyword = this.activeSearchKeyword.toLowerCase();
if (!keyword) return this.deviceList;
return this.deviceList.filter(device =>
(device.model && device.model.toLowerCase().includes(keyword)) ||
@@ -155,8 +156,8 @@ export default {
},
methods: {
handleSearch() {
+ this.activeSearchKeyword = this.searchKeyword;
this.currentPage = 1;
- this.fetchBindDevices(this.currentAgentId);
},
handleSelectionChange(val) {
@@ -168,7 +169,53 @@ export default {
},
deleteSelected() {
- console.log("批量解绑")
+ if (this.selectedDevices.length === 0) {
+ this.$message.warning({
+ message: '请至少选择一条记录',
+ showClose: true
+ });
+ return;
+ }
+
+ this.$confirm(`确认要解绑选中的 ${this.selectedDevices.length} 台设备吗?`, '警告', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ const deviceIds = this.selectedDevices.map(device => device.device_id);
+ this.batchUnbindDevices(deviceIds);
+ });
+ },
+
+ batchUnbindDevices(deviceIds) {
+ const promises = deviceIds.map(id => {
+ return new Promise((resolve, reject) => {
+ Api.device.unbindDevice(id, ({ data }) => {
+ if (data.code === 0) {
+ resolve();
+ } else {
+ reject(data.msg || '解绑失败');
+ }
+ });
+ });
+ });
+
+ Promise.all(promises)
+ .then(() => {
+ this.$message.success({
+ message: `成功解绑 ${deviceIds.length} 台设备`,
+ showClose: true
+ });
+ this.fetchBindDevices(this.currentAgentId);
+ this.selectedDevices = [];
+ this.isAllSelected = false;
+ })
+ .catch(error => {
+ this.$message.error({
+ message: error || '批量解绑过程中出现错误',
+ showClose: true
+ });
+ });
},
handleAddDevice() {
@@ -237,6 +284,8 @@ export default {
};
})
.sort((a, b) => a.rawBindTime - b.rawBindTime);
+ this.activeSearchKeyword = "";
+ this.searchKeyword = "";
} else {
this.$message.error(data.msg || '获取设备列表失败');
}
@@ -465,4 +514,13 @@ export default {
font-weight: bold;
padding-bottom: 18px;
}
+
+:deep(.el-table .el-button--text) {
+ color: #7079aa;
+}
+
+:deep(.el-table .el-button--text:hover) {
+ color: #5a64b5;
+}
+
diff --git a/main/manager-web/src/views/ParamsManagement.vue b/main/manager-web/src/views/ParamsManagement.vue
index 47c4edf9..55fdf2d2 100644
--- a/main/manager-web/src/views/ParamsManagement.vue
+++ b/main/manager-web/src/views/ParamsManagement.vue
@@ -73,7 +73,6 @@
-