综合查询相关接口不再使用中文categoryName统一使用deviceCategory

This commit is contained in:
白菜
2025-10-16 16:10:29 +08:00
parent fb0eda4565
commit f4e6821484
14 changed files with 130 additions and 141 deletions

View File

@ -1,13 +1,13 @@
<template>
<el-dialog :visible.sync="dialogTableVisible" :close-on-click-modal="false" :show-close="false" destroy-on-close lock-scroll append-to-body width="600px" class="ems-dialog" :title="mode === 'add'?'新增设备':`编辑设备` " >
<el-form v-loading="loading>0" ref="addTempForm" :model="formData" :rules="rules" size="medium" label-width="100px">
<el-dialog :visible.sync="dialogTableVisible" :close-on-press-escape="false" :close-on-click-modal="false" :show-close="false" destroy-on-close lock-scroll append-to-body width="600px" class="ems-dialog" :title="mode === 'add'?'新增设备':`编辑设备` " >
<el-form v-loading="loading>0" ref="addTempForm" :model="formData" :rules="rules" size="medium" label-width="140px">
<el-form-item label="站点" prop="siteId">
<el-select v-model="formData.siteId" placeholder="请选择" :style="{width: '100%'}">
<el-select v-model="formData.siteId" placeholder="请选择" :style="{width: '100%'}" @change="changeType">
<el-option :label="item.siteName" :value="item.siteId" v-for="(item,index) in siteList" :key="index+'siteOptions'"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备id" prop="deviceId" >
<el-input v-model="formData.deviceId" maxlength="60" clearable :style="{width: '100%'}">
<el-input v-model="formData.deviceId" placeholder="请输入" maxlength="60" clearable :style="{width: '100%'}">
</el-input>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
@ -29,11 +29,11 @@
</el-select>
</el-form-item>
<el-form-item label="设备类别" prop="deviceCategory">
<el-select v-model="formData.deviceCategory" placeholder="请选择" :style="{width: '100%'}">
<el-option :label="item" :value="item" v-for="(item,index) in deviceCategoryList" :key="index+'deviceCategoryList'"></el-option>
<el-select v-model="formData.deviceCategory" placeholder="请选择" :style="{width: '100%'}" @change="changeType">
<el-option :label="item.name" :value="item.code" v-for="(item,index) in deviceCategoryList" :key="index+'deviceCategoryList'"></el-option>
</el-select>
</el-form-item>
<el-form-item label="上级设备" prop="parentId" v-if="formData.deviceCategory === dccDeviceCategory">
<el-form-item label="上级设备" prop="parentId" v-if="dccDeviceCategoryList.includes(formData.deviceCategory)">
<el-select v-model="formData.parentId" :placeholder="parentDeviceList.length === 0 && !formData.siteId ? '请先选择站点' : '请选择'" :style="{width: '100%'}">
<el-option :label="item.deviceName" :value="item.id" v-for="(item,index) in parentDeviceList" :key="index+'parentDeviceList'" ></el-option>
</el-select>
@ -80,10 +80,10 @@
</template>
<script>
import {mapState} from "vuex";
import {getStackNameList} from '@/api/ems/dzjk'
import {getAllSites} from '@/api/ems/zddt'
import {validText} from '@/utils/validate'
import {getDeviceDetailInfo,getDeviceCategory,updateDevice,addDevice} from "@/api/ems/site";
import {getDeviceDetailInfo,updateDevice,addDevice,getParentDeviceId} from "@/api/ems/site";
import {getAllDeviceCategory} from '@/api/ems/search'
export default {
props:{
mode:{
@ -112,7 +112,7 @@ export default {
}
return {
loading:0,
dccDeviceCategory:'CLUSTER',
dccDeviceCategoryList:['CLUSTER','BATTERY'],//需要展示上级设备的设备类型
dialogTableVisible:false,
parentDeviceList:[],//上级设备列表 从接口获取数据
siteList:[],//站点列表 从接口获取数据
@ -195,24 +195,6 @@ export default {
})
},
watch:{
'formData.deviceCategory':{
handler(newVal){
// 只有电池簇需要选择上级设备 调用接口获取电池堆列表
if(newVal && newVal === this.dccDeviceCategory){
this.getParentDeviceList()
}
},
immediate:true
},
'formData.siteId':{
handler(newVal,oldVal){
// 只有电池簇需要选择上级设备 调用接口获取电池堆列表
if(newVal && oldVal!== newVal && this.formData.deviceCategory === this.dccDeviceCategory){
this.getParentDeviceList()
}
},
immediate:true
},
dialogTableVisible:{
handler(newVal){
//打开弹窗
@ -229,6 +211,9 @@ export default {
this.loading+=1
getDeviceDetailInfo(newVal).then(response => {
this.formData = JSON.parse(JSON.stringify(response?.data || {}));
if(this.dccDeviceCategoryList.includes(this.formData.deviceCategory)){
this.getParentDeviceList(true)
}
}).finally(() => {this.loading-=1})
}
},
@ -236,6 +221,11 @@ export default {
}
},
methods: {
changeType(){
if(this.dccDeviceCategoryList.includes(this.formData.deviceCategory)){
this.getParentDeviceList()
}
},
uploadImage(data){
this.formData.pictureUrl = data
},
@ -249,18 +239,18 @@ export default {
// 获取设备类别
getDeviceCategoryList(){
this.loading+=1
getDeviceCategory().then(response => {
getAllDeviceCategory().then(response => {
this.deviceCategoryList = response?.data || []
}).finally(() => {this.loading-=1})
},
//获取上级id列表
getParentDeviceList(){
getParentDeviceList(init=false){
if(!this.formData.siteId){
return console.log('请先选择站点')
}
this.formData.parentId=''
!init && (this.formData.parentId='')
this.loading= this.loading+1
getStackNameList(this.formData.siteId).then(response => {
getParentDeviceId({siteId:this.formData.siteId,deviceCategory:this.formData.deviceCategory}).then(response => {
this.parentDeviceList = JSON.parse(JSON.stringify(response?.data || []));
}).finally(() => {
this.loading=this.loading -1
@ -318,26 +308,26 @@ export default {
closeDialog(){
this.$emit('clear')
// 清空所有数据
this.$refs.addTempForm.resetFields()
this.formData= {
id:'',//设备唯一标识
siteId:'',//站点ID
deviceId:'',//设备id
deviceName:'',//设备名称
description:'',//设备描述
communicationStatus:'',//工作状态
deviceType:'',//设备类型
deviceCategory:'',//设备类别
parentId:'',//上级设备id
ipAddress:'',//TCP设备的ip地址
ipPort:"",//TCP端口号
serialPort:'',//串口路径
baudRate:'',//波特率
dataBits:'',//数据位
stopBits:'',//停止位
parity:'',//校验位
pictureUrl:'',//设备图片
id:'',//设备唯一标识
siteId:'',//站点ID
deviceId:'',//设备id
deviceName:'',//设备名称
description:'',//设备描述
communicationStatus:'',//工作状态
deviceType:'',//设备类型
deviceCategory:'',//设备类别
parentId:'',//上级设备id
ipAddress:'',//TCP设备的ip地址
ipPort:"",//TCP端口号
serialPort:'',//串口路径
baudRate:'',//波特率
dataBits:'',//数据位
stopBits:'',//停止位
parity:'',//校验位
pictureUrl:'',//设备图片
}
this.$refs.addTempForm.resetFields()
this.dialogTableVisible=false
}
}

View File

@ -75,9 +75,7 @@
class="pointer"
@click="
showChart(
scope.row.pointName,
scope.row.deviceName,
scope.row.deviceId
scope.row
)
"
>{{ scope.row.pointValue }}</span
@ -118,7 +116,7 @@ export default {
if (!val) {
this.tableData = [];
this.deviceId = "";
this.deviceName = "";
this.parentId='';
this.siteId = "";
this.pageSize = 10;
this.pageNum = 1;
@ -135,6 +133,11 @@ export default {
}
},
},
computed:{
isDtdc(){
return this.deviceCategory === 'BATTERY'
}
},
data() {
return {
// 默认排序
@ -150,8 +153,8 @@ export default {
upper: "", //
},
deviceCategory: "",
deviceName: "",
deviceId: "",
parentId:'',
siteId: "",
tableData: [],
pageSize: 10, //分页栏当前每个数据总数
@ -160,10 +163,12 @@ export default {
};
},
methods: {
showChart(pointName, deviceName, deviceId) {
console.log("点击查询图表", pointName, deviceName, deviceId);
pointName &&
this.$refs.pointChart.showChart({ pointName, deviceName, deviceId });
showChart({pointName}) {
if(pointName){
const {deviceCategory,deviceId}=this
if(this.isDtdc) this.$refs.pointChart.showChart({ pointName, deviceCategory, deviceId:this.parentId,child:[deviceId] });
else this.$refs.pointChart.showChart({ pointName, deviceCategory, deviceId });
}
},
handleSortChange(column) {
this.form.sortData = column.prop
@ -175,11 +180,11 @@ export default {
this.pageNum = 1;
this.getData();
},
showTable({ deviceCategory, siteId, deviceId, deviceName }) {
showTable({ deviceCategory, siteId, deviceId ,parentId=''}) {
this.deviceCategory = deviceCategory;
this.siteId = siteId;
this.deviceId = deviceId;
this.deviceName = deviceName;
this.parentId=deviceCategory === 'BATTERY' ? parentId : ''//只有单体电池需要这个值
this.show = true;
this.getData();
},
@ -189,6 +194,7 @@ export default {
siteId,
deviceId,
deviceCategory,
parentId,
pageNum,
pageSize,
form: {
@ -204,6 +210,7 @@ export default {
siteId,
deviceId,
deviceCategory,
parentDeviceId: parentId,
pageNum,
pageSize,
sortData,