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
6b9aaf3c
authored
Dec 17, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能完善】IOT: 产品物模型-数组型的 dataSpecs 校验规则完善
parent
12abcddb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelArrayTypeDataSpecs.vue
+28
-3
No files found.
src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelArrayTypeDataSpecs.vue
View file @
6b9aaf3c
<
template
>
<
template
>
<el-form-item
label=
"元素类型"
prop=
"childDataType"
>
<el-form-item
:rules=
"[
{ required: true, message: '元素类型不能为空' }]"
label="元素类型"
prop="property.dataSpecs.childDataType"
>
<el-radio-group
v-model=
"dataSpecs.childDataType"
>
<el-radio-group
v-model=
"dataSpecs.childDataType"
>
<template
v-for=
"item in dataTypeOptions"
:key=
"item.value"
>
<template
v-for=
"item in dataTypeOptions"
:key=
"item.value"
>
<el-radio
<el-radio
:value=
"item.value"
v-if=
"
v-if=
"
!(
!(
[DataSpecsDataType.ENUM, DataSpecsDataType.ARRAY, DataSpecsDataType.DATE] as any[]
[DataSpecsDataType.ENUM, DataSpecsDataType.ARRAY, DataSpecsDataType.DATE] as any[]
).includes(item.value)
).includes(item.value)
"
"
:value=
"item.value"
>
>
{{
item
.
label
}}
{{
item
.
label
}}
</el-radio>
</el-radio>
</
template
>
</
template
>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"元素个数"
prop=
"size"
>
<el-form-item
:rules=
"[
{ required: true, message: '元素个数不能为空' },
{ validator: validateSize, trigger: 'blur' }
]"
label=
"元素个数"
prop=
"property.dataSpecs.size"
>
<el-input
v-model=
"dataSpecs.size"
placeholder=
"请输入数组中的元素个数"
/>
<el-input
v-model=
"dataSpecs.size"
placeholder=
"请输入数组中的元素个数"
/>
</el-form-item>
</el-form-item>
</template>
</template>
...
@@ -23,12 +34,26 @@
...
@@ -23,12 +34,26 @@
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
useVModel
}
from
'@vueuse/core'
import
{
useVModel
}
from
'@vueuse/core'
import
{
DataSpecsDataType
,
dataTypeOptions
}
from
'../config'
import
{
DataSpecsDataType
,
dataTypeOptions
}
from
'../config'
import
{
isEmpty
}
from
'@/utils/is'
/** 数组型的 dataSpecs 配置组件 */
/** 数组型的 dataSpecs 配置组件 */
defineOptions
({
name
:
'ThingModelArrayTypeDataSpecs'
})
defineOptions
({
name
:
'ThingModelArrayTypeDataSpecs'
})
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
props
=
defineProps
<
{
modelValue
:
any
}
>
()
const
emits
=
defineEmits
([
'update:modelValue'
])
const
emits
=
defineEmits
([
'update:modelValue'
])
const
dataSpecs
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
any
>
const
dataSpecs
=
useVModel
(
props
,
'modelValue'
,
emits
)
as
Ref
<
any
>
/** 校验元素个数 */
const
validateSize
=
(
_
:
any
,
value
:
any
,
callback
:
any
)
=>
{
if
(
isEmpty
(
value
))
{
callback
(
new
Error
(
'元素个数不能为空'
))
return
}
if
(
isNaN
(
Number
(
value
)))
{
callback
(
new
Error
(
'元素个数必须是数字'
))
return
}
callback
()
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
<
style
lang=
"scss"
scoped
></
style
>
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