Files
iot-device-management-frontend/apps/web-antd/src/views/iot/thingmodel/modules/dataSpecs/ThingModelArrayDataSpecs.vue

62 lines
1.9 KiB
Vue
Raw Normal View History

<!-- dataTypearray 数组类型 -->
2025-10-10 20:26:17 +08:00
<script lang="ts" setup>
2025-10-13 10:17:19 +08:00
import type { Ref } from 'vue';
2025-10-10 20:26:17 +08:00
import { useVModel } from '@vueuse/core';
2025-10-13 10:17:19 +08:00
import { Form, Input, Radio } from 'ant-design-vue';
2025-10-10 20:26:17 +08:00
import {
getDataTypeOptions,
IoTDataSpecsDataTypeEnum,
} from '#/views/iot/utils/constants';
import ThingModelStructDataSpecs from './ThingModelStructDataSpecs.vue';
/** 数组型的 dataSpecs 配置组件 */
defineOptions({ name: 'ThingModelArrayDataSpecs' });
const props = defineProps<{ modelValue: any }>();
const emits = defineEmits(['update:modelValue']);
const dataSpecs = useVModel(props, 'modelValue', emits) as Ref<any>;
/** 元素类型改变时间。当值为 struct 时,对 dataSpecs 中的 dataSpecsList 进行初始化 */
2025-10-13 10:17:19 +08:00
function handleChange(val: any) {
2025-10-10 20:26:17 +08:00
if (val !== IoTDataSpecsDataTypeEnum.STRUCT) {
return;
}
dataSpecs.value.dataSpecsList = [];
2025-10-13 10:17:19 +08:00
}
2025-10-10 20:26:17 +08:00
</script>
<template>
2025-10-13 10:17:19 +08:00
<Form.Item label="元素类型" prop="property.dataSpecs.childDataType">
<Radio.Group v-model="dataSpecs.childDataType" @change="handleChange">
<template v-for="item in getDataTypeOptions()" :key="item.value">
2025-10-13 10:17:19 +08:00
<Radio
v-if="
!(
[
IoTDataSpecsDataTypeEnum.ENUM,
IoTDataSpecsDataTypeEnum.ARRAY,
2025-10-10 20:26:17 +08:00
IoTDataSpecsDataTypeEnum.DATE,
] as any[]
).includes(item.value)
"
:value="item.value"
class="w-1/3"
>
{{ `${item.value}(${item.label})` }}
2025-10-13 10:17:19 +08:00
</Radio>
</template>
2025-10-13 10:17:19 +08:00
</Radio.Group>
</Form.Item>
<Form.Item label="元素个数" prop="property.dataSpecs.size">
<Input v-model="dataSpecs.size" placeholder="请输入数组中的元素个数" />
</Form.Item>
<!-- Struct 型配置-->
<ThingModelStructDataSpecs
v-if="dataSpecs.childDataType === IoTDataSpecsDataTypeEnum.STRUCT"
v-model="dataSpecs.dataSpecsList"
/>
</template>