Files
yudao-ui-admin-vue3/src/views/iot/thingmodel/ThingModelEvent.vue

62 lines
1.9 KiB
Vue
Raw Normal View History

<!-- 产品的物模型表单event -->
<template>
<el-form-item
:rules="[{ required: true, message: '请选择事件类型', trigger: 'change' }]"
label="事件类型"
prop="event.type"
>
<el-radio-group v-model="thingModelEvent.type">
<!-- TODO @AI使用枚举 -->
<el-radio :value="IoTThingModelEventTypeEnum.INFO.value">
{{ IoTThingModelEventTypeEnum.INFO.label }}
</el-radio>
<el-radio :value="IoTThingModelEventTypeEnum.ALERT.value">
{{ IoTThingModelEventTypeEnum.ALERT.label }}
</el-radio>
<el-radio :value="IoTThingModelEventTypeEnum.ERROR.value">
{{ IoTThingModelEventTypeEnum.ERROR.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="输出参数">
<ThingModelInputOutputParam
v-model="thingModelEvent.outputParams"
:direction="IoTThingModelParamDirectionEnum.OUTPUT"
/>
</el-form-item>
</template>
<script lang="ts" setup>
import ThingModelInputOutputParam from './ThingModelInputOutputParam.vue'
import { useVModel } from '@vueuse/core'
import { ThingModelEvent } from '@/api/iot/thingmodel'
2025-02-20 16:30:36 +08:00
import { isEmpty } from '@/utils/is'
import {
IoTThingModelEventTypeEnum,
IoTThingModelParamDirectionEnum
} from '@/views/iot/utils/constants'
/** IoT 物模型事件 */
defineOptions({ name: 'ThingModelEvent' })
const props = defineProps<{ modelValue: any; isStructDataSpecs?: boolean }>()
const emits = defineEmits(['update:modelValue'])
const thingModelEvent = useVModel(props, 'modelValue', emits) as Ref<ThingModelEvent>
2025-02-20 16:30:36 +08:00
// 默认选中INFO 信息
watch(
() => thingModelEvent.value.type,
(val: string) =>
isEmpty(val) && (thingModelEvent.value.type = IoTThingModelEventTypeEnum.INFO.value),
2025-02-20 16:30:36 +08:00
{ immediate: true }
)
</script>
<style lang="scss" scoped>
:deep(.el-form-item) {
.el-form-item {
margin-bottom: 0;
}
}
</style>