|
@@ -27,13 +27,13 @@
|
|
|
<div class="charge-table">
|
|
|
<div class="charge-table-bottom">
|
|
|
<el-table :data="datalist" :header-cell-style="{
|
|
|
- background: '#1d283e',
|
|
|
- borderColor: '#2f3c86',
|
|
|
- height: '36px',
|
|
|
- lineHeight: '36px',
|
|
|
- color: 'white',
|
|
|
- fontSize: '15px',
|
|
|
- }" stripe fit :height="tableheight" style="width: 100%">
|
|
|
+ background: '#1d283e',
|
|
|
+ borderColor: '#2f3c86',
|
|
|
+ height: '36px',
|
|
|
+ lineHeight: '36px',
|
|
|
+ color: 'white',
|
|
|
+ fontSize: '15px',
|
|
|
+ }" stripe fit :height="tableheight" style="width: 100%">
|
|
|
<el-table-column prop="exportName" label="导出任务名称" />
|
|
|
<el-table-column label="日志类型">
|
|
|
<template slot-scope="scope">
|
|
@@ -45,7 +45,8 @@
|
|
|
<el-table-column prop="exporterName" label="创建人" />
|
|
|
<el-table-column label="状态" width="400">
|
|
|
<template slot-scope="scope">
|
|
|
- <span v-if="scope.row.exportStatus !== 2">{{ scope.row.exportStatus === 0 ? '完成' : '失败' }}</span>
|
|
|
+ <span v-if="scope.row.exportStatus !== 2">{{ scope.row.exportStatus === 0 ? '完成' : '失败'
|
|
|
+ }}</span>
|
|
|
<span v-else><el-progress :percentage="scope.row.exportProgress"></el-progress></span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -54,17 +55,19 @@
|
|
|
<template slot-scope="scope">
|
|
|
<span v-if="scope.row.exportStatus === 0">
|
|
|
<el-button type="primary" class="handle" size="small"
|
|
|
- @click="handleDownFile(scope.row.exportFilePath,scope.row.exportName)">下载</el-button>
|
|
|
+ @click="handleDownFile(scope.row.exportFilePath, scope.row.exportName)">下载</el-button>
|
|
|
</span>
|
|
|
<span v-if="scope.row.exportStatus !== 2">
|
|
|
<el-button type="primary" class="handle" size="small"
|
|
|
- @click="handleDelete(scope.row.id)">删除</el-button>
|
|
|
+ @click="handleDelete(scope.row.id)">删除</el-button>
|
|
|
</span>
|
|
|
-
|
|
|
+
|
|
|
<span v-else>— —</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <vue-loading :isLoading="showTotip" type="loading3" text="下载中..." color="lightgreen"
|
|
|
+ scale="1"></vue-loading>
|
|
|
</div>
|
|
|
<div class="pageblock">
|
|
|
<el-pagination :current-page="queryParams.page" :page-sizes="[10, 20, 30, 40]"
|
|
@@ -77,33 +80,36 @@
|
|
|
|
|
|
<script>
|
|
|
import "./log.scss";
|
|
|
-import { exportList,deleteExportData,RecordFile } from "@/api/log";
|
|
|
+import { exportList, deleteExportData } from "@/api/downfile";
|
|
|
+import request from '@/utils/requestfile';
|
|
|
export default {
|
|
|
name: "DataExport",
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
+ //下载提示框
|
|
|
+ showTotip: false,
|
|
|
// 查询时间数组
|
|
|
dateTime: "",
|
|
|
// 导出类型
|
|
|
LogTypeArr: [
|
|
|
{
|
|
|
- id:1,
|
|
|
- value:'机器人',
|
|
|
+ id: 1,
|
|
|
+ value: '机器人',
|
|
|
},
|
|
|
{
|
|
|
- id:2,
|
|
|
- value:'充电机',
|
|
|
+ id: 2,
|
|
|
+ value: '充电机',
|
|
|
},
|
|
|
{
|
|
|
- id:3,
|
|
|
- value:'BMS',
|
|
|
+ id: 3,
|
|
|
+ value: 'BMS',
|
|
|
}
|
|
|
],//日志类型
|
|
|
// 数据列表
|
|
|
datalist: [],
|
|
|
- exportLogType:undefined,
|
|
|
- exporterId:0, //导出人id
|
|
|
+ exportLogType: undefined,
|
|
|
+ exporterId: 0, //导出人id
|
|
|
// 查询参数
|
|
|
queryParams: {
|
|
|
page: 1, // 当前页
|
|
@@ -114,13 +120,13 @@ export default {
|
|
|
endTime: undefined,
|
|
|
orderByField: 'createTime', // 排序字段
|
|
|
orderByWays: 'desc',// 排序方式
|
|
|
- exporterId:this.$store.getters.userId
|
|
|
+ exporterId: this.$store.getters.userId
|
|
|
},
|
|
|
total: 0, // 总条数,
|
|
|
tableheight: 0, // 表格高度设置
|
|
|
loading: false,
|
|
|
heightTimer: false,
|
|
|
- exportTimer:null,//定时器
|
|
|
+ exportTimer: null,//定时器
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -136,7 +142,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
- destroyed(){
|
|
|
+ destroyed() {
|
|
|
this.clearListTimer()
|
|
|
},
|
|
|
mounted() {
|
|
@@ -149,15 +155,15 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
//定时请求导出列表
|
|
|
- setListTimer(){
|
|
|
+ setListTimer() {
|
|
|
this.getExportList()
|
|
|
- this.exportTimer=setInterval(() => {
|
|
|
+ this.exportTimer = setInterval(() => {
|
|
|
this.getExportList()
|
|
|
}, 1000);
|
|
|
},
|
|
|
//清除定时器
|
|
|
- clearListTimer(){
|
|
|
- if(this.exportTimer){
|
|
|
+ clearListTimer() {
|
|
|
+ if (this.exportTimer) {
|
|
|
clearInterval(this.exportTimer)
|
|
|
}
|
|
|
},
|
|
@@ -179,7 +185,7 @@ export default {
|
|
|
dialogClose() { },
|
|
|
//获取换电记录列表
|
|
|
getExportList() {
|
|
|
- exportList(this.queryParams).then( res=> {
|
|
|
+ exportList(this.queryParams).then(res => {
|
|
|
this.datalist = res.data.list;
|
|
|
this.total = res.data.total;
|
|
|
});
|
|
@@ -211,28 +217,67 @@ export default {
|
|
|
window.location.reload();
|
|
|
},
|
|
|
//删除导出任务列表
|
|
|
- handleDelete(id){
|
|
|
+ handleDelete(id) {
|
|
|
this.$confirm('删除数据将丢失,请确认是否删除', '确认删除', {
|
|
|
confirmButtonText: '确认',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
})
|
|
|
- .then(async() => {
|
|
|
- await deleteExportData(id)
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- })
|
|
|
- this.getExportList()
|
|
|
- })
|
|
|
- .catch(err => { console.error(err) })
|
|
|
+ .then(async () => {
|
|
|
+ await deleteExportData(id)
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ })
|
|
|
+ this.getExportList()
|
|
|
+ })
|
|
|
+ .catch(err => { console.error(err) })
|
|
|
},
|
|
|
//下载文件
|
|
|
- async handleDownFile(url,fileName){
|
|
|
- //window.location.href=url
|
|
|
- const fileDownName=fileName+'_'+(new Date().getTime())
|
|
|
- const resUrl=await RecordFile(url, fileDownName)
|
|
|
- }
|
|
|
+ async handleDownFile(url, fileName) {
|
|
|
+ this.showTotip = true;
|
|
|
+ // const execlUrl = process.env.VUE_APP_BASE_API + "/excel/" + url;
|
|
|
+ const fileDownName = fileName + '_' + (new Date().getTime())
|
|
|
+ const resUrl = await this.RecordFile(url, fileDownName)
|
|
|
+ },
|
|
|
+ RecordFile(Fileurl, fileName) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.showTotip = false
|
|
|
+ }, 5000)
|
|
|
+ //接口方法
|
|
|
+ return request({
|
|
|
+ url: Fileurl,
|
|
|
+ method: "get",
|
|
|
+ responseType: "blob",
|
|
|
+ }).then((data) => {
|
|
|
+ console.log("RecordFile then", data);
|
|
|
+ if (!data) {
|
|
|
+ this.showTotip = false
|
|
|
+ return alert("文件下载失败");
|
|
|
+ }
|
|
|
+ // let fileName = '统计表计';
|
|
|
+ if (typeof window.navigator.msSaveBlob !== "undefined") {
|
|
|
+ // window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx');
|
|
|
+ window.navigator.msSaveBlob(
|
|
|
+ new Blob([data], { type: "application/vnd.ms-excel" }),
|
|
|
+ fileName
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ let url = window.URL.createObjectURL(
|
|
|
+ new Blob([data], { type: "application/vnd.ms-excel" })
|
|
|
+ );
|
|
|
+ let link = document.createElement("a");
|
|
|
+ link.style.display = "none";
|
|
|
+ link.href = url;
|
|
|
+ link.setAttribute("download", fileName);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link); //下载完成移除元素
|
|
|
+ window.URL.revokeObjectURL(url); //释放掉blob对象
|
|
|
+ }
|
|
|
+ this.showTotip = false
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|