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
Unverified
Commit
afaea197
authored
Dec 28, 2024
by
芋道源码
Committed by
Gitee
Dec 28, 2024
Browse files
Options
Browse Files
Download
Plain Diff
!630 【代码优化】IOT: ThingModel
Merge pull request !630 from puhui999/feature/iot
parents
5d2adcac
ca035932
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
18 deletions
+35
-18
src/api/iot/thingmodel/index.ts
+6
-6
src/utils/dict.ts
+2
-2
src/views/iot/thingmodel/ThingModelForm.vue
+20
-2
src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue
+1
-1
src/views/iot/thingmodel/index.vue
+6
-7
No files found.
src/api/iot/thingmodel/index.ts
View file @
afaea197
...
...
@@ -42,34 +42,34 @@ export interface ThingModelService {
export
const
ThingModelApi
=
{
// 查询产品物模型分页
getThingModelPage
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/
product-
thing-model/page`
,
params
})
return
await
request
.
get
({
url
:
`/iot/thing-model/page`
,
params
})
},
// 获得产品物模型
getThingModelListByProductId
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/
product-
thing-model/list-by-product-id`
,
url
:
`/iot/thing-model/list-by-product-id`
,
params
})
},
// 查询产品物模型详情
getThingModel
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/iot/
product-
thing-model/get?id=`
+
id
})
return
await
request
.
get
({
url
:
`/iot/thing-model/get?id=`
+
id
})
},
// 新增产品物模型
createThingModel
:
async
(
data
:
ThingModelData
)
=>
{
return
await
request
.
post
({
url
:
`/iot/
product-
thing-model/create`
,
data
})
return
await
request
.
post
({
url
:
`/iot/thing-model/create`
,
data
})
},
// 修改产品物模型
updateThingModel
:
async
(
data
:
ThingModelData
)
=>
{
return
await
request
.
put
({
url
:
`/iot/
product-
thing-model/update`
,
data
})
return
await
request
.
put
({
url
:
`/iot/thing-model/update`
,
data
})
},
// 删除产品物模型
deleteThingModel
:
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/iot/
product-
thing-model/delete?id=`
+
id
})
return
await
request
.
delete
({
url
:
`/iot/thing-model/delete?id=`
+
id
})
}
}
src/utils/dict.ts
View file @
afaea197
...
...
@@ -236,9 +236,9 @@ export enum DICT_TYPE {
IOT_DATA_FORMAT
=
'iot_data_format'
,
// IOT 数据格式
IOT_PROTOCOL_TYPE
=
'iot_protocol_type'
,
// IOT 接入网关协议
IOT_DEVICE_STATUS
=
'iot_device_status'
,
// IOT 设备状态
IOT_
PRODUCT_THING_MODEL_TYPE
=
'iot_produc
t_thing_model_type'
,
// IOT 产品功能类型
IOT_
THING_MODEL_TYPE
=
'io
t_thing_model_type'
,
// IOT 产品功能类型
IOT_DATA_TYPE
=
'iot_data_type'
,
// IOT 数据类型
IOT_
PRODUCT_THING_MODEL_UNIT
=
'iot_produc
t_thing_model_unit'
,
// IOT 物模型单位
IOT_
THING_MODEL_UNIT
=
'io
t_thing_model_unit'
,
// IOT 物模型单位
IOT_RW_TYPE
=
'iot_rw_type'
,
// IOT 读写类型
IOT_PLUGIN_DEPLOY_TYPE
=
'iot_plugin_deploy_type'
,
// IOT 插件部署类型
IOT_PLUGIN_STATUS
=
'iot_plugin_status'
,
// IOT 插件状态
...
...
src/views/iot/thingmodel/ThingModelForm.vue
View file @
afaea197
...
...
@@ -10,7 +10,7 @@
<el-form-item
label=
"功能类型"
prop=
"type"
>
<el-radio-group
v-model=
"formData.type"
>
<el-radio-button
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_
PRODUCT_
THING_MODEL_TYPE)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
:key=
"dict.value"
:value=
"dict.value"
>
...
...
@@ -67,7 +67,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import
{
isEmpty
}
from
'@/utils/is'
/** IoT 物模型数据表单 */
defineOptions
({
name
:
'IoT
Product
ThingModelForm'
})
defineOptions
({
name
:
'IoTThingModelForm'
})
const
product
=
inject
<
Ref
<
ProductVO
>>
(
IOT_PROVIDE_KEY
.
PRODUCT
)
// 注入产品信息
...
...
@@ -103,6 +103,24 @@ const open = async (type: string, id?: number) => {
formLoading
.
value
=
true
try
{
formData
.
value
=
await
ThingModelApi
.
getThingModel
(
id
)
// 情况一:属性初始化
if
(
isEmpty
(
formData
.
value
.
property
))
{
formData
.
value
.
dataType
=
DataSpecsDataType
.
INT
formData
.
value
.
property
=
{
dataType
:
DataSpecsDataType
.
INT
,
dataSpecs
:
{
dataType
:
DataSpecsDataType
.
INT
}
}
}
// 情况二:服务初始化
if
(
isEmpty
(
formData
.
value
.
service
))
{
formData
.
value
.
service
=
{}
}
// 情况三:事件初始化
if
(
isEmpty
(
formData
.
value
.
event
))
{
formData
.
value
.
event
=
{}
}
}
finally
{
formLoading
.
value
=
false
}
...
...
src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue
View file @
afaea197
...
...
@@ -47,7 +47,7 @@
@
change=
"unitChange"
>
<el-option
v-for=
"(item, index) in getStrDictOptions(DICT_TYPE.IOT_
PRODUCT_
THING_MODEL_UNIT)"
v-for=
"(item, index) in getStrDictOptions(DICT_TYPE.IOT_THING_MODEL_UNIT)"
:key=
"index"
:label=
"item.label + '-' + item.value"
:value=
"item.label + '-' + item.value"
...
...
src/views/iot/thingmodel/index.vue
View file @
afaea197
...
...
@@ -16,7 +16,7 @@
placeholder=
"请选择功能类型"
>
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_
PRODUCT_
THING_MODEL_TYPE)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
...
...
@@ -33,7 +33,7 @@
重置
</el-button>
<el-button
v-hasPermi=
"[`iot:
product-
thing-model:create`]"
v-hasPermi=
"[`iot:thing-model:create`]"
plain
type=
"primary"
@
click=
"openForm('create')"
...
...
@@ -49,7 +49,7 @@
<el-table
v-loading=
"loading"
:data=
"list"
:show-overflow-tooltip=
"true"
:stripe=
"true"
>
<el-table-column
align=
"center"
label=
"功能类型"
prop=
"type"
>
<template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.IOT_
PRODUCT_
THING_MODEL_TYPE"
:value=
"scope.row.type"
/>
<dict-tag
:type=
"DICT_TYPE.IOT_THING_MODEL_TYPE"
:value=
"scope.row.type"
/>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"功能名称"
prop=
"name"
/>
...
...
@@ -118,7 +118,7 @@
<
el
-
table
-
column
align
=
"center"
label
=
"操作"
>
<
template
#
default
=
"scope"
>
<
el
-
button
v
-
hasPermi
=
"[`iot:
product-
thing-model:update`]"
v
-
hasPermi
=
"[`iot:thing-model:update`]"
link
type
=
"primary"
@
click
=
"openForm('update', scope.row.id)"
...
...
@@ -126,7 +126,7 @@
编辑
<
/el-button
>
<
el
-
button
v
-
hasPermi
=
"['iot:
product-
thing-model:delete']"
v
-
hasPermi
=
"['iot:thing-model:delete']"
link
type
=
"danger"
@
click
=
"handleDelete(scope.row.id)"
...
...
@@ -161,9 +161,8 @@ import {
getEventTypeByValue
,
ThingModelType
}
from
'./config'
import
{
ThingModelNumberDataSpecs
}
from
'@/views/iot/thingmodel/dataSpecs'
defineOptions
({
name
:
'IoT
Product
ThingModel'
}
)
defineOptions
({
name
:
'IoTThingModel'
}
)
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
...
...
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