Merge remote-tracking branch 'origin/feature/iot' into feature/iot

This commit is contained in:
安浩浩
2024-12-30 12:05:03 +08:00
5 changed files with 35 additions and 18 deletions

View File

@ -10,7 +10,7 @@
<el-form-item label="功能类型" prop="type">
<el-radio-group v-model="formData.type">
<el-radio-button
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE)"
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
:key="dict.value"
:value="dict.value"
>
@ -67,7 +67,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { isEmpty } from '@/utils/is'
/** IoT 物模型数据表单 */
defineOptions({ name: 'IoTProductThingModelForm' })
defineOptions({ name: 'IoTThingModelForm' })
const product = inject<Ref<ProductVO>>(IOT_PROVIDE_KEY.PRODUCT) // 注入产品信息
@ -103,6 +103,24 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
formData.value = await ThingModelApi.getThingModel(id)
// 情况一:属性初始化
if (isEmpty(formData.value.property)) {
formData.value.dataType = DataSpecsDataType.INT
formData.value.property = {
dataType: DataSpecsDataType.INT,
dataSpecs: {
dataType: DataSpecsDataType.INT
}
}
}
// 情况二:服务初始化
if (isEmpty(formData.value.service)) {
formData.value.service = {}
}
// 情况三:事件初始化
if (isEmpty(formData.value.event)) {
formData.value.event = {}
}
} finally {
formLoading.value = false
}

View File

@ -47,7 +47,7 @@
@change="unitChange"
>
<el-option
v-for="(item, index) in getStrDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_UNIT)"
v-for="(item, index) in getStrDictOptions(DICT_TYPE.IOT_THING_MODEL_UNIT)"
:key="index"
:label="item.label + '-' + item.value"
:value="item.label + '-' + item.value"

View File

@ -16,7 +16,7 @@
placeholder="请选择功能类型"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE)"
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -33,7 +33,7 @@
重置
</el-button>
<el-button
v-hasPermi="[`iot:product-thing-model:create`]"
v-hasPermi="[`iot:thing-model:create`]"
plain
type="primary"
@click="openForm('create')"
@ -49,7 +49,7 @@
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="功能类型" prop="type">
<template #default="scope">
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_THING_MODEL_TYPE" :value="scope.row.type" />
<dict-tag :type="DICT_TYPE.IOT_THING_MODEL_TYPE" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column align="center" label="功能名称" prop="name" />
@ -118,7 +118,7 @@
<el-table-column align="center" label="操作">
<template #default="scope">
<el-button
v-hasPermi="[`iot:product-thing-model:update`]"
v-hasPermi="[`iot:thing-model:update`]"
link
type="primary"
@click="openForm('update', scope.row.id)"
@ -126,7 +126,7 @@
编辑
</el-button>
<el-button
v-hasPermi="['iot:product-thing-model:delete']"
v-hasPermi="['iot:thing-model:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
@ -161,9 +161,8 @@ import {
getEventTypeByValue,
ThingModelType
} from './config'
import { ThingModelNumberDataSpecs } from '@/views/iot/thingmodel/dataSpecs'
defineOptions({ name: 'IoTProductThingModel' })
defineOptions({ name: 'IoTThingModel' })
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗