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
341eb570
authored
Dec 17, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】IOT: 产品物模型独立包
parent
c8ab57f7
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
63 deletions
+56
-63
src/api/iot/thinkmodel/index.ts
+17
-17
src/views/iot/product/product/detail/ThingModel/dataSpecs/index.ts
+0
-5
src/views/iot/product/product/detail/index.vue
+3
-3
src/views/iot/product/product/index.vue
+1
-1
src/views/iot/thinkmodel/ThinkModelDataSpecs.vue
+9
-9
src/views/iot/thinkmodel/ThinkModelForm.vue
+9
-13
src/views/iot/thinkmodel/config.ts
+0
-0
src/views/iot/thinkmodel/dataSpecs/ThinkModelArrayTypeDataSpecs.vue
+1
-1
src/views/iot/thinkmodel/dataSpecs/ThinkModelEnumTypeDataSpecs.vue
+2
-5
src/views/iot/thinkmodel/dataSpecs/ThinkModelNumberTypeDataSpecs.vue
+1
-1
src/views/iot/thinkmodel/dataSpecs/index.ts
+5
-0
src/views/iot/thinkmodel/index.vue
+8
-8
No files found.
src/api/iot/thinkmodel
function
/index.ts
→
src/api/iot/thinkmodel/index.ts
View file @
341eb570
...
...
@@ -3,7 +3,7 @@ import request from '@/config/axios'
/**
* IoT 产品物模型
*/
export
interface
Thin
g
ModelData
{
export
interface
Thin
k
ModelData
{
id
?:
number
// 物模型功能编号
identifier
?:
string
// 功能标识
name
?:
string
// 功能名称
...
...
@@ -12,29 +12,29 @@ export interface ThingModelData {
productKey
?:
string
// 产品标识
dataType
:
string
// 数据类型,与 dataSpecs 的 dataType 保持一致
type
:
ProductFunctionTypeEnum
// 功能类型
property
:
Thin
g
ModelProperty
// 属性
event
?:
Thin
g
ModelEvent
// 事件
service
?:
Thin
g
ModelService
// 服务
property
:
Thin
k
ModelProperty
// 属性
event
?:
Thin
k
ModelEvent
// 事件
service
?:
Thin
k
ModelService
// 服务
}
/**
* Thin
g
ModelProperty 类型
* Thin
k
ModelProperty 类型
*/
export
interface
Thin
g
ModelProperty
{
export
interface
Thin
k
ModelProperty
{
[
key
:
string
]:
any
}
/**
* Thin
g
ModelEvent 类型
* Thin
k
ModelEvent 类型
*/
export
interface
Thin
g
ModelEvent
{
export
interface
Thin
k
ModelEvent
{
[
key
:
string
]:
any
}
/**
* Thin
g
ModelService 类型
* Thin
k
ModelService 类型
*/
export
interface
Thin
g
ModelService
{
export
interface
Thin
k
ModelService
{
[
key
:
string
]:
any
}
...
...
@@ -52,14 +52,14 @@ export enum ProductFunctionAccessModeEnum {
}
// IoT 产品物模型 API
export
const
ThinkModel
Function
Api
=
{
export
const
ThinkModelApi
=
{
// 查询产品物模型分页
getProductThin
g
ModelPage
:
async
(
params
:
any
)
=>
{
getProductThin
k
ModelPage
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/product-thing-model/page`
,
params
})
},
// 获得产品物模型
getProductThin
g
ModelListByProductId
:
async
(
params
:
any
)
=>
{
getProductThin
k
ModelListByProductId
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/product-thing-model/list-by-product-id`
,
params
...
...
@@ -67,22 +67,22 @@ export const ThinkModelFunctionApi = {
},
// 查询产品物模型详情
getProductThin
g
Model
:
async
(
id
:
number
)
=>
{
getProductThin
k
Model
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/iot/product-thing-model/get?id=`
+
id
})
},
// 新增产品物模型
createProductThin
gModel
:
async
(
data
:
Thing
ModelData
)
=>
{
createProductThin
kModel
:
async
(
data
:
Think
ModelData
)
=>
{
return
await
request
.
post
({
url
:
`/iot/product-thing-model/create`
,
data
})
},
// 修改产品物模型
updateProductThin
gModel
:
async
(
data
:
Thing
ModelData
)
=>
{
updateProductThin
kModel
:
async
(
data
:
Think
ModelData
)
=>
{
return
await
request
.
put
({
url
:
`/iot/product-thing-model/update`
,
data
})
},
// 删除产品物模型
deleteProductThin
g
Model
:
async
(
id
:
number
)
=>
{
deleteProductThin
k
Model
:
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/iot/product-thing-model/delete?id=`
+
id
})
}
}
src/views/iot/product/product/detail/ThingModel/dataSpecs/index.ts
deleted
100644 → 0
View file @
c8ab57f7
import
ThingModelEnumTypeDataSpecs
from
'./ThingModelEnumTypeDataSpecs.vue'
import
ThingModelNumberTypeDataSpecs
from
'./ThingModelNumberTypeDataSpecs.vue'
import
ThingModelArrayTypeDataSpecs
from
'./ThingModelArrayTypeDataSpecs.vue'
export
{
ThingModelEnumTypeDataSpecs
,
ThingModelNumberTypeDataSpecs
,
ThingModelArrayTypeDataSpecs
}
src/views/iot/product/product/detail/index.vue
View file @
341eb570
...
...
@@ -8,8 +8,8 @@
<el-tab-pane
label=
"Topic 类列表"
name=
"topic"
>
<ProductTopic
v-if=
"activeTab === 'topic'"
:product=
"product"
/>
</el-tab-pane>
<el-tab-pane
label=
"功能定义"
lazy
name=
"thin
g
Model"
>
<IoTProductThin
gModel
ref=
"thing
ModelRef"
/>
<el-tab-pane
label=
"功能定义"
lazy
name=
"thin
k
Model"
>
<IoTProductThin
kModel
ref=
"think
ModelRef"
/>
</el-tab-pane>
<el-tab-pane
label=
"消息解析"
name=
"message"
/>
<el-tab-pane
label=
"服务端订阅"
name=
"subscription"
/>
...
...
@@ -22,7 +22,7 @@ import { DeviceApi } from '@/api/iot/device'
import
ProductDetailsHeader
from
'./ProductDetailsHeader.vue'
import
ProductDetailsInfo
from
'./ProductDetailsInfo.vue'
import
ProductTopic
from
'./ProductTopic.vue'
import
IoTProductThin
gModel
from
'./ThingM
odel/index.vue'
import
IoTProductThin
kModel
from
'@/views/iot/thinkm
odel/index.vue'
import
{
useTagsViewStore
}
from
'@/store/modules/tagsView'
import
{
useRouter
}
from
'vue-router'
import
{
IOT_PROVIDE_KEY
}
from
'@/views/iot/utils/constants'
...
...
src/views/iot/product/product/index.vue
View file @
341eb570
...
...
@@ -309,7 +309,7 @@ const openObjectModel = (item: ProductVO) => {
push
({
name
:
'IoTProductDetail'
,
params
:
{
id
:
item
.
id
},
query
:
{
tab
:
'thin
g
Model'
}
query
:
{
tab
:
'thin
k
Model'
}
})
}
...
...
src/views/iot/
product/product/detail/ThingModel/Thing
ModelDataSpecs.vue
→
src/views/iot/
thinkmodel/Think
ModelDataSpecs.vue
View file @
341eb570
...
...
@@ -14,7 +14,7 @@
</el-select>
</el-form-item>
<!-- 数值型配置 -->
<Thin
g
ModelNumberTypeDataSpecs
<Thin
k
ModelNumberTypeDataSpecs
v-if=
"
[DataSpecsDataType.INT, DataSpecsDataType.DOUBLE, DataSpecsDataType.FLOAT].includes(
property.dataType || ''
...
...
@@ -23,7 +23,7 @@
v-model=
"property.dataSpecs"
/>
<!-- 枚举型配置 -->
<Thin
g
ModelEnumTypeDataSpecs
<Thin
k
ModelEnumTypeDataSpecs
v-if=
"property.dataType === DataSpecsDataType.ENUM"
v-model=
"property.dataSpecsList"
/>
...
...
@@ -74,7 +74,7 @@
<el-input
class=
"w-255px!"
disabled
placeholder=
"String类型的UTC时间戳(毫秒)"
/>
</el-form-item>
<!-- 数组型配置-->
<Thin
g
ModelArrayTypeDataSpecs
<Thin
k
ModelArrayTypeDataSpecs
v-if=
"property.dataType === DataSpecsDataType.ARRAY"
v-model=
"property.dataSpecs"
/>
...
...
@@ -104,18 +104,18 @@
import
{
useVModel
}
from
'@vueuse/core'
import
{
DataSpecsDataType
,
dataTypeOptions
}
from
'./config'
import
{
Thin
g
ModelArrayTypeDataSpecs
,
Thin
g
ModelEnumTypeDataSpecs
,
Thin
g
ModelNumberTypeDataSpecs
Thin
k
ModelArrayTypeDataSpecs
,
Thin
k
ModelEnumTypeDataSpecs
,
Thin
k
ModelNumberTypeDataSpecs
}
from
'./dataSpecs'
import
{
Thin
gModelProperty
}
from
'@/api/iot/thinkmodelfunction
'
import
{
Thin
kModelProperty
}
from
'@/api/iot/thinkmodel
'
import
{
isEmpty
}
from
'@/utils/is'
/** 物模型数据 */
defineOptions
({
name
:
'
Thing
ModelDataSpecs'
})
defineOptions
({
name
:
'
IoTProductThink
ModelDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
property
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
Thin
g
ModelProperty
>
const
property
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
Thin
k
ModelProperty
>
/** 属性值的数据类型切换时初始化相关数据 */
const
handleChange
=
(
dataType
:
any
)
=>
{
...
...
src/views/iot/
product/product/detail/ThingModel/Thing
ModelForm.vue
→
src/views/iot/
thinkmodel/Think
ModelForm.vue
View file @
341eb570
...
...
@@ -21,7 +21,7 @@
<el-input
v-model=
"formData.identifier"
placeholder=
"请输入标识符"
/>
</el-form-item>
<!-- 属性配置 -->
<Thin
g
ModelDataSpecs
<Thin
k
ModelDataSpecs
v-if=
"formData.type === ProductFunctionTypeEnum.PROPERTY"
v-model=
"formData.property"
/>
...
...
@@ -36,17 +36,13 @@
<
script
lang=
"ts"
setup
>
import
{
ProductVO
}
from
'@/api/iot/product/product'
import
ThingModelDataSpecs
from
'./ThingModelDataSpecs.vue'
import
{
ProductFunctionTypeEnum
,
ThingModelData
,
ThinkModelFunctionApi
}
from
'@/api/iot/thinkmodelfunction'
import
ThinkModelDataSpecs
from
'./ThinkModelDataSpecs.vue'
import
{
ProductFunctionTypeEnum
,
ThinkModelApi
,
ThinkModelData
}
from
'@/api/iot/thinkmodel'
import
{
IOT_PROVIDE_KEY
}
from
'@/views/iot/utils/constants'
import
{
DataSpecsDataType
}
from
'./config'
import
{
cloneDeep
}
from
'lodash-es'
defineOptions
({
name
:
'IoTProductThin
g
ModelForm'
})
defineOptions
({
name
:
'IoTProductThin
k
ModelForm'
})
const
product
=
inject
<
Ref
<
ProductVO
>>
(
IOT_PROVIDE_KEY
.
PRODUCT
)
// 注入产品信息
...
...
@@ -57,7 +53,7 @@ const dialogVisible = ref(false)
const
dialogTitle
=
ref
(
''
)
const
formLoading
=
ref
(
false
)
const
formType
=
ref
(
''
)
const
formData
=
ref
<
Thin
g
ModelData
>
({
const
formData
=
ref
<
Thin
k
ModelData
>
({
type
:
ProductFunctionTypeEnum
.
PROPERTY
,
dataType
:
DataSpecsDataType
.
INT
,
property
:
{
...
...
@@ -115,7 +111,7 @@ const open = async (type: string, id?: number) => {
if
(
id
)
{
formLoading
.
value
=
true
try
{
formData
.
value
=
await
ThinkModel
FunctionApi
.
getProductThing
Model
(
id
)
formData
.
value
=
await
ThinkModel
Api
.
getProductThink
Model
(
id
)
}
finally
{
formLoading
.
value
=
false
}
...
...
@@ -129,7 +125,7 @@ const submitForm = async () => {
await
formRef
.
value
.
validate
()
formLoading
.
value
=
true
try
{
const
data
=
cloneDeep
(
formData
.
value
)
as
Thin
g
ModelData
const
data
=
cloneDeep
(
formData
.
value
)
as
Thin
k
ModelData
// 信息补全
data
.
productId
=
product
!
.
value
.
id
data
.
productKey
=
product
!
.
value
.
productKey
...
...
@@ -138,10 +134,10 @@ const submitForm = async () => {
data
.
property
.
identifier
=
data
.
identifier
data
.
property
.
name
=
data
.
name
if
(
formType
.
value
===
'create'
)
{
await
ThinkModel
FunctionApi
.
createProductThing
Model
(
data
)
await
ThinkModel
Api
.
createProductThink
Model
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
await
ThinkModel
FunctionApi
.
updateProductThing
Model
(
data
)
await
ThinkModel
Api
.
updateProductThink
Model
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
}
}
finally
{
...
...
src/views/iot/
product/product/detail/ThingM
odel/config.ts
→
src/views/iot/
thinkm
odel/config.ts
View file @
341eb570
File moved
src/views/iot/
product/product/detail/ThingModel/dataSpecs/Thing
ModelArrayTypeDataSpecs.vue
→
src/views/iot/
thinkmodel/dataSpecs/Think
ModelArrayTypeDataSpecs.vue
View file @
341eb570
...
...
@@ -37,7 +37,7 @@ import { DataSpecsDataType, dataTypeOptions } from '../config'
import
{
isEmpty
}
from
'@/utils/is'
/** 数组型的 dataSpecs 配置组件 */
defineOptions
({
name
:
'
Thing
ModelArrayTypeDataSpecs'
})
defineOptions
({
name
:
'
IoTProductThink
ModelArrayTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
dataSpecs
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
any
>
...
...
src/views/iot/
product/product/detail/ThingModel/dataSpecs/Thing
ModelEnumTypeDataSpecs.vue
→
src/views/iot/
thinkmodel/dataSpecs/Think
ModelEnumTypeDataSpecs.vue
View file @
341eb570
...
...
@@ -44,14 +44,11 @@
<
script
lang=
"ts"
setup
>
import
{
useVModel
}
from
'@vueuse/core'
import
{
DataSpecsDataType
,
DataSpecsEnumOrBoolDataVO
}
from
'@/views/iot/product/product/detail/ThingModel/config'
import
{
DataSpecsDataType
,
DataSpecsEnumOrBoolDataVO
}
from
'../config'
import
{
isEmpty
}
from
'@/utils/is'
/** 枚举型的 dataSpecs 配置组件 */
defineOptions
({
name
:
'
Thing
ModelEnumTypeDataSpecs'
})
defineOptions
({
name
:
'
IoTProductThink
ModelEnumTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
dataSpecsList
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
DataSpecsEnumOrBoolDataVO
[]
>
...
...
src/views/iot/
product/product/detail/ThingModel/dataSpecs/Thing
ModelNumberTypeDataSpecs.vue
→
src/views/iot/
thinkmodel/dataSpecs/Think
ModelNumberTypeDataSpecs.vue
View file @
341eb570
...
...
@@ -62,7 +62,7 @@ import { UnifyUnitSpecsDTO } from '@/views/iot/utils/constants'
import
{
DataSpecsNumberDataVO
}
from
'../config'
/** 数值型的 dataSpecs 配置组件 */
defineOptions
({
name
:
'
Thing
ModelNumberTypeDataSpecs'
})
defineOptions
({
name
:
'
IoTProductThink
ModelNumberTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
dataSpecs
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
DataSpecsNumberDataVO
>
...
...
src/views/iot/thinkmodel/dataSpecs/index.ts
0 → 100644
View file @
341eb570
import
ThinkModelEnumTypeDataSpecs
from
'./ThinkModelEnumTypeDataSpecs.vue'
import
ThinkModelNumberTypeDataSpecs
from
'./ThinkModelNumberTypeDataSpecs.vue'
import
ThinkModelArrayTypeDataSpecs
from
'./ThinkModelArrayTypeDataSpecs.vue'
export
{
ThinkModelEnumTypeDataSpecs
,
ThinkModelNumberTypeDataSpecs
,
ThinkModelArrayTypeDataSpecs
}
src/views/iot/
product/product/detail/ThingM
odel/index.vue
→
src/views/iot/
thinkm
odel/index.vue
View file @
341eb570
...
...
@@ -96,23 +96,23 @@
</el-tabs>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<Thin
g
ModelForm
ref=
"formRef"
@
success=
"getList"
/>
<Thin
k
ModelForm
ref=
"formRef"
@
success=
"getList"
/>
</template>
<
script
lang=
"ts"
setup
>
import
{
Thin
gModelData
,
ThinkModelFunctionApi
}
from
'@/api/iot/thinkmodelfunction
'
import
{
Thin
kModelApi
,
ThinkModelData
}
from
'@/api/iot/thinkmodel
'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
Thin
gModelForm
from
'./Thing
ModelForm.vue'
import
Thin
kModelForm
from
'./Think
ModelForm.vue'
import
{
ProductVO
}
from
'@/api/iot/product/product'
import
{
IOT_PROVIDE_KEY
}
from
'@/views/iot/utils/constants'
import
{
getDataTypeOptionsLabel
}
from
'@/views/iot/
product/product/detail/ThingM
odel/config'
import
{
getDataTypeOptionsLabel
}
from
'@/views/iot/
thinkm
odel/config'
defineOptions
({
name
:
'IoTProductThin
g
Model'
})
defineOptions
({
name
:
'IoTProductThin
k
Model'
})
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
<
Thin
g
ModelData
[]
>
([])
// 列表的数据
const
list
=
ref
<
Thin
k
ModelData
[]
>
([])
// 列表的数据
const
total
=
ref
(
0
)
// 列表的总页数
const
queryParams
=
reactive
({
pageNo
:
1
,
...
...
@@ -130,7 +130,7 @@ const getList = async () => {
loading
.
value
=
true
try
{
queryParams
.
productId
=
product
?.
value
?.
id
||
-
1
const
data
=
await
ThinkModel
FunctionApi
.
getProductThing
ModelPage
(
queryParams
)
const
data
=
await
ThinkModel
Api
.
getProductThink
ModelPage
(
queryParams
)
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
...
...
@@ -162,7 +162,7 @@ const handleDelete = async (id: number) => {
// 删除的二次确认
await
message
.
delConfirm
()
// 发起删除
await
ThinkModel
FunctionApi
.
deleteProductThing
Model
(
id
)
await
ThinkModel
Api
.
deleteProductThink
Model
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
await
getList
()
...
...
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