实时数据:修改枚举类值
This commit is contained in:
parent
805f0d1906
commit
c89764d22d
@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main">
|
<div class="default-main">
|
||||||
<el-dialog v-model="visible" title="测点选择" width="1000" :before-close="handleClose" :show-close="false">
|
<el-dialog v-model="visible" title="测点选择" width="1000" :before-close="handleClose" :show-close="false">
|
||||||
<!-- <el-transfer v-model="value" :data="data" />-->
|
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="14">
|
<el-col :span="14">
|
||||||
<div class="transferLeft">
|
<div class="transferLeft">
|
||||||
@ -88,7 +87,7 @@
|
|||||||
<div class="realConter">
|
<div class="realConter">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<el-button type="primary" :icon="Crop" class="defaultBtn" @click="openMeasure">测点选择</el-button>
|
<el-button type="primary" :icon="Crop" class="defaultBtn" @click="openMeasure">测点选择</el-button>
|
||||||
<el-button style="color: rgb(0, 100, 170);;" :icon="Download" class="defaultBtn" @click="downFun(realtableColumn,realtableData)">数据导出</el-button>
|
<el-button style="color: rgb(0, 100, 170);;" :icon="Download" class="defaultBtn" @click="downFun(tableColumn,tableData)">数据导出</el-button>
|
||||||
<div class="selectPart">
|
<div class="selectPart">
|
||||||
<span>自动更新:</span>
|
<span>自动更新:</span>
|
||||||
<el-switch
|
<el-switch
|
||||||
@ -99,8 +98,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="realTable">
|
<div class="realTable">
|
||||||
<el-table height="100%" :data="realtableData">
|
<el-table height="100%" :data="tableData">
|
||||||
<template v-for="item in realtableColumn">
|
<template v-for="item in tableColumn">
|
||||||
<el-table-column :prop="item.prop" :label="item.label" :align="item.align" />
|
<el-table-column :prop="item.prop" :label="item.label" :align="item.align" />
|
||||||
<!-- <el-table-column v-if="item.custom === 'default'" :prop="item.prop" :label="item.label" :align="item.align" />
|
<!-- <el-table-column v-if="item.custom === 'default'" :prop="item.prop" :label="item.label" :align="item.align" />
|
||||||
<el-table-column v-if="item.custom === 'header'" :prop="item.prop" :label="item.label+item.unit" :align="item.align" />-->
|
<el-table-column v-if="item.custom === 'header'" :prop="item.prop" :label="item.label+item.unit" :align="item.align" />-->
|
||||||
@ -116,16 +115,19 @@ import {Crop,Download,Top,Bottom,Close} from '@element-plus/icons-vue'
|
|||||||
import {onMounted, onUnmounted, reactive, ref, watch,computed,nextTick} from 'vue'
|
import {onMounted, onUnmounted, reactive, ref, watch,computed,nextTick} from 'vue'
|
||||||
import {ElMessage} from 'element-plus'
|
import {ElMessage} from 'element-plus'
|
||||||
import {equipList,getModelAttributeList,getsnapshotData} from "/@/api/backend/realData/request.ts";
|
import {equipList,getModelAttributeList,getsnapshotData} from "/@/api/backend/realData/request.ts";
|
||||||
|
import {getAllEnumData} from "/@/api/backend/Enumeration/request";
|
||||||
|
import { useEnumStore } from '/@/stores/enums'
|
||||||
|
const enumStore = useEnumStore()
|
||||||
|
|
||||||
const realtableData = ref()
|
const tableData = ref()
|
||||||
const tableItem0: any = [
|
const tableItem0: any = [
|
||||||
{
|
{
|
||||||
label: '风机列表',
|
label: '风机列表',
|
||||||
unit:' ',
|
unit:' ',
|
||||||
prop: 'code',
|
prop: 'name',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
custom: 'default',
|
custom: 'default',
|
||||||
name:'',
|
name:'name',
|
||||||
title: '风机列表'
|
title: '风机列表'
|
||||||
}]
|
}]
|
||||||
const tableItem1: any = [
|
const tableItem1: any = [
|
||||||
@ -221,7 +223,7 @@ const tableItem1: any = [
|
|||||||
title: '变桨角度'
|
title: '变桨角度'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const realtableColumn=ref(
|
const tableColumn=ref(
|
||||||
[...tableItem0,...tableItem1]
|
[...tableItem0,...tableItem1]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -235,10 +237,23 @@ const objectType= ref(10002);
|
|||||||
const iotModelId=ref()
|
const iotModelId=ref()
|
||||||
const radioActiveName=ref('138')
|
const radioActiveName=ref('138')
|
||||||
const selectedIndex=ref(0)
|
const selectedIndex=ref(0)
|
||||||
|
|
||||||
|
const newtableData=ref()
|
||||||
const deviceQuery = (data: any) => {
|
const deviceQuery = (data: any) => {
|
||||||
equipList(data).then((res) => {
|
equipList(data).then((res) => {
|
||||||
deviceList.value = res.data
|
deviceList.value = res.data
|
||||||
realtableData.value = res.data
|
tableData.value = res.data.map((item) => {
|
||||||
|
return {
|
||||||
|
id:item.id,
|
||||||
|
name: item.name ?? '-',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
newtableData.value = res.data.map((item) => {
|
||||||
|
return {
|
||||||
|
id:item.id,
|
||||||
|
name: item.name ?? '-',
|
||||||
|
}
|
||||||
|
})
|
||||||
iotModelId.value=res.data[0].iotModelId
|
iotModelId.value=res.data[0].iotModelId
|
||||||
defaultdeviceQuery()
|
defaultdeviceQuery()
|
||||||
})
|
})
|
||||||
@ -248,7 +263,7 @@ const defaultdeviceQuery = () => {
|
|||||||
let attributesCode:any[]=[]
|
let attributesCode:any[]=[]
|
||||||
deviceId.forEach((item,index) => {
|
deviceId.forEach((item,index) => {
|
||||||
objparms.deviceId=item
|
objparms.deviceId=item
|
||||||
attributesCode=realtableColumn.value.map((item1)=>item1.prop)
|
attributesCode=tableColumn.value.map((item1)=>item1.prop)
|
||||||
attributesCode.push('iPitchAngle1','iPitchAngle2', 'iPitchAngle3')
|
attributesCode.push('iPitchAngle1','iPitchAngle2', 'iPitchAngle3')
|
||||||
objparms.attributes=attributesCode
|
objparms.attributes=attributesCode
|
||||||
snapshotParms.push({...objparms})
|
snapshotParms.push({...objparms})
|
||||||
@ -257,14 +272,14 @@ const defaultdeviceQuery = () => {
|
|||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const tsnapshotVoObject: any = res.data;
|
const tsnapshotVoObject: any = res.data;
|
||||||
const tsnapshotVoMap = new Map(Object.entries(tsnapshotVoObject));
|
const tsnapshotVoMap = new Map(Object.entries(tsnapshotVoObject));
|
||||||
const updatedTableData = realtableColumn.value.reduce((acc, item1) => {
|
const updatedTableData = tableColumn.value.reduce((acc, item1) => {
|
||||||
acc.forEach((item, i) => {
|
acc.forEach((item, i) => {
|
||||||
const itemKey = item.id;
|
const itemKey = item.id;
|
||||||
if (tsnapshotVoMap.has(itemKey)) {
|
if (tsnapshotVoMap.has(itemKey)) {
|
||||||
const tsnapshotVoItem = tsnapshotVoMap.get(itemKey);
|
const tsnapshotVoItem = tsnapshotVoMap.get(itemKey);
|
||||||
//const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
//const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
||||||
const attributeCodeLower = item1.prop;
|
const attributeCodeLower = item1.prop;
|
||||||
if(attributeCodeLower!='code'){
|
if(attributeCodeLower!='name'){
|
||||||
if (attributeCodeLower) {
|
if (attributeCodeLower) {
|
||||||
const ipitchangle=Math.min(tsnapshotVoItem.ipitchangle1, tsnapshotVoItem.ipitchangle2, tsnapshotVoItem.ipitchangle3)
|
const ipitchangle=Math.min(tsnapshotVoItem.ipitchangle1, tsnapshotVoItem.ipitchangle2, tsnapshotVoItem.ipitchangle3)
|
||||||
let ipitchanglevalue;
|
let ipitchanglevalue;
|
||||||
@ -282,9 +297,8 @@ const defaultdeviceQuery = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return acc;
|
return acc;
|
||||||
}, [...realtableData.value]);
|
}, [...tableData.value]);
|
||||||
realtableData.value = updatedTableData;
|
tableData.value = updatedTableData;
|
||||||
debugger;
|
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error({
|
ElMessage.error({
|
||||||
message: res.msg,
|
message: res.msg,
|
||||||
@ -334,12 +348,11 @@ interface TableType {
|
|||||||
|
|
||||||
const selectList=ref([])
|
const selectList=ref([])
|
||||||
const getSel = () => {
|
const getSel = () => {
|
||||||
debugger
|
|
||||||
selectList.value=[]
|
selectList.value=[]
|
||||||
try {
|
try {
|
||||||
if (realtableColumn.value && Array.isArray(realtableColumn.value)) {
|
if (tableColumn.value && Array.isArray(tableColumn.value)) {
|
||||||
for (const item of realtableColumn.value) {
|
for (const item of tableColumn.value) {
|
||||||
if (item && item.prop && item.prop !== 'code') {
|
if (item && item.prop && item.prop !== 'name') {
|
||||||
if(item.title!==undefined){
|
if(item.title!==undefined){
|
||||||
selectList.value.push({
|
selectList.value.push({
|
||||||
attributeName: item.title || '',
|
attributeName: item.title || '',
|
||||||
@ -426,6 +439,7 @@ const clearList=() => {
|
|||||||
Statistic.value=0
|
Statistic.value=0
|
||||||
multipleSelection.value = [];
|
multipleSelection.value = [];
|
||||||
RealtableRef.value.clearSelection()
|
RealtableRef.value.clearSelection()
|
||||||
|
//tableData.value=[]
|
||||||
queryListData.iotModelId=iotModelId.value
|
queryListData.iotModelId=iotModelId.value
|
||||||
queryListData.attributeType=radioActiveName.value
|
queryListData.attributeType=radioActiveName.value
|
||||||
modelAttributeList(queryListData)
|
modelAttributeList(queryListData)
|
||||||
@ -496,12 +510,11 @@ const getTableData = () => {
|
|||||||
const deviceId=deviceList.value.map((item) => item.id);
|
const deviceId=deviceList.value.map((item) => item.id);
|
||||||
const tableColumnEnds = ref([]);
|
const tableColumnEnds = ref([]);
|
||||||
if(multipleSelection.value.length === 0){
|
if(multipleSelection.value.length === 0){
|
||||||
realtableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||||
}else{
|
}else{
|
||||||
multipleSelection.value.forEach(item => {
|
multipleSelection.value.forEach(item => {
|
||||||
if (item.attributeCode) {
|
if (item.attributeCode) {
|
||||||
const attributeCodeLower = item.attributeCode.toLowerCase();
|
const attributeCodeLower = item.attributeCode.toLowerCase();
|
||||||
//if (!tableColumnMap.has(attributeCodeLower)) {
|
|
||||||
if(attributeCodeLower==='ipitchangle1'||attributeCodeLower==='ipitchangle2'||attributeCodeLower==='ipitchangle3'){
|
if(attributeCodeLower==='ipitchangle1'||attributeCodeLower==='ipitchangle2'||attributeCodeLower==='ipitchangle3'){
|
||||||
tableColumnEnds.value.push({
|
tableColumnEnds.value.push({
|
||||||
label: '变桨角度',
|
label: '变桨角度',
|
||||||
@ -523,14 +536,10 @@ const getTableData = () => {
|
|||||||
title: item.attributeName,
|
title: item.attributeName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
realtableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
deviceId.forEach((item,index) => {
|
deviceId.forEach((item,index) => {
|
||||||
objparms.deviceId=item
|
objparms.deviceId=item
|
||||||
objparms.attributes=multipleSelection.value.map((item) => item.attributeCode)
|
objparms.attributes=multipleSelection.value.map((item) => item.attributeCode)
|
||||||
@ -539,10 +548,8 @@ const getTableData = () => {
|
|||||||
getsnapshotData(snapshotParms).then((res) => {
|
getsnapshotData(snapshotParms).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const tsnapshotVoObject: any = res.data;
|
const tsnapshotVoObject: any = res.data;
|
||||||
//console.log(multipleSelection.value, tsnapshotVoObject, tableData.value, 'multipleSelection.valuemultipleSelection.value');
|
|
||||||
multipleSelection.value.map((item1: any) => {
|
multipleSelection.value.map((item1: any) => {
|
||||||
// const newItem: any = { };
|
tableData.value.forEach((item: any, i: number, arr: any) => {
|
||||||
realtableData.value.forEach((item: any, i: number, arr: any) => {
|
|
||||||
for (const itemKey in tsnapshotVoObject) {
|
for (const itemKey in tsnapshotVoObject) {
|
||||||
if (item.id === itemKey) {
|
if (item.id === itemKey) {
|
||||||
const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
||||||
@ -554,15 +561,29 @@ const getTableData = () => {
|
|||||||
}else{
|
}else{
|
||||||
ipitchanglevalue=ipitchangle1 !== undefined ? (ipitchangle1 % 1 === 0 ? ipitchangle1 : ipitchangle1.toFixed(3)) : '-';
|
ipitchanglevalue=ipitchangle1 !== undefined ? (ipitchangle1 % 1 === 0 ? ipitchangle1 : ipitchangle1.toFixed(3)) : '-';
|
||||||
}
|
}
|
||||||
// for (const rowKey in item) {
|
|
||||||
// if (attributeCodeLower == rowKey) {
|
|
||||||
// newItem[rowKey] = item[rowKey];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
const value = tsnapshotVoObject[itemKey]?.[attributeCodeLower];
|
const value = tsnapshotVoObject[itemKey]?.[attributeCodeLower];
|
||||||
const formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
|
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
|
||||||
//arr[i] = { code: item.code, [attributeCodeLower]: formattedValue,[ipitchangle]: ipitchanglevalue};
|
if (enumStore.keys.includes(item1.attributeCode)) {
|
||||||
|
formattedValue = enumStore.data[item1.attributeCode][formattedValue]
|
||||||
|
}
|
||||||
|
/*const newItem = {};
|
||||||
|
for (const key in item) {
|
||||||
|
if (item.hasOwnProperty(key)) {
|
||||||
|
//newItem[key] = item[key];
|
||||||
|
newItem['id'] = item['id'];
|
||||||
|
newItem['name'] = item['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newItem[attributeCodeLower] = formattedValue;*/
|
||||||
|
if(attributeCodeLower==='ipitchangle'||
|
||||||
|
attributeCodeLower==='ipitchangle1'||
|
||||||
|
attributeCodeLower==='ipitchangle2'||
|
||||||
|
attributeCodeLower==='ipitchangle3'){
|
||||||
arr[i] = { ...item, [attributeCodeLower]: formattedValue,[ipitchangle]: ipitchanglevalue};
|
arr[i] = { ...item, [attributeCodeLower]: formattedValue,[ipitchangle]: ipitchanglevalue};
|
||||||
|
}else{
|
||||||
|
arr[i] = { ...item, [attributeCodeLower]: formattedValue};
|
||||||
|
//arr[i]=newItem
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -580,9 +601,9 @@ const sureBtn = (done: () => void) => {
|
|||||||
getTableData()
|
getTableData()
|
||||||
visible.value = false
|
visible.value = false
|
||||||
}
|
}
|
||||||
const downFun=(tableColumn,realtableData)=>{
|
const downFun=(tableColumn,tableData)=>{
|
||||||
const itemsWithoutAge = realtableData.map(item => {
|
const itemsWithoutAge = tableData.map(item => {
|
||||||
const { id, belongLine, iotModelId, location,madeinFactory,model,name,nominalCapacity,objectType,parentEquipmentId,remarks,standard,...rest } = item;
|
const { id, ...rest } = item;
|
||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
let addobj = {}
|
let addobj = {}
|
||||||
@ -591,7 +612,6 @@ const downFun=(tableColumn,realtableData)=>{
|
|||||||
})
|
})
|
||||||
let tableDatadown = JSON.parse(JSON.stringify(itemsWithoutAge))
|
let tableDatadown = JSON.parse(JSON.stringify(itemsWithoutAge))
|
||||||
tableDatadown.unshift(addobj)
|
tableDatadown.unshift(addobj)
|
||||||
console.log(tableDatadown, 'tableDatadowntableDatadowntableDatadown')
|
|
||||||
let str = ``;
|
let str = ``;
|
||||||
for(let i = 0; i < tableDatadown.length; i++) {
|
for(let i = 0; i < tableDatadown.length; i++) {
|
||||||
for(let item in tableDatadown[i]) {
|
for(let item in tableDatadown[i]) {
|
||||||
@ -626,7 +646,7 @@ onMounted(() => {
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
$paginationHeight: 32px;
|
$paginationHeight: 32px;
|
||||||
.default-main {
|
.default-main {
|
||||||
width: 100%;
|
/* width: 100%;*/
|
||||||
height: 100%;
|
height: 100%;
|
||||||
.realConter {
|
.realConter {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
Loading…
Reference in New Issue
Block a user