Skip to content

Commit ca03593

Browse files
author
puhui999
committed
【功能完善】IOT: ThingModel 表单编辑回显
1 parent 44d634c commit ca03593

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/utils/dict.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ export enum DICT_TYPE {
236236
IOT_DATA_FORMAT = 'iot_data_format', // IOT 数据格式
237237
IOT_PROTOCOL_TYPE = 'iot_protocol_type', // IOT 接入网关协议
238238
IOT_DEVICE_STATUS = 'iot_device_status', // IOT 设备状态
239-
IOT_PRODUCT_THING_MODEL_TYPE = 'iot_product_thing_model_type', // IOT 产品功能类型
239+
IOT_THING_MODEL_TYPE = 'iot_thing_model_type', // IOT 产品功能类型
240240
IOT_DATA_TYPE = 'iot_data_type', // IOT 数据类型
241-
IOT_PRODUCT_THING_MODEL_UNIT = 'iot_product_thing_model_unit', // IOT 物模型单位
241+
IOT_THING_MODEL_UNIT = 'iot_thing_model_unit', // IOT 物模型单位
242242
IOT_RW_TYPE = 'iot_rw_type', // IOT 读写类型
243243
IOT_PLUGIN_DEPLOY_TYPE = 'iot_plugin_deploy_type', // IOT 插件部署类型
244244
IOT_PLUGIN_STATUS = 'iot_plugin_status', // IOT 插件状态

src/views/iot/thingmodel/ThingModelForm.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<el-form-item label="功能类型" prop="type">
1111
<el-radio-group v-model="formData.type">
1212
<el-radio-button
13-
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE)"
13+
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
1414
:key="dict.value"
1515
:value="dict.value"
1616
>
@@ -103,6 +103,24 @@ const open = async (type: string, id?: number) => {
103103
formLoading.value = true
104104
try {
105105
formData.value = await ThingModelApi.getThingModel(id)
106+
// 情况一:属性初始化
107+
if (isEmpty(formData.value.property)) {
108+
formData.value.dataType = DataSpecsDataType.INT
109+
formData.value.property = {
110+
dataType: DataSpecsDataType.INT,
111+
dataSpecs: {
112+
dataType: DataSpecsDataType.INT
113+
}
114+
}
115+
}
116+
// 情况二:服务初始化
117+
if (isEmpty(formData.value.service)) {
118+
formData.value.service = {}
119+
}
120+
// 情况三:事件初始化
121+
if (isEmpty(formData.value.event)) {
122+
formData.value.event = {}
123+
}
106124
} finally {
107125
formLoading.value = false
108126
}

src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@change="unitChange"
4848
>
4949
<el-option
50-
v-for="(item, index) in getStrDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_UNIT)"
50+
v-for="(item, index) in getStrDictOptions(DICT_TYPE.IOT_THING_MODEL_UNIT)"
5151
:key="index"
5252
:label="item.label + '-' + item.value"
5353
:value="item.label + '-' + item.value"

src/views/iot/thingmodel/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
placeholder="请选择功能类型"
1717
>
1818
<el-option
19-
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE)"
19+
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
2020
:key="dict.value"
2121
:label="dict.label"
2222
:value="dict.value"
@@ -49,7 +49,7 @@
4949
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
5050
<el-table-column align="center" label="功能类型" prop="type">
5151
<template #default="scope">
52-
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE" :value="scope.row.type" />
52+
<dict-tag :type="DICT_TYPE.IOT_THING_MODEL_TYPE" :value="scope.row.type" />
5353
</template>
5454
</el-table-column>
5555
<el-table-column align="center" label="功能名称" prop="name" />

0 commit comments

Comments
 (0)