You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-front/src/pages/shop/IncreaseDataCompany.vue

295 lines
12 KiB
Vue

6 years ago
<template>
<div>
<Row style="margin-top: 20px;width: 100%;background-color: #F7F8FA;">
<i-col span="24" style="text-align: left;padding-left: 10px;">
<Row class="row-style">
<i-col span="1" style="text-align: right;">
<p class="region">选择日期</p>
</i-col>
<i-col span="3" style="padding-left: 10px;">
6 years ago
<DatePicker :value="selectDate" type="daterange" split-panels placeholder="请选择日期" @on-change="onChangeDateLister"
style="width: 200px"></DatePicker>
6 years ago
</i-col>
<i-col span="2" style="text-align: right;">
6 years ago
<span class="region">零售公司</span>
6 years ago
</i-col>
<i-col span="4" style="padding-left: 10px;">
<Select v-model="selectedCompany" filterable style="width: 200px;">
<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select>
</i-col>
<i-col span="4">
<Button type="primary" @click="generalizeOfRetail"></Button>
</i-col>
6 years ago
<div style="text-align: right;padding-right: 20px;float: right">
6 years ago
<Button type="primary" @click="exportZeroExtend" :loading="loading" >导出数据</Button>
6 years ago
</div>
6 years ago
</Row>
</i-col>
</Row>
6 years ago
6 years ago
<Table :loading="tableLoading" ref="table" :columns="columns1" :data="data1" style="margin-top: 20px;" size="small"></Table>
6 years ago
<Page :total="totalSize" :current="pageNum" :page-size="pageSize" show-elevator show-total
6 years ago
placement="top" @on-change="handlePage" style="float: right;margin-top: 20px"></Page>
6 years ago
</div>
</template>
<script>
import IncreaseData from "../../services/generalize/IncreaseData";
6 years ago
6 years ago
export default {
name: "IncreaseDataCompany",
data() {
return {
6 years ago
loading:false,
6 years ago
selectedCompany: null,
companyList: [],
columns1: [
{
title: '序号',
6 years ago
key: 'index',
width: '80px'
6 years ago
},
{
title: '零售公司名称',
6 years ago
key: 'retailCompany',
width: '250px'
6 years ago
},
{
6 years ago
title: '总好友数',
6 years ago
key: 'allCustomer'
},
{
6 years ago
title: '总好友数(去重)',
6 years ago
key: 'effectiveCustomer'
},
{
6 years ago
title: '新增好友数',
6 years ago
key: 'newCustomer',
render: (h, params) => {
let that = this;
if(that.data1[params.index].newCustomer != null){
return h('div', [
h('span', {}, that.data1[params.index].newCustomer),
])
}else {
return h('div', [
h('span', {}, '0'),
])
}
}
6 years ago
},
{
6 years ago
title: '新增好友数(去重)',
6 years ago
key: 'newEffectiveCustomer',
render: (h, params) => {
let that = this;
if(that.data1[params.index].newEffectiveCustomer != null){
return h('div', [
h('span', {}, that.data1[params.index].newEffectiveCustomer),
])
}else {
return h('div', [
h('span', {}, '0'),
])
}
}
6 years ago
},
{
6 years ago
title: '日增好友平均',
6 years ago
key: 'avgNewCustomer',
render: (h, params) => {
let that = this;
if(that.data1[params.index].avgNewCustomer != null){
return h('div', [
h('span', {}, that.data1[params.index].avgNewCustomer),
])
}else {
return h('div', [
h('span', {}, '0'),
])
}
}
6 years ago
},
6 years ago
{
title: '日增好友平均(去重)',
6 years ago
key: 'avgNewEffectiveCustomer',
render: (h, params) => {
let that = this;
if(that.data1[params.index].avgNewEffectiveCustomer != null){
return h('div', [
h('span', {}, that.data1[params.index].avgNewEffectiveCustomer),
])
}else {
return h('div', [
h('span', {}, '0'),
])
}
}
6 years ago
},
6 years ago
{
6 years ago
title: '删除/拉黑成员客户数(累计)',
6 years ago
key: 'delCustomer'
},
{
title: '拉黑率(累计)',
key: 'delRate'
}
],
data1: [],
//分页内容
totalSize: 0,
pageNum: 1,
6 years ago
pageSize: 10,
selectDate: [],
6 years ago
tableLoading:false,
6 years ago
}
},
mounted: function () {
6 years ago
let startDate = this.$moment(new Date()).add(-29,"day").format("YYYY-MM-DD");
6 years ago
let endDate = this.$moment(new Date()).format("YYYY-MM-DD");
this.selectDate.push(startDate);
this.selectDate.push(endDate);
6 years ago
this.allCompany();
this.generalizeOfRetail();
},
methods: {
onChangeDateLister(date) {
6 years ago
this.selectDate = date;
6 years ago
},
6 years ago
allCompany() {
6 years ago
let that = this;
let request = {
6 years ago
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId
6 years ago
};
this.companyList = [];
6 years ago
IncreaseData.listOfRetailCompany(request, function (data) {
6 years ago
data = data.data;
if (data.code === '0001') {
that.$Message.error("查询零售公司出错!");
return;
}
if (data.code === '0000') {
6 years ago
that.companyList.push({id:'-1',name:"全部"});
6 years ago
that.selectedCompany = "-1";
6 years ago
data.results.forEach(da => {
that.companyList.push(da);
})
6 years ago
}
})
},
6 years ago
generalizeOfRetail() {
6 years ago
this.tableLoading = true;
6 years ago
if(this.selectDate[0] === ""){
this.$Message.info("请选择日期");
return
}
6 years ago
let orgId = this.selectedCompany;
if(this.selectedCompany === '-1'){
orgId = null;
}
6 years ago
let request = {
6 years ago
startTime: this.selectDate[0],
endTime: this.selectDate[1],
6 years ago
orgId: orgId,
6 years ago
pageNum: this.pageNum,
6 years ago
pageSize: this.pageSize,
userId:JSON.parse(sessionStorage.getItem("loginInfo")).userId
6 years ago
};
let that = this;
that.data1 = [];
6 years ago
IncreaseData.generalizeOfRetail(request, function (data) {
6 years ago
that.tableLoading = false;
6 years ago
data = data.data;
6 years ago
if (data.code === '0001') {
6 years ago
that.$Message.info("查询推广数据失败!");
return;
}
6 years ago
if (data.code === '0000') {
6 years ago
that.tableLoading = false;
6 years ago
that.data1 = data.results.dataVOS;
that.totalSize = data.results.sizeNum;
6 years ago
if(that.data1){
for(let i = 0; i < that.data1.length;i++){
6 years ago
that.data1[i].index = (that.pageNum - 1) * that.pageSize + i+1;
6 years ago
}
}
6 years ago
}
})
},
6 years ago
//切页处理
handlePage: function (value) {
this.pageNum = value;
this.generalizeOfRetail();
},
6 years ago
//零推广导出
exportZeroExtend: function(){
6 years ago
this.loading = true;
6 years ago
if(this.selectDate[0] === ""){
this.$Message.info("请选择日期");
return
}
let orgId = this.selectedCompany;
if(this.selectedCompany === '-1'){
orgId = null;
}
let request = {
startTime: this.selectDate[0],
endTime: this.selectDate[1],
orgId: orgId,
pageNum: 1,
6 years ago
pageSize: this.totalSize,
userId:JSON.parse(sessionStorage.getItem("loginInfo")).userId
6 years ago
};
let that = this;
let originAllData = [];
IncreaseData.generalizeOfRetail(request,function (data) {
if(data.data.code !== "0000"){
that.$Message.error("系统异常");
}
data = data.data.results.dataVOS;
if(data && data.length > 0){
6 years ago
that.loading = false;
6 years ago
for(let i=0;i<data.length;i++){
let entity = data[i];
entity.index = i+1;
originAllData.push(entity);
}
6 years ago
let title = "零售公司推广情况"+ that.$moment(new Date()).format("YYYY-MM-DD");
6 years ago
require.ensure([], () => {
const { export_json_to_excel } = require('../../excel/Export2Excel');
6 years ago
const tHeader = ['序号', '零售公司名称', '总好友数', '总好友数(去重)', '新增好友数', '新增好友数(去重)','日增好友平均','日增好友平均(去重)','删除/拉黑成员客户数(累计)','拉黑率(累计)'];
6 years ago
// 属性名
6 years ago
const filterVal = ['index', 'retailCompany', 'allCustomer', 'effectiveCustomer', 'newCustomer', 'newEffectiveCustomer','avgNewCustomer','avgNewEffectiveCustomer','delCustomer','delRate'];
6 years ago
// 数据
//把data里的tableData存到list
const data = that.formatJson(filterVal, originAllData);
export_json_to_excel(tHeader, data, title);
});
}
if(!data || data.length === 0){
that.$Message.info("暂无数据");
}
6 years ago
});
},
6 years ago
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
6 years ago
}
}
</script>
<style scoped>
.region {
font-size: 14px;
line-height: 32px;
}
6 years ago
6 years ago
.row-style {
padding-top: 20px;
padding-bottom: 20px;
}
</style>