1
1
<template >
2
2
<el-form-item label =" 数据类型" prop =" dataType" >
3
- <el-select v-model =" formData .dataType" placeholder =" 请选择数据类型" @change =" handleChange" >
3
+ <el-select v-model =" property .dataType" placeholder =" 请选择数据类型" @change =" handleChange" >
4
4
<el-option
5
5
v-for =" option in dataTypeOptions"
6
6
:key =" option.value"
13
13
<ThingModelNumberTypeDataSpecs
14
14
v-if ="
15
15
[DataSpecsDataType.INT, DataSpecsDataType.DOUBLE, DataSpecsDataType.FLOAT].includes(
16
- formData .dataType || ''
16
+ property .dataType || ''
17
17
)
18
18
"
19
- v-model =" formData .dataSpecs"
19
+ v-model =" property .dataSpecs"
20
20
/>
21
21
<!-- 枚举型配置 -->
22
22
<ThingModelEnumTypeDataSpecs
23
- v-if =" formData .dataType === DataSpecsDataType.ENUM"
24
- v-model =" formData .dataSpecsList"
23
+ v-if =" property .dataType === DataSpecsDataType.ENUM"
24
+ v-model =" property .dataSpecsList"
25
25
/>
26
26
<!-- 布尔型配置 -->
27
- <el-form-item label =" 布尔值" prop =" bool" v-if =" formData .dataType === DataSpecsDataType.BOOL" >
28
- <template v-for =" item in formData .dataSpecsList " :key =" item .value " >
27
+ <el-form-item label =" 布尔值" prop =" bool" v-if =" property .dataType === DataSpecsDataType.BOOL" >
28
+ <template v-for =" item in property .dataSpecsList " :key =" item .value " >
29
29
<div class =" flex items-center justify-start w-1/1 mb-5px" >
30
30
<span >{{ item.value }}</span >
31
31
<span class =" mx-2" >-</span >
38
38
</template >
39
39
</el-form-item >
40
40
<!-- 文本型配置 -->
41
- <el-form-item label =" 数据长度" prop =" text" v-if =" formData .dataType === DataSpecsDataType.TEXT" >
42
- <el-input v-model =" formData .length" class =" w-255px!" placeholder =" 请输入文本字节长度" >
41
+ <el-form-item label =" 数据长度" prop =" text" v-if =" property .dataType === DataSpecsDataType.TEXT" >
42
+ <el-input v-model =" property .length" class =" w-255px!" placeholder =" 请输入文本字节长度" >
43
43
<template #append >字节</template >
44
44
</el-input >
45
45
</el-form-item >
46
46
<!-- 时间型配置 -->
47
- <el-form-item label =" 时间格式" prop =" date" v-if =" formData .dataType === DataSpecsDataType.DATE" >
47
+ <el-form-item label =" 时间格式" prop =" date" v-if =" property .dataType === DataSpecsDataType.DATE" >
48
48
<el-input disabled class =" w-255px!" placeholder =" String类型的UTC时间戳(毫秒)" />
49
49
</el-form-item >
50
50
<!-- 数组型配置-->
51
51
<ThingModelArrayTypeDataSpecs
52
- v-model =" formData .dataSpecs"
53
- v-if =" formData .dataType === DataSpecsDataType.ARRAY"
52
+ v-model =" property .dataSpecs"
53
+ v-if =" property .dataType === DataSpecsDataType.ARRAY"
54
54
/>
55
+ <el-form-item label =" 读写类型" prop =" accessMode" >
56
+ <el-radio-group v-model =" property.accessMode" >
57
+ <el-radio label =" rw" >读写</el-radio >
58
+ <el-radio label =" r" >只读</el-radio >
59
+ </el-radio-group >
60
+ </el-form-item >
61
+ <el-form-item label =" 属性描述" prop =" description" >
62
+ <el-input v-model =" property.description" placeholder =" 请输入属性描述" type =" textarea" />
63
+ </el-form-item >
55
64
</template >
56
65
57
66
<script lang="ts" setup>
@@ -62,46 +71,47 @@ import {
62
71
ThingModelEnumTypeDataSpecs ,
63
72
ThingModelNumberTypeDataSpecs
64
73
} from ' ./dataSpecs'
74
+ import { ThingModelProperty } from ' @/api/iot/thinkmodelfunction'
65
75
66
76
/** 物模型数据 */
67
77
defineOptions ({ name: ' ThingModelDataSpecs' })
68
78
const props = defineProps <{ modelValue: any }>()
69
79
const emits = defineEmits ([' update:modelValue' ])
70
- const formData = useVModel (props , ' modelValue' , emits ) as Ref <any >
80
+ const property = useVModel (props , ' modelValue' , emits ) as Ref <ThingModelProperty >
71
81
72
82
/** 属性值的数据类型切换时初始化相关数据 */
73
83
const handleChange = (dataType : any ) => {
74
- formData .value .dataSpecsList = []
75
- formData .value .dataSpecs = {}
84
+ property .value .dataSpecsList = []
85
+ property .value .dataSpecs = {}
76
86
77
87
switch (dataType ) {
78
88
case DataSpecsDataType .INT :
79
- formData .value .dataSpecs .dataType = DataSpecsDataType .INT
89
+ property .value .dataSpecs .dataType = DataSpecsDataType .INT
80
90
break
81
91
case DataSpecsDataType .DOUBLE :
82
- formData .value .dataSpecs .dataType = DataSpecsDataType .DOUBLE
92
+ property .value .dataSpecs .dataType = DataSpecsDataType .DOUBLE
83
93
break
84
94
case DataSpecsDataType .FLOAT :
85
- formData .value .dataSpecs .dataType = DataSpecsDataType .FLOAT
95
+ property .value .dataSpecs .dataType = DataSpecsDataType .FLOAT
86
96
break
87
97
case DataSpecsDataType .ENUM :
88
- formData .value .dataSpecsList .push ({
98
+ property .value .dataSpecsList .push ({
89
99
dataType: DataSpecsDataType .ENUM ,
90
100
name: ' ' , // 枚举项的名称
91
101
value: undefined // 枚举值
92
102
})
93
103
break
94
104
case DataSpecsDataType .BOOL :
95
105
for (let i = 0 ; i < 2 ; i ++ ) {
96
- formData .value .dataSpecsList .push ({
106
+ property .value .dataSpecsList .push ({
97
107
dataType: DataSpecsDataType .BOOL ,
98
108
name: ' ' , // 布尔值的名称
99
109
value: i // 布尔值
100
110
})
101
111
}
102
112
break
103
113
case DataSpecsDataType .ARRAY :
104
- formData .value .dataSpecs .dataType = DataSpecsDataType .ARRAY
114
+ property .value .dataSpecs .dataType = DataSpecsDataType .ARRAY
105
115
break
106
116
}
107
117
}
0 commit comments