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
c55e0acb
Commit
c55e0acb
authored
Sep 12, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:切换接口
parent
908b6b54
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
29 deletions
+66
-29
views.py
device_data_op/views.py
+10
-0
App.vue
frontend/src/App.vue
+27
-1
KitCollapse.vue
frontend/src/components/protocol/KitCollapse.vue
+6
-1
device.ts
frontend/src/dao/device.ts
+4
-4
protocolInfo.ts
frontend/src/stores/protocolInfo.ts
+13
-0
protocol.vue
frontend/src/views/protocol/protocol.vue
+6
-23
xdc.sqlite
xdc.sqlite
+0
-0
No files found.
device_data_op/views.py
View file @
c55e0acb
...
@@ -20,6 +20,11 @@ class TableAllDevCmdDefineView_1(ModelViewSet):
...
@@ -20,6 +20,11 @@ class TableAllDevCmdDefineView_1(ModelViewSet):
queryset
=
TableAllDevCmdDefine
.
objects
.
all
()
queryset
=
TableAllDevCmdDefine
.
objects
.
all
()
serializer_class
=
TableAllDevCmdDefineSerializer
serializer_class
=
TableAllDevCmdDefineSerializer
def
list
(
self
,
request
):
serializer
=
self
.
get_serializer
(
self
.
get_queryset
(),
many
=
True
)
data
=
tree_data
(
serializer
.
data
,
'cmd_name'
)
return
Response
(
data
)
def
perform_create
(
self
,
serializer
):
def
perform_create
(
self
,
serializer
):
"""
"""
新增指令字段,给 TableAllDevCmdDefine 表创建记录时,同时给 AllDevCmdDefineAndVersion 表创建
新增指令字段,给 TableAllDevCmdDefine 表创建记录时,同时给 AllDevCmdDefineAndVersion 表创建
...
@@ -88,6 +93,11 @@ class TableDevCmdNamePollView_1(ModelViewSet):
...
@@ -88,6 +93,11 @@ class TableDevCmdNamePollView_1(ModelViewSet):
queryset
=
TableDevCmdNamePoll
.
objects
.
all
()
queryset
=
TableDevCmdNamePoll
.
objects
.
all
()
serializer_class
=
TableDevCmdNamePollSerializer
serializer_class
=
TableDevCmdNamePollSerializer
def
list
(
self
,
request
):
serializer
=
self
.
get_serializer
(
self
.
get_queryset
(),
many
=
True
)
data
=
tree_data
(
serializer
.
data
,
'protocol_name'
)
return
Response
(
data
)
def
perform_create
(
self
,
serializer
):
def
perform_create
(
self
,
serializer
):
"""
"""
新增指令,给 TableDevCmdNamePollView 表创建记录时,同时给 AllProtocolDefineAndVersion 表创建
新增指令,给 TableDevCmdNamePollView 表创建记录时,同时给 AllProtocolDefineAndVersion 表创建
...
...
frontend/src/App.vue
View file @
c55e0acb
...
@@ -27,8 +27,34 @@
...
@@ -27,8 +27,34 @@
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'vue'
import
{
onBeforeMount
,
ref
}
from
'vue'
const
activeIndex
=
ref
(
'1'
)
const
activeIndex
=
ref
(
'1'
)
import
{
DeviceProtocol
,
ProtocolCmd
}
from
"@/dao/device"
;
import
{
GetProtocolVersion
,
GetCurrentVersion
}
from
'@/dao/protocol'
;
import
{
useProtocolInfoStore
}
from
'./stores/protocolInfo'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
const
store
=
useProtocolVersionStore
()
const
protocolStore
=
useProtocolInfoStore
()
onBeforeMount
(
async
()
=>
{
await
GetProtocolVersion
()
.
then
(
res
=>
{
store
.
protocolVersions
.
push
(...
res
)
})
await
GetCurrentVersion
()
.
then
(
res
=>
{
store
.
currentVersions
=
res
})
await
DeviceProtocol
()
.
then
((
res
)
=>
{
protocolStore
.
deviceProtocol
=
res
})
await
ProtocolCmd
()
.
then
((
res
)
=>
{
protocolStore
.
protocolCmd
=
res
})
})
</
script
>
</
script
>
<
style
>
<
style
>
...
...
frontend/src/components/protocol/KitCollapse.vue
View file @
c55e0acb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
watch
}
from
'vue'
import
{
onMounted
,
ref
,
watch
}
from
'vue'
import
CollapseTable
from
"./CollapseTable.vue"
;
import
CollapseTable
from
"./CollapseTable.vue"
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'./types'
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'./types'
;
...
@@ -27,6 +27,11 @@ type propsType = {
...
@@ -27,6 +27,11 @@ type propsType = {
}
}
const
props
=
defineProps
<
propsType
>
()
const
props
=
defineProps
<
propsType
>
()
onMounted
(()
=>
{
let
{
fields
}
=
props
.
deviceProtocol
protocol_names
.
value
=
fields
})
const
protocol_names
=
ref
<
string
[]
>
([]);
const
protocol_names
=
ref
<
string
[]
>
([]);
watch
(()
=>
props
.
deviceProtocol
,
(
val
)
=>
{
watch
(()
=>
props
.
deviceProtocol
,
(
val
)
=>
{
let
{
fields
}
=
val
let
{
fields
}
=
val
...
...
frontend/src/dao/device.ts
View file @
c55e0acb
...
@@ -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
_1
/'
).
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
_1
/'
).
then
(
function
(
response
)
{
function
(
response
)
{
return
response
.
data
return
response
.
data
}
}
...
@@ -19,7 +19,7 @@ export function ProtocolCmd() {
...
@@ -19,7 +19,7 @@ export function ProtocolCmd() {
}
}
export
function
EditProtocolCmd
(
id
:
number
,
params
:
any
)
{
export
function
EditProtocolCmd
(
id
:
number
,
params
:
any
)
{
return
axios
.
put
(
'/api/all_dev_cmd_define/'
+
id
+
'/'
,
params
).
then
(
return
axios
.
put
(
'/api/all_dev_cmd_define
_1
/'
+
id
+
'/'
,
params
).
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
_1
/'
+
id
+
'/'
).
then
(
function
(
response
)
{
function
(
response
)
{
return
response
.
data
return
response
.
data
}
}
...
...
frontend/src/stores/protocolInfo.ts
0 → 100644
View file @
c55e0acb
import
{
defineStore
}
from
'pinia'
import
{
ref
}
from
'vue'
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'@/components/protocol/types'
;
export
const
useProtocolInfoStore
=
defineStore
(
'protocolInfo'
,
()
=>
{
const
deviceProtocol
=
ref
<
DeviceProtocolResponse
>
()
const
protocolCmd
=
ref
<
ProtocolCmdResponse
>
()
return
{
deviceProtocol
,
protocolCmd
}
});
frontend/src/views/protocol/protocol.vue
View file @
c55e0acb
...
@@ -32,33 +32,18 @@
...
@@ -32,33 +32,18 @@
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
onBeforeMount
}
from
'vue'
;
import
{
ref
,
onBeforeMount
}
from
'vue'
;
import
KitCollapse
from
'@/components/protocol/KitCollapse.vue'
;
import
KitCollapse
from
'@/components/protocol/KitCollapse.vue'
;
import
{
GetProtocolVersion
,
GetCurrentVersion
}
from
'@/dao/protocol'
;
import
{
useProtocolInfoStore
}
from
'@/stores/protocolInfo'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
import
{
DeviceProtocol
,
ProtocolCmd
}
from
"@/dao/device"
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'@/components/protocol/types'
;
import
type
{
DeviceProtocolResponse
,
ProtocolCmdResponse
}
from
'@/components/protocol/types'
;
const
isShow
=
ref
<
boolean
>
(
false
)
const
isShow
=
ref
<
boolean
>
(
false
)
const
formLabelWidth
=
'140px'
const
formLabelWidth
=
'140px'
const
store
=
useProtocolVersionStore
()
const
protocolStore
=
useProtocolInfoStore
()
const
deviceProtocol
=
ref
<
DeviceProtocolResponse
>
()
const
protocolCmd
=
ref
<
ProtocolCmdResponse
>
()
onBeforeMount
(()
=>
{
onBeforeMount
(()
=>
{
GetProtocolVersion
()
deviceProtocol
.
value
=
protocolStore
.
deviceProtocol
.
then
(
res
=>
{
protocolCmd
.
value
=
protocolStore
.
protocolCmd
store
.
protocolVersions
.
push
(...
res
)
})
GetCurrentVersion
()
.
then
(
res
=>
{
store
.
currentVersions
=
res
})
DeviceProtocol
()
.
then
((
res
)
=>
{
deviceProtocol
.
value
=
res
})
ProtocolCmd
()
.
then
((
res
)
=>
{
protocolCmd
.
value
=
res
})
})
})
const
protocolName
=
ref
<
string
>
(
''
)
const
protocolName
=
ref
<
string
>
(
''
)
...
@@ -67,8 +52,6 @@ const addProtocol = () => {
...
@@ -67,8 +52,6 @@ const addProtocol = () => {
deviceProtocol
.
value
!
.
fields
.
push
(
protocolName
.
value
)
deviceProtocol
.
value
!
.
fields
.
push
(
protocolName
.
value
)
deviceProtocol
.
value
!
[
protocolName
.
value
]
=
[]
deviceProtocol
.
value
!
[
protocolName
.
value
]
=
[]
}
}
const
deviceProtocol
=
ref
<
DeviceProtocolResponse
>
()
const
protocolCmd
=
ref
<
ProtocolCmdResponse
>
()
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
...
...
xdc.sqlite
View file @
c55e0acb
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