Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
94ccfc4a
Commit
94ccfc4a
authored
Sep 08, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:切换协议版本
parent
18636750
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
17 deletions
+55
-17
CollapseTable.vue
frontend/src/components/protocol/CollapseTable.vue
+45
-13
KitCollapse.vue
frontend/src/components/protocol/KitCollapse.vue
+1
-1
types.ts
frontend/src/components/protocol/types.ts
+6
-0
device.ts
frontend/src/dao/device.ts
+3
-3
xdc.sqlite
xdc.sqlite
+0
-0
No files found.
frontend/src/components/protocol/CollapseTable.vue
View file @
94ccfc4a
...
@@ -3,19 +3,19 @@
...
@@ -3,19 +3,19 @@
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"left"
>
<div
class=
"left"
>
<div
class=
"mr-4"
>
协议版本
</div>
<div
class=
"mr-4"
>
协议版本
</div>
<el-select
v-model=
"currentVersion"
>
<el-select
v-model=
"currentVersion"
@
change=
"changeProtocolVersion"
>
<!-- TODO: 选择协议版本 -->
<!-- TODO: 选择协议版本 -->
<el-option
<el-option
v-for=
"option in options"
v-for=
"option in options"
:key=
"option.value"
:key=
"option.value"
:label=
"option.label"
:label=
"option.label"
:value=
"option.value"
:value=
"option.value"
>
>
</el-option>
</el-option>
</el-select>
</el-select>
</div>
</div>
<div
class=
"right"
>
<div
class=
"right"
>
<el-button>
上传原始文件
</el-button>
<el-button
@
click=
"addCmd = true"
>
新增指令
</el-button>
<el-button
@
click=
"addCmd = true"
>
新增指令
</el-button>
<el-button>
导出协议
</el-button>
<el-button>
导出协议
</el-button>
</div>
</div>
...
@@ -25,13 +25,13 @@
...
@@ -25,13 +25,13 @@
<el-collapse
class=
"mt-4"
>
<el-collapse
class=
"mt-4"
>
<el-collapse-item
<el-collapse-item
v-for=
"cmd in
props.info[props.name]
"
v-for=
"cmd in
cmdInfos
"
:title=
"cmd.cmd_name + ' ' + cmd.cmd_explain + ' ' + cmd.cmd_type"
>
:title=
"cmd.cmd_name + ' ' + cmd.cmd_explain + ' ' + cmd.cmd_type"
>
<protocol-table
<protocol-table
v-if=
"
props.protocolCmd
!== undefined"
v-if=
"
fieldInfos
!== undefined"
:cmd-name=
"cmd.cmd_name"
:cmd-name=
"cmd.cmd_name"
:cmd-type=
"cmd.cmd_type"
:cmd-type=
"cmd.cmd_type"
:message=
"
props.protocolCmd
[cmd.cmd_name]"
/>
:message=
"
fieldInfos
[cmd.cmd_name]"
/>
</el-collapse-item>
</el-collapse-item>
</el-collapse>
</el-collapse>
...
@@ -75,12 +75,13 @@
...
@@ -75,12 +75,13 @@
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
}
from
'vue'
import
{
ref
,
onMounted
}
from
'vue'
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
ProtocolInit
}
from
"@/dao/protocol"
import
{
ProtocolInit
}
from
"@/dao/protocol"
import
ProtocolTable
from
"./ProtocolTable.vue"
;
import
ProtocolTable
from
"./ProtocolTable.vue"
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'./types'
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'./types'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
import
axios
from
'axios'
;
const
addCmd
=
ref
<
boolean
>
(
false
)
const
addCmd
=
ref
<
boolean
>
(
false
)
const
currentVersion
=
ref
(
''
)
const
currentVersion
=
ref
(
''
)
...
@@ -135,10 +136,18 @@ function Init(){
...
@@ -135,10 +136,18 @@ function Init(){
}
}
const
store
=
useProtocolVersionStore
()
const
store
=
useProtocolVersionStore
()
onMounted
(()
=>
{
const
cmdInfos
=
ref
()
const
fieldInfos
=
ref
<
Record
<
string
,
any
>>
({})
// 需要延时一下,不然 store 里面的数据可能没有被赋值上去,组件就被渲染了
onMounted
(()
=>
setTimeout
(()
=>
{
// 判断是否需要初始化
// 判断是否需要初始化
let
flag
=
true
let
flag
=
true
cmdInfos
.
value
=
props
.
info
[
props
.
name
]
// 将 props.protocolCmd 转成 Record
<
string
,
any
>
类型
,
统一类型,方便后面过来的数据操作
for
(
const
[
key
,
value
]
of
Object
.
entries
(
props
.
protocolCmd
)){
fieldInfos
.
value
[
key
]
=
value
}
for
(
let
protocolVersion
of
store
.
protocolVersions
){
for
(
let
protocolVersion
of
store
.
protocolVersions
){
if
(
protocolVersion
.
protocol_name
===
props
.
name
)
{
if
(
protocolVersion
.
protocol_name
===
props
.
name
)
{
let
version_paths
=
JSON
.
parse
(
protocolVersion
.
version_paths
)
let
version_paths
=
JSON
.
parse
(
protocolVersion
.
version_paths
)
...
@@ -164,7 +173,30 @@ onMounted(() => {
...
@@ -164,7 +173,30 @@ onMounted(() => {
if
(
flag
){
if
(
flag
){
Init
()
Init
()
}
}
})
},
500
))
// 修改协议版本
const
changeProtocolVersion
=
()
=>
{
axios
.
post
(
'/api/protocol_version_manage/change_protocol_version/'
,
{
version
:
currentVersion
.
value
,
protocol_name
:
props
.
name
,
})
.
then
((
res
)
=>
{
const
{
cmds
}
=
res
.
data
cmdInfos
.
value
=
cmds
// 转成和上面 ProtocolCmdResponse 一样的类型
for
(
let
cmd
of
cmds
)
{
const
{
fields
,
...
info
}
=
cmd
fieldInfos
.
value
[
info
.
cmd_name
]
=
fields
}
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
})
}
</
script
>
</
script
>
<
style
>
<
style
>
...
...
frontend/src/components/protocol/KitCollapse.vue
View file @
94ccfc4a
...
@@ -47,7 +47,7 @@ function getProtocolCmd() {
...
@@ -47,7 +47,7 @@ function getProtocolCmd() {
})
})
}
}
onMounted
(
async
()
=>
{
onMounted
(()
=>
{
getDeviceProtocol
()
getDeviceProtocol
()
getProtocolCmd
()
getProtocolCmd
()
})
})
...
...
frontend/src/components/protocol/types.ts
View file @
94ccfc4a
...
@@ -59,9 +59,14 @@ interface ProtocolCmdResponse {
...
@@ -59,9 +59,14 @@ interface ProtocolCmdResponse {
fields
:
any
[];
fields
:
any
[];
}
}
interface
ChangeCmdInfo
extends
ProtocolInfo
{
version
:
string
fields
:
any
[]
}
export
type
{
export
type
{
DeviceProtocolResponse
,
DeviceProtocolResponse
,
ProtocolCmdResponse
,
ProtocolCmdResponse
,
CmdInfo
,
CmdInfo
,
ChangeCmdInfo
}
}
\ No newline at end of file
frontend/src/dao/device.ts
View file @
94ccfc4a
...
@@ -3,7 +3,7 @@ import axios from "axios"
...
@@ -3,7 +3,7 @@ import axios from "axios"
// const baseURL = 'http://192.168.0.214:8000/op'
// const baseURL = 'http://192.168.0.214:8000/op'
export
function
DeviceProtocol
()
{
export
function
DeviceProtocol
()
{
return
axios
.
get
(
'/api/dev_cmd_name_poll'
).
then
(
return
axios
.
get
(
'/api/dev_cmd_name_poll
/
'
).
then
(
function
(
response
)
{
function
(
response
)
{
return
response
.
data
return
response
.
data
}
}
...
@@ -11,7 +11,7 @@ export function DeviceProtocol() {
...
@@ -11,7 +11,7 @@ export function DeviceProtocol() {
}
}
export
function
ProtocolCmd
()
{
export
function
ProtocolCmd
()
{
return
axios
.
get
(
'/api/all_dev_cmd_define'
).
then
(
return
axios
.
get
(
'/api/all_dev_cmd_define
/
'
).
then
(
function
(
response
)
{
function
(
response
)
{
return
response
.
data
return
response
.
data
}
}
...
@@ -27,7 +27,7 @@ export function EditProtocolCmd(id: number, params: any) {
...
@@ -27,7 +27,7 @@ export function EditProtocolCmd(id: number, params: any) {
}
}
export
function
DeleteProtocolCmd
(
id
:
number
)
{
export
function
DeleteProtocolCmd
(
id
:
number
)
{
return
axios
.
delete
(
'/api/all_dev_cmd_define/'
+
id
).
then
(
return
axios
.
delete
(
'/api/all_dev_cmd_define/'
+
id
+
'/'
).
then
(
function
(
response
)
{
function
(
response
)
{
return
response
.
data
return
response
.
data
}
}
...
...
xdc.sqlite
View file @
94ccfc4a
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment