Skip to content

Commit b08aae6

Browse files
committed
Merge remote-tracking branch 'origin/feature/iot' into feature/iot
2 parents e6a5bb0 + afaea19 commit b08aae6

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

src/api/iot/thingmodel/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,34 @@ export interface ThingModelService {
4242
export const ThingModelApi = {
4343
// 查询产品物模型分页
4444
getThingModelPage: async (params: any) => {
45-
return await request.get({ url: `/iot/product-thing-model/page`, params })
45+
return await request.get({ url: `/iot/thing-model/page`, params })
4646
},
4747

4848
// 获得产品物模型
4949
getThingModelListByProductId: async (params: any) => {
5050
return await request.get({
51-
url: `/iot/product-thing-model/list-by-product-id`,
51+
url: `/iot/thing-model/list-by-product-id`,
5252
params
5353
})
5454
},
5555

5656
// 查询产品物模型详情
5757
getThingModel: async (id: number) => {
58-
return await request.get({ url: `/iot/product-thing-model/get?id=` + id })
58+
return await request.get({ url: `/iot/thing-model/get?id=` + id })
5959
},
6060

6161
// 新增产品物模型
6262
createThingModel: async (data: ThingModelData) => {
63-
return await request.post({ url: `/iot/product-thing-model/create`, data })
63+
return await request.post({ url: `/iot/thing-model/create`, data })
6464
},
6565

6666
// 修改产品物模型
6767
updateThingModel: async (data: ThingModelData) => {
68-
return await request.put({ url: `/iot/product-thing-model/update`, data })
68+
return await request.put({ url: `/iot/thing-model/update`, data })
6969
},
7070

7171
// 删除产品物模型
7272
deleteThingModel: async (id: number) => {
73-
return await request.delete({ url: `/iot/product-thing-model/delete?id=` + id })
73+
return await request.delete({ url: `/iot/thing-model/delete?id=` + id })
7474
}
7575
}

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: 20 additions & 2 deletions
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
>
@@ -67,7 +67,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
6767
import { isEmpty } from '@/utils/is'
6868
6969
/** IoT 物模型数据表单 */
70-
defineOptions({ name: 'IoTProductThingModelForm' })
70+
defineOptions({ name: 'IoTThingModelForm' })
7171
7272
const product = inject<Ref<ProductVO>>(IOT_PROVIDE_KEY.PRODUCT) // 注入产品信息
7373
@@ -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: 6 additions & 7 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"
@@ -33,7 +33,7 @@
3333
重置
3434
</el-button>
3535
<el-button
36-
v-hasPermi="[`iot:product-thing-model:create`]"
36+
v-hasPermi="[`iot:thing-model:create`]"
3737
plain
3838
type="primary"
3939
@click="openForm('create')"
@@ -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" />
@@ -118,15 +118,15 @@
118118
<el-table-column align="center" label="操作">
119119
<template #default="scope">
120120
<el-button
121-
v-hasPermi="[`iot:product-thing-model:update`]"
121+
v-hasPermi="[`iot:thing-model:update`]"
122122
link
123123
type="primary"
124124
@click="openForm('update', scope.row.id)"
125125
>
126126
编辑
127127
</el-button>
128128
<el-button
129-
v-hasPermi="['iot:product-thing-model:delete']"
129+
v-hasPermi="['iot:thing-model:delete']"
130130
link
131131
type="danger"
132132
@click="handleDelete(scope.row.id)"
@@ -161,9 +161,8 @@ import {
161161
getEventTypeByValue,
162162
ThingModelType
163163
} from './config'
164-
import { ThingModelNumberDataSpecs } from '@/views/iot/thingmodel/dataSpecs'
165164
166-
defineOptions({ name: 'IoTProductThingModel' })
165+
defineOptions({ name: 'IoTThingModel' })
167166
168167
const { t } = useI18n() // 国际化
169168
const message = useMessage() // 消息弹窗

0 commit comments

Comments
 (0)