feat(product): 添加设备类型筛选功能并优化物模型管理

- 在查询表单中新增设备类型筛选条件
- 在表格列中显示设备类型信息
- 在编辑表单中添加设备类型选择字段
- 更新数据字典配置以支持设备类型
- 修复标识符重复验证提示信息,明确指出同设备类型下不能重复
- 优化数据类型转换逻辑,确保前后端数据一致性
- 修复重置查询时devType字段的处理逻辑
This commit is contained in:
Gjm
2026-04-09 16:26:49 +08:00
parent 4f468c4569
commit ba4d30f048
2 changed files with 183 additions and 138 deletions

View File

@@ -248,7 +248,7 @@
"product.product-things-model.142341-1": "导入通用物模型",
"product.product-things-model.142341-2": "刷新",
"product.product-things-model.142341-3": "查看物模型",
"product.product-things-model.142341-4": "注意:标识符不能重复",
"product.product-things-model.142341-4": "注意:同设备类型下标识符不能重复",
"product.product-things-model.142341-5": "请选择设备从机:",
"product.product-things-model.142341-6": "请选择设备从机",
"product.product-things-model.142341-7": "网关物模型",
@@ -377,6 +377,10 @@
"product.product-things-model.142341-133": "搜索",
"product.product-things-model.142341-134": "重置",
"product.product-things-model.142341-135": "分组",
"product.product-things-model.142341-136": "设备类型",
"product.product-things-model.142341-137": "请选择设备类型",
"product.product-things-model.142341-138": "模型名称",
"product.product-things-model.142341-139": "请选择模型名称",
"product.product-modbus.562372-0": "网关子设备配置",
"product.product-modbus.562372-1": "网关子设备配置默认的子设备地址,轮询方式",
"product.product-modbus.562372-2": "编辑设备配置",

View File

@@ -1,17 +1,20 @@
<template>
<div style="padding-left: 20px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
<!-- <el-form-item :label="$t('product.product-things-model.142341-127')" prop="isAPP">
<el-select v-model="queryParams.isAPP" :placeholder="$t('product.product-things-model.142341-128')" clearable
size="small">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item> -->
<!-- <el-form-item :label="$t('product.product-things-model.142341-138')" prop="modelName">-->
<!-- <el-input v-model="queryParams.modelName" :placeholder="$t('product.product-things-model.142341-139')" clearable size="small" @keyup.enter.native="handleQuery" />-->
<!-- </el-form-item>-->
<el-form-item :label="$t('product.product-things-model.142341-129')" prop="type">
<el-select v-model="queryParams.type" :placeholder="$t('product.product-things-model.142341-130')" clearable size="small">
<el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('product.product-things-model.142341-136')" prop="devType">
<el-select v-model="queryParams.devType" :placeholder="$t('product.product-things-model.142341-137')" clearable size="small">
<el-option v-for="dict in dict.type.model_dev_type" :key="dict.value" :label="dict.label" :value="Number(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('product.product-things-model.142341-131')" prop="isHistory">
<el-select v-model="queryParams.isHistory" :placeholder="$t('product.product-things-model.142341-132')" clearable size="small">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
@@ -22,7 +25,6 @@
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('product.product-things-model.142341-134') }}</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-if="productInfo.status == 1 && productInfo.isOwner != 0" v-hasPermi="['iot:model:add']">
@@ -98,6 +100,11 @@
<div v-html="formatSpecsDisplay(scope.row.specs)"></div>
</template>
</el-table-column>
<el-table-column :label="$t('product.product-things-model.142341-136')" align="center" prop="devType" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.model_dev_type" :value="scope.row.devType" />
</template>
</el-table-column>
<el-table-column :label="$t('product.product-things-model.142341-19')" align="center" prop="formula" />
<el-table-column :label="$t('product.product-things-model.142341-20')" align="center" prop="modelOrder" width="80" />
<el-table-column :label="$t('product.product-things-model.142341-21')" align="center" class-name="small-padding fixed-width" fixed="right">
@@ -133,6 +140,11 @@
<el-radio-button label="3">{{ $t('product.product-things-model.142341-33') }}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('product.product-things-model.142341-136')" prop="devType">
<el-select v-model="form.devType" :placeholder="$t('product.product-things-model.142341-137')" clearable style="width: 385px">
<el-option v-for="dict in dict.type.model_dev_type" :key="dict.value" :label="dict.label" :value="String(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('product.product-things-model.142341-34')" prop="property">
<el-checkbox name="isChart" :label="$t('product.product-things-model.142341-12')" @change="isChartChange" v-show="form.type == 1" v-model="form.isChart" :true-label="1" :false-label="0"></el-checkbox>
<el-checkbox
@@ -391,7 +403,7 @@ import importBatch from './components/batchImportThingsModel';
export default {
name: 'product-things-model',
dicts: ['iot_things_type', 'iot_data_type', 'iot_yes_no'],
dicts: ['iot_things_type', 'iot_data_type', 'iot_yes_no', 'model_dev_type'],
components: {
productSelectTemplate,
thingsParameter,
@@ -537,6 +549,7 @@ export default {
modelOrder: 0,
type: 1,
datatype: 'integer',
devType: null,
isSys: null,
isChart: 1,
isHistory: 1,
@@ -569,9 +582,12 @@ export default {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
// 重置后确保 devType 为 undefined 而不是空字符串
this.queryParams.devType = undefined;
this.handleQuery();
},
/** 新增按钮操作 */
@@ -581,6 +597,7 @@ export default {
this.title = this.$t('product.product-things-model.142341-99');
},
/** 修改按钮操作 */
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const modelId = row.modelId;
@@ -588,6 +605,12 @@ export default {
let tempForm = response.data;
this.open = true;
this.title = this.$t('product.product-things-model.142341-100');
// devType类型转换确保与下拉选项类型一致String类型
if (tempForm.devType != null && tempForm.devType !== '') {
tempForm.devType = String(tempForm.devType);
} else {
tempForm.devType = undefined;
}
// Json转对象
tempForm.specs = JSON.parse(tempForm.specs);
if (!tempForm.specs.enumList) {
@@ -615,8 +638,13 @@ export default {
}
}
this.form = tempForm;
// 强制更新视图
this.$nextTick(() => {
this.$set(this.form, 'devType', this.form.devType);
});
});
},
/**查看物模型 */
handleOpenThingsModel() {
this.title = this.$t('product.product-things-model.142341-101');
@@ -734,6 +762,12 @@ export default {
// 格式化specs
let tempForm = JSON.parse(JSON.stringify(this.form));
tempForm.specs = this.formatThingsSpecs();
// devType类型转换String转Number如果devType有值
if (tempForm.devType != null && tempForm.devType !== '' && tempForm.devType !== undefined) {
tempForm.devType = Number(tempForm.devType);
} else {
tempForm.devType = null;
}
if (this.form.type == 2) {
tempForm.isMonitor = 0;
tempForm.isChart = 0;
@@ -751,6 +785,12 @@ export default {
// 格式化specs
let tempForm = JSON.parse(JSON.stringify(this.form));
tempForm.specs = this.formatThingsSpecs();
// devType类型转换String转Number如果devType有值
if (tempForm.devType != null && tempForm.devType !== '' && tempForm.devType !== undefined) {
tempForm.devType = Number(tempForm.devType);
} else {
tempForm.devType = null;
}
tempForm.productId = this.productInfo.productId;
tempForm.productName = this.productInfo.productName;
if (this.form.type == 2) {
@@ -769,6 +809,7 @@ export default {
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const modelIds = row.modelId;