Skip to content

Commit 107ee7b

Browse files
committed
feat: 增加设备配置
1 parent 1f4c70a commit 107ee7b

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"sortablejs": "^1.15.3",
6868
"steady-xml": "^0.1.0",
6969
"url": "^0.11.3",
70+
"v3-jsoneditor": "^0.0.6",
7071
"video.js": "^7.21.5",
7172
"vue": "3.5.12",
7273
"vue-dompurify-html": "^4.1.4",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<template>
2+
<div>
3+
<el-alert
4+
title="IoT平台支持远程更新设备的配置文件(SON格式),您可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置,通过批量更新对设备进行批量远程维护和管理。"
5+
type="info"
6+
show-icon
7+
class="my-4"
8+
description="如需编辑文件,请点击下方编辑按钮"
9+
/>
10+
11+
<Vue3Jsoneditor
12+
ref="editor"
13+
v-if="isEditing"
14+
v-model="deviceConfig"
15+
:options="editorOptions"
16+
height="500px"
17+
currentMode="code"
18+
@error="onError"
19+
/>
20+
<Vue3Jsoneditor
21+
ref="editor"
22+
v-else
23+
v-model="deviceConfig"
24+
:options="editorOptions"
25+
height="500px"
26+
currentMode="view"
27+
@error="onError"
28+
/>
29+
<div class="button-group">
30+
<el-button v-if="isEditing" @click="cancelEdit">取消</el-button>
31+
<el-button v-if="isEditing" type="primary" @click="saveConfig">保存</el-button>
32+
<el-button v-else @click="enableEdit">编辑</el-button>
33+
</div>
34+
</div>
35+
</template>
36+
37+
<script lang="ts" setup>
38+
import { ref, computed } from 'vue';
39+
import Vue3Jsoneditor from 'v3-jsoneditor/src/Vue3Jsoneditor.vue';
40+
41+
// 定义设备配置的状态
42+
const deviceConfig = ref({
43+
"name": "dyla1n"
44+
});
45+
46+
// 编辑状态
47+
const isEditing = ref(false);
48+
49+
// JSON 编辑器的选项
50+
const editorOptions = computed(() => ({
51+
mainMenuBar: false,
52+
navigationBar: false,
53+
statusBar: false,
54+
}));
55+
56+
// 启用编辑模式的函数
57+
const enableEdit = () => {
58+
isEditing.value = true;
59+
};
60+
61+
// 取消编辑的函数
62+
const cancelEdit = () => {
63+
isEditing.value = false;
64+
// 逻辑代码
65+
console.log('取消编辑');
66+
};
67+
68+
// 保存配置的函数
69+
const saveConfig = () => {
70+
isEditing.value = false;
71+
// 逻辑代码
72+
console.log('保存配置');
73+
};
74+
75+
// 处理 JSON 编辑器错误的函数
76+
const onError = (e: any) => {
77+
console.log('onError', e);
78+
};
79+
</script>
80+
81+
<style scoped>
82+
.button-group {
83+
display: flex;
84+
justify-content: center;
85+
margin-top: 20px;
86+
}
87+
</style>

src/views/iot/device/device/detail/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
:device="device"
2727
/>
2828
</el-tab-pane>
29+
<el-tab-pane label="设备配置" name="config">
30+
<DeviceDetailConfig />
31+
</el-tab-pane>
2932
</el-tabs>
3033
</el-col>
3134
</template>
@@ -38,6 +41,7 @@ import DeviceDetailsInfo from './DeviceDetailsInfo.vue'
3841
import DeviceDetailsModel from './DeviceDetailsModel.vue'
3942
import DeviceDetailsLog from './DeviceDetailsLog.vue'
4043
import DeviceDetailsSimulator from './DeviceDetailsSimulator.vue'
44+
import DeviceDetailConfig from './DeviceDetailConfig.vue';
4145
4246
defineOptions({ name: 'IoTDeviceDetail' })
4347

0 commit comments

Comments
 (0)