Commit 22f76d29 authored by guoyou's avatar guoyou

员工业绩报表多选导出

parent 8e5ce18c
......@@ -12,7 +12,13 @@
>
<el-option v-for="item in allCompaniesArr" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<el-select v-model="listquery.userPostionId" clearable placeholder="请选择身份" @change="changeStaff" ref="userPostion">
<el-select
v-model="listquery.userPostionId"
clearable
placeholder="请选择身份"
@change="changeStaff"
ref="userPostion"
>
<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<el-button type="primary" :loading="excelLoading" @click="downloadExcel">导出报表</el-button>
......@@ -47,7 +53,7 @@
ref="multipleTable"
>
<el-table-column type="selection" width="55" align="center"></el-table-column>
<!-- <el-table-column type="index" width="80" label="序号" align="center"></!--> -->
<!-- <el-table-column type="index" width="80" label="序号" align="center"></!-->
<el-table-column label="序号" align="center" width="70">
<template scope="scope">
<span>{{scope.$index+(listquery.page - 1) * listquery.limit + 1}}</span>
......@@ -102,7 +108,7 @@
</template>
<script>
import { getAll } from 'api/base_info/branch_company/'
import { getDate,exports } from 'api/statistics'
import { getDate, exports } from 'api/statistics'
import { getrewardSetting } from 'api/purseManage'
export default {
created() {
......@@ -121,13 +127,15 @@ export default {
allCompaniesArr: [], //公司
options: [], //身份
allChoose: false, //是否全选
userIds: [],
listquery: {
startDate: null, //开始日期
endDate: null, //结束日期
companyId: null, //公司
userPostionId: null, //身份
userIds: [],
page: 1,
limit: 10,
limit: 10
}
}
},
......@@ -138,7 +146,13 @@ export default {
},
//多选
choose(val, row) {
console.log(val)
this.userIds = val
// console.log(val);
// val.forEach(element => {
// if (this.userIds.filter(item => item != element.userId)) {
// this.userIds.push(element.userId)
// }
// })
},
//页码
handleSizeChange(val) {
......@@ -166,14 +180,14 @@ export default {
},
//分公司筛选
changeCompany(val) {
this.listquery.companyName =this.$refs.company.query
this.listquery.companyName = this.$refs.company.query
this.listquery.page = 1
this.getList()
},
//身份筛选
changeStaff() {
this.listquery.page = 1
this.listquery.postionName =this.$refs.userPostion.selectedLabel
this.listquery.postionName = this.$refs.userPostion.selectedLabel
this.getList()
},
//列表数据
......@@ -184,8 +198,8 @@ export default {
this.tableData = data.data.page.data
this.total = data.data.page.totalCount
//点击全选所有分页都全选
if (!!this.allChoose) {
this.$nextTick(function() {
this.$nextTick(function() {
if (!!this.allChoose) {
for (
let index = 0;
index < this.tableData.length;
......@@ -195,8 +209,20 @@ export default {
this.tableData[index]
)
}
})
}
}
//多选
// for (let i = 0; i < this.userIds.length; i++) {
// let demo = this.tableData.findIndex(
// item => item.userId == this.userIds[i]
// )
// if (demo > 0) {
// this.$refs.multipleTable.toggleRowSelection(
// this.tableData[demo]
// )
// }
// }
})
//第一页才调取统计
if (data.data.page.pageNum == 1) {
this.information = data.data.total
......@@ -221,43 +247,68 @@ export default {
},
//导出
downloadExcel() {
if (this.userIds.length > 0) {
this.userIds.forEach(element => {
this.listquery.userIds.push(element.userId)
})
}
this.$refs.multipleTable.clearSelection()
this.userIds = []
this.excelLoading = true
var u = navigator.userAgent, app = navigator.appVersion;
exports(this.listquery,{responseType: 'arraybuffer'}).then(res => {
const content = res
const blob = new Blob([content], {type: "application/vnd.ms-excel"})
const fileName = this.timestamp(new Date())+'会员订单列表.xlsx'
if(u.indexOf('Edge') > -1){
window.navigator.msSaveBlob(blob, fileName)
console.log('ie');
}else{
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
var u = navigator.userAgent,
app = navigator.appVersion
exports(this.listquery, { responseType: 'arraybuffer' }).then(
res => {
const content = res
const blob = new Blob([content], {
type: 'application/vnd.ms-excel'
})
const fileName =
this.timestamp(new Date()) + '员工业绩统计.xlsx'
if (u.indexOf('Edge') > -1) {
window.navigator.msSaveBlob(blob, fileName)
console.log('ie')
} else {
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
}
this.excelLoading = false
this.listquery.userIds = []
}
this.excelLoading = false
})
},
timestamp(now) {
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
var Hours = now.getHours();
var Minutes = now.getMinutes();
var Seconds = now.getSeconds();
month = month.toString().length == 1 ? '0'+ month : month;
date = date.toString().length == 1 ? '0'+ date : date;
Hours = Hours.toString().length == 1 ? '0'+ Hours : Hours;
Minutes = Minutes.toString().length == 1 ? '0'+ Minutes : Minutes;
Seconds = Seconds.toString().length == 1 ? '0'+ Seconds : Seconds;
return year+"-"+month+"-"+date+' '+ Hours+':'+Minutes+":"+Seconds
)
},
timestamp(now) {
var year = now.getFullYear()
var month = now.getMonth() + 1
var date = now.getDate()
var Hours = now.getHours()
var Minutes = now.getMinutes()
var Seconds = now.getSeconds()
month = month.toString().length == 1 ? '0' + month : month
date = date.toString().length == 1 ? '0' + date : date
Hours = Hours.toString().length == 1 ? '0' + Hours : Hours
Minutes = Minutes.toString().length == 1 ? '0' + Minutes : Minutes
Seconds = Seconds.toString().length == 1 ? '0' + Seconds : Seconds
return (
year +
'-' +
month +
'-' +
date +
' ' +
Hours +
':' +
Minutes +
':' +
Seconds
)
}
}
}
</script>
......
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