riku
2025-03-25 642d31285d7aff59415a5eb37f87a79f41d308a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<template>
  <el-row align="top">
    <el-upload
      ref="upload"
      class="upload-file"
      :limit="1"
      :on-change="handleChange"
      :on-exceed="handleExceed"
      :auto-upload="false"
    >
      <template #trigger>
        <el-button type="primary">上传监测数据统计结果</el-button>
      </template>
    </el-upload>
    <el-text>{{ loadTxt }}</el-text>
  </el-row>
  <el-table
    ref="tableRef"
    :data="data"
    v-loading="loading"
    table-layout="fixed"
    :stripe="true"
    size="small"
    height="60vh"
    border
  >
    <el-table-column
      :show-overflow-tooltip="true"
      prop="drSceneName"
      label="名称"
      width="300"
    />
    <el-table-column prop="drDeviceCode" label="设备号" width="130" />
    <el-table-column prop="drTime" label="时间" width="100">
      <template #default="{ row }">
        <span>{{ $fm.formatYMD(row.drTime) }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="drExceedTimes" label="超标次数" />
    <el-table-column prop="drAvg" label="平均值" />
    <el-table-column prop="drMax" label="最大值" />
    <el-table-column prop="drMin" label="最小值" />
    <el-table-column prop="drOverAvgPer" label="超区均值百分比" />
    <el-table-column prop="drDataNum" label="数据量" />
    <el-table-column prop="drEffectiveRate" label="有效率" />
  </el-table>
</template>
<script setup>
import { ref, watch, onMounted } from 'vue';
import { genFileId } from 'element-plus';
import monitordataApi from '@/api/fysp/monitordataApi';
import * as XLSX from 'xlsx';
 
const props = defineProps({
  areaInfo: { type: Object }
});
 
let workbook;
const data = ref([]);
const upload = ref();
const loadTxt = ref('');
 
// 获取历史统计结果
function fetchDustDataResult() {
  monitordataApi.fetchDustDataResult(props.areaInfo).then((res) => {
    data.value = res.data;
  });
}
 
function handleExceed(files, uploadFiles) {
  upload.value.clearFiles();
  const file = files[0];
  file.uid = genFileId();
  upload.value.handleStart(file);
}
 
function handleChange(uploadFile, uploadFiles) {
  // console.log(uploadFile, uploadFiles);
  const fileReader = new FileReader();
  fileReader.onload = (file) => {
    const data = file.target.result;
    workbook = XLSX.read(data, { type: 'array' });
    console.log(workbook.SheetNames);
  };
  fileReader.readAsArrayBuffer(uploadFile.raw);
}
 
// 上传统计结果文档
function uploadFile() {}
 
onMounted(() => {
  fetchDustDataResult();
});
</script>
<style scoped>
.upload-file {
  /* background-color: aliceblue; */
  width: 300px;
  min-height: 60px;
}
 
:deep(.el-text) {
  align-self: auto;
}
</style>