feat(iot): 实现设备分类和分组的树形结构管理功能
- 添加设备分类树形展示和展开/折叠功能 - 实现设备分组的层级树形结构显示 - 集成treeselect组件支持分类和分组的选择 - 添加上级分类和类型编码字段及验证规则 - 更新国际化语言包中的分类相关文案 - 优化产品编辑页面的分类选择功能 - 调整登录页面的统一身份认证配置 - 完善删除操作的提示信息和错误处理
This commit is contained in:
@@ -628,6 +628,10 @@
|
|||||||
"iot.group.index.637432-25": "新增成功",
|
"iot.group.index.637432-25": "新增成功",
|
||||||
"iot.group.index.637432-26": "是否确认删除设备分组编号为{0}的数据项?",
|
"iot.group.index.637432-26": "是否确认删除设备分组编号为{0}的数据项?",
|
||||||
"iot.group.index.637432-27": "删除成功",
|
"iot.group.index.637432-27": "删除成功",
|
||||||
|
"iot.group.index.637432-28": "上级分类",
|
||||||
|
"iot.group.index.637432-29": "请选择上级分类",
|
||||||
|
"iot.group.index.637432-30": "类型编码",
|
||||||
|
"iot.group.index.637432-31": "请选择设备类型编码",
|
||||||
"iot.group.device-list.849593-0": "选择设备",
|
"iot.group.device-list.849593-0": "选择设备",
|
||||||
"iot.group.device-list.849593-1": "设备名称",
|
"iot.group.device-list.849593-1": "设备名称",
|
||||||
"iot.group.device-list.849593-2": "请输入设备名称",
|
"iot.group.device-list.849593-2": "请输入设备名称",
|
||||||
|
|||||||
@@ -449,15 +449,20 @@
|
|||||||
"product.thimgs-mopdel-list.738493-8": "关 闭",
|
"product.thimgs-mopdel-list.738493-8": "关 闭",
|
||||||
"product.components.batchImportModbus.745343-0": "IO寄存器模板",
|
"product.components.batchImportModbus.745343-0": "IO寄存器模板",
|
||||||
"product.components.batchImportModbus.745343-1": "数据寄存器模板",
|
"product.components.batchImportModbus.745343-1": "数据寄存器模板",
|
||||||
"product.category.142342-0": "产品分类名称",
|
"product.category.142342-0": "设备分类名称",
|
||||||
"product.category.142342-1": "显示顺序",
|
"product.category.142342-1": "显示顺序",
|
||||||
"product.category.142342-2": "请输入显示顺序",
|
"product.category.142342-2": "请输入显示顺序",
|
||||||
"product.category.142342-3": "请输入内容",
|
"product.category.142342-3": "请输入内容",
|
||||||
"product.category.142342-4": "产品分类名称不能为空",
|
"product.category.142342-4": "设备分类名称不能为空",
|
||||||
"product.category.142342-5": "是否系统通用不能为空",
|
"product.category.142342-5": "是否系统通用不能为空",
|
||||||
"product.category.142342-6": "添加产品分类",
|
"product.category.142342-6": "添加设备分类",
|
||||||
"product.category.142342-7": "修改产品分类",
|
"product.category.142342-7": "修改设备分类",
|
||||||
"product.category.142342-8": "是否确认删除产品分类编号为{0}的数据项?",
|
"product.category.142342-8": "是否确认删除设备分类名称为:“{0}”的数据项?",
|
||||||
|
"product.category.142342-9": "上级分类",
|
||||||
|
"product.category.142342-10": "请选择上级分类",
|
||||||
|
"product.category.142342-14": "类型编码不能为空",
|
||||||
|
"product.category.142342-12": "类型编码",
|
||||||
|
"product.category.142342-13": "请选择设备类型编码",
|
||||||
"product.product-scada.034908-0": "创建组态",
|
"product.product-scada.034908-0": "创建组态",
|
||||||
"product.product-sub.3843945-0": "添加子产品",
|
"product.product-sub.3843945-0": "添加子产品",
|
||||||
"product.product-sub.3843945-1": "删除子产品",
|
"product.product-sub.3843945-1": "删除子产品",
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">{{ $t('add') }}</el-button>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">{{ $t('add') }}</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">{{ $t('role.index.094567-18') }}</el-button>
|
||||||
|
</el-col>
|
||||||
<el-col :span="1.5" style="line-height: 28px">
|
<el-col :span="1.5" style="line-height: 28px">
|
||||||
<el-checkbox v-model="queryParams.showSenior" style="margin: 0 10px" @change="handleQuery">{{ $t('product.index.091251-8') }}</el-checkbox>
|
<el-checkbox v-model="queryParams.showSenior" style="margin: 0 10px" @change="handleQuery">{{ $t('product.index.091251-8') }}</el-checkbox>
|
||||||
<el-tooltip :content="$t('product.index.091251-9')" placement="top"><i class="el-icon-question"></i></el-tooltip>
|
<el-tooltip :content="$t('product.index.091251-9')" placement="top"><i class="el-icon-question"></i></el-tooltip>
|
||||||
@@ -24,8 +27,9 @@
|
|||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange" :border="false">
|
<el-table v-if="refreshTable" v-loading="loading" :data="categoryList" :border="false" row-key="categoryId" :default-expand-all="isExpandAll" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
|
||||||
<el-table-column :label="$t('product.category.142342-0')" align="center" prop="categoryName" />
|
<el-table-column :label="$t('product.category.142342-0')" align="left" prop="categoryName" min-width="250" />
|
||||||
|
<el-table-column :label="$t('product.category.142342-12')" align="center" prop="industryCode" width="150" />
|
||||||
<el-table-column :label="$t('template.index.891112-12')" align="center" prop="isSys" width="100">
|
<el-table-column :label="$t('template.index.891112-12')" align="center" prop="isSys" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
|
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
|
||||||
@@ -57,9 +61,19 @@
|
|||||||
<!-- 添加或修改产品分类对话框 -->
|
<!-- 添加或修改产品分类对话框 -->
|
||||||
<el-dialog :title="$t('product.index.091251-2')" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="$t('product.index.091251-2')" :visible.sync="open" width="500px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item :label="$t('product.category.142342-9')" prop="parentId">
|
||||||
|
<treeselect v-model="form.parentId" :options="categoryOptions" :normalizer="normalizer" :placeholder="$t('product.category.142342-10')" :max-height="300" :searchable="true" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<el-form-item :label="$t('product.index.091251-2')" prop="categoryName">
|
<el-form-item :label="$t('product.index.091251-2')" prop="categoryName">
|
||||||
<el-input v-model="form.categoryName" :placeholder="$t('product.index.091251-3')" />
|
<el-input v-model="form.categoryName" :placeholder="$t('product.index.091251-3')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('product.category.142342-12')" prop="industryCode">
|
||||||
|
<el-input v-model="form.industryCode" :placeholder="$t('product.category.142342-13')" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$t('product.category.142342-1')" prop="orderNum">
|
<el-form-item :label="$t('product.category.142342-1')" prop="orderNum">
|
||||||
<el-input-number controls-position="right" v-model="form.orderNum" type="number" :placeholder="$t('product.category.142342-2')" style="width: 100%" />
|
<el-input-number controls-position="right" v-model="form.orderNum" type="number" :placeholder="$t('product.category.142342-2')" style="width: 100%" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -78,32 +92,35 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from '@/api/iot/category';
|
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from '@/api/iot/category';
|
||||||
|
import Treeselect from '@riophae/vue-treeselect';
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Category',
|
name: 'Category',
|
||||||
dicts: ['iot_yes_no'],
|
dicts: ['iot_yes_no'],
|
||||||
|
components: { Treeselect },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 是否为租户
|
// 是否为租户
|
||||||
isTenant: false,
|
isTenant: false,
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
|
||||||
ids: [],
|
|
||||||
// 非单个禁用
|
|
||||||
single: true,
|
|
||||||
// 非多个禁用
|
|
||||||
multiple: true,
|
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 产品分类表格数据
|
// 产品分类表格数据
|
||||||
categoryList: [],
|
categoryList: [],
|
||||||
|
// 分类树选项
|
||||||
|
categoryOptions: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: '',
|
title: '',
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
// 是否展开,默认全部展开
|
||||||
|
isExpandAll: true,
|
||||||
|
// 重新渲染表格状态
|
||||||
|
refreshTable: true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
showSenior: false,
|
showSenior: false,
|
||||||
@@ -123,6 +140,13 @@ export default {
|
|||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
industryCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: this.$t('product.category.142342-14'),
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
isSys: [
|
isSys: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
@@ -147,11 +171,53 @@ export default {
|
|||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listCategory(this.queryParams).then((response) => {
|
listCategory(this.queryParams).then((response) => {
|
||||||
this.categoryList = response.rows;
|
this.categoryList = this.handleTree(response.rows, 'categoryId');
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 转换树形结构 */
|
||||||
|
handleTree(data, id) {
|
||||||
|
const tree = [];
|
||||||
|
const map = {};
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
map[item[id]] = item;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const parent = map[item.parentId];
|
||||||
|
if (parent) {
|
||||||
|
if (!parent.children) {
|
||||||
|
parent.children = [];
|
||||||
|
}
|
||||||
|
parent.children.push(item);
|
||||||
|
} else {
|
||||||
|
tree.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return tree;
|
||||||
|
},
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
toggleExpandAll() {
|
||||||
|
this.refreshTable = false;
|
||||||
|
this.isExpandAll = !this.isExpandAll;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.refreshTable = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 转换分类数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.categoryId,
|
||||||
|
label: node.categoryName,
|
||||||
|
children: node.children,
|
||||||
|
};
|
||||||
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
@@ -166,6 +232,7 @@ export default {
|
|||||||
tenantName: null,
|
tenantName: null,
|
||||||
isSys: null,
|
isSys: null,
|
||||||
parentId: null,
|
parentId: null,
|
||||||
|
industryCode: null,
|
||||||
orderNum: null,
|
orderNum: null,
|
||||||
delFlag: null,
|
delFlag: null,
|
||||||
createBy: null,
|
createBy: null,
|
||||||
@@ -186,26 +253,37 @@ export default {
|
|||||||
this.resetForm('queryForm');
|
this.resetForm('queryForm');
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map((item) => item.categoryId);
|
|
||||||
this.single = selection.length !== 1;
|
|
||||||
this.multiple = !selection.length;
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
if (row != undefined) {
|
||||||
|
this.form.parentId = row.categoryId;
|
||||||
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = this.$t('product.category.142342-6');
|
this.title = this.$t('product.category.142342-6');
|
||||||
|
const params = {
|
||||||
|
pageSize: 9999 // 确保加载所有分类
|
||||||
|
};
|
||||||
|
listCategory(params).then((response) => {
|
||||||
|
this.categoryOptions = this.handleTree(response.rows, 'categoryId');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
const categoryId = row.categoryId || this.ids;
|
// 先加载分类树选项
|
||||||
getCategory(categoryId).then((response) => {
|
const params = {
|
||||||
this.form = response.data;
|
pageSize: 9999 // 确保加载所有分类
|
||||||
this.open = true;
|
};
|
||||||
this.title = this.$t('product.category.142342-7');
|
listCategory(params).then((categoryResponse) => {
|
||||||
|
this.categoryOptions = this.handleTree(categoryResponse.rows, 'categoryId');
|
||||||
|
// 再加载分类详情
|
||||||
|
getCategory(row.categoryId).then((response) => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = this.$t('product.category.142342-7');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
@@ -230,18 +308,14 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const categoryIds = row.categoryId || this.ids;
|
|
||||||
let msg = '';
|
|
||||||
this.$modal
|
this.$modal
|
||||||
.confirm(this.$t('product.category.142342-8', [categoryIds]))
|
.confirm(this.$t('product.category.142342-8', [row.categoryName]))
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return delCategory(categoryIds).then((response) => {
|
return delCategory(row.categoryId);
|
||||||
msg = response.msg;
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.$modal.msgSuccess(msg);
|
this.$modal.msgSuccess(this.$t('delSuccess'));
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,11 +18,15 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:group:add']">{{ $t('iot.group.index.637432-5') }}</el-button>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:group:add']">{{ $t('iot.group.index.637432-5') }}</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">{{ $t('role.index.094567-18') }}</el-button>
|
||||||
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="groupList" :border="false" @selection-change="handleSelectionChange">
|
<el-table v-if="refreshTable" v-loading="loading" :data="groupList" :border="false" row-key="groupId" :default-expand-all="isExpandAll" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
|
||||||
<el-table-column :label="$t('iot.group.index.637432-0')" align="center" prop="groupName" min-width="200" />
|
<el-table-column :label="$t('iot.group.index.637432-0')" align="left" prop="groupName" min-width="200" />
|
||||||
|
<el-table-column :label="$t('product.category.142342-12')" align="center" prop="industryCode" width="150" />
|
||||||
<el-table-column :label="$t('iot.group.index.637432-6')" align="center" prop="groupOrder" width="100" />
|
<el-table-column :label="$t('iot.group.index.637432-6')" align="center" prop="groupOrder" width="100" />
|
||||||
<el-table-column :label="$t('iot.group.index.637432-7')" align="center" prop="createTime" width="160">
|
<el-table-column :label="$t('iot.group.index.637432-7')" align="center" prop="createTime" width="160">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -54,12 +58,23 @@
|
|||||||
<!-- 添加或修改设备分组对话框 -->
|
<!-- 添加或修改设备分组对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item :label="$t('iot.group.index.637432-28')" prop="parentId">
|
||||||
|
<treeselect v-model="form.parentId" :options="groupOptions" :normalizer="normalizer" :placeholder="$t('iot.group.index.637432-29')" :max-height="300" :searchable="true" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<el-form-item :label="$t('iot.group.index.637432-0')" prop="groupName">
|
<el-form-item :label="$t('iot.group.index.637432-0')" prop="groupName">
|
||||||
<el-input v-model="form.groupName" :placeholder="$t('iot.group.index.637432-1')" />
|
<el-input v-model="form.groupName" :placeholder="$t('iot.group.index.637432-1')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('product.category.142342-12')" prop="industryCode">
|
||||||
|
<el-input v-model="form.industryCode" :placeholder="$t('product.category.142342-13')" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$t('iot.group.index.637432-6')" prop="groupOrder">
|
<el-form-item :label="$t('iot.group.index.637432-6')" prop="groupOrder">
|
||||||
<el-input v-model="form.groupOrder" type="number" :placeholder="$t('iot.group.index.637432-15')" />
|
<el-input v-model="form.groupOrder" type="number" :placeholder="$t('iot.group.index.637432-15')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('iot.group.index.637432-9')" prop="remark">
|
<el-form-item :label="$t('iot.group.index.637432-9')" prop="remark">
|
||||||
<el-input v-model="form.remark" type="textarea" :placeholder="$t('iot.group.index.637432-16')" />
|
<el-input v-model="form.remark" type="textarea" :placeholder="$t('iot.group.index.637432-16')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -77,11 +92,14 @@
|
|||||||
import deviceList from './device-list';
|
import deviceList from './device-list';
|
||||||
import { listGroup, getGroup, delGroup, addGroup, updateGroup } from '@/api/iot/group';
|
import { listGroup, getGroup, delGroup, addGroup, updateGroup } from '@/api/iot/group';
|
||||||
import { getUserId } from '@/utils/auth';
|
import { getUserId } from '@/utils/auth';
|
||||||
|
import Treeselect from '@riophae/vue-treeselect';
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Group',
|
name: 'Group',
|
||||||
components: {
|
components: {
|
||||||
deviceList,
|
deviceList,
|
||||||
|
Treeselect,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -103,14 +121,20 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
// 设备分组表格数据
|
// 设备分组表格数据
|
||||||
groupList: [],
|
groupList: [],
|
||||||
|
// 分组树选项
|
||||||
|
groupOptions: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: '',
|
title: '',
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
// 是否展开,默认全部展开
|
||||||
|
isExpandAll: true,
|
||||||
|
// 重新渲染表格状态
|
||||||
|
refreshTable: true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
groupName: null,
|
groupName: null,
|
||||||
userId: null,
|
userId: null,
|
||||||
},
|
},
|
||||||
@@ -165,11 +189,53 @@ export default {
|
|||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listGroup(this.queryParams).then((response) => {
|
listGroup(this.queryParams).then((response) => {
|
||||||
this.groupList = response.rows;
|
this.groupList = this.handleTree(response.rows, 'groupId');
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 转换树形结构 */
|
||||||
|
handleTree(data, id) {
|
||||||
|
const tree = [];
|
||||||
|
const map = {};
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
map[item[id]] = item;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const parent = map[item.parentId];
|
||||||
|
if (parent) {
|
||||||
|
if (!parent.children) {
|
||||||
|
parent.children = [];
|
||||||
|
}
|
||||||
|
parent.children.push(item);
|
||||||
|
} else {
|
||||||
|
tree.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return tree;
|
||||||
|
},
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
toggleExpandAll() {
|
||||||
|
this.refreshTable = false;
|
||||||
|
this.isExpandAll = !this.isExpandAll;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.refreshTable = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 转换分组数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.groupId,
|
||||||
|
label: node.groupName,
|
||||||
|
children: node.children,
|
||||||
|
};
|
||||||
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
@@ -183,6 +249,8 @@ export default {
|
|||||||
groupOrder: null,
|
groupOrder: null,
|
||||||
userId: null,
|
userId: null,
|
||||||
userName: null,
|
userName: null,
|
||||||
|
parentId: null,
|
||||||
|
industryCode: null,
|
||||||
delFlag: null,
|
delFlag: null,
|
||||||
createBy: null,
|
createBy: null,
|
||||||
createTime: null,
|
createTime: null,
|
||||||
@@ -209,19 +277,35 @@ export default {
|
|||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length;
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
if (row != undefined) {
|
||||||
|
this.form.parentId = row.groupId;
|
||||||
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = this.$t('iot.group.index.637432-22');
|
this.title = this.$t('iot.group.index.637432-22');
|
||||||
|
const params = {
|
||||||
|
pageSize: 9999 // 确保加载所有分组
|
||||||
|
};
|
||||||
|
listGroup(params).then((response) => {
|
||||||
|
this.groupOptions = this.handleTree(response.rows, 'groupId');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
const groupId = row.groupId || this.ids;
|
// 先加载分组树选项
|
||||||
getGroup(groupId).then((response) => {
|
const params = {
|
||||||
this.form = response.data;
|
pageSize: 9999 // 确保加载所有分组
|
||||||
this.open = true;
|
};
|
||||||
this.title = this.$t('iot.group.index.637432-23');
|
listGroup(params).then((groupResponse) => {
|
||||||
|
this.groupOptions = this.handleTree(groupResponse.rows, 'groupId');
|
||||||
|
// 再加载分组详情
|
||||||
|
getGroup(row.groupId).then((response) => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = this.$t('iot.group.index.637432-23');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 选择设备 */
|
/** 选择设备 */
|
||||||
@@ -252,11 +336,10 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const groupIds = row.groupId || this.ids;
|
|
||||||
this.$modal
|
this.$modal
|
||||||
.confirm(this.$t('iot.group.index.637432-26', [groupIds]))
|
.confirm(this.$t('iot.group.index.637432-26', [row.groupName]))
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return delGroup(groupIds);
|
return delGroup(row.groupId);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
|
|||||||
@@ -14,16 +14,17 @@
|
|||||||
<el-input v-model="form.productName" :placeholder="$t('product.product-edit.473153-2')" :readonly="form.status == 2 || form.isOwner == 0" />
|
<el-input v-model="form.productName" :placeholder="$t('product.product-edit.473153-2')" :readonly="form.status == 2 || form.isOwner == 0" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('product.product-edit.473153-3')" prop="categoryId">
|
<el-form-item :label="$t('product.product-edit.473153-3')" prop="categoryId">
|
||||||
<el-select
|
<treeselect
|
||||||
v-model="form.categoryId"
|
v-model="form.categoryId"
|
||||||
|
:options="categoryOptions"
|
||||||
|
:normalizer="normalizer"
|
||||||
:placeholder="$t('product.product-edit.473153-4')"
|
:placeholder="$t('product.product-edit.473153-4')"
|
||||||
@change="selectCategory"
|
@change="selectCategory"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:disabled="form.status == 2 || form.isOwner == 0"
|
:disabled="form.status == 2 || form.isOwner == 0"
|
||||||
:filterable="true"
|
:max-height="300"
|
||||||
>
|
:searchable="true"
|
||||||
<el-option v-for="category in categoryShortList" :key="category.id" :label="category.name" :value="category.id"></el-option>
|
/>
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('product.product-edit.473153-78')" prop="deviceType">
|
<el-form-item :label="$t('product.product-edit.473153-78')" prop="deviceType">
|
||||||
<el-select
|
<el-select
|
||||||
@@ -285,8 +286,10 @@ import productModbus from './product-modbus';
|
|||||||
import { listProtocol } from '@/api/iot/protocol';
|
import { listProtocol } from '@/api/iot/protocol';
|
||||||
import productSub from './product-sub'; //子产品
|
import productSub from './product-sub'; //子产品
|
||||||
import productModbusTask from './product-modbus-task'; //轮询任务
|
import productModbusTask from './product-modbus-task'; //轮询任务
|
||||||
import { listShortCategory } from '@/api/iot/category';
|
import { listShortCategory, listCategory } from '@/api/iot/category';
|
||||||
import { getProduct, addProduct, updateProduct, changeProductStatus, deviceCount } from '@/api/iot/product';
|
import { getProduct, addProduct, updateProduct, changeProductStatus, deviceCount } from '@/api/iot/product';
|
||||||
|
import Treeselect from '@riophae/vue-treeselect';
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
|
||||||
import { getTempByPId, listTemp } from '@/api/iot/temp';
|
import { getTempByPId, listTemp } from '@/api/iot/temp';
|
||||||
import { getAllPoints } from '@/api/iot/template';
|
import { getAllPoints } from '@/api/iot/template';
|
||||||
import ProductModbus from '@/views/iot/product/product-modbus';
|
import ProductModbus from '@/views/iot/product/product-modbus';
|
||||||
@@ -297,6 +300,7 @@ export default {
|
|||||||
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_transport_type', 'data_collect_type', 'iot_location_way', 'sub_gateway_type'],
|
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_transport_type', 'data_collect_type', 'iot_location_way', 'sub_gateway_type'],
|
||||||
components: {
|
components: {
|
||||||
ProductModbus,
|
ProductModbus,
|
||||||
|
Treeselect,
|
||||||
productThingsModel,
|
productThingsModel,
|
||||||
productApp,
|
productApp,
|
||||||
productModbus,
|
productModbus,
|
||||||
@@ -317,6 +321,8 @@ export default {
|
|||||||
activeName: 'basic',
|
activeName: 'basic',
|
||||||
// 分类短列表
|
// 分类短列表
|
||||||
categoryShortList: [],
|
categoryShortList: [],
|
||||||
|
// 分类树选项
|
||||||
|
categoryOptions: [],
|
||||||
//协议列表
|
//协议列表
|
||||||
protocolList: [],
|
protocolList: [],
|
||||||
//组态相关按钮是否显示,true显示,false不显示
|
//组态相关按钮是否显示,true显示,false不显示
|
||||||
@@ -451,15 +457,52 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 获取简短分类列表
|
// 获取分类树
|
||||||
getShortCategory() {
|
getShortCategory() {
|
||||||
const data = {
|
const params = {
|
||||||
pageSize: 999,
|
pageSize: 9999 // 确保加载所有分类
|
||||||
};
|
};
|
||||||
listShortCategory(data).then((response) => {
|
listCategory(params).then((response) => {
|
||||||
this.categoryShortList = response.data;
|
console.log('listCategory response:', response);
|
||||||
|
this.categoryOptions = this.handleTree(response.rows, 'categoryId');
|
||||||
|
console.log('categoryOptions after handleTree:', this.categoryOptions);
|
||||||
|
console.log('Total categories loaded:', response.rows.length);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 转换树形结构 */
|
||||||
|
handleTree(data, id) {
|
||||||
|
const tree = [];
|
||||||
|
const map = {};
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
map[item[id]] = item;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const parent = map[item.parentId];
|
||||||
|
if (parent) {
|
||||||
|
if (!parent.children) {
|
||||||
|
parent.children = [];
|
||||||
|
}
|
||||||
|
parent.children.push(item);
|
||||||
|
} else {
|
||||||
|
tree.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return tree;
|
||||||
|
},
|
||||||
|
/** 转换分类数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.categoryId,
|
||||||
|
label: node.categoryName,
|
||||||
|
children: node.children,
|
||||||
|
};
|
||||||
|
},
|
||||||
//接收网关子设备配置的参数,为了轮询任务页签的显示
|
//接收网关子设备配置的参数,为了轮询任务页签的显示
|
||||||
sendPollType(value) {
|
sendPollType(value) {
|
||||||
this.polltype = value;
|
this.polltype = value;
|
||||||
@@ -512,6 +555,28 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm() {
|
submitForm() {
|
||||||
|
// 确保categoryName被正确赋值
|
||||||
|
if (this.form.categoryId && !this.form.categoryName) {
|
||||||
|
const findCategoryName = (options, id) => {
|
||||||
|
for (const option of options) {
|
||||||
|
if (option.categoryId == id) {
|
||||||
|
return option.categoryName;
|
||||||
|
}
|
||||||
|
if (option.children && option.children.length > 0) {
|
||||||
|
const name = findCategoryName(option.children, id);
|
||||||
|
if (name) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
const categoryName = findCategoryName(this.categoryOptions, this.form.categoryId);
|
||||||
|
if (categoryName) {
|
||||||
|
this.form.categoryName = categoryName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Form data before submit:', this.form);
|
||||||
this.$refs['form'].validate((valid) => {
|
this.$refs['form'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.productId != null && this.form.productId != 0) {
|
if (this.form.productId != null && this.form.productId != 0) {
|
||||||
@@ -582,11 +647,29 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 选择分类 */
|
/** 选择分类 */
|
||||||
selectCategory(val) {
|
selectCategory(val) {
|
||||||
for (var i = 0; i < this.categoryShortList.length; i++) {
|
console.log('selectCategory called with val:', val);
|
||||||
if (this.categoryShortList[i].id == val) {
|
console.log('categoryOptions:', this.categoryOptions);
|
||||||
this.form.categoryName = this.categoryShortList[i].name;
|
// 在树形结构中查找分类名称
|
||||||
return;
|
const findCategoryName = (options, id) => {
|
||||||
|
for (const option of options) {
|
||||||
|
if (option.categoryId == id) {
|
||||||
|
return option.categoryName;
|
||||||
|
}
|
||||||
|
if (option.children && option.children.length > 0) {
|
||||||
|
const name = findCategoryName(option.children, id);
|
||||||
|
if (name) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const categoryName = findCategoryName(this.categoryOptions, val);
|
||||||
|
console.log('Found categoryName:', categoryName);
|
||||||
|
if (categoryName) {
|
||||||
|
this.form.categoryName = categoryName;
|
||||||
|
console.log('form.categoryName set to:', this.form.categoryName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**获取上传图片的路径 */
|
/**获取上传图片的路径 */
|
||||||
|
|||||||
@@ -309,8 +309,8 @@ export default {
|
|||||||
// 没有ticket且没有token,跳转统一身份认证
|
// 没有ticket且没有token,跳转统一身份认证
|
||||||
const isTs = true;
|
const isTs = true;
|
||||||
if (isTs) {
|
if (isTs) {
|
||||||
window.location.href = 'http://192.168.1.241/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2F192.168.1.241%3A9000%2Flogin'+(this.redirect?'&ssUrl='+this.redirect:'');
|
// window.location.href = 'http://192.168.1.241/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2F192.168.1.241%3A9000%2Flogin'+(this.redirect?'&ssUrl='+this.redirect:'');
|
||||||
// window.location.href = 'http://localhost:81/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2Flocalhost%3A80%2Flogin' + (this.redirect ? '&ssUrl=' + this.redirect : '');
|
window.location.href = 'http://localhost:81/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2Flocalhost%3A80%2Flogin' + (this.redirect ? '&ssUrl=' + this.redirect : '');
|
||||||
}
|
}
|
||||||
} else if (ticket && !token) {
|
} else if (ticket && !token) {
|
||||||
// 有ticket但没有token,请求登录
|
// 有ticket但没有token,请求登录
|
||||||
|
|||||||
Reference in New Issue
Block a user