修改实时数据页面
This commit is contained in:
parent
6a7e2bf8b7
commit
242ae64da9
@ -7,7 +7,7 @@
|
|||||||
<div class="transferLeft">
|
<div class="transferLeft">
|
||||||
<div class="transferHeader">
|
<div class="transferHeader">
|
||||||
<span class="transferTitle">可添加的测点</span>
|
<span class="transferTitle">可添加的测点</span>
|
||||||
<el-radio-group v-model="radioActiveName" @change="handleradioClose">
|
<el-radio-group v-model="radioActiveName" @change="handleradioChange">
|
||||||
<el-radio value="138">模拟量</el-radio>
|
<el-radio value="138">模拟量</el-radio>
|
||||||
<el-radio value="140">状态量</el-radio>
|
<el-radio value="140">状态量</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
@ -16,8 +16,9 @@
|
|||||||
<el-table class="tablePart"
|
<el-table class="tablePart"
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data="modalTbleData"
|
:data="modalTbleData"
|
||||||
@selectionChange="selectTable">
|
@selectionChange="selectTable"
|
||||||
<el-table-column type="selection" width="55" />
|
:row-key="getRowKey">
|
||||||
|
<el-table-column type="selection" width="55" :reserve-selection="true"/>
|
||||||
<el-table-column prop="porder" label="序号" width="60" />
|
<el-table-column prop="porder" label="序号" width="60" />
|
||||||
<el-table-column prop="attributeCode" sortable label="名称" />
|
<el-table-column prop="attributeCode" sortable label="名称" />
|
||||||
<el-table-column prop="attributeName" sortable label="描述" />
|
<el-table-column prop="attributeName" sortable label="描述" />
|
||||||
@ -111,14 +112,8 @@ import {Crop,Download,Top,Bottom} from '@element-plus/icons-vue'
|
|||||||
import {onMounted, onUnmounted, reactive, ref, watch,computed} from 'vue'
|
import {onMounted, onUnmounted, reactive, ref, watch,computed} 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 * as console from "console";
|
|
||||||
|
|
||||||
const tableData = ref()
|
const tableData = ref()
|
||||||
/*const tableItem0: any = {
|
|
||||||
label: '风机列表',
|
|
||||||
prop: 'code',
|
|
||||||
align: 'center',
|
|
||||||
}*/
|
|
||||||
const tableItem0: any = [
|
const tableItem0: any = [
|
||||||
{
|
{
|
||||||
label: '风机列表',
|
label: '风机列表',
|
||||||
@ -190,7 +185,7 @@ const tableColumn=ref(
|
|||||||
|
|
||||||
const deviceList = ref()
|
const deviceList = ref()
|
||||||
const tableList=ref()
|
const tableList=ref()
|
||||||
var modalTbleData=ref<any[]>([])
|
const modalTbleData=ref<any[]>([])
|
||||||
const devicelistData = reactive({
|
const devicelistData = reactive({
|
||||||
objectType: 10002,
|
objectType: 10002,
|
||||||
})
|
})
|
||||||
@ -210,12 +205,10 @@ const deviceQuery = (data: any) => {
|
|||||||
snapshotParms.push({...objparms})
|
snapshotParms.push({...objparms})
|
||||||
})
|
})
|
||||||
getsnapshotData(snapshotParms).then((res) => {
|
getsnapshotData(snapshotParms).then((res) => {
|
||||||
debugger
|
|
||||||
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 = tableColumn.value.reduce((acc, item1) => {
|
const updatedTableData = tableColumn.value.reduce((acc, item1) => {
|
||||||
debugger
|
|
||||||
acc.forEach((item, i) => {
|
acc.forEach((item, i) => {
|
||||||
const itemKey = item.id;
|
const itemKey = item.id;
|
||||||
if (tsnapshotVoMap.has(itemKey)) {
|
if (tsnapshotVoMap.has(itemKey)) {
|
||||||
@ -265,7 +258,7 @@ const modelAttributeList=(data: any) =>{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const Statistic=ref(0)
|
|
||||||
|
|
||||||
interface TableType {
|
interface TableType {
|
||||||
attributeCode:string
|
attributeCode:string
|
||||||
@ -282,12 +275,26 @@ interface TableType {
|
|||||||
visible:number | null
|
visible:number | null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tableRef=ref()
|
||||||
const multipleSelection = ref<TableType[]>([])
|
const multipleSelection = ref<TableType[]>([])
|
||||||
const selectTable = (selected: TableType[]) => {
|
const Statistic = computed(() => multipleSelection.value.length)
|
||||||
Statistic.value=selected.length
|
const selectTable = (selected: TableType[] | null) => {
|
||||||
multipleSelection.value =selected
|
if (!selected) {
|
||||||
selectpageTotal.value=selected.length
|
console.error('Selected is null or undefined')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
multipleSelection.value = selected
|
||||||
|
}
|
||||||
|
const getRowKey = (row) => row.id;
|
||||||
|
const visible = ref(false)
|
||||||
|
const openMeasure=() =>{
|
||||||
|
visible.value=true
|
||||||
|
queryListData.iotModelId=iotModelId.value
|
||||||
|
queryListData.attributeType=radioActiveName.value
|
||||||
|
modelAttributeList(queryListData)
|
||||||
|
}
|
||||||
|
|
||||||
const moveUp = (index:number) => {
|
const moveUp = (index:number) => {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
const temp = multipleSelection.value[index];
|
const temp = multipleSelection.value[index];
|
||||||
@ -308,12 +315,13 @@ const moveDown = (index:number) => {
|
|||||||
const clearList=() => {
|
const clearList=() => {
|
||||||
Statistic.value=0
|
Statistic.value=0
|
||||||
multipleSelection.value = [];
|
multipleSelection.value = [];
|
||||||
|
tableRef.value.clearSelection()
|
||||||
queryListData.iotModelId=iotModelId.value
|
queryListData.iotModelId=iotModelId.value
|
||||||
queryListData.attributeType=radioActiveName.value
|
queryListData.attributeType=radioActiveName.value
|
||||||
modelAttributeList(queryListData)
|
modelAttributeList(queryListData)
|
||||||
}
|
}
|
||||||
const handleradioClose=() => {
|
const handleradioChange=() => {
|
||||||
multipleSelection.value = [];
|
//multipleSelection.value = [];
|
||||||
queryListData.iotModelId=iotModelId.value
|
queryListData.iotModelId=iotModelId.value
|
||||||
queryListData.attributeType=radioActiveName.value
|
queryListData.attributeType=radioActiveName.value
|
||||||
modelAttributeList(queryListData)
|
modelAttributeList(queryListData)
|
||||||
@ -366,13 +374,7 @@ const selecthandleCurrentChange = (val: number) => {
|
|||||||
modelAttributeList(queryListData)*/
|
modelAttributeList(queryListData)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const visible = ref(false)
|
|
||||||
const openMeasure=() =>{
|
|
||||||
visible.value=true
|
|
||||||
queryListData.iotModelId=iotModelId.value
|
|
||||||
queryListData.attributeType=radioActiveName.value
|
|
||||||
modelAttributeList(queryListData)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleClose = (done: () => void) => {
|
const handleClose = (done: () => void) => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
@ -388,26 +390,38 @@ const objparms = reactive({
|
|||||||
const getTableData = () => {
|
const getTableData = () => {
|
||||||
const deviceId=deviceList.value.map((item) => item.id);
|
const deviceId=deviceList.value.map((item) => item.id);
|
||||||
const tableColumnEnds = ref([]);
|
const tableColumnEnds = ref([]);
|
||||||
|
const tableColumnup = ref([]);
|
||||||
const tableColumnMap = new Map();
|
const tableColumnMap = new Map();
|
||||||
tableColumn.value.forEach(item1 => {
|
tableColumn.value.forEach(item1 => {
|
||||||
if (item1.prop) {
|
if (item1.prop) {
|
||||||
tableColumnMap.set(item1.prop, item1);
|
tableColumnMap.set(item1.prop, item1);
|
||||||
|
tableColumnup.value.push({
|
||||||
|
label: item1.label,
|
||||||
|
prop: item1.prop,
|
||||||
|
align: 'center',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if(multipleSelection.value.length === 0){
|
||||||
|
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||||
|
}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 (!tableColumnMap.has(attributeCodeLower)) {
|
||||||
tableColumnEnds.value.push({
|
tableColumnEnds.value.push({
|
||||||
label: item.attributeName,
|
label: item.attributeName+'\n'+item.unit,
|
||||||
prop: attributeCodeLower,
|
prop: attributeCodeLower,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
tableColumn.value = [...tableColumnup.value, ...tableColumnEnds.value];
|
||||||
|
}
|
||||||
|
|
||||||
tableColumn.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)
|
||||||
@ -416,36 +430,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;
|
||||||
/* const validatedSelections = multipleSelection.value.filter(item => typeof item === 'object' && item !== null);
|
|
||||||
const validatedTableItems = tableData.value.filter(item => typeof item === 'object' && item !== null);
|
|
||||||
|
|
||||||
const attributeCodeMap = new Map();
|
|
||||||
validatedSelections.forEach(selectionItem => {
|
|
||||||
if (selectionItem.attributeCode) {
|
|
||||||
attributeCodeMap.set(selectionItem.id, selectionItem.attributeCode.toLowerCase());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
validatedTableItems.forEach((tableItem: any, index: number, tableArray: any) => {
|
|
||||||
try {
|
|
||||||
debugger
|
|
||||||
for (const key in tsnapshotVoObject) {
|
|
||||||
if (tableItem.id === key) {
|
|
||||||
const attributeCodeLower = attributeCodeMap.get(key);
|
|
||||||
if (attributeCodeLower) {
|
|
||||||
const value = tsnapshotVoObject[key]?.[attributeCodeLower];
|
|
||||||
const formattedValue = value ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
|
|
||||||
tableArray[index] = { ...tableItem, [attributeCodeLower]: formattedValue };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error processing data:', error);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
multipleSelection.value.map((item1: any) => {
|
multipleSelection.value.map((item1: any) => {
|
||||||
tableData.value.forEach((item: any, i: number, arr: any) => {
|
tableData.value.forEach((item: any, i: number, arr: any) => {
|
||||||
debugger
|
|
||||||
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();
|
||||||
@ -483,9 +469,11 @@ const downFun=(tableColumn,tableData)=>{
|
|||||||
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]) {
|
||||||
// 2.5.1 注意要将本身就有换行或者英文逗号的内容进行变换 否则表格内容会错乱
|
if (typeof tableDatadown[i][item] === 'string') {
|
||||||
//tableDatadown[i][item] = tableDatadown[i][item].replace(/\n/g, ' ')
|
tableDatadown[i][item] = tableDatadown[i][item].replace(/[\n,]/g, match => match === '\n' ? ' ' : ',');
|
||||||
//tableDatadown[i][item] = tableDatadown[i][item].replace(/,/g, ',') // 英文替换为中文
|
} else {
|
||||||
|
console.warn(`tableDatadown[${i}][${item}] is not a string`);
|
||||||
|
}
|
||||||
str += `${tableDatadown[i][item] + '\t'},`;
|
str += `${tableDatadown[i][item] + '\t'},`;
|
||||||
}
|
}
|
||||||
str += '\n';
|
str += '\n';
|
||||||
|
Loading…
Reference in New Issue
Block a user