【功能新增】IOT: 产品物模型,30%
parent
94d74f1a09
commit
e1b2cb106a
|
@ -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示例:
|
||||||
//
|
//
|
||||||
|
|
|
@ -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({
|
||||||
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 = () => {
|
||||||
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()
|
||||||
|
|
|
@ -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 // 枚举值
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 属性值的数据类型 */
|
/** 属性值的数据类型 */
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,41 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form-item label="枚举项" prop="enumItem">
|
<el-form-item label="枚举项" prop="enumItem">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex flex-col">
|
||||||
<span> 参数值 </span>
|
<div class="flex items-center justify-between">
|
||||||
<span> 参数描述 </span>
|
<span> 参数值 </span>
|
||||||
|
<span> 参数描述 </span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
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>
|
||||||
|
<el-input v-model="item.name" placeholder="对该枚举项的描述" />
|
||||||
|
</div>
|
||||||
|
<el-button link type="primary" @click="addEnum">+添加枚举项</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="(item, index) in formData" :key="index" class="flex items-center justify-between">
|
|
||||||
<el-input v-model="item.value" placeholder="请输入参数值" />
|
|
||||||
<span class="mx-2">~</span>
|
|
||||||
<el-input v-model="item.name" placeholder="请输入参数描述" />
|
|
||||||
</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>
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<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'
|
||||||
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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue