联调准实时数据

This commit is contained in:
GGJ
2024-11-20 16:20:15 +08:00
parent 876c29bdaf
commit affaafea83
5 changed files with 207 additions and 15 deletions

View File

@@ -0,0 +1,66 @@
<template>
<div :style="{ height: height }">
<vxe-table height="auto" auto-resize :data="dataList" v-bind="defaultAttribute" :key="key">
<vxe-column v-for="item in column" :field="item.field" :title="item.title"></vxe-column>
< <!-- <vxe-column field="valueM" title=""></vxe-column> -->
</vxe-table>
</div>
</template>
<script setup lang='ts'>
import { mainHeight } from '@/utils/layout'
import { ref, reactive } from 'vue'
import { defaultAttribute } from '@/components/table/defaultAttribute'
const props = defineProps(['tableData'])
const height = mainHeight(325).height
const dataList = ref([])
const key: any = ref(0)
const column: any = ref([])
const setData = (data: any, targetType: any) => {
dataList.value = JSON.parse(JSON.stringify(data))
console.log("🚀 ~ setData ~ targetType:", targetType[0].code)
if (targetType[0].code == 'base_data') {
column.value = [
{ field: 'otherName', title: '名称', },
{ field: 'valueA', title: 'A相', },
{ field: 'valueB', title: 'B相', },
{ field: 'valueC', title: 'C相', },
]
} else if (targetType[0].code == 'other_data') {
let list: any = []
data.forEach((item: any, i: any) => {
if (i % 2 == 0) {
list.push(item)
} else {
list[list.length - 1].otherName1 = item.otherName
list[list.length - 1].valueM1 = item.valueM
}
})
dataList.value = JSON.parse(JSON.stringify(list))
column.value = [
{ field: 'otherName', title: '名称', },
{ field: 'valueM', title: '', },
{ field: 'otherName1', title: '名称', },
{ field: 'valueM1', title: '', },
]
} else {
column.value = [
{ field: 'otherName', title: '谐波次数', },
{ field: 'valueA', title: 'A相', },
{ field: 'valueB', title: 'B相', },
{ field: 'valueC', title: 'C相', },
]
}
key.value += 1
}
defineExpose({ setData })
</script>
<style lang="scss" scoped></style>