Commit 8f17505d authored by jiaorz's avatar jiaorz

修改车辆统计功能

parent bd46dee9
......@@ -16,3 +16,11 @@ export function excelExport(query) {
});
}
export function excelDownload(query) {
return fetch({
url: '/vehicle/vehicleCount/app/unauth/download',
method: 'get',
params: query
});
}
......@@ -98,3 +98,7 @@ export function getYMD(timestamp) {
let date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
return formatDate(date, 'yyyy-MM-dd');
}
export function getYMD_date(date) {
return formatDate(date, 'yyyy-MM-dd');
}
......@@ -23,11 +23,11 @@
<el-col :span="5">
<el-form-item>
<el-date-picker
v-model="listQuery.time"
v-model="listQuery.startTime"
type="date"
:editable="false"
format="yyyy-MM-dd"
prop="time"
prop="startTime"
placeholder="请选择日期">
</el-date-picker>
</el-form-item>
......@@ -114,16 +114,16 @@
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
import {
get,excelExport
get,excelExport,excelDownload
} from 'api/vehicle/vehicleCount';
import { formatDate,deepCopyDate,getYMD } from "../../../utils/dateUtils";
import { formatDate,deepCopyDate,getYMD_date } from "../../../utils/dateUtils";
export default {
name: 'vehicleInfo',
data() {
return {
listQuery: {
type: null,
startTime: getYMD(new Date().getTime())
startTime: new Date()
},
tableKey: 0,
typeList: [
......@@ -133,7 +133,7 @@
],
list : [],
header : ['序号','类型','应交车','提前交车','正常交车','延期交车','应还车','提前还车','正常还车','延期还车','日期'],
name: '出车统计'
name: 'export'
}
},
created() {
......@@ -144,6 +144,7 @@
},
methods: {
handlerSearch() {
this.listQuery.startTime = getYMD_date(this.listQuery.startTime);
get(this.listQuery).then(response => {
if (response.status === 200) {
this.list = response.data
......@@ -170,56 +171,61 @@
return '';
},
downloadExcel() {
this.$confirm('确定导出吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var valueList = []
var mapList = []
this.list.forEach(v=>{
for(let key in v) {
if(key == 'type') {
if(v[key] == 1) {
mapList.push('用户租车')
}
if(v[key] == 2) {
mapList.push('用户旅游')
}
if(v[key] == 3) {
mapList.push('内部用车')
}
} else {
mapList.push(v[key])
var valueList = []
var mapList = []
this.list.forEach(v=>{
for(let key in v) {
if(key == 'type') {
if(v[key] == 1) {
mapList.push('用户租车')
}
if(v[key] == 2) {
mapList.push('用户旅游')
}
if(v[key] == 3) {
mapList.push('内部用车')
}
} else {
mapList.push(v[key])
}
valueList.push(mapList)
mapList = []
})
let param = {
"data": valueList,
"header":this.header,
"name":this.name
}
valueList.push(mapList)
mapList = []
})
let param = {
"data": valueList,
"header":this.header,
"name":this.name
}
let fileName = null;
excelExport(param).then(response => {
if (response.status === 200) {
if (response.status === 200) {
this.$notify({
title: "成功",
message: this.name + "导出到D盘成功!",
type: "success",
duration: 3000
title: "成功",
message: this.name + "导出成功!",
type: "success",
duration: 3000
});
} else {
this.$notify({
title: "失败",
message: response.message,
type: "error",
duration: 2000
});
}
console.log(response)
fileName = response.data
} else {
this.$notify({
title: "失败",
message: response.message,
type: "error",
duration: 2000
});
}
})
this.$confirm('确定导出吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var domain = document.domain;
console.log(domain)
window.location.href="https://"+domain+"/vehicle/vehicleCount/app/unauth/download?path="+fileName;
})
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment