ThingModelEvent.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 :value="ThingModelEventType.INFO.value">
  10. {{ ThingModelEventType.INFO.label }}
  11. </el-radio>
  12. <el-radio :value="ThingModelEventType.ALERT.value">
  13. {{ ThingModelEventType.ALERT.label }}
  14. </el-radio>
  15. <el-radio :value="ThingModelEventType.ERROR.value">
  16. {{ ThingModelEventType.ERROR.label }}
  17. </el-radio>
  18. </el-radio-group>
  19. </el-form-item>
  20. <el-form-item label="输出参数">
  21. <ThingModelInputOutputParam
  22. v-model="thingModelEvent.outputParams"
  23. :direction="ThingModelParamDirection.OUTPUT"
  24. />
  25. </el-form-item>
  26. </template>
  27. <script lang="ts" setup>
  28. import ThingModelInputOutputParam from './ThingModelInputOutputParam.vue'
  29. import { useVModel } from '@vueuse/core'
  30. import { ThingModelEvent } from '@/api/iot/thingmodel'
  31. import { ThingModelEventType, ThingModelParamDirection } from './config'
  32. import { isEmpty } from '@/utils/is'
  33. /** IoT 物模型事件 */
  34. defineOptions({ name: 'ThingModelEvent' })
  35. const props = defineProps<{ modelValue: any; isStructDataSpecs?: boolean }>()
  36. const emits = defineEmits(['update:modelValue'])
  37. const thingModelEvent = useVModel(props, 'modelValue', emits) as Ref<ThingModelEvent>
  38. // 默认选中,INFO 信息
  39. watch(
  40. () => thingModelEvent.value.type,
  41. (val: string) => isEmpty(val) && (thingModelEvent.value.type = ThingModelEventType.INFO.value),
  42. { immediate: true }
  43. )
  44. </script>
  45. <style lang="scss" scoped>
  46. :deep(.el-form-item) {
  47. .el-form-item {
  48. margin-bottom: 0;
  49. }
  50. }
  51. </style>