Commit 8f17505d authored by jiaorz's avatar jiaorz

修改车辆统计功能

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