|
@@ -7,8 +7,8 @@
|
|
|
style="margin-bottom: 20px" />
|
|
|
</div>
|
|
|
<div class="head-container">
|
|
|
- <el-tree :data="treeAreaOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree"
|
|
|
- node-key="id" default-expand-all highlight-current @node-click="handleNodeClick" />
|
|
|
+ <el-tree :data="areaList" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree"
|
|
|
+ node-key="id" default-expand-all highlight-current @node-click="handleNodeClick"/>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
|
|
@@ -37,16 +37,6 @@
|
|
|
<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-hasPermi="['ems:area:add']"
|
|
|
- >新增</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="1.5">
|
|
|
- <el-button
|
|
|
type="info"
|
|
|
plain
|
|
|
icon="el-icon-sort"
|
|
@@ -60,8 +50,7 @@
|
|
|
<el-table
|
|
|
v-if="refreshTable"
|
|
|
v-loading="loading"
|
|
|
- :data="areaList"
|
|
|
- row-key="areaCode"
|
|
|
+ :data="areaOptions"
|
|
|
:default-expand-all="isExpandAll"
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
|
>
|
|
@@ -90,144 +79,10 @@
|
|
|
@click="handleDevice(scope.row)"
|
|
|
v-hasPermi="['ems:area:edit']"
|
|
|
>计量设备</el-button>
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-edit"
|
|
|
- @click="handleUpdate(scope.row)"
|
|
|
- v-hasPermi="['ems:area:edit']"
|
|
|
- >修改</el-button>
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-plus"
|
|
|
- @click="handleAdd(scope.row)"
|
|
|
- v-hasPermi="['ems:area:add']"
|
|
|
- >新增</el-button>
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-delete"
|
|
|
- @click="handleDelete(scope.row)"
|
|
|
- v-hasPermi="['ems:area:remove']"
|
|
|
- >删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
- <!-- 添加或修改区域对象对话框 -->
|
|
|
- <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
|
|
- <SubTitle title="区域基础信息" style="margin-bottom: 15px;font-size: 15px; font-weight: bold"/>
|
|
|
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="区域代码" prop="areaCode">
|
|
|
- <el-input v-model="form.areaCode" placeholder="请输入区域代码" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="上级区域" prop="parentCode">
|
|
|
- <treeselect v-model="form.parentCode" :options="areaOptions" :normalizer="normalizer" placeholder="请选择上级区域代码" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="区域名称" prop="areaName">
|
|
|
- <el-input v-model="form.areaName" placeholder="请输入区域名称" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="区域简称" prop="shortName">
|
|
|
- <el-input v-model="form.shortName" placeholder="请输入区域简称" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="区域描述" prop="desc">
|
|
|
- <el-input v-model="form.desc" placeholder="请输入区域描述" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="显示排序" prop="orderNum">
|
|
|
- <el-input-number v-model="form.orderNum" controls-position="right" :min="0" style="width: 100%"/>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form>
|
|
|
- <template v-if="form.areaAttr">
|
|
|
- <SubTitle title="区域属性信息" style="margin-bottom: 15px;font-size: 15px; font-weight: bold"/>
|
|
|
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12" >
|
|
|
- <el-form-item label="属性代码" prop="areaAttr.areaCode">
|
|
|
- <el-input v-model="form.areaAttr.areaCode" placeholder="请输入属性代码" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="区块标签" prop="areaAttr.tagCodeList">
|
|
|
- <el-select v-model="form.areaAttr.tagCodeList" placeholder="请选择区块标签" multiple clearable :style="{width: '100%'}">
|
|
|
- <el-option v-for="item in emsTagOptions" :label="item.label" :value="item.value" :key="item.value" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="所有单位" prop="areaAttr.attrOrg">
|
|
|
- <el-input v-model="form.areaAttr.attrOrg" placeholder="请输入所有单位" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="管理单位" prop="areaAttr.mgrOrg">
|
|
|
- <el-input v-model="form.areaAttr.mgrOrg" placeholder="请输入管理单位" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="负责人" prop="areaAttr.leader">
|
|
|
- <el-input v-model="form.areaAttr.leader" placeholder="请输入负责人" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="联系电话" prop="areaAttr.phone">
|
|
|
- <el-input v-model="form.areaAttr.phone" placeholder="请输入联系电话" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="开通时间" prop="areaAttr.openDate">
|
|
|
- <el-date-picker v-model="form.areaAttr.openDate" type="date" placeholder="选择日期" style="width: 100%"/>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="建筑面积" prop="areaAttr.floorArea">
|
|
|
- <el-input v-model="form.areaAttr.floorArea" placeholder="请输入建筑面积" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="使用面积" prop="areaAttr.usableArea">
|
|
|
- <el-input v-model="form.areaAttr.usableArea" placeholder="请输入使用面积" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="楼层" prop="areaAttr.floor">
|
|
|
- <el-input v-model="form.areaAttr.floor" placeholder="请输入楼层" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form>
|
|
|
- </template>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
- <el-button @click="cancel">取 消</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
<!-- 计量设备弹框 -->
|
|
|
<el-dialog :title="dialogTitle" :visible.sync="deviceDialogVisible" width="1000px" append-to-body>
|
|
|
<el-tabs v-model="activeDeviceTab" @tab-click="handleADTabClick">
|
|
@@ -244,7 +99,13 @@
|
|
|
<template slot-scope="scope">
|
|
|
{{ getObjTypeLabel(scope.row.objType) }}
|
|
|
</template>
|
|
|
- </el-table-column> </el-table>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-arrow-down" @click="downToDevice(scope.row)">取消绑定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
<SubTitle title="未绑定列表" />
|
|
|
<el-table v-loading="loading" :data="Unbound" style="width: 100%">
|
|
|
<el-table-column label="设备编号" align="left" prop="deviceCode" />
|
|
@@ -268,8 +129,6 @@
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button size="mini" type="text" icon="el-icon-arrow-up" @click="moveToDevice(scope.row)">绑定</el-button>
|
|
|
- <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn" @click="handleMeterDelete(scope.row)" v-hasPermi="['basecfg:device:remove']">
|
|
|
- 删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -293,7 +152,7 @@ import { addArea, areaTreeSelect, delArea, getArea, listDetailArea, updateArea }
|
|
|
import SubTitle from '@/components/SubTitle/index.vue'
|
|
|
import { getEmsTag } from '@/api/commonApi'
|
|
|
import { delDevice, listDevice } from '@/api/device/meterDevice'
|
|
|
-import { addByObj, listByObj } from '@/api/basecfg/boundaryRel'
|
|
|
+import { addByObj,addAllByObj, listByObj } from '@/api/basecfg/boundaryRel'
|
|
|
|
|
|
|
|
|
export default {
|
|
@@ -309,17 +168,15 @@ export default {
|
|
|
areaName: undefined,
|
|
|
defaultProps: {
|
|
|
children: 'children',
|
|
|
- label: 'label'
|
|
|
+ label: 'areaName'
|
|
|
},
|
|
|
-
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
|
// 显示搜索条件
|
|
|
showSearch: true,
|
|
|
// 区域对象表格数据
|
|
|
areaList: [],
|
|
|
- // 区域对象树选项
|
|
|
- // areaOptions: [],
|
|
|
+ areaList1: [],
|
|
|
treeAreaOptions: undefined,
|
|
|
// 总条数
|
|
|
total: 0,
|
|
@@ -363,7 +220,6 @@ export default {
|
|
|
objStatusMapping: {
|
|
|
0: '正常',
|
|
|
1: '停用',
|
|
|
-
|
|
|
},
|
|
|
// 表单参数
|
|
|
form: {
|
|
@@ -380,7 +236,6 @@ export default {
|
|
|
tagCodes:null,
|
|
|
tagNames:null,
|
|
|
tagCodeList:[]
|
|
|
-
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -402,27 +257,61 @@ export default {
|
|
|
activeDeviceTab: 'electricMeter',
|
|
|
Bound: [], // 已绑定数据
|
|
|
Unbound: [], // 未绑定数据
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
created() {
|
|
|
- this.getAreaTree('0', true)
|
|
|
this.getEmsTag('Area');
|
|
|
// 初始化 form.areaAttr 为一个空对象
|
|
|
this.form.areaAttr = {};
|
|
|
+ this.getList();
|
|
|
},
|
|
|
methods: {
|
|
|
- getAreaTree(areaCode, recursion) {
|
|
|
- areaTreeSelect(areaCode, recursion).then(response => {
|
|
|
- this.treeAreaOptions = response.data
|
|
|
- // 自动选中并触发点击第一个节点
|
|
|
- if (response.data && response.data.length > 0) {
|
|
|
- const firstNode = response.data[0];
|
|
|
- this.$refs.tree.setCurrentKey(firstNode.id); // 设置当前选中节点
|
|
|
- this.handleNodeClick(firstNode); // 触发点击事件
|
|
|
+ filterNode(value, data) {
|
|
|
+ if (!value) return true
|
|
|
+ return data.label.indexOf(value) !== -1
|
|
|
+ },
|
|
|
+ getObjTypeLabel(objType) {
|
|
|
+ const typeLabels = {
|
|
|
+ 1: '区域位置',
|
|
|
+ 2: '设施',
|
|
|
+ 3: '设备',
|
|
|
+ 4: '组织'
|
|
|
+ };
|
|
|
+ return typeLabels[objType] || '未知类型';
|
|
|
+ },
|
|
|
+ formatDict(val, options, key = 'code', text = 'name') {
|
|
|
+ if (!this[options] || !Array.isArray(this[options])) {
|
|
|
+ console.error(`Expected an array for this[${options}], but got ${typeof this[options]}`);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ let name = '';
|
|
|
+ this[options].forEach(item => {
|
|
|
+ if (val === item[key]) {
|
|
|
+ name = item[text];
|
|
|
}
|
|
|
});
|
|
|
+ return name;
|
|
|
+ },
|
|
|
+
|
|
|
+ getColCycleName(colCycle) {
|
|
|
+ const cycleMap = {
|
|
|
+ 0: '实时',
|
|
|
+ 1: '分钟',
|
|
|
+ 2: '小时',
|
|
|
+ 3: '天',
|
|
|
+ 4: '月'
|
|
|
+ }
|
|
|
+ return cycleMap[colCycle] || ''
|
|
|
+ },
|
|
|
+ getColModeName(colMode) {
|
|
|
+ const modeMap = {
|
|
|
+ 0: '自动抄表',
|
|
|
+ 1: '手动抄表'
|
|
|
+ }
|
|
|
+ return modeMap[colMode] || '未知'
|
|
|
},
|
|
|
/**分页*/
|
|
|
handleTabClick() {
|
|
@@ -433,75 +322,67 @@ export default {
|
|
|
this.activeDeviceTab = tab.name;
|
|
|
this.getMeterData(); // 重新获取数据
|
|
|
},
|
|
|
- // 筛选节点
|
|
|
- filterNode(value, data) {
|
|
|
- if (!value) return true
|
|
|
- return data.label.indexOf(value) !== -1
|
|
|
- },
|
|
|
- // 节点单击事件
|
|
|
+
|
|
|
+ // 节点点击事件处理
|
|
|
handleNodeClick(data) {
|
|
|
- this.queryParams.areaCode = data.id
|
|
|
- this.MeterQueryParams.areaCode = data.id
|
|
|
- this.handleQuery()
|
|
|
+ if (data && data.ancestors) {
|
|
|
+ const ancestorsArray = data.ancestors.split(',');
|
|
|
+ if (ancestorsArray.length > 1) {
|
|
|
+ const areaCode = ancestorsArray[1];
|
|
|
+ this.queryParams.areaCode = areaCode;
|
|
|
+ this.MeterQueryParams.areaCode = areaCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 从点击的节点中获取areaCode
|
|
|
+ const areaCode = data.areaCode;
|
|
|
+ const filteredData = this.filterDataByAreaCode(this.areaList, areaCode);
|
|
|
+ if (filteredData.length > 0) {
|
|
|
+ this.areaOptions = filteredData;
|
|
|
+ } else {
|
|
|
+ this.areaOptions = [data];
|
|
|
+ }
|
|
|
this.getMeterData()
|
|
|
-
|
|
|
},
|
|
|
|
|
|
- //--------------------------------
|
|
|
- getTagStyle(tagName) {
|
|
|
- // 从tagName找到对应的tagCode
|
|
|
- const tagCode = this.emsTagOptions.find(tag => tag.label === tagName)?.value;
|
|
|
- const color = this.tagCodeToColorMap[tagCode] || '#FFFFFF'; // 默认白色
|
|
|
- return {
|
|
|
- backgroundColor: color,
|
|
|
- color:'#808080',
|
|
|
- padding: '4px 8px',
|
|
|
- borderRadius: '4px',
|
|
|
- width: '80px',
|
|
|
- height: '30px',
|
|
|
- margin: '4px 8px 4px 0',
|
|
|
- display: 'inline-block',
|
|
|
- verticalAlign: 'top'
|
|
|
- };
|
|
|
+ // 根据areaCode过滤节点和children数组的方法
|
|
|
+ filterDataByAreaCode(list, areaCode) {
|
|
|
+ let result = [];
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ if (list[i].areaCode === areaCode) {
|
|
|
+ result.push(list[i]);
|
|
|
+ if (list[i].children && list[i].children.length > 0) {
|
|
|
+ result = result.concat(list[i].children);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 如果当前节点有children,递归查找
|
|
|
+ if (list[i].children && list[i].children.length > 0) {
|
|
|
+ const foundChildren = this.filterDataByAreaCode(list[i].children, areaCode);
|
|
|
+ if (foundChildren.length > 0) {
|
|
|
+ return foundChildren;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
},
|
|
|
/** 查询区域对象列表 */
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
+ console.log("this.queryParams",this.queryParams)
|
|
|
listDetailArea(this.queryParams).then(response => {
|
|
|
this.areaList = this.handleTree(response.data, "areaCode", "parentCode");
|
|
|
- // 递归处理 tagNames
|
|
|
- this.areaList = this.extractTagNames(this.areaList);
|
|
|
- console.log("查询", this.areaList);
|
|
|
+ this.areaList = this.extractTagNames(this.areaList);
|
|
|
this.loading = false;
|
|
|
+ this.activateSecondLevelNode();
|
|
|
});
|
|
|
},
|
|
|
- moveToDevice(row) {
|
|
|
-
|
|
|
+ // 激活第一层的第一个子节点
|
|
|
+ activateSecondLevelNode() {
|
|
|
+ if (this.areaList.length > 0 && this.areaList[0].children && this.areaList[0].children.length > 0) {
|
|
|
+ this.handleNodeClick(this.areaList[0].children[0]);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- saveByObj() {
|
|
|
- // 构建要保存的数据数组
|
|
|
- const dataToSave = this.Bound.map(item => {
|
|
|
- return {
|
|
|
- boundaryObj: item.boundaryObj,
|
|
|
- meterDevice: item.meterDevice,
|
|
|
- objType: item.objType
|
|
|
- };
|
|
|
- });
|
|
|
- console.log("dataToSave",dataToSave)
|
|
|
- addByObj(dataToSave).then(response => {
|
|
|
- if (response.code === 200) {
|
|
|
- this.$message.success('保存成功');
|
|
|
- this.deviceDialogVisible = false;
|
|
|
- this.getMeterData();
|
|
|
- } else {
|
|
|
- this.$message.error('保存失败');
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
- console.error('保存失败:', error);
|
|
|
- this.$message.error('保存失败');
|
|
|
- });
|
|
|
- },
|
|
|
// 递归提取 tagNames
|
|
|
extractTagNames(list) {
|
|
|
return list.map(item => {
|
|
@@ -511,32 +392,12 @@ export default {
|
|
|
item.tagNames = '';
|
|
|
}
|
|
|
if (item.children) {
|
|
|
- item.children = this.extractTagNames(item.children); // 递归处理子区域
|
|
|
+ item.children = this.extractTagNames(item.children);
|
|
|
}
|
|
|
return item;
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- /** 转换区域对象数据结构 */
|
|
|
- normalizer(node) {
|
|
|
- if (node.children && !node.children.length) {
|
|
|
- delete node.children;
|
|
|
- }
|
|
|
- return {
|
|
|
- id: node.areaCode,
|
|
|
- label: node.areaName,
|
|
|
- children: node.children
|
|
|
- };
|
|
|
- },
|
|
|
- /** 查询区域对象下拉树结构 */
|
|
|
- getTreeselect() {
|
|
|
- listDetailArea().then(response => {
|
|
|
- this.areaOptions = [];
|
|
|
- const data = { areaCode: 0, areaName: '顶级节点', children: [] };
|
|
|
- data.children = this.handleTree(response.data, "areaCode", "parentCode");
|
|
|
- this.areaOptions.push(data);
|
|
|
- });
|
|
|
- },
|
|
|
// 取消按钮
|
|
|
cancel() {
|
|
|
this.open = false;
|
|
@@ -585,24 +446,6 @@ export default {
|
|
|
this.handleQuery();
|
|
|
},
|
|
|
|
|
|
- /** 新增按钮操作 */
|
|
|
- handleAdd(row) {
|
|
|
- this.reset();
|
|
|
- this.getTreeselect();
|
|
|
- if (row != null && row.areaCode) {
|
|
|
- this.form.parentCode = row.areaCode;
|
|
|
- } else {
|
|
|
- this.form.parentCode = 0;
|
|
|
- }
|
|
|
- // 确保 areaAttr 和 tagCodeList 是对象和数组
|
|
|
- this.form.areaAttr = this.form.areaAttr || {};
|
|
|
- console.log("this.form.areaAttr",this.form.areaAttr)
|
|
|
- this.form.areaAttr.tagCodeList = this.form.areaAttr.tagCodeList || [];
|
|
|
- console.log("this.form.areaAttr.tagCodeList",this.form.areaAttr.tagCodeList)
|
|
|
- this.open = true;
|
|
|
- this.title = "添加区域对象";
|
|
|
- },
|
|
|
-
|
|
|
/** 展开/折叠操作 */
|
|
|
toggleExpandAll() {
|
|
|
this.refreshTable = false;
|
|
@@ -613,11 +456,9 @@ export default {
|
|
|
},
|
|
|
/**计量设备*/
|
|
|
handleDevice(row) {
|
|
|
- this.dialogTitle = `计量设备 - ${row.areaName}`; // 设置弹框标题
|
|
|
- this.deviceDialogVisible = true; // 显示弹框
|
|
|
-
|
|
|
+ this.dialogTitle = `计量设备 - ${row.areaName}`;
|
|
|
+ this.deviceDialogVisible = true;
|
|
|
},
|
|
|
-
|
|
|
getMeterData() {
|
|
|
this.loading = true;
|
|
|
let meterCls = '';
|
|
@@ -632,114 +473,66 @@ export default {
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
});
|
|
|
- listByObj(1,this.queryParams.areaCode).then(response=>{
|
|
|
+ listByObj(1,meterCls,this.queryParams.areaCode).then(response=>{
|
|
|
this.Bound = response.data;
|
|
|
console.log("this.Bound",this.Bound);
|
|
|
})
|
|
|
},
|
|
|
- getObjTypeLabel(objType) {
|
|
|
- const typeLabels = {
|
|
|
- 1: '区域位置',
|
|
|
- 2: '设施',
|
|
|
- 3: '设备',
|
|
|
- 4: '组织'
|
|
|
- };
|
|
|
- return typeLabels[objType] || '未知类型';
|
|
|
- },
|
|
|
- formatDict(val, options, key = 'code', text = 'name') {
|
|
|
- if (!this[options] || !Array.isArray(this[options])) {
|
|
|
- console.error(`Expected an array for this[${options}], but got ${typeof this[options]}`);
|
|
|
- return '';
|
|
|
- }
|
|
|
-
|
|
|
- let name = '';
|
|
|
- this[options].forEach(item => {
|
|
|
- if (val === item[key]) {
|
|
|
- name = item[text];
|
|
|
- }
|
|
|
- });
|
|
|
- return name;
|
|
|
- },
|
|
|
|
|
|
- getColCycleName(colCycle) {
|
|
|
- const cycleMap = {
|
|
|
- 0: '实时',
|
|
|
- 1: '分钟',
|
|
|
- 2: '小时',
|
|
|
- 3: '天',
|
|
|
- 4: '月'
|
|
|
- }
|
|
|
- return cycleMap[colCycle] || ''
|
|
|
- },
|
|
|
- getColModeName(colMode) {
|
|
|
- const modeMap = {
|
|
|
- 0: '自动抄表',
|
|
|
- 1: '手动抄表'
|
|
|
+ /**绑定设备*/
|
|
|
+ moveToDevice(row) {
|
|
|
+ const index = this.Unbound.indexOf(row);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.Unbound.splice(index, 1);
|
|
|
}
|
|
|
- return modeMap[colMode] || '未知'
|
|
|
+ const boundRow = {
|
|
|
+ ...row,
|
|
|
+ boundaryObj: this.queryParams.areaCode,
|
|
|
+ meterDevice: row.deviceCode,
|
|
|
+ objType: 1
|
|
|
+ };
|
|
|
+ this.Bound.push(boundRow);
|
|
|
},
|
|
|
- /** 修改按钮操作 */
|
|
|
- handleUpdate(row) {
|
|
|
- this.reset();
|
|
|
- this.getTreeselect();
|
|
|
- if (row != null) {
|
|
|
- this.form.parentCode = row.areaCode;
|
|
|
+ /**取消绑定设备*/
|
|
|
+ downToDevice(row){
|
|
|
+ const index = this.Bound.indexOf(row);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.Bound.splice(index, 1);
|
|
|
}
|
|
|
- getArea(row.id).then(response => {
|
|
|
- this.form = response.data;
|
|
|
- this.open = true;
|
|
|
- // 确保 areaAttr 和 tagCodeList 是对象和数组
|
|
|
- this.form.areaAttr = this.form.areaAttr || {};
|
|
|
- this.form.areaAttr.tagCodeList = this.form.areaAttr.tagCodeList || [];
|
|
|
- console.log(this.form.areaAttr);
|
|
|
- this.title = "修改区域对象";
|
|
|
- });
|
|
|
+ this.Unbound.push(row);
|
|
|
+ // 清除之前设置的属性值
|
|
|
+ delete row.boundaryObj;
|
|
|
+ delete row.meterDevice;
|
|
|
+ delete row.objType;
|
|
|
},
|
|
|
|
|
|
- /** 提交按钮 */
|
|
|
- submitForm() {
|
|
|
- this.$refs["form"].validate(valid => {
|
|
|
- if (valid) {
|
|
|
- if (this.form.id != null) {
|
|
|
- updateArea(this.form).then(response => {
|
|
|
- this.$modal.msgSuccess("修改成功");
|
|
|
- this.open = false;
|
|
|
- this.getList();
|
|
|
- });
|
|
|
- } else {
|
|
|
- addArea(this.form).then(response => {
|
|
|
- this.$modal.msgSuccess("新增成功");
|
|
|
- this.open = false;
|
|
|
- this.getList();
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ /**构建要保存的数据数组*/
|
|
|
+ saveByObj() {
|
|
|
+ const dataToSave = this.Bound.map(item => {
|
|
|
+ return {
|
|
|
+ boundaryObj: item.boundaryObj,
|
|
|
+ meterCls: item.meterCls || (item.objType === 'electricMeter' ? 45 : 70),
|
|
|
+ objType: item.objType
|
|
|
+ };
|
|
|
});
|
|
|
- },
|
|
|
-
|
|
|
- /** 删除按钮操作 */
|
|
|
- handleDelete(row) {
|
|
|
- this.$modal.confirm('是否确认删除区域对象编号为"' + row.id + '"的数据项?').then(function() {
|
|
|
- return delArea(row.id);
|
|
|
- }).then(() => {
|
|
|
- this.getList();
|
|
|
- this.$modal.msgSuccess("删除成功");
|
|
|
- }).catch(() => {});
|
|
|
- },
|
|
|
- /**删除水表,电表*/
|
|
|
- handleMeterDelete(row) {
|
|
|
- const ids = row.id || this.ids
|
|
|
- this.$modal
|
|
|
- .confirm('是否确认删除计量设备编号为"' + ids + '"的数据项?')
|
|
|
- .then(function() {
|
|
|
- return delDevice(ids)
|
|
|
+ console.log("dataToSave", dataToSave);
|
|
|
+
|
|
|
+ addAllByObj(dataToSave)
|
|
|
+ .then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('保存成功');
|
|
|
+ this.deviceDialogVisible = false;
|
|
|
+ this.getMeterData();
|
|
|
+ } else {
|
|
|
+ this.$message.error('保存失败');
|
|
|
+ }
|
|
|
})
|
|
|
- .then(() => {
|
|
|
- this.getMeterData()
|
|
|
- this.$modal.msgSuccess('删除成功')
|
|
|
- })
|
|
|
- .catch(() => {})
|
|
|
+ .catch(error => {
|
|
|
+ console.error('保存失败:', error);
|
|
|
+ this.$message.error('保存失败');
|
|
|
+ });
|
|
|
},
|
|
|
+
|
|
|
getEmsTag(tagModel) {
|
|
|
console.log("tagModel", tagModel)
|
|
|
getEmsTag(tagModel).then(response => {
|
|
@@ -757,7 +550,23 @@ export default {
|
|
|
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ getTagStyle(tagName) {
|
|
|
+ // 从tagName找到对应的tagCode
|
|
|
+ const tagCode = this.emsTagOptions.find(tag => tag.label === tagName)?.value;
|
|
|
+ const color = this.tagCodeToColorMap[tagCode] || '#FFFFFF'; // 默认白色
|
|
|
+ return {
|
|
|
+ backgroundColor: color,
|
|
|
+ color:'#808080',
|
|
|
+ padding: '4px 8px',
|
|
|
+ borderRadius: '4px',
|
|
|
+ width: '80px',
|
|
|
+ height: '30px',
|
|
|
+ margin: '4px 8px 4px 0',
|
|
|
+ display: 'inline-block',
|
|
|
+ verticalAlign: 'top'
|
|
|
+ };
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|