修改实时数据页面
This commit is contained in:
parent
6a7e2bf8b7
commit
242ae64da9
@ -7,7 +7,7 @@
|
||||
<div class="transferLeft">
|
||||
<div class="transferHeader">
|
||||
<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="140">状态量</el-radio>
|
||||
</el-radio-group>
|
||||
@ -16,8 +16,9 @@
|
||||
<el-table class="tablePart"
|
||||
ref="tableRef"
|
||||
:data="modalTbleData"
|
||||
@selectionChange="selectTable">
|
||||
<el-table-column type="selection" width="55" />
|
||||
@selectionChange="selectTable"
|
||||
: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="attributeCode" 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 {ElMessage} from 'element-plus'
|
||||
import {equipList,getModelAttributeList,getsnapshotData} from "/@/api/backend/realData/request.ts";
|
||||
import * as console from "console";
|
||||
|
||||
const tableData = ref()
|
||||
/*const tableItem0: any = {
|
||||
label: '风机列表',
|
||||
prop: 'code',
|
||||
align: 'center',
|
||||
}*/
|
||||
const tableItem0: any = [
|
||||
{
|
||||
label: '风机列表',
|
||||
@ -190,7 +185,7 @@ const tableColumn=ref(
|
||||
|
||||
const deviceList = ref()
|
||||
const tableList=ref()
|
||||
var modalTbleData=ref<any[]>([])
|
||||
const modalTbleData=ref<any[]>([])
|
||||
const devicelistData = reactive({
|
||||
objectType: 10002,
|
||||
})
|
||||
@ -210,12 +205,10 @@ const deviceQuery = (data: any) => {
|
||||
snapshotParms.push({...objparms})
|
||||
})
|
||||
getsnapshotData(snapshotParms).then((res) => {
|
||||
debugger
|
||||
if (res.code == 200) {
|
||||
const tsnapshotVoObject: any = res.data;
|
||||
const tsnapshotVoMap = new Map(Object.entries(tsnapshotVoObject));
|
||||
const updatedTableData = tableColumn.value.reduce((acc, item1) => {
|
||||
debugger
|
||||
acc.forEach((item, i) => {
|
||||
const itemKey = item.id;
|
||||
if (tsnapshotVoMap.has(itemKey)) {
|
||||
@ -265,7 +258,7 @@ const modelAttributeList=(data: any) =>{
|
||||
})
|
||||
}
|
||||
|
||||
const Statistic=ref(0)
|
||||
|
||||
|
||||
interface TableType {
|
||||
attributeCode:string
|
||||
@ -282,12 +275,26 @@ interface TableType {
|
||||
visible:number | null
|
||||
|
||||
}
|
||||
|
||||
const tableRef=ref()
|
||||
const multipleSelection = ref<TableType[]>([])
|
||||
const selectTable = (selected: TableType[]) => {
|
||||
Statistic.value=selected.length
|
||||
multipleSelection.value =selected
|
||||
selectpageTotal.value=selected.length
|
||||
const Statistic = computed(() => multipleSelection.value.length)
|
||||
const selectTable = (selected: TableType[] | null) => {
|
||||
if (!selected) {
|
||||
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) => {
|
||||
if (index > 0) {
|
||||
const temp = multipleSelection.value[index];
|
||||
@ -308,12 +315,13 @@ const moveDown = (index:number) => {
|
||||
const clearList=() => {
|
||||
Statistic.value=0
|
||||
multipleSelection.value = [];
|
||||
tableRef.value.clearSelection()
|
||||
queryListData.iotModelId=iotModelId.value
|
||||
queryListData.attributeType=radioActiveName.value
|
||||
modelAttributeList(queryListData)
|
||||
}
|
||||
const handleradioClose=() => {
|
||||
multipleSelection.value = [];
|
||||
const handleradioChange=() => {
|
||||
//multipleSelection.value = [];
|
||||
queryListData.iotModelId=iotModelId.value
|
||||
queryListData.attributeType=radioActiveName.value
|
||||
modelAttributeList(queryListData)
|
||||
@ -366,13 +374,7 @@ const selecthandleCurrentChange = (val: number) => {
|
||||
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) => {
|
||||
visible.value = false
|
||||
@ -388,26 +390,38 @@ const objparms = reactive({
|
||||
const getTableData = () => {
|
||||
const deviceId=deviceList.value.map((item) => item.id);
|
||||
const tableColumnEnds = ref([]);
|
||||
const tableColumnup = ref([]);
|
||||
const tableColumnMap = new Map();
|
||||
tableColumn.value.forEach(item1 => {
|
||||
if (item1.prop) {
|
||||
tableColumnMap.set(item1.prop, item1);
|
||||
tableColumnup.value.push({
|
||||
label: item1.label,
|
||||
prop: item1.prop,
|
||||
align: 'center',
|
||||
});
|
||||
}
|
||||
});
|
||||
multipleSelection.value.forEach(item => {
|
||||
if (item.attributeCode) {
|
||||
const attributeCodeLower = item.attributeCode.toLowerCase();
|
||||
if (!tableColumnMap.has(attributeCodeLower)) {
|
||||
tableColumnEnds.value.push({
|
||||
label: item.attributeName,
|
||||
prop: attributeCodeLower,
|
||||
align: 'center',
|
||||
});
|
||||
if(multipleSelection.value.length === 0){
|
||||
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
}else{
|
||||
multipleSelection.value.forEach(item => {
|
||||
if (item.attributeCode) {
|
||||
const attributeCodeLower = item.attributeCode.toLowerCase();
|
||||
if (!tableColumnMap.has(attributeCodeLower)) {
|
||||
tableColumnEnds.value.push({
|
||||
label: item.attributeName+'\n'+item.unit,
|
||||
prop: attributeCodeLower,
|
||||
align: 'center',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
tableColumn.value = [...tableColumnup.value, ...tableColumnEnds.value];
|
||||
}
|
||||
|
||||
tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
|
||||
//tableColumn.value = [...tableItem0, ...tableColumnEnds.value];
|
||||
deviceId.forEach((item,index) => {
|
||||
objparms.deviceId=item
|
||||
objparms.attributes=multipleSelection.value.map((item) => item.attributeCode)
|
||||
@ -416,36 +430,8 @@ const getTableData = () => {
|
||||
getsnapshotData(snapshotParms).then((res) => {
|
||||
if (res.code == 200) {
|
||||
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) => {
|
||||
tableData.value.forEach((item: any, i: number, arr: any) => {
|
||||
debugger
|
||||
for (const itemKey in tsnapshotVoObject) {
|
||||
if (item.id === itemKey) {
|
||||
const attributeCodeLower = item1.attributeCode?.toLowerCase();
|
||||
@ -483,9 +469,11 @@ const downFun=(tableColumn,tableData)=>{
|
||||
let str = ``;
|
||||
for(let i = 0; i < tableDatadown.length; i++) {
|
||||
for(let item in tableDatadown[i]) {
|
||||
// 2.5.1 注意要将本身就有换行或者英文逗号的内容进行变换 否则表格内容会错乱
|
||||
//tableDatadown[i][item] = tableDatadown[i][item].replace(/\n/g, ' ')
|
||||
//tableDatadown[i][item] = tableDatadown[i][item].replace(/,/g, ',') // 英文替换为中文
|
||||
if (typeof tableDatadown[i][item] === 'string') {
|
||||
tableDatadown[i][item] = tableDatadown[i][item].replace(/[\n,]/g, match => match === '\n' ? ' ' : ',');
|
||||
} else {
|
||||
console.warn(`tableDatadown[${i}][${item}] is not a string`);
|
||||
}
|
||||
str += `${tableDatadown[i][item] + '\t'},`;
|
||||
}
|
||||
str += '\n';
|
||||
|
Loading…
Reference in New Issue
Block a user