Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit a29450c

Browse files
committed
前端配置保存
1 parent a70b268 commit a29450c

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

WebPage/assets/js/switch.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
axios.get('/file/config')
2+
.then(function (response) {
3+
$("[name='checkbox-sda']").bootstrapSwitch('state',response.data.IsSaveDataAddr,true)
4+
$("[name='checkbox-svm']").bootstrapSwitch('state',response.data.IsSaveVariablesToMod,true)
5+
$("[name='checkbox-svr']").bootstrapSwitch('state',response.data.IsSaveVariablesToRead,true)
6+
})
7+
.catch(function (error) {
8+
console.log(error);
9+
})
10+
11+
$.fn.bootstrapSwitch.defaults.onText = '是';
12+
$.fn.bootstrapSwitch.defaults.offText = '否';
13+
$.fn.bootstrapSwitch.defaults.onColor = 'info';
14+
$.fn.bootstrapSwitch.defaults.offColor = 'danger';
15+
$.fn.bootstrapSwitch.defaults.size = 'mini';
16+
$("[name='checkbox-sda']").bootstrapSwitch({
17+
onSwitchChange:function(event,state){
18+
axios.get('/file/config', {
19+
params: {
20+
sda: state
21+
}
22+
})
23+
}
24+
});
25+
$("[name='checkbox-svr']").bootstrapSwitch({
26+
onSwitchChange:function(event,state){
27+
axios.get('/file/config', {
28+
params: {
29+
svr: state
30+
}
31+
})
32+
}
33+
});
34+
$("[name='checkbox-svm']").bootstrapSwitch({
35+
onSwitchChange:function(event,state){
36+
axios.get('/file/config', {
37+
params: {
38+
svm: state
39+
}
40+
})
41+
}
42+
});

WebPage/index.html

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>坠好用的上位机</title>
77
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-switch/dist/css/bootstrap-switch.min.css" rel="stylesheet">
89
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
910
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
11+
<script src="https://cdn.jsdelivr.net/npm/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
1012
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
1113
<script src="https://cdn.jsdelivr.net/npm/vue-toasted/dist/vue-toasted.min.js"></script>
1214
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
@@ -41,6 +43,7 @@
4143
</nav>
4244

4345
<div class="tab-content" id="nav-tabContent">
46+
4447
<div class="tab-pane fade show active" id="nav-serialport" role="tabpanel" aria-labelledby="nav-home-tab">
4548
<div id="serial">
4649
<p><div class="input-group mb-3">
@@ -54,16 +57,22 @@
5457
<p><button class="btn btn-primary" v-on:click="openserial">打开串口</button>
5558
<button class="btn btn-danger" v-on:click="closeserial">关闭串口</button></p>
5659
</div>
57-
<div class="input-group" id="fileupload">
60+
<p><div class="input-group" id="fileupload">
5861
<div class="input-group-prepend">
5962
<button class="btn btn-primary" v-on:click="upload">上传</button>
6063
</div>
6164
<div class="custom-file">
6265
<input type="file" class="custom-file-input" @change="choose($event)">
6366
<label class="custom-file-label">{{file.name}}</label>
6467
</div>
68+
</div></p>
69+
<div><p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#variablesModalScrollable">变量列表</button></p></div>
70+
<div id="saveconfig">
71+
<p>保存变量列表 <input type="checkbox" name="checkbox-sda"></p>
72+
<p>保存观察变量 <input type="checkbox" name="checkbox-svr"></p>
73+
<p>保存修改列表 <input type="checkbox" name="checkbox-svm"></p>
6574
</div>
66-
<div><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#variablesModalScrollable">变量列表</button></div>
75+
6776
<div class="modal fade" id="variablesModalScrollable" tabindex="-1" role="dialog">
6877
<div class="modal-dialog modal-dialog-scrollable modal-xl" role="document">
6978
<div class="modal-content">
@@ -239,6 +248,7 @@ <h5 class="modal-title" id="NewVariableModLabel">添加变量</h5>
239248
</div>
240249
</div>
241250
</div>
251+
<script src="/assets/js/switch.js"></script>
242252
<script src="/assets/js/toast.js"></script>
243253
<script src="/assets/js/file.js"></script>
244254
<script src="/assets/js/serial.js"></script>

0 commit comments

Comments
 (0)