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

Commit fb26705

Browse files
committed
新增调参面板
1 parent 321040e commit fb26705

File tree

4 files changed

+90
-2
lines changed

4 files changed

+90
-2
lines changed

frontend/mock/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ export default {
130130
status: 0
131131
})
132132
},
133+
'POST /variable-modi/mod': (req, res) => {
134+
const { Board, Name, Type, Addr, Data } = req.body;
135+
return res.json({
136+
status: 0
137+
})
138+
},
133139

134140
'POST /file/upload': (req, res) => {
135141
return res.json({

frontend/src/components/ChartCard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-card>
3-
<div id="chart" style="width: 100%; height: 500px;"></div>
3+
<div id="chart" style="width: 100%; height: 420px;"></div>
44
<Notice ref="notice" />
55
</v-card>
66
</template>

frontend/src/components/PanelCard.vue

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<template>
2+
<div class="text-center">
3+
<v-menu
4+
v-model="menu"
5+
:close-on-content-click="false"
6+
transition="scale-transition"
7+
offset-y
8+
:nudge-top="300"
9+
>
10+
<template v-slot:activator="{ on }">
11+
<v-btn color="secondary" dark absolute bottom left fab v-on="on">
12+
<v-icon>mdi-iframe-variable</v-icon>
13+
</v-btn>
14+
</template>
15+
<v-card>
16+
<v-card-title>调参面板</v-card-title>
17+
<v-list dense>
18+
<v-list-item-group color="primary">
19+
<v-list-item v-for="i in variables" :key="i.Name">
20+
<v-list-item-content>
21+
<v-text-field dense v-model="i.Data" v-bind:label="i.Name" v-on:keyup.enter="modiVariable(i)"></v-text-field>
22+
</v-list-item-content>
23+
<v-list-item-icon>
24+
<v-btn icon v-on:click="modiVariable(i)">
25+
<v-icon>mdi-send</v-icon>
26+
</v-btn>
27+
</v-list-item-icon>
28+
</v-list-item>
29+
</v-list-item-group>
30+
</v-list>
31+
<Notice ref="notice" />
32+
</v-card>
33+
</v-menu>
34+
</div>
35+
</template>
36+
37+
<script>
38+
import axios from "axios";
39+
import Notice from "@/components/Notice.vue";
40+
export default {
41+
components: {
42+
Notice
43+
},
44+
data: () => ({
45+
menu: false,
46+
variables: []
47+
}),
48+
mounted() {
49+
this.getVariables();
50+
},
51+
methods: {
52+
openMenu() {
53+
this.menu = true;
54+
},
55+
getVariables() {
56+
axios.get("/variable-modi/list").then(response => {
57+
this.variables = response.data.Variables;
58+
});
59+
},
60+
modiVariable(i) {
61+
axios
62+
.post("/variable-modi/mod", {
63+
Board: 1,
64+
Name: i.Name,
65+
Type: i.Type,
66+
Addr: i.Addr,
67+
Data: parseFloat(i.Data)
68+
})
69+
.then(response => {
70+
if (response.data.status == 0) {
71+
this.$refs.notice.show("变量修改成功", 0);
72+
} else if (response.data.status == 22) {
73+
this.$refs.notice.show("变量操作时串口错误", 1);
74+
}
75+
});
76+
}
77+
}
78+
};
79+
</script>

frontend/src/views/Chart.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
<v-col cols="12">
55
<ChartCard />
66
</v-col>
7+
<PanelCard />
78
</v-row>
89
</v-container>
910
</template>
1011

1112
<script>
1213
import ChartCard from "@/components/ChartCard.vue";
14+
import PanelCard from "@/components/PanelCard.vue";
1315
export default {
1416
components: {
15-
ChartCard
17+
ChartCard,
18+
PanelCard
1619
}
1720
};
1821
</script>

0 commit comments

Comments
 (0)