实时数据:修改枚举类值
This commit is contained in:
parent
805f0d1906
commit
c89764d22d
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<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-col :span="14">
|
||||
<div class="transferLeft">
|
||||
@ -88,7 +87,7 @@
|
||||
<div class="realConter">
|
||||
<div class="header">
|
||||
<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">
|
||||
<span>自动更新:</span>
|
||||
<el-switch
|
||||
@ -99,8 +98,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="realTable">
|
||||
<el-table height="100%" :data="realtableData">
|
||||
<template v-for="item in realtableColumn">
|
||||
<el-table height="100%" :data="tableData">
|
||||
<template v-for="item in tableColumn">
|
||||
<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 === '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 {ElMessage} from 'element-plus'
|
||||
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 = [
|
||||
{
|
||||
label: '风机列表',
|
||||
unit:' ',
|
||||
prop: 'code',
|
||||
prop: 'name',
|
||||
align: 'center',
|
||||
custom: 'default',
|
||||
name:'',
|
||||
name:'name',
|
||||
title: '风机列表'
|
||||
}]
|
||||
const tableItem1: any = [
|
||||
@ -221,7 +223,7 @@ const tableItem1: any = [
|
||||
title: '变桨角度'
|
||||
}
|
||||
]
|
||||
const realtableColumn=ref(
|
||||
const tableColumn=ref(
|
||||
[...tableItem0,...tableItem1]
|
||||
)
|
||||
|
||||
@ -235,10 +237,23 @@ const objectType= ref(10002);
|
||||
const iotModelId=ref()
|
||||
const radioActiveName=ref('138')
|
||||
const selectedIndex=ref(0)
|
||||
|
||||
const newtableData=ref()
|
||||
const deviceQuery = (data: any) => {
|
||||
equipList(data).then((res) => {
|
||||
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
|
||||
defaultdeviceQuery()
|
||||
})
|
||||
@ -248,7 +263,7 @@ const defaultdeviceQuery = () => {
|
||||
let attributesCode:any[]=[]
|
||||
deviceId.forEach((item,index) => {
|
||||
objparms.deviceId=item
|
||||
attributesCode=realtableColumn.value.map((item1)=>item1.prop)
|
||||
attributesCode=tableColumn.value.map((item1)=>item1.prop)
|
||||
attributesCode.push('iPitchAngle1','iPitchAngle2', 'iPitchAngle3')
|
||||
objparms.attributes=attributesCode
|
||||
snapshotParms.push({...objparms})
|
||||
@ -257,14 +272,14 @@ const defaultdeviceQuery = () => {
|
||||
if (res.code == 200) {
|
||||
const tsnapshotVoObject: any = res.data;
|
||||
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) => {
|
||||
const itemKey = item.id;
|
||||
if (tsnapshotVoMap.has(itemKey)) {
|
||||
const tsnapshotVoItem = tsnapshotVoMap.get(itemKey);
|
||||
//const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
||||
const attributeCodeLower = item1.prop;
|
||||
if(attributeCodeLower!='code'){
|
||||
if(attributeCodeLower!='name'){
|
||||
if (attributeCodeLower) {
|
||||
const ipitchangle=Math.min(tsnapshotVoItem.ipitchangle1, tsnapshotVoItem.ipitchangle2, tsnapshotVoItem.ipitchangle3)
|
||||
let ipitchanglevalue;
|
||||
@ -282,9 +297,8 @@ const defaultdeviceQuery = () => {
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}, [...realtableData.value]);
|
||||
realtableData.value = updatedTableData;
|
||||
debugger;
|
||||
}, [...tableData.value]);
|
||||
tableData.value = updatedTableData;
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
@ -334,12 +348,11 @@ interface TableType {
|
||||
|
||||
const selectList=ref([])
|
||||
const getSel = () => {
|
||||
debugger
|
||||
selectList.value=[]
|
||||
try {
|
||||
if (realtableColumn.value && Array.isArray(realtableColumn.value)) {
|
||||
for (const item of realtableColumn.value) {
|
||||
if (item && item.prop && item.prop !== 'code') {
|
||||
if (tableColumn.value && Array.isArray(tableColumn.value)) {
|
||||
for (const item of tableColumn.value) {
|
||||
if (item && item.prop && item.prop !== 'name') {
|
||||
if(item.title!==undefined){
|
||||
selectList.value.push({
|
||||
attributeName: item.title || '',
|
||||
@ -426,6 +439,7 @@ const clearList=() => {
|
||||
Statistic.value=0
|
||||
multipleSelection.value = [];
|
||||
RealtableRef.value.clearSelection()
|
||||
//tableData.value=[]
|
||||
queryListData.iotModelId=iotModelId.value
|
||||
queryListData.attributeType=radioActiveName.value
|
||||
modelAttributeList(queryListData)
|
||||
@ -496,12 +510,11 @@ const getTableData = () => {
|
||||
const deviceId=deviceList.value.map((item) => item.id);
|
||||
const tableColumnEnds = ref([]);
|
||||
if(multipleSelection.value.length === 0){
|
||||
realtableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
}else{
|
||||
multipleSelection.value.forEach(item => {
|
||||
if (item.attributeCode) {
|
||||
const attributeCodeLower = item.attributeCode.toLowerCase();
|
||||
//if (!tableColumnMap.has(attributeCodeLower)) {
|
||||
if(attributeCodeLower==='ipitchangle1'||attributeCodeLower==='ipitchangle2'||attributeCodeLower==='ipitchangle3'){
|
||||
tableColumnEnds.value.push({
|
||||
label: '变桨角度',
|
||||
@ -523,14 +536,10 @@ const getTableData = () => {
|
||||
title: item.attributeName,
|
||||
});
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
});
|
||||
realtableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
}
|
||||
|
||||
|
||||
deviceId.forEach((item,index) => {
|
||||
objparms.deviceId=item
|
||||
objparms.attributes=multipleSelection.value.map((item) => item.attributeCode)
|
||||
@ -539,10 +548,8 @@ const getTableData = () => {
|
||||
getsnapshotData(snapshotParms).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const tsnapshotVoObject: any = res.data;
|
||||
//console.log(multipleSelection.value, tsnapshotVoObject, tableData.value, 'multipleSelection.valuemultipleSelection.value');
|
||||
multipleSelection.value.map((item1: any) => {
|
||||
// const newItem: any = { };
|
||||
realtableData.value.forEach((item: any, i: number, arr: any) => {
|
||||
tableData.value.forEach((item: any, i: number, arr: any) => {
|
||||
for (const itemKey in tsnapshotVoObject) {
|
||||
if (item.id === itemKey) {
|
||||
const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
||||
@ -554,15 +561,29 @@ const getTableData = () => {
|
||||
}else{
|
||||
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 formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
|
||||
//arr[i] = { code: item.code, [attributeCodeLower]: formattedValue,[ipitchangle]: ipitchanglevalue};
|
||||
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
|
||||
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};
|
||||
}else{
|
||||
arr[i] = { ...item, [attributeCodeLower]: formattedValue};
|
||||
//arr[i]=newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -580,9 +601,9 @@ const sureBtn = (done: () => void) => {
|
||||
getTableData()
|
||||
visible.value = false
|
||||
}
|
||||
const downFun=(tableColumn,realtableData)=>{
|
||||
const itemsWithoutAge = realtableData.map(item => {
|
||||
const { id, belongLine, iotModelId, location,madeinFactory,model,name,nominalCapacity,objectType,parentEquipmentId,remarks,standard,...rest } = item;
|
||||
const downFun=(tableColumn,tableData)=>{
|
||||
const itemsWithoutAge = tableData.map(item => {
|
||||
const { id, ...rest } = item;
|
||||
return rest;
|
||||
});
|
||||
let addobj = {}
|
||||
@ -591,7 +612,6 @@ const downFun=(tableColumn,realtableData)=>{
|
||||
})
|
||||
let tableDatadown = JSON.parse(JSON.stringify(itemsWithoutAge))
|
||||
tableDatadown.unshift(addobj)
|
||||
console.log(tableDatadown, 'tableDatadowntableDatadowntableDatadown')
|
||||
let str = ``;
|
||||
for(let i = 0; i < tableDatadown.length; i++) {
|
||||
for(let item in tableDatadown[i]) {
|
||||
@ -626,7 +646,7 @@ onMounted(() => {
|
||||
<style scoped lang="scss">
|
||||
$paginationHeight: 32px;
|
||||
.default-main {
|
||||
width: 100%;
|
||||
/* width: 100%;*/
|
||||
height: 100%;
|
||||
.realConter {
|
||||
width: 100%;
|
||||
|
Loading…
Reference in New Issue
Block a user