1.对接能耗监测接口
2.对接设备监测接口 3.修改设备监测表格序号列显示错误的bug
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
<template>
|
||||
<a-table :columns="columns" :data-source="data" bordered />
|
||||
<a-table
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:data-source="data"
|
||||
bordered
|
||||
:row-selection="rowSelection">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.title === '操作'">
|
||||
<a-button type="link" @click="setStandard(record)" v-if="record.id != selectedKey[0]"
|
||||
>设为目标值</a-button
|
||||
>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -8,25 +21,35 @@
|
||||
export default defineComponent({
|
||||
name: 'AnalysisTable',
|
||||
setup() {
|
||||
const selectedKey = ref([]);
|
||||
const rowSelection = {
|
||||
type: 'radio',
|
||||
|
||||
selectedRowKeys: selectedKey,
|
||||
// onChange: (selectedRowKeys: string[]) => {
|
||||
// selectedKey.value = selectedRowKeys;
|
||||
// debugger;
|
||||
// },
|
||||
};
|
||||
const columns = [
|
||||
{
|
||||
title: '设备/节点',
|
||||
dataIndex: 'key',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '统计值',
|
||||
dataIndex: 'name',
|
||||
dataIndex: 'value',
|
||||
},
|
||||
{
|
||||
title: '同比',
|
||||
children: [
|
||||
{
|
||||
title: '△差值',
|
||||
dataIndex: 'position',
|
||||
dataIndex: 'yoyDiff',
|
||||
},
|
||||
{
|
||||
title: '增长率',
|
||||
dataIndex: 'unit',
|
||||
dataIndex: 'yoyRate',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -35,11 +58,11 @@
|
||||
children: [
|
||||
{
|
||||
title: '△差值',
|
||||
dataIndex: 'position',
|
||||
dataIndex: 'momDiff',
|
||||
},
|
||||
{
|
||||
title: '增长率',
|
||||
dataIndex: 'unit',
|
||||
dataIndex: 'momRate',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -48,18 +71,18 @@
|
||||
children: [
|
||||
{
|
||||
title: '△差值',
|
||||
dataIndex: 'position',
|
||||
dataIndex: 'zongxiangDiff',
|
||||
},
|
||||
{
|
||||
title: '增长率',
|
||||
dataIndex: 'unit',
|
||||
dataIndex: 'zongxiangRate',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'date',
|
||||
// dataIndex: 'date',
|
||||
},
|
||||
];
|
||||
let data = ref<any[]>([]);
|
||||
@@ -85,16 +108,45 @@
|
||||
watch(
|
||||
() => pageData as PageData,
|
||||
(_newValue, _oldValue) => {
|
||||
data.value = pageData.analysisTableList;
|
||||
// 深度拷贝
|
||||
data.value = JSON.parse(JSON.stringify(pageData.analysisTableList));
|
||||
setStandard(data.value[0]);
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
onMounted(() => {
|
||||
data.value = pageData.analysisTableList;
|
||||
// 深度拷贝
|
||||
data.value = JSON.parse(JSON.stringify(pageData.analysisTableList));
|
||||
// selectedKey.value = [data.value[0]];
|
||||
setStandard(data.value[0]);
|
||||
});
|
||||
const setStandard = (record: any) => {
|
||||
selectedKey.value = [record.id];
|
||||
data.value.forEach((item) => {
|
||||
// id: 'HLlmTZp8_0805_0001';
|
||||
// momDiff: 38.28; 环比差值
|
||||
// momRate: '-171.58%'; 环比率
|
||||
// momValue: -22.31; 环比值
|
||||
// name: '总电表';
|
||||
// value: 10.56; 值
|
||||
// yoyDiff: 38.28; 同比差值
|
||||
// yoyRate: '-138.10%'; 同比率
|
||||
// yoyValue: -27.72; 同比值
|
||||
if (item.id == record.id) {
|
||||
item.zongxiangDiff = '——';
|
||||
item.zongxiangRate = '——';
|
||||
} else {
|
||||
item.zongxiangDiff = (item.value - record.value).toFixed(2);
|
||||
item.zongxiangRate = ((item.zongxiangDiff / record.value) * 100).toFixed(2) + '%';
|
||||
}
|
||||
});
|
||||
};
|
||||
return {
|
||||
data,
|
||||
columns,
|
||||
rowSelection,
|
||||
selectedKey,
|
||||
setStandard,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user