| | |
| | | </el-form> |
| | | </div> |
| | | <el-table :data="state.tableData.data" style="width: 100%"> |
| | | <el-table-column align="center" prop="date" label="日期"/> |
| | | <el-table-column align="center" label="文件名称"> |
| | | <template #default="scope"> |
| | | <div v-for="(item, index) in scope.row.file" :key="index"> |
| | | {{ item.filename}} |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column align="center" prop="gmtCreate" label="日期"/> |
| | | <el-table-column align="center" prop="name" label="文件名称"/> |
| | | <el-table-column label="操作" show-overflow-tooltip width="140"> |
| | | <template #default="scope"> |
| | | <el-button size="small" text type="primary" @click="downLoad(scope.row)">下载</el-button> |
| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import {reactive, ref} from "vue"; |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import { TableDailytState } from "/@/types/monitorData"; |
| | | import axios from "axios"; |
| | | import Cookies from "js-cookie"; |
| | | import { ElMessage } from 'element-plus' |
| | | import {dailyApi} from "/@/api/monitorData/daily"; |
| | | import moment from "moment/moment"; |
| | | |
| | | const state = reactive<TableDailytState>({ |
| | | tableData: { |
| | |
| | | } |
| | | }); |
| | | |
| | | const initDailyData = () => { |
| | | console.log("数据列表") |
| | | onMounted( |
| | | () => { |
| | | getNowTime(); |
| | | initDailyData() |
| | | } |
| | | ); |
| | | |
| | | const initDailyData = async () => { |
| | | const param = { |
| | | pageIndex: state.tableData.listQuery.pageIndex, |
| | | pageSize: state.tableData.listQuery.pageSize, |
| | | searchParams: { |
| | | year: state.tableData.listQuery.searchParams.time.substring(0,4), |
| | | month: state.tableData.listQuery.searchParams.time.substring(5,7) |
| | | } |
| | | } |
| | | let res = await dailyApi().getDaily(param); |
| | | if(res.data.code == 100) { |
| | | state.tableData.data = res.data.data; |
| | | state.tableData.total = res.data.total; |
| | | state.tableData.listQuery.pageIndex = res.data.pageIndex; |
| | | state.tableData.listQuery.pageSize = res.data.pageSize; |
| | | } |
| | | |
| | | console.log("数据列表",res) |
| | | }; |
| | | const getNowTime = () => { |
| | | let isDate = new Date() |
| | | const year = isDate.getFullYear(); |
| | | const month = isDate.getMonth() + 1; |
| | | state.tableData.listQuery.searchParams.time = (year + "-" + (month >= 10 ? month : "0" + month)).toString(); |
| | | } |
| | | const onHandleSizeChange = (val: number) => { |
| | | state.tableData.listQuery.pageSize = val; |
| | | initDailyData(); |
| | |
| | | initDailyData(); |
| | | }; |
| | | const downLoad = (file: any) => { |
| | | // axios.get(process.env.VITE_API_URL + file.fileUrl, { |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'Authorization': Cookies.get('token'), |
| | | // }, |
| | | // responseType: 'blob' |
| | | // }).then(res => { |
| | | // if (res) { |
| | | // const link = document.createElement('a') |
| | | // let blob = new Blob([res.data], { |
| | | // type: res.data.type |
| | | // }) |
| | | // link.style.display = "none"; |
| | | // link.href = URL.createObjectURL(blob); // 创建URL |
| | | // link.setAttribute("download", file.fileName); |
| | | // document.body.appendChild(link); |
| | | // link.click(); |
| | | // document.body.removeChild(link); |
| | | // } else { |
| | | // ElMessage({ |
| | | // message: '获取文件失败', |
| | | // type: 'error', |
| | | // }) |
| | | // } |
| | | // }) |
| | | console.log("file",file) |
| | | axios.get(import.meta.env.VITE_API_URL + file.fileUrl, { |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'tk': `${Cookies.get('token')}`, |
| | | 'uid':`${Cookies.get('uid')}` |
| | | }, |
| | | responseType: 'blob' |
| | | }).then(res => { |
| | | if (res) { |
| | | const link = document.createElement('a') |
| | | let blob = new Blob([res.data], { |
| | | type: res.data.type |
| | | }) |
| | | link.style.display = "none"; |
| | | link.href = URL.createObjectURL(blob); // 创建URL |
| | | link.setAttribute("download", file.name); |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | ElMessage({ |
| | | message: '下载成功', |
| | | type: 'success', |
| | | }) |
| | | } else { |
| | | ElMessage({ |
| | | message: '获取文件失败', |
| | | type: 'error', |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | const search = () => { |
| | | console.log("xxxx",state.tableData.listQuery.searchParams) |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | initDailyData(); |
| | | console.log("vla",state.tableData.listQuery.searchParams) |
| | | } |
| | | const reset = () => { |
| | | state.tableData.listQuery.searchParams.time = ''; |
| | | getNowTime(); |
| | | initDailyData(); |
| | | } |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |
| | | </style> |