积分统计完成

This commit is contained in:
aixianling
2023-05-25 10:15:21 +08:00
parent ccd8cdf9ba
commit 44ce4979d7

View File

@@ -1,17 +1,17 @@
<template>
<section class="AppIntegralStatistics">
<el-row class="overallStatistics">
<div class="title">
<p>总体统计</p>
<div class="title_right">
<div>
<span v-for="(item,index) in timeCheck" :key="index" :class="type == index? 'active':''"
@click="timeChange(index)">{{ item }}</span>
</div>
<ai-detail list>
<ai-title slot="title" title="总体统计">
<template #rightBtn>
<el-row type="flex" align="middle">
<span class="shortcut" v-for="(item,i) in timeCheck" :key="i" :class="{active:type==i}"
@click="timeChange(i)" v-text="item"/>
<el-cascader ref="cascader1" v-model="girdArr" :options="girdOptions" placeholder="所属网格" size="small"
:props="defaultProps" :show-all-levels="false" @change="gridChange" clearable></el-cascader>
</div>
</div>
:props="defaultProps" :show-all-levels="false" @change="gridChange" clearable/>
</el-row>
</template>
</ai-title>
<template #content>
<div class="card_list">
<div class="card">
<h2>积分余额汇总
@@ -33,35 +33,48 @@
<p class="color1">{{ Math.abs(data.reduceIntegral) || 0 }}</p>
</div>
</div>
<div class="echertsBox">
<div class="left_Box">
<p>个人积分排行</p>
<el-row type="flex" class="mar-t20 gap-20">
<div class="chartBox fill">
<b>个人积分排行</b>
<div>
<div id="chart1" style="height: 300px; width: 100%;" v-show="userSortListX.length && userSortListY.length"></div>
<ai-empty v-show="!userSortListX.length && !userSortListY.length" style="height: 200px; width: 100%;" id="empty"></ai-empty>
<div id="chart1" style="height: 300px; width: 100%;"
v-show="userSortListX.length && userSortListY.length"></div>
<ai-empty v-if="!userSortListX.length && !userSortListY.length" style="height: 200px; width: 100%;"
id="empty"/>
</div>
</div>
<div class="right_Box">
<p>网格积分排行</p>
<div class="chartBox fill">
<b>网格积分排行</b>
<div>
<div id="chart2" style="height: 300px; width: 100%;" v-show="girdSortListX.length && girdSortListY.length"></div>
<ai-empty v-show="!girdSortListX.length && !girdSortListY.length" style="height: 200px; width: 100%;" id="empty"></ai-empty>
</div>
<div id="chart2" style="height: 300px; width: 100%;" v-show="girdSortListX.length && girdSortListY.length"/>
<ai-empty v-show="!girdSortListX.length && !girdSortListY.length" style="height: 200px; width: 100%;"
id="empty"/>
</div>
</div>
</el-row>
<ai-card>
<ai-title slot="title" title="积分明细"/>
<el-row type="flex" class="mar-t20 gap-20">
<div class="chartBox fill" v-for="item in sta" :key="item.id">
<div flex>
<b class="fill" v-text="item.label"/>
<div class="color-primary" v-text="`总次数:${item.total}`"/>
</div>
<div class="chart" :id="item.id" v-show="item.sta.length>0"/>
<ai-empty v-if="item.sta.length==0" style="height: 200px; width: 100%;"/>
</div>
</el-row>
<ai-card class="mar-t20" title="积分明细">
<template #content>
<ai-search-bar>
<template #left>
<el-cascader ref="cascader2" v-model="girdIdArr" :options="girdOptions" placeholder="所属网格" size="small"
:props="defaultProps" :show-all-levels="false" clearable @change="gridChangeOpt"></el-cascader>
<el-cascader ref="cascader2" v-model="girdIdArr" :options="girdOptions" placeholder="所属网格"
size="small"
:props="defaultProps" :show-all-levels="false" clearable
@change="gridChangeOpt"></el-cascader>
<ai-select v-model="search.integralType" placeholder="请选择类型" @change="current=1, getTableData()"
:selectList="dict.getDict('integralType')"/>
<el-date-picker v-model="time" size="small" type="daterange" value-format="yyyy-MM-dd"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" @change="onChange">
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期"
@change="onChange">
</el-date-picker>
</template>
<template #right>
@@ -90,7 +103,8 @@
</ai-table>
</template>
</ai-card>
</template>
</ai-detail>
<el-dialog title="详情" :visible.sync="dialog" customFooter width="700">
<ai-detail>
<template #content>
@@ -116,7 +130,6 @@
<el-button @click="dialog = false" style="width: 92px">关闭</el-button>
</span>
</el-dialog>
<ai-dialog :visible.sync="dialogDate" title="选择时间" width="500px" customFooter>
<el-date-picker v-model="timeList" size="small" type="daterange" value-format="yyyy-MM-dd"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期">
@@ -130,8 +143,12 @@
import {mapState} from "vuex"
import * as echarts from 'echarts';
import dayjs from 'dayjs'
import AiDetail from "dui/packages/layout/AiDetail.vue";
import AiTitle from "dui/packages/basic/AiTitle.vue";
export default {
name: "AppIntegralStatistics",
components: {AiTitle, AiDetail},
label: "积分统计",
props: {
instance: Function,
@@ -180,6 +197,7 @@ export default {
userSortListY: [],
girdSortListX: [],
girdSortListY: [],
sta: []
}
},
computed: {
@@ -195,14 +213,12 @@ export default {
{prop: "createTime", label: '时间', align: "center",},
{slot: "options"}
]
}
},
},
created() {
this.time = [dayjs().subtract(1, 'week').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
this.$dict.load('epidemicDangerousAreaLevel', 'integralType', 'integralRuleEvent', 'integralRuleEventType').then(() => {
this.getStatistics()
this.getGridList()
this.getRanking()
this.search.startTime = this.time?.[0]
this.search.endTime = this.time?.[1]
this.getTableData()
@@ -211,6 +227,7 @@ export default {
methods: {
// 统计接口
getStatistics() {
return Promise.all([
this.instance.post('/app/appintegraluser/allAppletUserIntegral', null, {
params: {
type: this.type,
@@ -220,14 +237,34 @@ export default {
}
}).then(res => {
if (res?.data) {
this.data = res.data
return this.data = res.data
}
})
}),
this.instance.post("/app/appwechatsigninfo/userSignAndIntegralApplyAndIntegralExchangeSort", null, {
params: {
type: this.type,
girdId: this.girdId,
startTime: this.startTime,
endTime: this.endTime,
}
}).then(res => {
if (res?.data) {
const {
signCountList = [], integralApplyCountList = [], integralExchangeCountList = [],
signCount = 0, integralExchangeCount = 0, integralApplyCount = 0
} = res.data
return this.sta = [
{label: "签到次数统计", id: 'signCount', sta: signCountList, total: signCount},
{label: "积分申请次数统计", id: 'integralApplyCount', sta: integralApplyCountList, total: integralApplyCount},
{label: "积分兑换次数统计(小程序用户)", id: 'integralExchangeCount', sta: integralExchangeCountList, total: integralExchangeCount}
]
}
}).then(() => this.sta.map(this.renderChart))
])
},
// 人员、网格排行
getRanking() {
this.instance.post('/app/appintegraluser/userAndGirdIntegralSortByApplet',null,{
return this.instance.post('/app/appintegraluser/userAndGirdIntegralSortByApplet', null, {
params: {
type: this.type,
girdId: this.girdId,
@@ -240,9 +277,11 @@ export default {
this.userSortListY = res.data.userSortList.map(e => e.changeIntegral).reverse()
this.girdSortListX = res.data.girdSortList.map(e => e.girdName).reverse()
this.girdSortListY = res.data.girdSortList.map(e => e.changeIntegral).reverse()
return 1;
}
}).then(() => {
this.getColEcherts1(this.userSortListX, this.userSortListY)
this.getColEcherts2(this.girdSortListX, this.girdSortListY)
}
})
},
// 积分明细
@@ -301,7 +340,6 @@ export default {
show: false,
},
},
series: [
{
data: yData,
@@ -324,7 +362,6 @@ export default {
}
]
}, true);
window.addEventListener("resize", this.onResize)
},
getColEcherts2(xData, yData) {
let chartDom2 = document.getElementById('chart2');
@@ -394,14 +431,11 @@ export default {
}
]
}, true);
window.addEventListener("resize", this.onResize2)
// this.extension(this.myChart2)
},
onResize1() {
this.myChart1.resize()
},
onResize2() {
this.myChart2.resize()
onResize() {
this.myChart1?.resize()
this.myChart2?.resize()
this.sta.map(e => e.chart?.resize())
},
gridChange(val) {
this.girdArr = val
@@ -441,12 +475,13 @@ export default {
},
timeChange(index) {
this.type = index
if (index == 3) {
this.dialogDate = true
}
this.type = index
} else {
this.getStatistics()
this.getRanking()
}
},
open(id) {
@@ -485,9 +520,25 @@ export default {
this.getStatistics()
this.getRanking()
},
renderChart(item = {}) {
if (!item.chart) {
const el = document.getElementById(item.id)
el.style.width = (window.innerWidth - 435) / 3 + "px";
item.chart = echarts.init(el)
}
item.chart.setOption({
xAxis: {minInterval: 1},
tooltip: {},
legend: {},
yAxis: {type: 'category'},
dataset: {dimensions: ['username', 'count', 'integral'], source: item.sta},
series: [
{name: "次数", barWidth: 10, barGap: '20%', type: 'bar'},
{name: "获取积分", barWidth: 10, barGap: '20%', type: 'bar'}
]
}, true)
}
},
filters: {
formatTime(num) {
if (num > 0) {
@@ -497,17 +548,14 @@ export default {
}
}
},
mounted() {
this.getColEcherts1()
this.getColEcherts2()
window.addEventListener('resize', this.onResize)
this.getRanking()
this.getStatistics()
},
destroyed() {
window.removeEventListener('resize', this.onResize1)
window.removeEventListener('resize', this.onResize2)
window.removeEventListener('resize', this.onResize)
},
}
</script>
@@ -515,31 +563,8 @@ export default {
.AppIntegralStatistics {
height: 100%;
box-sizing: border-box;
padding-top: 20px;
overflow-y: scroll;
.overallStatistics {
width: 100%;
margin-bottom: 16px;
padding: 20px;
box-sizing: border-box;
background: #FFF;
.title {
width: 100%;
display: flex;
justify-content: space-between;
margin-bottom: 16px;
p {
font-size: 16px;
font-family: MicrosoftYaHeiSemibold;
color: #222222;
font-weight: 600;
}
.title_right {
display: flex;
align-items: center;
span {
.shortcut {
display: inline-block;
width: 70px;
height: 32px;
@@ -549,16 +574,29 @@ export default {
margin-right: 8px;
text-align: center;
cursor: pointer;
}
.active {
&.active {
color: #2266FF;
border: 1px solid #2266FF;
}
}
.chartBox {
background: #F9F9F9;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.1500);
border-radius: 4px;
padding: 16px;
box-sizing: border-box;
.chart {
width: 100%;
height: 300px;
}
}
.card_list {
display: flex;
.card {
flex: 1;
height: 96px;
@@ -567,79 +605,46 @@ export default {
margin-right: 20px;
padding: 16px 24px;
box-sizing: border-box;
h2 {
color: #888888;
font-weight: 600;
font-size: 16px;
}
p {
margin-top: 8px;
font-size: 24px;
font-weight: 600;
}
.color1 {
color: #2891FF;
}
.color2 {
color: #22AA99;
}
.color3 {
color: #F8B425;
}
}
.card:last-child {
margin-right: 0;
}
}
.echertsBox {
width: 100%;
margin-top: 20px;
background: #FFF;
display: flex;
.left_Box {
margin-right: 16px;
flex: 1;
}
.right_Box {
width: 100%;
flex: 1;
}
.left_Box,
.right_Box {
background: #F9F9F9;
box-shadow: 0px 4px 6px -2px rgba(15,15,21,0.1500);
border-radius: 4px;
padding: 16px;
box-sizing: border-box;
#chart1,
#chart2 {
width: 100%;
height: 300px;
}
p {
font-weight: 600;
}
}
}
}
// .chartCss {
// position: absolute;
// color: black;
// background:white;
// font-family: Aril;
// font-size: 12px;
// padding: 5px;
// display: inline;
// }
:deep( .el-dialog__footer ) {
text-align: center;
}
:deep( .el-dialog__header ) {
border-bottom: 1px solid #DDD;
}
:deep( .ai-detail ) {
background: #FFF;
}