Commit a8c710b2 by 姜鹏凯

下载方式更改

1 parent 5fb4e0e0
import request from '@/utils/request' import request from '@/utils/request'
const service = const service = window.lwConfig.services.system + window.lwConfig.services.wecom + '/operation/customer'
window.lwConfig.services.system + window.lwConfig.services.wecom + '/operation/customer'
/** /**
* 客户数据分析 * 客户数据分析
*/ */
export function getAnalysis() { export function getAnalysis() {
return request({ return request({
url: service + '/getAnalysis', url: service + '/getAnalysis'
}) })
} }
...@@ -22,7 +21,7 @@ endTime 是 结束时间 ...@@ -22,7 +21,7 @@ endTime 是 结束时间
export function getTotalCnt(params) { export function getTotalCnt(params) {
return request({ return request({
url: service + '/getTotalCnt', url: service + '/getTotalCnt',
params, params
}) })
} }
...@@ -37,7 +36,7 @@ endTime 是 结束时间 ...@@ -37,7 +36,7 @@ endTime 是 结束时间
export function getRealCnt(params) { export function getRealCnt(params) {
return request({ return request({
url: service + '/getCustomerRealPageCnt', url: service + '/getCustomerRealPageCnt',
params, params
}) })
} }
...@@ -52,7 +51,7 @@ endTime 是 结束时间 ...@@ -52,7 +51,7 @@ endTime 是 结束时间
export function getRankCnt(params) { export function getRankCnt(params) {
return request({ return request({
url: service + '/getRankCnt', url: service + '/getRankCnt',
params, params
}) })
} }
...@@ -68,5 +67,6 @@ export function realDataExport(params) { ...@@ -68,5 +67,6 @@ export function realDataExport(params) {
return request({ return request({
url: service + '/real/export', url: service + '/real/export',
params, params,
responseType: 'blob'
}) })
} }
import request from '@/utils/request' import request from '@/utils/request'
const service = const service = window.lwConfig.services.system + window.lwConfig.services.wecom + '/operation/group'
window.lwConfig.services.system + window.lwConfig.services.wecom + '/operation/group'
/** /**
* 客群数据分析 * 客群数据分析
*/ */
export function getAnalysis() { export function getAnalysis() {
return request({ return request({
url: service + '/getAnalysis', url: service + '/getAnalysis'
}) })
} }
...@@ -22,7 +21,7 @@ endTime 是 结束时间 ...@@ -22,7 +21,7 @@ endTime 是 结束时间
export function getTotalCnt(params) { export function getTotalCnt(params) {
return request({ return request({
url: service + '/getTotalCnt', url: service + '/getTotalCnt',
params, params
}) })
} }
...@@ -37,7 +36,7 @@ endTime 是 结束时间 ...@@ -37,7 +36,7 @@ endTime 是 结束时间
export function getTotalCntMember(params) { export function getTotalCntMember(params) {
return request({ return request({
url: service + '/member/getTotalCnt', url: service + '/member/getTotalCnt',
params, params
}) })
} }
...@@ -52,7 +51,7 @@ endTime 是 结束时间 ...@@ -52,7 +51,7 @@ endTime 是 结束时间
export function getRealCnt(params) { export function getRealCnt(params) {
return request({ return request({
url: service + '/getGroupRealPageCnt', url: service + '/getGroupRealPageCnt',
params, params
}) })
} }
...@@ -67,7 +66,7 @@ endTime 是 结束时间 ...@@ -67,7 +66,7 @@ endTime 是 结束时间
export function getRealCntMember(params) { export function getRealCntMember(params) {
return request({ return request({
url: service + '/member/getGroupMemberRealPageCnt', url: service + '/member/getGroupMemberRealPageCnt',
params, params
}) })
} }
...@@ -83,6 +82,7 @@ export function realDataExport(params) { ...@@ -83,6 +82,7 @@ export function realDataExport(params) {
return request({ return request({
url: service + '/real/export', url: service + '/real/export',
params, params,
responseType: 'blob'
}) })
} }
...@@ -98,5 +98,6 @@ export function realDataExportMember(params) { ...@@ -98,5 +98,6 @@ export function realDataExportMember(params) {
return request({ return request({
url: service + '/member/real/export', url: service + '/member/real/export',
params, params,
responseType: 'blob'
}) })
} }
<script> <script>
// import * as customerApi from '@/api/operateCenter/customerAnalysis' // import * as customerApi from '@/api/operateCenter/customerAnalysis'
// import * as groupApi from '@/api/operateCenter/groupAnalysis' // import * as groupApi from '@/api/operateCenter/groupAnalysis'
// import * as conversationApi from '@/api/operateCenter/conversationAnalysis' // import * as conversationApi from '@/api/operateCenter/conversationAnalysis'
import { getList as getGroupList } from '@/api/customer/group' import { getList as getGroupList } from '@/api/customer/group'
export default { export default {
name: '', name: '',
components: { components: {
ChartLine: () => import('@/components/ChartLine'), ChartLine: () => import('@/components/ChartLine'),
ChartBar: () => import('@/components/ChartBar'), ChartBar: () => import('@/components/ChartBar')
}, },
props: { props: {
// 图表类型 // 图表类型
type: { type: {
type: String, type: String,
default: '', default: ''
}, },
// 图表图例; 单个图例可传字符串,多个图例传数组 // 图表图例; 单个图例可传字符串,多个图例传数组
legend: { legend: {
type: [Array, String], type: [Array, String],
default: null, default: null
}, },
// 接口请求 // 接口请求
request: { request: {
type: Function, type: Function,
default: () => {}, default: () => {}
}, },
// 导出接口请求 // 导出接口请求
requestExport: { requestExport: {
type: Function, type: Function,
default: () => {}, default: () => {}
}, },
// 自定义图表配置项,使用loadsh.merge(origin, option)和原有的配置进行覆盖合并 // 自定义图表配置项,使用loadsh.merge(origin, option)和原有的配置进行覆盖合并
// loadsh.merge: https://www.html.cn/doc/lodash/#_mergeobject-sources // loadsh.merge: https://www.html.cn/doc/lodash/#_mergeobject-sources
option: { option: {
type: Object, type: Object,
default: null, default: null
}, }
}, },
data() { data() {
return { return {
...@@ -49,7 +49,7 @@ export default { ...@@ -49,7 +49,7 @@ export default {
series: [], series: [],
legendDict: { legendDict: {
customerTotalChart: ['客群总数'], customerTotalChart: ['客群总数'],
customerTotalChart: ['客群总数'], customerTotalChart: ['客群总数']
}, },
// 日期范围 // 日期范围
dateRange: [], dateRange: [],
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
chatIds: [], chatIds: [],
ownerIds: [], ownerIds: [],
beginTime: undefined, beginTime: undefined,
endTime: undefined, endTime: undefined
}, },
// 群聊 // 群聊
groupChats: [], groupChats: [],
...@@ -74,21 +74,21 @@ export default { ...@@ -74,21 +74,21 @@ export default {
{ prop: 'addCnt', label: '新增客户数' }, { prop: 'addCnt', label: '新增客户数' },
{ prop: 'lostCnt', label: '流失客户数' }, { prop: 'lostCnt', label: '流失客户数' },
{ prop: 'netCnt', label: '净增客户数' }, { prop: 'netCnt', label: '净增客户数' },
{ prop: 'applyCnt', label: '昨日发送申请数' }, { prop: 'applyCnt', label: '昨日发送申请数' }
], ],
// 客群数据报表 // 客群数据报表
customerGroupTotalTable: [ customerGroupTotalTable: [
{ prop: 'xtime', label: '日期' }, { prop: 'xtime', label: '日期' },
{ prop: 'totalCnt', label: '客群总数' }, { prop: 'totalCnt', label: '客群总数' },
{ prop: 'addCnt', label: '新增客群数' }, { prop: 'addCnt', label: '新增客群数' },
{ prop: 'dissolveCnt', label: '解散客群数' }, { prop: 'dissolveCnt', label: '解散客群数' }
], ],
// 客群成员数据报表 // 客群成员数据报表
customerGroupMemberTotalTable: [ customerGroupMemberTotalTable: [
{ prop: 'xtime', label: '日期' }, { prop: 'xtime', label: '日期' },
{ prop: 'totalCnt', label: '客群成员总数' }, { prop: 'totalCnt', label: '客群成员总数' },
{ prop: 'addCnt', label: '新增客群成员数' }, { prop: 'addCnt', label: '新增客群成员数' },
{ prop: 'quitCnt', label: '流失客群成员数' }, { prop: 'quitCnt', label: '流失客群成员数' }
], ],
// 客户联系 // 客户联系
customerContactTable: [ customerContactTable: [
...@@ -96,19 +96,19 @@ export default { ...@@ -96,19 +96,19 @@ export default {
{ prop: 'chatCnt', label: '单聊总数' }, { prop: 'chatCnt', label: '单聊总数' },
{ prop: 'messageCnt', label: '发送消息数' }, { prop: 'messageCnt', label: '发送消息数' },
{ prop: 'replyPercentage', label: '已回复聊天占比' }, { prop: 'replyPercentage', label: '已回复聊天占比' },
{ prop: 'avgReplyTime', label: '平均回复时长(分)' }, { prop: 'avgReplyTime', label: '平均回复时长(分)' }
], ],
// 客群联系 // 客群联系
customerGroupContactTable: [ customerGroupContactTable: [
{ prop: 'xtime', label: '日期' }, { prop: 'xtime', label: '日期' },
{ prop: 'chatTotal', label: '群聊总数' }, { prop: 'chatTotal', label: '群聊总数' },
{ prop: 'msgTotal', label: '群聊消息数' }, { prop: 'msgTotal', label: '群聊消息数' },
{ prop: 'memberHasMsg', label: '发送消息群成员数' }, { prop: 'memberHasMsg', label: '发送消息群成员数' }
], ]
}, },
userArray: [], // 选择人员 userArray: [], // 选择人员
dialogVisible: false, dialogVisible: false,
dialogType: '_users', dialogType: '_users'
} }
}, },
computed: {}, computed: {},
...@@ -185,7 +185,7 @@ export default { ...@@ -185,7 +185,7 @@ export default {
averageReplyDurationChart: 'avgReplyTime', // 平均首次回复时长 averageReplyDurationChart: 'avgReplyTime', // 平均首次回复时长
groupChatTotalChart: 'chatTotal', // 群聊总数 groupChatTotalChart: 'chatTotal', // 群聊总数
groupChatMessageNumChart: 'msgTotal', // 群聊消息数 groupChatMessageNumChart: 'msgTotal', // 群聊消息数
sendMessageGroupMemberChart: 'memberHasMsg', // 发送消息群成员数 sendMessageGroupMemberChart: 'memberHasMsg' // 发送消息群成员数
} }
this.series = data.map((e) => e[dict[this.type]]) this.series = data.map((e) => e[dict[this.type]])
} }
...@@ -240,7 +240,7 @@ export default { ...@@ -240,7 +240,7 @@ export default {
if (['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(this.type)) { if (['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(this.type)) {
this.query.chatIds = '' this.query.chatIds = ''
this.getGroupList({ this.getGroupList({
userIds: this.query[this.dialogType], userIds: this.query[this.dialogType]
}) })
} }
this.getList() this.getList()
...@@ -249,7 +249,7 @@ export default { ...@@ -249,7 +249,7 @@ export default {
this.$confirm('是否确认导出吗?', '提示', { this.$confirm('是否确认导出吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}) })
.then(() => { .then(() => {
this.loading = true this.loading = true
...@@ -257,7 +257,20 @@ export default { ...@@ -257,7 +257,20 @@ export default {
return this.requestExport(query) return this.requestExport(query)
}) })
.then((res) => { .then((res) => {
this.download(res.data) if (res != null) {
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
let url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // 创建a标签
link.href = url
link.download =
this.type == 'customerGroupMemberTotalTable'
? '客群分析-客群成员数据报表.xlsx'
: this.type == 'customerTotalTable'
? '客户分析-数据报表.xlsx'
: '客群分析-数据报表.xlsx' //指定下载文件名
link.click()
URL.revokeObjectURL(url) // 释放内存
}
}) })
.catch((error) => { .catch((error) => {
console.error(error) console.error(error)
...@@ -265,9 +278,9 @@ export default { ...@@ -265,9 +278,9 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}, }
}, }
} }
</script> </script>
<template> <template>
...@@ -282,7 +295,7 @@ export default { ...@@ -282,7 +295,7 @@ export default {
v-if="!timeRange" v-if="!timeRange"
v-model="dateRange" v-model="dateRange"
class="ml20" class="ml20"
style="width: 260px" style="width: 260px;"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
type="daterange" type="daterange"
:clearable="false" :clearable="false"
...@@ -290,34 +303,39 @@ export default { ...@@ -290,34 +303,39 @@ export default {
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@change="getList(1)"></el-date-picker> @change="getList(1)"
></el-date-picker>
<el-input <el-input
v-if="type.toLowerCase().includes('group')" v-if="type.toLowerCase().includes('group')"
style="width: 180px; margin-left: 20px" style="width: 180px; margin-left: 20px;"
:value="userArray.map((e) => e.name) + ''" :value="userArray.map((e) => e.name) + ''"
readonly readonly
@focus="showDialog('_groupOwners')" @focus="showDialog('_groupOwners')"
placeholder="请选择群主"></el-input> placeholder="请选择群主"
></el-input>
<el-select <el-select
style="margin-left: 20px" style="margin-left: 20px;"
v-if="['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(type)" v-if="['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(type)"
v-model="query.chatIds" v-model="query.chatIds"
placeholder="请选择群聊" placeholder="请选择群聊"
clearable clearable
@change="getList()"> @change="getList()"
>
<el-option <el-option
v-for="item in groupChats" v-for="item in groupChats"
:key="item.chatId" :key="item.chatId"
:label="item.groupName" :label="item.groupName"
:value="item.chatId"></el-option> :value="item.chatId"
></el-option>
</el-select> </el-select>
<el-input <el-input
v-if="['customerTotalChart', 'customerTotalTable', 'realDataChart', 'customerContactTable'].includes(type)" v-if="['customerTotalChart', 'customerTotalTable', 'realDataChart', 'customerContactTable'].includes(type)"
style="width: 180px; margin-left: 20px" style="width: 180px; margin-left: 20px;"
:value="userArray.map((e) => e.name) + ''" :value="userArray.map((e) => e.name) + ''"
readonly readonly
@focus="showDialog('_users')" @focus="showDialog('_users')"
placeholder="请选择部门或员工" /> placeholder="请选择部门或员工"
/>
<el-button v-if="type.includes('Table')" class="fr" type="primary" @click="exprotTable">导出 Excel</el-button> <el-button v-if="type.includes('Table')" class="fr" type="primary" @click="exprotTable">导出 Excel</el-button>
</div> </div>
...@@ -325,16 +343,18 @@ export default { ...@@ -325,16 +343,18 @@ export default {
v-if="type.includes('Chart')" v-if="type.includes('Chart')"
:xData="xData" :xData="xData"
:legend="legend || legendDict[type]" :legend="legend || legendDict[type]"
:series="series"></ChartLine> :series="series"
></ChartLine>
<template v-else-if="type.includes('Table')"> <template v-else-if="type.includes('Table')">
<el-table :data="list" style="width: 100%"> <el-table :data="list" style="width: 100%;">
<el-table-column <el-table-column
v-for="(item, index) in tableProps[type]" v-for="(item, index) in tableProps[type]"
:key="index" :key="index"
:prop="item.prop" :prop="item.prop"
:label="item.label" :label="item.label"
align="center"></el-table-column> align="center"
></el-table-column>
</el-table> </el-table>
<pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList()" /> <pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList()" />
</template> </template>
...@@ -346,14 +366,16 @@ export default { ...@@ -346,14 +366,16 @@ export default {
:xData="xData" :xData="xData"
:legend="legend || legendDict[type]" :legend="legend || legendDict[type]"
:series="series" :series="series"
:option="option"></ChartLine> :option="option"
></ChartLine>
<SelectWeUser <SelectWeUser
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
title="组织架构" title="组织架构"
:defaultValues="userArray" :defaultValues="userArray"
@success="getSelectUser" @success="getSelectUser"
:isOnlyLeaf="dialogType === '_groupOwners'"></SelectWeUser> :isOnlyLeaf="dialogType === '_groupOwners'"
></SelectWeUser>
</div> </div>
</template> </template>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!