1.设备监测 接口对接
2.环境监测 平均数据 前台页面开发
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
<template>
|
||||
<a-table :columns="columns" :data-source="data" bordered />
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="data"
|
||||
bordered
|
||||
style="width: 100%"
|
||||
:scroll="{ x: 2000 }" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -7,14 +12,14 @@
|
||||
import type { TableColumnType } from 'ant-design-vue';
|
||||
import { inject } from 'vue';
|
||||
|
||||
// let data: any[] = [];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EnvironmentTable',
|
||||
setup() {
|
||||
let data = ref<any[]>([]);
|
||||
let columns = ref<TableColumnType[]>([]);
|
||||
|
||||
let index = ref(0);
|
||||
|
||||
interface PageData {
|
||||
tableList: any[];
|
||||
tableColumns: any[];
|
||||
@@ -29,13 +34,14 @@
|
||||
watch(
|
||||
() => pageData as PageData,
|
||||
(_newValue, _oldValue) => {
|
||||
data.value = pageData.tableList;
|
||||
// data.value = pageData.tableList;
|
||||
|
||||
let columnA: any[] = [...column];
|
||||
columnA.push(...pageData.tableColumns);
|
||||
columns.value = columnA;
|
||||
// pageData.graphList;
|
||||
// 执行你的逻辑代码
|
||||
// let columnA: any[] = [...column];
|
||||
// columnA.push(...pageData.tableColumns);
|
||||
// columns.value = columnA;
|
||||
// // pageData.graphList;
|
||||
// // 执行你的逻辑代码
|
||||
init();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
@@ -62,7 +68,13 @@
|
||||
const column: TableColumnType[] = [
|
||||
{
|
||||
title: '序号',
|
||||
dataIndex: 'key',
|
||||
customRender: ({ record, index }) => {
|
||||
// 自定义单元格内容,这里返回序号
|
||||
if (index == 0 || data.value[index - 1].deviceName == record.deviceName) {
|
||||
return index + 1;
|
||||
}
|
||||
return index;
|
||||
},
|
||||
customCell: (record, rowIndex) => {
|
||||
if (rowIndex == undefined) {
|
||||
return {
|
||||
@@ -70,8 +82,8 @@
|
||||
colSpan: 0,
|
||||
};
|
||||
}
|
||||
const rowSpan = getRowSpan('name', record, data.value);
|
||||
if (rowIndex != 0 && data.value[rowIndex - 1].key == record.key) {
|
||||
const rowSpan = getRowSpan('deviceName', record, data.value);
|
||||
if (rowIndex != 0 && data.value[rowIndex - 1].deviceName == record.deviceName) {
|
||||
return {
|
||||
rowSpan: 0,
|
||||
colSpan: 0,
|
||||
@@ -82,9 +94,16 @@
|
||||
};
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: '序号',
|
||||
// customRender: (text: any) => {
|
||||
// index.value += 1;
|
||||
// return index.value;
|
||||
// },
|
||||
// },
|
||||
{
|
||||
title: '设备名称',
|
||||
dataIndex: 'name',
|
||||
dataIndex: 'deviceName',
|
||||
customCell: (record, rowIndex) => {
|
||||
if (rowIndex == undefined) {
|
||||
return {
|
||||
@@ -92,8 +111,8 @@
|
||||
colSpan: 0,
|
||||
};
|
||||
}
|
||||
const rowSpan = getRowSpan('name', record, data.value);
|
||||
if (rowIndex != 0 && data.value[rowIndex - 1].name == record.name) {
|
||||
const rowSpan = getRowSpan('deviceName', record, data.value);
|
||||
if (rowIndex != 0 && data.value[rowIndex - 1].deviceName == record.deviceName) {
|
||||
return {
|
||||
rowSpan: 0,
|
||||
colSpan: 0,
|
||||
@@ -106,7 +125,7 @@
|
||||
},
|
||||
{
|
||||
title: '设备点位',
|
||||
dataIndex: 'position',
|
||||
dataIndex: 'devicePositionName',
|
||||
customCell: (record, rowIndex) => {
|
||||
if (rowIndex == undefined) {
|
||||
return {
|
||||
@@ -114,11 +133,11 @@
|
||||
colSpan: 0,
|
||||
};
|
||||
}
|
||||
const rowSpan = getRowSpan('position', record, data.value, ['name']);
|
||||
const rowSpan = getRowSpan('devicePositionName', record, data.value, ['deviceName']);
|
||||
if (
|
||||
rowIndex != 0 &&
|
||||
data.value[rowIndex - 1].name == record.name &&
|
||||
data.value[rowIndex - 1].position == record.position
|
||||
data.value[rowIndex - 1].deviceName == record.deviceName &&
|
||||
data.value[rowIndex - 1].devicePositionName == record.devicePositionName
|
||||
) {
|
||||
return {
|
||||
rowSpan: 0,
|
||||
@@ -132,7 +151,7 @@
|
||||
},
|
||||
{
|
||||
title: '计量单位',
|
||||
dataIndex: 'unit',
|
||||
dataIndex: 'devicePositionUnit',
|
||||
customCell: (record, rowIndex) => {
|
||||
if (rowIndex == undefined) {
|
||||
return {
|
||||
@@ -140,12 +159,15 @@
|
||||
colSpan: 0,
|
||||
};
|
||||
}
|
||||
const rowSpan = getRowSpan('unit', record, data.value, ['name', 'position']);
|
||||
const rowSpan = getRowSpan('devicePositionUnit', record, data.value, [
|
||||
'deviceName',
|
||||
'devicePositionName',
|
||||
]);
|
||||
if (
|
||||
rowIndex != 0 &&
|
||||
data.value[rowIndex - 1].name == record.name &&
|
||||
data.value[rowIndex - 1].position == record.position &&
|
||||
data.value[rowIndex - 1].unit == record.unit
|
||||
data.value[rowIndex - 1].deviceName == record.deviceName &&
|
||||
data.value[rowIndex - 1].devicePositionName == record.devicePositionName &&
|
||||
data.value[rowIndex - 1].devicePositionUnit == record.devicePositionUnit
|
||||
) {
|
||||
return {
|
||||
rowSpan: 0,
|
||||
@@ -157,14 +179,26 @@
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
dataIndex: 'time',
|
||||
},
|
||||
];
|
||||
|
||||
onMounted(() => {
|
||||
const init = () => {
|
||||
index.value = 0;
|
||||
data.value = pageData.tableList;
|
||||
|
||||
let columnA: any[] = [...column];
|
||||
columnA.push(...pageData.tableColumns);
|
||||
let columnB: any[] = [];
|
||||
pageData.tableColumns.forEach((item) => {
|
||||
columnB.push({ title: item, dataIndex: item });
|
||||
});
|
||||
columnA.push(...columnB);
|
||||
columns.value = columnA;
|
||||
};
|
||||
onMounted(() => {
|
||||
init();
|
||||
});
|
||||
return {
|
||||
data,
|
||||
|
Reference in New Issue
Block a user