File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed
src/views/iot/device/device/detail Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 67
67
"sortablejs" : " ^1.15.3" ,
68
68
"steady-xml" : " ^0.1.0" ,
69
69
"url" : " ^0.11.3" ,
70
+ "v3-jsoneditor" : " ^0.0.6" ,
70
71
"video.js" : " ^7.21.5" ,
71
72
"vue" : " 3.5.12" ,
72
73
"vue-dompurify-html" : " ^4.1.4" ,
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change 26
26
:device =" device"
27
27
/>
28
28
</el-tab-pane >
29
+ <el-tab-pane label =" 设备配置" name =" config" >
30
+ <DeviceDetailConfig />
31
+ </el-tab-pane >
29
32
</el-tabs >
30
33
</el-col >
31
34
</template >
@@ -38,6 +41,7 @@ import DeviceDetailsInfo from './DeviceDetailsInfo.vue'
38
41
import DeviceDetailsModel from ' ./DeviceDetailsModel.vue'
39
42
import DeviceDetailsLog from ' ./DeviceDetailsLog.vue'
40
43
import DeviceDetailsSimulator from ' ./DeviceDetailsSimulator.vue'
44
+ import DeviceDetailConfig from ' ./DeviceDetailConfig.vue' ;
41
45
42
46
defineOptions ({ name: ' IoTDeviceDetail' })
43
47
You can’t perform that action at this time.
0 commit comments