-
设备列表
+ 设备列表
+ 添加设备
-
+
-
+
@@ -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);
}