【功能完善】IOT: 物模型布尔值数据类型组件完善

pull/620/head
puhui999 2024-12-14 23:09:14 +08:00
parent 5209318bb2
commit c7d9a7fe52
3 changed files with 27 additions and 4 deletions

View File

@ -16,6 +16,20 @@
v-if="formData.dataType === DataSpecsDataType.ENUM" v-if="formData.dataType === DataSpecsDataType.ENUM"
v-model="formData.dataSpecsList" v-model="formData.dataSpecsList"
/> />
<!-- 布尔型配置 -->
<el-form-item label="布尔值" prop="bool" v-if="formData.dataType === DataSpecsDataType.BOOL">
<template v-for="item in formData.dataSpecsList" :key="item.value">
<div class="flex items-center justify-start w-1/1 mb-5px">
<span>{{ item.value }}</span>
<span class="mx-2">-</span>
<el-input
v-model="item.name"
class="w-255px!"
:placeholder="`如:${item.value === 0 ? '关' : '开'}`"
/>
</div>
</template>
</el-form-item>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -41,10 +55,19 @@ const handleChange = (dataType: any) => {
switch (dataType) { switch (dataType) {
case DataSpecsDataType.ENUM: case DataSpecsDataType.ENUM:
formData.value.dataSpecsList.push({ formData.value.dataSpecsList.push({
dataType: 'ENUM', dataType: DataSpecsDataType.ENUM,
name: '', // name: '', //
value: undefined // value: undefined //
}) })
break
case DataSpecsDataType.BOOL:
for (let i = 0; i < 2; i++) {
formData.value.dataSpecsList.push({
dataType: DataSpecsDataType.BOOL,
name: '', //
value: i //
})
}
} }
} }
// dataTypeINTdataSpecs // dataTypeINTdataSpecs

View File

@ -17,7 +17,7 @@ export interface DataSpecsTextDataVO {
} }
/** dataSpecs 枚举型数据结构 */ /** dataSpecs 枚举型数据结构 */
export interface DataSpecsEnumDataVO { export interface DataSpecsEnumOrBoolDataVO {
dataType: 'enum' | 'bool' dataType: 'enum' | 'bool'
defaultValue?: string // 默认值,可选 defaultValue?: string // 默认值,可选
name: string // 枚举项的名称 name: string // 枚举项的名称

View File

@ -24,14 +24,14 @@
import { useVModel } from '@vueuse/core' import { useVModel } from '@vueuse/core'
import { import {
DataSpecsDataType, DataSpecsDataType,
DataSpecsEnumDataVO DataSpecsEnumOrBoolDataVO
} from '@/views/iot/product/product/detail/ThingModel/config' } 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 dataSpecsList = useVModel(props, 'modelValue', emits) as Ref<DataSpecsEnumDataVO[]> const dataSpecsList = useVModel(props, 'modelValue', emits) as Ref<DataSpecsEnumOrBoolDataVO[]>
const message = useMessage() const message = useMessage()
/** 添加枚举项 */ /** 添加枚举项 */