加统计导出

This commit is contained in:
dengbw
2022-12-12 17:23:57 +08:00
parent 1c03a24903
commit 0524eb6c43
4 changed files with 229 additions and 13 deletions
+28
View File
@@ -81,3 +81,31 @@ export async function getGroupsStatisticsWatchOrder(params) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导出门店
* @param params 查询条件
*/
export async function exportGroupsStatisticsBiz(params) {
const res = await request.get('/sylive/groupsStatistics/biz_export', {
params
});
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导出顾问
* @param params 查询条件
*/
export async function exportGroupsStatisticsConsultant(params) {
const res = await request.get('/sylive/groupsStatistics/consultant_export', {
params
});
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
@@ -45,13 +45,29 @@
<div class="list-tool-divider">
<el-divider direction="vertical" />
</div>
<el-button
size="small"
type="primary"
class="ele-btn-icon"
icon="el-icon-download"
@click="exportData"
>
导出
</el-button>
<div class="list-tool-divider">
<el-divider direction="vertical" />
</div>
</template>
</ele-pro-table>
</el-card>
</template>
<script>
import { getGroupsStatisticsBiz } from '@/api/sylive/groups-statistics';
import {
getGroupsStatisticsBiz,
exportGroupsStatisticsBiz
} from '@/api/sylive/groups-statistics';
import { utils, writeFile } from 'xlsx';
export default {
props: { data: Object },
@@ -64,9 +80,23 @@
selection: [],
// 表格列配置
columns: [
{
prop: 'levelName1',
label: '战区',
align: 'center',
showOverflowTooltip: true,
minWidth: 80
},
{
prop: 'levelName2',
label: '战队',
align: 'center',
showOverflowTooltip: true,
minWidth: 80
},
{
prop: 'bizName',
label: '门店名称',
label: '门店',
align: 'center',
showOverflowTooltip: true,
minWidth: 120
@@ -76,14 +106,21 @@
label: '参与顾问数',
align: 'center',
showOverflowTooltip: true,
minWidth: 90
minWidth: 85
},
{
prop: 'allConsultant',
label: '全部顾问数',
align: 'center',
showOverflowTooltip: true,
minWidth: 90
minWidth: 85
},
{
prop: 'consultantPer',
label: '开工率',
align: 'center',
showOverflowTooltip: true,
minWidth: 75
},
{
prop: 'browse',
@@ -91,7 +128,7 @@
align: 'center',
sortable: 'custom',
showOverflowTooltip: true,
minWidth: 120
minWidth: 115
},
{
prop: 'subscribe',
@@ -99,7 +136,7 @@
align: 'center',
sortable: 'custom',
showOverflowTooltip: true,
minWidth: 120
minWidth: 115
},
{
prop: 'watch',
@@ -107,7 +144,7 @@
align: 'center',
sortable: 'custom',
showOverflowTooltip: true,
minWidth: 120
minWidth: 115
},
{
prop: 'order',
@@ -115,7 +152,7 @@
align: 'center',
sortable: 'custom',
showOverflowTooltip: true,
minWidth: 120
minWidth: 115
},
{
prop: 'livePV',
@@ -146,6 +183,67 @@
itemId: this.itemId
});
},
/* 导出数据 */
exportData() {
const array = [
[
'战区',
'战队',
'门店',
'参与顾问数',
'全部顾问数',
'开工率',
'浏览数(人)',
'预约数(人)',
'观看数(人)',
'订单数(单)',
'观看数(人次)',
'人均观看(分)'
]
];
const loading = this.$loading({ lock: true });
this.$refs.table.doRequest(({ where, order }) => {
exportGroupsStatisticsBiz({
...where,
...order,
activityId: this.activityId,
day: this.day,
itemId: this.itemId
})
.then((data) => {
loading.close();
data.forEach((d) => {
array.push([
d.levelName1,
d.levelName2,
d.bizName,
d.consultant,
d.allConsultant,
d.consultantPer,
d.browse,
d.subscribe,
d.watch,
d.order,
d.livePV,
d.watchDuration
]);
});
writeFile(
{
SheetNames: ['Sheet1'],
Sheets: {
Sheet1: utils.aoa_to_sheet(array)
}
},
'门店统计.xlsx'
);
})
.catch((e) => {
loading.close();
this.$message.error(e.message);
});
});
},
/* 更新选中数据 */
updateValue() {
this.$refs.table.reload({ page: 1 });
@@ -45,13 +45,29 @@
<div class="list-tool-divider">
<el-divider direction="vertical" />
</div>
<el-button
size="small"
type="primary"
class="ele-btn-icon"
icon="el-icon-download"
@click="exportData"
>
导出
</el-button>
<div class="list-tool-divider">
<el-divider direction="vertical" />
</div>
</template>
</ele-pro-table>
</el-card>
</template>
<script>
import { getGroupsStatisticsConsultant } from '@/api/sylive/groups-statistics';
import {
getGroupsStatisticsConsultant,
exportGroupsStatisticsConsultant
} from '@/api/sylive/groups-statistics';
import { utils, writeFile } from 'xlsx';
export default {
props: { data: Object },
@@ -63,11 +79,32 @@
// 表格列配置
columns: [
{
prop: 'consultantName',
label: '顾问名称',
prop: 'levelName1',
label: '战区',
align: 'center',
showOverflowTooltip: true,
minWidth: 180
minWidth: 80
},
{
prop: 'levelName2',
label: '战队',
align: 'center',
showOverflowTooltip: true,
minWidth: 80
},
{
prop: 'bizName',
label: '门店',
align: 'center',
showOverflowTooltip: true,
minWidth: 120
},
{
prop: 'consultantName',
label: '顾问',
align: 'center',
showOverflowTooltip: true,
minWidth: 90
},
{
prop: 'browse',
@@ -116,6 +153,59 @@
itemId: this.itemId
});
},
/* 导出数据 */
exportData() {
const array = [
[
'战区',
'战队',
'门店',
'顾问',
'浏览数(人)',
'预约数(人)',
'观看数(人)',
'订单数(单)'
]
];
const loading = this.$loading({ lock: true });
this.$refs.table.doRequest(({ where, order }) => {
exportGroupsStatisticsConsultant({
...where,
...order,
activityId: this.activityId,
day: this.day,
itemId: this.itemId
})
.then((data) => {
loading.close();
data.forEach((d) => {
array.push([
d.levelName1,
d.levelName2,
d.bizName,
d.consultantName,
d.browse,
d.subscribe,
d.watch,
d.order
]);
});
writeFile(
{
SheetNames: ['Sheet1'],
Sheets: {
Sheet1: utils.aoa_to_sheet(array)
}
},
'顾问统计.xlsx'
);
})
.catch((e) => {
loading.close();
this.$message.error(e.message);
});
});
},
/* 更新选中数据 */
updateValue() {
this.$refs.table.reload({ page: 1 });
@@ -123,7 +123,7 @@
columns: [
{
prop: 'groupsName',
label: '分级名称',
label: '名称',
align: 'center',
showOverflowTooltip: true,
minWidth: 110