Commit 22f76d29 authored by guoyou's avatar guoyou

员工业绩报表多选导出

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