ThingModelEvent.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!-- 产品的物模型表单(event 项) -->
  2. <template>
  3. <el-form-item
  4. :rules="[{ required: true, message: '请选择事件类型', trigger: 'change' }]"
  5. label="事件类型"
  6. prop="event.type"
  7. >
  8. <el-radio-group v-model="thingModelEvent.type">
  9. <el-radio
  10. v-for="eventType in Object.values(IoTThingModelEventTypeEnum)"
  11. :key="eventType.value"
  12. :value="eventType.value"
  13. >
  14. {{ eventType.label }}
  15. </el-radio>
  16. </el-radio-group>
  17. </el-form-item>
  18. <el-form-item label="输出参数">
  19. <ThingModelInputOutputParam
  20. v-model="thingModelEvent.outputParams"
  21. :direction="IoTThingModelParamDirectionEnum.OUTPUT"
  22. />
  23. </el-form-item>
  24. </template>
  25. <script lang="ts" setup>
  26. import ThingModelInputOutputParam from './ThingModelInputOutputParam.vue'
  27. import { useVModel } from '@vueuse/core'
  28. import { ThingModelEvent } from '@/api/iot/thingmodel'
  29. import { isEmpty } from '@/utils/is'
  30. import {
  31. IoTThingModelEventTypeEnum,
  32. IoTThingModelParamDirectionEnum
  33. } from '@/views/iot/utils/constants'
  34. /** IoT 物模型事件 */
  35. defineOptions({ name: 'ThingModelEvent' })
  36. const props = defineProps<{ modelValue: any; isStructDataSpecs?: boolean }>()
  37. const emits = defineEmits(['update:modelValue'])
  38. const thingModelEvent = useVModel(props, 'modelValue', emits) as Ref<ThingModelEvent>
  39. // 默认选中,INFO 信息
  40. watch(
  41. () => thingModelEvent.value.type,
  42. (val: string) =>
  43. isEmpty(val) && (thingModelEvent.value.type = IoTThingModelEventTypeEnum.INFO.value),
  44. { immediate: true }
  45. )
  46. </script>
  47. <style lang="scss" scoped>
  48. :deep(.el-form-item) {
  49. .el-form-item {
  50. margin-bottom: 0;
  51. }
  52. }
  53. </style>