review:【iot 物联网】场景联动的 review

This commit is contained in:
YunaiV
2025-07-28 23:25:54 +08:00
parent 9b88826a17
commit 5021c711a7
15 changed files with 145 additions and 66 deletions

View File

@ -1,5 +1,5 @@
<!-- IoT场景联动规则表单 - 主表单组件 -->
<template>
<!-- TODO @puhui999这个抽屉的高度太高了 -->
<el-drawer
v-model="drawerVisible"
:title="drawerTitle"
@ -28,7 +28,6 @@
<ActionSection v-model:actions="formData.actions" @validate="handleActionValidate" />
</el-form>
</div>
<template #footer>
<el-button :disabled="submitLoading" type="primary" @click="handleSubmit"> </el-button>
<el-button @click="handleClose"> </el-button>
@ -55,11 +54,13 @@ import { generateUUID } from '@/utils'
/** IoT 场景联动规则表单 - 主表单组件 */
defineOptions({ name: 'RuleSceneForm' })
// TODO @puhui999是不是融合到 props
interface Props {
modelValue: boolean
ruleScene?: IotRuleScene
}
// TODO @puhui999Emits 是不是融合到 emit
interface Emits {
(e: 'update:modelValue', value: boolean): void
(e: 'success'): void
@ -68,11 +69,11 @@ interface Emits {
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
const drawerVisible = useVModel(props, 'modelValue', emit)
const drawerVisible = useVModel(props, 'modelValue', emit) // 是否可见
/**
* 创建默认的表单数据
*/
// TODO @puhui999使用 /** 注释风格哈 */
/** 创建默认的表单数据 */
const createDefaultFormData = (): RuleSceneFormData => {
return {
name: '',
@ -93,8 +94,9 @@ const createDefaultFormData = (): RuleSceneFormData => {
}
}
// TODO @puhui999使用 convertFormToVO下面也是类似哈
/**
* 将表单数据转换为API请求格式
* 将表单数据转换为 API 请求格式
*/
const transformFormToApi = (formData: RuleSceneFormData): IotRuleScene => {
return {
@ -196,7 +198,6 @@ const handleSubmit = async () => {
if (!formRef.value) return
const valid = await formRef.value.validate()
if (!valid) return
// 验证触发器和执行器
if (!triggerValidation.value.valid) {
ElMessage.error(triggerValidation.value.message)
@ -214,6 +215,7 @@ const handleSubmit = async () => {
const apiData = transformFormToApi(formData.value)
// 这里应该调用API保存数据
// TODO @puhui999貌似还没接入
console.log('提交数据:', apiData)
// 模拟API调用
@ -250,7 +252,7 @@ watch(drawerVisible, (visible) => {
}
})
// 监听props变化
// 监听 props 变化
watch(
() => props.ruleScene,
() => {
@ -261,6 +263,7 @@ watch(
)
</script>
<!-- TODO @puhui999看看下面样式哪些是必要添加的 -->
<style scoped>
/* 滚动条样式 */
.h-\[calc\(100vh-120px\)\]::-webkit-scrollbar {