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
e1b2cb10
authored
Dec 13, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能新增】IOT: 产品物模型,30%
parent
94d74f1a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
21 deletions
+46
-21
src/views/iot/product/product/detail/ThingModel/ThingModelDataSpecs.vue
+11
-2
src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue
+5
-4
src/views/iot/product/product/detail/ThingModel/config.ts
+1
-1
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelDataType.vue
+2
-2
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue
+20
-5
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue
+7
-7
No files found.
src/views/iot/product/product/detail/ThingModel/ThingModelDataSpecs.vue
View file @
e1b2cb10
...
@@ -33,10 +33,19 @@ const props = defineProps<{ modelValue: any }>()
...
@@ -33,10 +33,19 @@ const props = defineProps<{ modelValue: any }>()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
emits
=
defineEmits
([
'update:modelValue'
])
const
formData
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
any
>
const
formData
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
any
>
/** 属性值的数据类型切换时 */
/** 属性值的数据类型切换时
初始化相关数据
*/
const
handleChange
=
()
=>
{
const
handleChange
=
(
dataType
:
any
)
=>
{
formData
.
value
.
dataSpecsList
=
[]
formData
.
value
.
dataSpecsList
=
[]
formData
.
value
.
dataSpecs
=
{}
formData
.
value
.
dataSpecs
=
{}
switch
(
dataType
)
{
case
DataSpecsDataType
.
ENUM
:
formData
.
value
.
dataSpecsList
.
push
({
dataType
:
'ENUM'
,
name
:
''
,
// 枚举项的名称
value
:
undefined
// 枚举值
})
}
}
}
// dataType为INT的dataSpecs示例:
// dataType为INT的dataSpecs示例:
//
//
...
...
src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue
View file @
e1b2cb10
...
@@ -48,6 +48,7 @@ import {
...
@@ -48,6 +48,7 @@ import {
ThinkModelFunctionVO
ThinkModelFunctionVO
}
from
'@/api/iot/thinkmodelfunction'
}
from
'@/api/iot/thinkmodelfunction'
import
{
IOT_PROVIDE_KEY
}
from
'@/views/iot/utils/constants'
import
{
IOT_PROVIDE_KEY
}
from
'@/views/iot/utils/constants'
import
{
DataSpecsDataType
}
from
'./config'
defineOptions
({
name
:
'IoTProductThingModelForm'
})
defineOptions
({
name
:
'IoTProductThingModelForm'
})
...
@@ -68,9 +69,9 @@ const formData = ref({
...
@@ -68,9 +69,9 @@ const formData = ref({
name
:
undefined
,
name
:
undefined
,
description
:
undefined
,
description
:
undefined
,
type
:
ProductFunctionTypeEnum
.
PROPERTY
,
type
:
ProductFunctionTypeEnum
.
PROPERTY
,
dataType
:
undefined
,
dataType
:
DataSpecsDataType
.
INT
,
dataSpecsList
:
[],
dataSpecsList
:
[],
dataSpecs
:
undefined
,
dataSpecs
:
{}
,
accessMode
:
undefined
accessMode
:
undefined
})
})
const
formRules
=
reactive
({
const
formRules
=
reactive
({
...
@@ -164,9 +165,9 @@ const resetForm = () => {
...
@@ -164,9 +165,9 @@ const resetForm = () => {
name
:
undefined
,
name
:
undefined
,
description
:
undefined
,
description
:
undefined
,
type
:
ProductFunctionTypeEnum
.
PROPERTY
,
type
:
ProductFunctionTypeEnum
.
PROPERTY
,
dataType
:
undefined
,
dataType
:
DataSpecsDataType
.
INT
,
dataSpecsList
:
[],
dataSpecsList
:
[],
dataSpecs
:
undefined
,
dataSpecs
:
{}
,
accessMode
:
undefined
accessMode
:
undefined
}
}
formRef
.
value
?.
resetFields
()
formRef
.
value
?.
resetFields
()
...
...
src/views/iot/product/product/detail/ThingModel/config.ts
View file @
e1b2cb10
...
@@ -21,7 +21,7 @@ export interface DataSpecsEnumDataVO {
...
@@ -21,7 +21,7 @@ export interface DataSpecsEnumDataVO {
dataType
:
'ENUM'
|
'BOOL'
dataType
:
'ENUM'
|
'BOOL'
defaultValue
?:
string
// 默认值,可选
defaultValue
?:
string
// 默认值,可选
name
:
string
// 枚举项的名称
name
:
string
// 枚举项的名称
value
:
number
// 枚举值
value
:
number
|
undefined
// 枚举值
}
}
/** 属性值的数据类型 */
/** 属性值的数据类型 */
...
...
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelDataType.vue
View file @
e1b2cb10
...
@@ -30,8 +30,8 @@ const dataTypeOptions = [
...
@@ -30,8 +30,8 @@ const dataTypeOptions = [
{
value
:
DataSpecsDataType
.
STRUCT
,
label
:
'struct (结构体)'
},
{
value
:
DataSpecsDataType
.
STRUCT
,
label
:
'struct (结构体)'
},
{
value
:
DataSpecsDataType
.
ARRAY
,
label
:
'array (数组)'
}
{
value
:
DataSpecsDataType
.
ARRAY
,
label
:
'array (数组)'
}
]
]
const
handleChange
=
()
=>
{
const
handleChange
=
(
value
:
any
)
=>
{
emits
(
'change'
)
emits
(
'change'
,
value
)
}
}
</
script
>
</
script
>
...
...
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue
View file @
e1b2cb10
<
template
>
<
template
>
<el-form-item
label=
"枚举项"
prop=
"enumItem"
>
<el-form-item
label=
"枚举项"
prop=
"enumItem"
>
<div
class=
"flex flex-col"
>
<div
class=
"flex items-center justify-between"
>
<div
class=
"flex items-center justify-between"
>
<span>
参数值
</span>
<span>
参数值
</span>
<span>
参数描述
</span>
<span>
参数描述
</span>
</div>
</div>
<div
v-for=
"(item, index) in formData"
:key=
"index"
class=
"flex items-center justify-between"
>
<div
<el-input
v-model=
"item.value"
placeholder=
"请输入参数值"
/>
v-for=
"(item, index) in dataSpecsList"
:key=
"index"
class=
"flex items-center justify-between mb-5px"
>
<el-input
v-model=
"item.value"
placeholder=
"请输入枚举值,如'0'"
/>
<span
class=
"mx-2"
>
~
</span>
<span
class=
"mx-2"
>
~
</span>
<el-input
v-model=
"item.name"
placeholder=
"请输入参数描述"
/>
<el-input
v-model=
"item.name"
placeholder=
"对该枚举项的描述"
/>
</div>
<el-button
link
type=
"primary"
@
click=
"addEnum"
>
+添加枚举项
</el-button>
</div>
</div>
<el-button
link
type=
"primary"
>
+添加枚举项
</el-button>
</el-form-item>
</el-form-item>
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
useVModel
}
from
'@vueuse/core'
import
{
useVModel
}
from
'@vueuse/core'
import
{
DataSpecsEnumDataVO
}
from
'@/views/iot/product/product/detail/ThingModel/config'
/** 枚举型的 dataSpecs 配置组件 */
/** 枚举型的 dataSpecs 配置组件 */
defineOptions
({
name
:
'ThingModelEnumTypeDataSpecs'
})
defineOptions
({
name
:
'ThingModelEnumTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
emits
=
defineEmits
([
'update:modelValue'
])
const
formData
=
useVModel
(
props
,
'modelValue'
,
emits
)
const
dataSpecsList
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
DataSpecsEnumDataVO
[]
>
const
addEnum
=
()
=>
{
dataSpecsList
.
value
.
push
({
dataType
:
'ENUM'
,
name
:
''
,
// 枚举项的名称
value
:
undefined
// 枚举值
})
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
<
style
lang=
"scss"
scoped
></
style
>
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue
View file @
e1b2cb10
<
template
>
<
template
>
<el-form-item
label=
"取值范围"
prop=
"max"
>
<el-form-item
label=
"取值范围"
prop=
"max"
>
<div
class=
"flex items-center justify-between"
>
<div
class=
"flex items-center justify-between"
>
<el-input
v-model=
"
formData
.min"
placeholder=
"请输入最小值"
/>
<el-input
v-model=
"
dataSpecs
.min"
placeholder=
"请输入最小值"
/>
<span
class=
"mx-2"
>
~
</span>
<span
class=
"mx-2"
>
~
</span>
<el-input
v-model=
"
formData
.max"
placeholder=
"请输入最大值"
/>
<el-input
v-model=
"
dataSpecs
.max"
placeholder=
"请输入最大值"
/>
</div>
</div>
</el-form-item>
</el-form-item>
<el-form-item
label=
"步长"
prop=
"step"
>
<el-form-item
label=
"步长"
prop=
"step"
>
<el-input
v-model=
"
formData
.step"
placeholder=
"请输入步长"
/>
<el-input
v-model=
"
dataSpecs
.step"
placeholder=
"请输入步长"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"单位"
prop=
"unit"
>
<el-form-item
label=
"单位"
prop=
"unit"
>
<el-select
<el-select
:model-value=
"
formData.unit ? formData.unitName + '-' + formData
.unit : ''"
:model-value=
"
dataSpecs.unit ? dataSpecs.unitName + '-' + dataSpecs
.unit : ''"
filterable
filterable
placeholder=
"请选择单位"
placeholder=
"请选择单位"
style=
"width: 240px"
style=
"width: 240px"
...
@@ -36,13 +36,13 @@ import { DataSpecsNumberDataVO } from '../config'
...
@@ -36,13 +36,13 @@ import { DataSpecsNumberDataVO } from '../config'
defineOptions
({
name
:
'ThingModelNumberTypeDataSpecs'
})
defineOptions
({
name
:
'ThingModelNumberTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
emits
=
defineEmits
([
'update:modelValue'
])
const
formData
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
DataSpecsNumberDataVO
>
const
dataSpecs
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
DataSpecsNumberDataVO
>
/** 单位发生变化时触发 */
/** 单位发生变化时触发 */
const
unitChange
=
(
UnitSpecs
:
string
)
=>
{
const
unitChange
=
(
UnitSpecs
:
string
)
=>
{
const
[
unitName
,
unit
]
=
UnitSpecs
.
split
(
'-'
)
const
[
unitName
,
unit
]
=
UnitSpecs
.
split
(
'-'
)
formData
.
value
.
unitName
=
unitName
dataSpecs
.
value
.
unitName
=
unitName
formData
.
value
.
unit
=
unit
dataSpecs
.
value
.
unit
=
unit
}
}
</
script
>
</
script
>
...
...
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