1. 新增 监控中心 - 环境监测 - 历史数据 导出功能

2. 新增 监控中心 - 环境监测 - 平均数据 导出功能
3. 修改 分组管理 左侧树图表
This commit is contained in:
fks-yangshouda
2024-08-28 17:38:27 +08:00
parent 06e0ec7425
commit ce97741978
6 changed files with 242 additions and 296 deletions

View File

@@ -38,7 +38,10 @@
查询
</a-button>
</div>
<a-button type="primary" style="position: absolute; right: 40px; top: -45px">
<a-button
type="primary"
style="position: absolute; right: 40px; top: -45px"
@click="export1()">
导出
</a-button>
</div>
@@ -66,6 +69,7 @@
<!-- </a-spin> -->
</template>
<script lang="ts" setup>
import { exportExcel } from '/@/util/ExcelUtil.js';
import { ref, onMounted } from 'vue';
// import { http } from '/nerv-lib/util/http';
import { Pagination, SelectProps, TreeSelectProps, TableColumnType } from 'ant-design-vue';
@@ -200,6 +204,13 @@
loading.value = false;
});
};
// 导出excel文件
const export1 = () => {
for (let i = 0; i < data.value.length; i++) {
data.value[i].index = i + 1;
}
exportExcel(tableColumns.value, data.value, '平均数据导出', false);
};
onMounted(async () => {
// 获取频率
let frequency = await getEnum({ params: { enumType: 'TimeFlagEnum' } });

View File

@@ -62,7 +62,7 @@
<a-button
type="primary"
style="position: absolute; right: 40px; top: -45px"
@click="exportExcel()">
@click="export1()">
导出
</a-button>
</div>
@@ -87,8 +87,7 @@
</div>
</template>
<script lang="ts" setup>
import XLSX from 'xlsx';
// import Export2Excel from '/@/util/Export2Excel.js';
import { exportExcel } from '/@/util/ExcelUtil.js';
import { ref, onMounted, defineOptions } from 'vue';
// import { http } from '/nerv-lib/util/http';
@@ -352,60 +351,9 @@
}
});
};
// 导出excel
/**导出按钮点击事件函数
* @前期准备 npm install -S xlsx file-saver 及 Export2Excel.js
*/
const exportExcel = () => {
import('/@/util/Export2Excel.js').then((excel) => {
// 导出的表头名
let tHeader = [];
let filterVal = [];
for (let i = 0; i < tableColumns.value.length; i++) {
if (tableColumns.value[i].dataIndex) {
tHeader.push(tableColumns.value[i].title);
filterVal.push(tableColumns.value[i].dataIndex);
}
}
// const tHeader = [
// 'ID',
// '名称',
// '视频ID',
// '视频标题',
// '发布',
// '视频类型',
// '播放量',
// '上传时间',
// ];
// // 导出的表头字段名
// const filterVal = [
// 'id',
// 'name',
// 'videoId',
// 'videoTitle',
// 'release',
// 'videoType',
// 'playVolume',
// 'updateTime',
// ];
//传入的数据
const list = data.value;
const datas = formatJson(filterVal, list);
excel.export_json_to_excel({
header: tHeader, // 表格头部
data: datas, // 表格数据
filename: '表格导出测试', // excel文件名
});
});
};
/**
* 格式化表格数据
* @filterVal 格式头
* @jsonData 用来格式化的表格数据
*/
const formatJson = (filterVal: any, jsonData: any) => {
return jsonData.map((v: any) => filterVal.map((j: any) => v[j]));
// 导出excel文件
const export1 = () => {
exportExcel(tableColumns.value, data.value, '历史数据导出', true, 1, 3);
};
onMounted(async () => {
// 获取频率