Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9b628620
authored
Dec 26, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能完善】IOT: ThingModel 服务和事件
parent
5391720b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
src/views/iot/thingmodel/ThingModelForm.vue
+28
-13
No files found.
src/views/iot/thingmodel/ThingModelForm.vue
View file @
9b628620
...
@@ -113,6 +113,7 @@ defineExpose({ open, close: () => (dialogVisible.value = false) })
...
@@ -113,6 +113,7 @@ defineExpose({ open, close: () => (dialogVisible.value = false) })
/** 提交表单 */
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
const
emit
=
defineEmits
([
'success'
])
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
debugger
await
formRef
.
value
.
validate
()
await
formRef
.
value
.
validate
()
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
...
@@ -120,10 +121,7 @@ const submitForm = async () => {
...
@@ -120,10 +121,7 @@ const submitForm = async () => {
// 信息补全
// 信息补全
data
.
productId
=
product
!
.
value
.
id
data
.
productId
=
product
!
.
value
.
id
data
.
productKey
=
product
!
.
value
.
productKey
data
.
productKey
=
product
!
.
value
.
productKey
data
.
dataType
=
data
.
property
.
dataType
fillExtraAttributes
(
data
)
data
.
property
.
identifier
=
data
.
identifier
data
.
property
.
name
=
data
.
name
removeExtraAttributes
(
data
)
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
await
ThingModelApi
.
createThingModel
(
data
)
await
ThingModelApi
.
createThingModel
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
message
.
success
(
t
(
'common.createSuccess'
))
...
@@ -138,29 +136,46 @@ const submitForm = async () => {
...
@@ -138,29 +136,46 @@ const submitForm = async () => {
}
}
}
}
/** 删除额外的属性 */
/** 填写额外的属性 */
const
removeExtraAttributes
=
(
data
:
any
)
=>
{
const
fillExtraAttributes
=
(
data
:
any
)
=>
{
// 处理 dataSpecs 为空的情况
if
(
isEmpty
(
data
.
property
.
dataSpecs
))
{
delete
data
.
property
.
dataSpecs
}
if
(
isEmpty
(
data
.
property
.
dataSpecsList
))
{
delete
data
.
property
.
dataSpecsList
}
// 处理不同类型的情况
// 处理不同类型的情况
// 属性
if
(
data
.
type
===
ThingModelType
.
PROPERTY
)
{
if
(
data
.
type
===
ThingModelType
.
PROPERTY
)
{
removeDataSpecs
(
data
.
property
)
data
.
dataType
=
data
.
property
.
dataType
data
.
property
.
identifier
=
data
.
identifier
data
.
property
.
name
=
data
.
name
delete
data
.
service
delete
data
.
service
delete
data
.
event
delete
data
.
event
}
}
// 服务
if
(
data
.
type
===
ThingModelType
.
SERVICE
)
{
if
(
data
.
type
===
ThingModelType
.
SERVICE
)
{
removeDataSpecs
(
data
.
service
)
data
.
dataType
=
data
.
service
.
dataType
data
.
service
.
identifier
=
data
.
identifier
data
.
service
.
name
=
data
.
name
delete
data
.
property
delete
data
.
property
delete
data
.
event
delete
data
.
event
}
}
// 事件
if
(
data
.
type
===
ThingModelType
.
EVENT
)
{
if
(
data
.
type
===
ThingModelType
.
EVENT
)
{
removeDataSpecs
(
data
.
event
)
data
.
dataType
=
data
.
event
.
dataType
data
.
event
.
identifier
=
data
.
identifier
data
.
event
.
name
=
data
.
name
delete
data
.
property
delete
data
.
property
delete
data
.
service
delete
data
.
service
}
}
}
}
/** 处理 dataSpecs 为空的情况 */
const
removeDataSpecs
=
(
val
:
any
)
=>
{
if
(
isEmpty
(
val
.
dataSpecs
))
{
delete
val
.
dataSpecs
}
if
(
isEmpty
(
val
.
dataSpecsList
))
{
delete
val
.
dataSpecsList
}
}
/** 重置表单 */
/** 重置表单 */
const
resetForm
=
()
=>
{
const
resetForm
=
()
=>
{
...
...
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