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
81a710c0
authored
Sep 29, 2024
by
安浩浩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增功能】 IOT 产品管理,物模型新增
parent
0e3ebbd2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
414 additions
and
10 deletions
+414
-10
src/api/iot/thinkmodelfunction/index.ts
+55
-0
src/utils/dict.ts
+5
-1
src/views/iot/product/detail/ThinkModelFunction.vue
+149
-0
src/views/iot/product/detail/ThinkModelFunctionForm.vue
+194
-0
src/views/iot/product/detail/index.vue
+11
-9
No files found.
src/api/iot/thinkmodelfunction/index.ts
0 → 100644
View file @
81a710c0
import
request
from
'@/config/axios'
// IoT 产品物模型 VO
export
interface
ThinkModelFunctionVO
{
id
:
number
// 物模型功能编号
identifier
:
string
// 功能标识
name
:
string
// 功能名称
description
:
string
// 功能描述
productId
:
number
// 产品ID(关联 IotProductDO 的 id)
productKey
:
string
// 产品Key(关联 IotProductDO 的 productKey)
type
:
number
// 功能类型(1 - 属性,2 - 服务,3 - 事件)
property
:
string
// 属性(存储 ThingModelProperty 的 JSON 数据)
event
:
string
// 事件(存储 ThingModelEvent 的 JSON 数据)
service
:
string
// 服务(存储服务的 JSON 数据)
}
// IoT 产品物模型 API
export
const
ThinkModelFunctionApi
=
{
// 查询IoT 产品物模型分页
getThinkModelFunctionPage
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/think-model-function/page`
,
params
})
},
// 获得IoT 产品物模型
getThinkModelFunctionListByProductId
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/think-model-function/list-by-product-id`
,
params
})
},
// 查询IoT 产品物模型详情
getThinkModelFunction
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/iot/think-model-function/get?id=`
+
id
})
},
// 新增IoT 产品物模型
createThinkModelFunction
:
async
(
data
:
ThinkModelFunctionVO
)
=>
{
return
await
request
.
post
({
url
:
`/iot/think-model-function/create`
,
data
})
},
// 修改IoT 产品物模型
updateThinkModelFunction
:
async
(
data
:
ThinkModelFunctionVO
)
=>
{
return
await
request
.
put
({
url
:
`/iot/think-model-function/update`
,
data
})
},
// 删除IoT 产品物模型
deleteThinkModelFunction
:
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/iot/think-model-function/delete?id=`
+
id
})
},
// 导出IoT 产品物模型 Excel
exportThinkModelFunction
:
async
(
params
)
=>
{
return
await
request
.
download
({
url
:
`/iot/think-model-function/export-excel`
,
params
})
}
}
src/utils/dict.ts
View file @
81a710c0
...
@@ -235,5 +235,9 @@ export enum DICT_TYPE {
...
@@ -235,5 +235,9 @@ export enum DICT_TYPE {
IOT_PRODUCT_DEVICE_TYPE
=
'iot_product_device_type'
,
// IOT 产品设备类型
IOT_PRODUCT_DEVICE_TYPE
=
'iot_product_device_type'
,
// IOT 产品设备类型
IOT_DATA_FORMAT
=
'iot_data_format'
,
// IOT 数据格式
IOT_DATA_FORMAT
=
'iot_data_format'
,
// IOT 数据格式
IOT_PROTOCOL_TYPE
=
'iot_protocol_type'
,
// IOT 接入网关协议
IOT_PROTOCOL_TYPE
=
'iot_protocol_type'
,
// IOT 接入网关协议
IOT_DEVICE_STATUS
=
'iot_device_status'
// IOT 设备状态
IOT_DEVICE_STATUS
=
'iot_device_status'
,
// IOT 设备状态
IOT_PRODUCT_FUNCTION_TYPE
=
'iot_product_function_type'
,
// IOT 产品功能类型
IOT_DATA_TYPE
=
'iot_data_type'
,
// IOT 数据类型
IOT_UNIT_TYPE
=
'iot_unit_type'
,
// IOT 单位类型
IOT_RW_TYPE
=
'iot_rw_type'
// IOT 读写类型
}
}
src/views/iot/product/detail/ThinkModelFunction.vue
0 → 100644
View file @
81a710c0
<
template
>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"功能类型"
prop=
"name"
>
<el-select
v-model=
"queryParams.type"
placeholder=
"请选择功能类型"
clearable
class=
"!w-240px"
>
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_FUNCTION_TYPE)"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
plain
@
click=
"openForm('create')"
v-hasPermi=
"['iot:think-model-function:create']"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
添加功能
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-tabs>
<el-table
v-loading=
"loading"
:data=
"list"
:stripe=
"true"
:show-overflow-tooltip=
"true"
>
<el-table-column
label=
"功能类型"
align=
"center"
prop=
"type"
/>
<el-table-column
label=
"功能名称"
align=
"center"
prop=
"name"
/>
<el-table-column
label=
"标识符"
align=
"center"
prop=
"identifier"
/>
<el-table-column
label=
"操作"
align=
"center"
>
<template
#
default=
"scope"
>
<el-button
link
type=
"primary"
@
click=
"openForm('update', scope.row.id)"
v-hasPermi=
"[`iot:think-model-function:update`]"
>
编辑
</el-button>
<el-button
link
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['iot:think-model-function:delete']"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
/>
</el-tabs>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<ThinkModelFunctionForm
ref=
"formRef"
:product=
"product"
@
success=
"getList"
/>
</template>
<
script
setup
lang=
"ts"
>
import
{
ProductVO
}
from
'@/api/iot/product'
import
{
ThinkModelFunctionApi
,
ThinkModelFunctionVO
}
from
'@/api/iot/thinkmodelfunction'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
ThinkModelFunctionForm
from
'@/views/iot/product/detail/ThinkModelFunctionForm.vue'
const
props
=
defineProps
<
{
product
:
ProductVO
}
>
()
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
<
ThinkModelFunctionVO
[]
>
([])
// 列表的数据
const
total
=
ref
(
0
)
// 列表的总页数
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
type
:
undefined
,
productId
:
undefined
})
const
queryFormRef
=
ref
()
// 搜索的表单
/** 查询列表 */
const
getList
=
async
()
=>
{
loading
.
value
=
true
try
{
queryParams
.
productId
=
props
.
product
.
id
const
data
=
await
ThinkModelFunctionApi
.
getThinkModelFunctionPage
(
queryParams
)
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
loading
.
value
=
false
}
}
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
getList
()
}
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
queryFormRef
.
value
.
resetFields
()
queryParams
.
type
=
undefined
handleQuery
()
}
/** 添加/修改操作 */
const
formRef
=
ref
()
const
openForm
=
(
type
:
string
,
id
?:
number
)
=>
{
formRef
.
value
.
open
(
type
,
id
)
}
/** 删除按钮操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
try
{
// 删除的二次确认
await
message
.
delConfirm
()
// 发起删除
await
ThinkModelFunctionApi
.
deleteThinkModelFunction
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
await
getList
()
}
catch
{}
}
/** 初始化 **/
onMounted
(()
=>
{
getList
()
})
</
script
>
src/views/iot/product/detail/ThinkModelFunctionForm.vue
0 → 100644
View file @
81a710c0
<
template
>
<Dialog
:title=
"dialogTitle"
v-model=
"dialogVisible"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"100px"
v-loading=
"formLoading"
>
<el-form-item
label=
"功能类型"
prop=
"type"
>
<el-select
v-model=
"formData.type"
placeholder=
"请选择功能类型"
>
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_FUNCTION_TYPE)"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"功能名称"
prop=
"name"
>
<el-input
v-model=
"formData.name"
placeholder=
"请输入功能名称"
/>
</el-form-item>
<el-form-item
label=
"标识符"
prop=
"identifier"
>
<el-input
v-model=
"formData.identifier"
placeholder=
"请输入标识符"
/>
</el-form-item>
<el-form-item
label=
"数据类型"
prop=
"dataType"
>
<el-select
v-model=
"formData.dataType"
placeholder=
"请选择数据类型"
>
<el-option
key=
"int"
label=
"int32 (整数型)"
value=
"int"
/>
<el-option
key=
"float"
label=
"float (单精度浮点型)"
value=
"float"
/>
<el-option
key=
"double"
label=
"double (双精度浮点型)"
value=
"double"
/>
<el-option
key=
"text"
label=
"text (文本型)"
value=
"text"
/>
<el-option
key=
"date"
label=
"date (日期型)"
value=
"date"
/>
<el-option
key=
"bool"
label=
"bool (布尔型)"
value=
"bool"
/>
<el-option
key=
"enum"
label=
"enum (枚举型)"
value=
"enum"
/>
<el-option
key=
"struct"
label=
"struct (结构体)"
value=
"struct"
/>
<el-option
key=
"array"
label=
"array (数组)"
value=
"array"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"取值范围"
prop=
"range"
>
<el-input
v-model=
"formData.property.dataType.specs.min"
placeholder=
"请输入最小值"
/>
<span
class=
"mx-2"
>
~
</span>
<el-input
v-model=
"formData.property.dataType.specs.max"
placeholder=
"请输入最大值"
/>
</el-form-item>
<el-form-item
label=
"步长"
prop=
"step"
>
<el-input
v-model=
"formData.property.dataType.specs.step"
placeholder=
"请输入步长"
/>
</el-form-item>
<el-form-item
label=
"单位"
prop=
"unit"
>
<el-select
v-model=
"formData.property.dataType.specs.unit"
placeholder=
"请选择单位"
>
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.IOT_UNIT_TYPE)"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"读写类型"
prop=
"accessMode"
>
<el-radio-group
v-model=
"formData.property.accessMode"
>
<el-radio
label=
"rw"
>
读写
</el-radio>
<el-radio
label=
"r"
>
只读
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"功能描述"
prop=
"description"
>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入功能描述"
/>
</el-form-item>
</el-form>
<template
#
footer
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
setup
lang=
"ts"
>
import
{
ProductVO
}
from
'@/api/iot/product'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
ThinkModelFunctionApi
,
ThinkModelFunctionVO
}
from
'@/api/iot/thinkmodelfunction'
const
props
=
defineProps
<
{
product
:
ProductVO
}
>
()
defineOptions
({
name
:
'ThinkModelFunctionForm'
})
const
{
t
}
=
useI18n
()
const
message
=
useMessage
()
const
dialogVisible
=
ref
(
false
)
const
dialogTitle
=
ref
(
''
)
const
formLoading
=
ref
(
false
)
const
formType
=
ref
(
''
)
const
formData
=
ref
({
id
:
undefined
,
productId
:
undefined
,
productKey
:
undefined
,
identifier
:
undefined
,
name
:
undefined
,
description
:
undefined
,
type
:
undefined
,
property
:
{
identifier
:
undefined
,
name
:
undefined
,
accessMode
:
undefined
,
required
:
true
,
dataType
:
{
type
:
undefined
,
specs
:
{
min
:
undefined
,
max
:
undefined
,
step
:
undefined
,
unit
:
undefined
}
}
}
})
const
formRules
=
reactive
({
name
:
[{
required
:
true
,
message
:
'功能名称不能为空'
,
trigger
:
'blur'
}],
type
:
[{
required
:
true
,
message
:
'功能类型不能为空'
,
trigger
:
'blur'
}],
identifier
:
[{
required
:
true
,
message
:
'标识符不能为空'
,
trigger
:
'blur'
}],
property
:
{
dataType
:
{
type
:
[{
required
:
true
,
message
:
'数据类型不能为空'
,
trigger
:
'blur'
}]
},
accessMode
:
[{
required
:
true
,
message
:
'读写类型不能为空'
,
trigger
:
'blur'
}]
}
})
const
formRef
=
ref
()
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
dialogVisible
.
value
=
true
dialogTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
resetForm
()
if
(
id
)
{
formLoading
.
value
=
true
try
{
formData
.
value
=
await
ThinkModelFunctionApi
.
getThinkModelFunction
(
id
)
}
finally
{
formLoading
.
value
=
false
}
}
}
defineExpose
({
open
,
close
:
()
=>
(
dialogVisible
.
value
=
false
)
})
const
emit
=
defineEmits
([
'success'
])
const
submitForm
=
async
()
=>
{
await
formRef
.
value
.
validate
()
formLoading
.
value
=
true
try
{
const
data
=
formData
.
value
as
unknown
as
ThinkModelFunctionVO
data
.
productId
=
props
.
product
.
id
data
.
productKey
=
props
.
product
.
productKey
if
(
formType
.
value
===
'create'
)
{
await
ThinkModelFunctionApi
.
createThinkModelFunction
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
await
ThinkModelFunctionApi
.
updateThinkModelFunction
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
}
dialogVisible
.
value
=
false
// 确保关闭弹框
emit
(
'success'
)
}
finally
{
formLoading
.
value
=
false
}
}
const
resetForm
=
()
=>
{
formData
.
value
=
{
id
:
undefined
,
productId
:
undefined
,
productKey
:
undefined
,
identifier
:
undefined
,
name
:
undefined
,
description
:
undefined
,
type
:
undefined
,
property
:
{
identifier
:
undefined
,
name
:
undefined
,
accessMode
:
undefined
,
required
:
true
,
dataType
:
{
type
:
undefined
,
specs
:
{
min
:
undefined
,
max
:
undefined
,
step
:
undefined
,
unit
:
undefined
}
}
}
}
formRef
.
value
?.
resetFields
()
}
</
script
>
src/views/iot/product/detail/index.vue
View file @
81a710c0
<
template
>
<
template
>
<ProductDetailsHeader
:loading=
"loading"
:product=
"product"
@
refresh=
"() => getProductData(id)"
/>
<ProductDetailsHeader
:loading=
"loading"
:product=
"product"
@
refresh=
"() => getProductData(id)"
/>
<el-col>
<el-col>
<el-tabs>
<el-tabs
v-model=
"activeTab"
>
<el-tab-pane
label=
"产品信息"
>
<el-tab-pane
label=
"产品信息"
name=
"info"
>
<ProductDetailsInfo
:product=
"product"
/>
<ProductDetailsInfo
v-if=
"activeTab === 'info'"
:product=
"product"
/>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"Topic 类列表"
>
<el-tab-pane
label=
"Topic 类列表"
name=
"topic"
>
<ProductTopic
:product=
"product"
/>
<ProductTopic
v-if=
"activeTab === 'topic'"
:product=
"product"
/>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"
物模型
"
>
<el-tab-pane
label=
"
功能定义"
name=
"function
"
>
<
!--
<ProductDetailsModel
:product=
"product"
/>
--
>
<
ThinkModelFunction
v-if=
"activeTab === 'function'"
:product=
"product"
/
>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"消息解析"
/>
<el-tab-pane
label=
"消息解析"
name=
"message"
/>
<el-tab-pane
label=
"服务端订阅"
/>
<el-tab-pane
label=
"服务端订阅"
name=
"subscription"
/>
</el-tabs>
</el-tabs>
</el-col>
</el-col>
</
template
>
</
template
>
...
@@ -22,6 +22,7 @@ import { DeviceApi } from '@/api/iot/device'
...
@@ -22,6 +22,7 @@ import { DeviceApi } from '@/api/iot/device'
import
ProductDetailsHeader
from
'@/views/iot/product/detail/ProductDetailsHeader.vue'
import
ProductDetailsHeader
from
'@/views/iot/product/detail/ProductDetailsHeader.vue'
import
ProductDetailsInfo
from
'@/views/iot/product/detail/ProductDetailsInfo.vue'
import
ProductDetailsInfo
from
'@/views/iot/product/detail/ProductDetailsInfo.vue'
import
ProductTopic
from
'@/views/iot/product/detail/ProductTopic.vue'
import
ProductTopic
from
'@/views/iot/product/detail/ProductTopic.vue'
import
ThinkModelFunction
from
'@/views/iot/product/detail/ThinkModelFunction.vue'
defineOptions
({
name
:
'IoTProductDetail'
})
defineOptions
({
name
:
'IoTProductDetail'
})
...
@@ -30,6 +31,7 @@ const message = useMessage()
...
@@ -30,6 +31,7 @@ const message = useMessage()
const
id
=
Number
(
route
.
params
.
id
)
// 编号
const
id
=
Number
(
route
.
params
.
id
)
// 编号
const
loading
=
ref
(
true
)
// 加载中
const
loading
=
ref
(
true
)
// 加载中
const
product
=
ref
<
ProductVO
>
({}
as
ProductVO
)
// 详情
const
product
=
ref
<
ProductVO
>
({}
as
ProductVO
)
// 详情
const
activeTab
=
ref
(
'info'
)
// 默认激活的标签页
/** 获取详情 */
/** 获取详情 */
const
getProductData
=
async
(
id
:
number
)
=>
{
const
getProductData
=
async
(
id
:
number
)
=>
{
...
...
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