-
设备列表
+ 设备列表
+ 添加设备
-
+
-
+
@@ -37,6 +37,16 @@
+
©2025 xiaozhi-esp32-server
@@ -55,43 +65,27 @@ export default {
data() {
return {
addDeviceDialogVisible: false,
- deviceList: [
- {
- model: 'xingzhi-cube-0.96oled-wifi',
- firmwareVersion: '1.4.6',
- macAddress: 'fc:01:2c:c5:d5:7c',
- bindTime: '2025-03-10 18:16:21',
- lastConversation: '6 天前',
- remark: '',
- isEdit: false,
- otaSwitch: false
- },
- {
- model: 'xingzhi-board-1.3tft-ble',
- firmwareVersion: '2.1.0',
- macAddress: 'ac:12:3d:e7:f8:9a',
- bindTime: '2025-03-12 09:30:15',
- lastConversation: '4 天前',
- remark: '测试设备',
- isEdit: false,
- otaSwitch: true
- },
- {
- model: 'xingzhi-kit-0.91oled-4g',
- firmwareVersion: '1.8.3',
- macAddress: 'bc:45:6f:1e:2d:3c',
- bindTime: '2025-03-15 14:22:08',
- lastConversation: '2 天前',
- remark: '生产环境设备',
- isEdit: false,
- otaSwitch: false
- },
- ]
+ currentPage: 1,
+ pageSize: 5,
+ deviceList: [],
+ loading: false,
};
},
+ computed: {
+ paginatedDeviceList() {
+ const start = (this.currentPage - 1) * this.pageSize;
+ const end = start + this.pageSize;
+ return this.deviceList.slice(start, end);
+ }
+ },
+ mounted() {
+ const agentId = this.$route.query.agentId;
+ if (agentId) {
+ this.fetchBindDevices(agentId);
+ }
+ },
methods: {
handleAddDevice() {
- // 添加设备逻辑
this.addDeviceDialogVisible = true;
},
startEditRemark(index, row) {
@@ -101,12 +95,42 @@ export default {
this.deviceList[index].isEdit = false;
},
handleUnbind(device) {
- // 解绑逻辑
console.log('解绑设备', device);
},
handleDeviceAdded(deviceCode) {
- console.log('添加的智慧体名称:', deviceCode);
+ console.log('添加的智能体名称:', deviceCode);
},
+ handleSizeChange(val) {
+ this.pageSize = val;
+ },
+ handleCurrentChange(val) {
+ this.currentPage = val;
+ },
+ fetchBindDevices(agentId) {
+ this.loading = true;
+ import('@/apis/module/user').then(({ default: userApi }) => {
+ userApi.getAgentBindDevices(agentId, ({ data }) => {
+ this.loading = false;
+ if (data.code === 0) {
+ this.deviceList = data.data[0]?.list.map(device => ({
+ id: device.id,
+ model: device.device_type,
+ firmwareVersion: device.app_version,
+ macAddress: device.mac_address,
+ lastConversation: device.recent_chat_time,
+ remark: '',
+ isEdit: false,
+ otaSwitch: device.ota_upgrade === 1
+ }));
+ } else {
+ this.$message.error(data.msg || '获取设备列表失败');
+ }
+ });
+ }).catch(error => {
+ console.error('模块加载失败:', error);
+ this.$message.error('功能模块加载失败');
+ });
+ },
}
};
@@ -166,4 +190,8 @@ export default {
vertical-align: middle;
}
-
\ No newline at end of file
+.pagination {
+ margin-top: 20px;
+ text-align: right;
+}
+
diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue
index adf8bedf..fb37fb16 100644
--- a/main/manager-web/src/views/roleConfig.vue
+++ b/main/manager-web/src/views/roleConfig.vue
@@ -225,6 +225,7 @@ export default {
},
mounted() {
const agentId = this.$route.query.agentId;
+ console.log('agentId2222',agentId);
if (agentId) {
this.fetchAgentConfig(agentId);
}
From a43acca37592b11e9c295c12789c6a469fe76514 Mon Sep 17 00:00:00 2001
From: CGD <3030332422@qq.com>
Date: Tue, 25 Mar 2025 18:59:05 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86user.js=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main/manager-web/src/apis/module/user.js | 79 +++++-------------------
1 file changed, 17 insertions(+), 62 deletions(-)
diff --git a/main/manager-web/src/apis/module/user.js b/main/manager-web/src/apis/module/user.js
index 6bd4acea..8110e6c7 100755
--- a/main/manager-web/src/apis/module/user.js
+++ b/main/manager-web/src/apis/module/user.js
@@ -18,51 +18,6 @@ export default {
})
}).send()
},
- // 获取设备信息
- getHomeList(callback) {
- RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/device/bind`)
- .method('GET')
- .success((res) => {
- RequestService.clearRequestTime()
- callback(res)
- })
- .fail(() => {
- RequestService.reAjaxFun(() => {
- this.getUserInfo()
- })
- }).send()
- },
- // 解绑设备
- unbindDevice(device_id, callback) {
- RequestService.sendRequest()
- .url(`${getServiceUrl()}/api/v1/user/device/unbind/${device_id}`)
- .method('PUT')
- .success((res) => {
- RequestService.clearRequestTime();
- callback(res);
- })
- .fail(() => {
- RequestService.reAjaxFun(() => {
- this.unbindDevice(device_id, callback);
- });
- }).send()
- },
- // 绑定设备
- bindDevice(deviceCode, callback) {
- RequestService.sendRequest()
- .url(`${getServiceUrl()}/api/v1/user/device/bind/${deviceCode}`)
- .method('POST')
- .success((res) => {
- RequestService.clearRequestTime();
- callback(res);
- })
- .fail((err) => {
- console.error('绑定设备失败:', err);
- RequestService.reAjaxFun(() => {
- this.bindDevice(deviceCode, callback);
- });
- }).send();
- },
// 获取验证码
getCaptcha(uuid, callback) {
@@ -158,7 +113,7 @@ export default {
});
}).send();
},
-
+ // 用户信息获取
getUserInfo(callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/user/info`)
@@ -257,20 +212,20 @@ export default {
});
}).send();
},
- // 获取已绑设备
- getAgentBindDevices(agentId, callback) {
- RequestService.sendRequest()
- .url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`)
- .method('GET')
- .success((res) => {
- RequestService.clearRequestTime();
- callback(res);
- })
- .fail((err) => {
- console.error('获取设备列表失败:', err);
- RequestService.reAjaxFun(() => {
- this.getAgentBindDevices(agentId, callback);
- });
- }).send();
- },
+ // 已绑设备
+ getAgentBindDevices(agentId, callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`)
+ .method('GET')
+ .success((res) => {
+ RequestService.clearRequestTime();
+ callback(res);
+ })
+ .fail((err) => {
+ console.error('获取设备列表失败:', err);
+ RequestService.reAjaxFun(() => {
+ this.getAgentBindDevices(agentId, callback);
+ });
+ }).send();
+ },
}