积分统计完成

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> <template>
<section class="AppIntegralStatistics"> <section class="AppIntegralStatistics">
<el-row class="overallStatistics"> <ai-detail list>
<div class="title"> <ai-title slot="title" title="总体统计">
<p>总体统计</p> <template #rightBtn>
<div class="title_right"> <el-row type="flex" align="middle">
<div> <span class="shortcut" v-for="(item,i) in timeCheck" :key="i" :class="{active:type==i}"
<span v-for="(item,index) in timeCheck" :key="index" :class="type == index? 'active':''" @click="timeChange(i)" v-text="item"/>
@click="timeChange(index)">{{ item }}</span>
</div>
<el-cascader ref="cascader1" v-model="girdArr" :options="girdOptions" placeholder="所属网格" size="small" <el-cascader ref="cascader1" v-model="girdArr" :options="girdOptions" placeholder="所属网格" size="small"
:props="defaultProps" :show-all-levels="false" @change="gridChange" clearable></el-cascader> :props="defaultProps" :show-all-levels="false" @change="gridChange" clearable/>
</div> </el-row>
</div> </template>
</ai-title>
<template #content>
<div class="card_list"> <div class="card_list">
<div class="card"> <div class="card">
<h2>积分余额汇总 <h2>积分余额汇总
@@ -33,48 +33,61 @@
<p class="color1">{{ Math.abs(data.reduceIntegral) || 0 }}</p> <p class="color1">{{ Math.abs(data.reduceIntegral) || 0 }}</p>
</div> </div>
</div> </div>
<div class="echertsBox"> <el-row type="flex" class="mar-t20 gap-20">
<div class="left_Box"> <div class="chartBox fill">
<p>个人积分排行</p> <b>个人积分排行</b>
<div> <div>
<div id="chart1" style="height: 300px; width: 100%;" v-show="userSortListX.length && userSortListY.length"></div> <div id="chart1" style="height: 300px; width: 100%;"
<ai-empty v-show="!userSortListX.length && !userSortListY.length" style="height: 200px; width: 100%;" id="empty"></ai-empty> 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> </div>
<div class="right_Box"> <div class="chartBox fill">
<p>网格积分排行</p> <b>网格积分排行</b>
<div> <div>
<div id="chart2" style="height: 300px; width: 100%;" v-show="girdSortListX.length && girdSortListY.length"></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"></ai-empty> <ai-empty v-show="!girdSortListX.length && !girdSortListY.length" style="height: 200px; width: 100%;"
</div> id="empty"/>
</div> </div>
</div> </div>
</el-row> </el-row>
<el-row type="flex" class="mar-t20 gap-20">
<ai-card> <div class="chartBox fill" v-for="item in sta" :key="item.id">
<ai-title slot="title" title="积分明细"/> <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> <template #content>
<ai-search-bar> <ai-search-bar>
<template #left> <template #left>
<el-cascader ref="cascader2" v-model="girdIdArr" :options="girdOptions" placeholder="所属网格" size="small" <el-cascader ref="cascader2" v-model="girdIdArr" :options="girdOptions" placeholder="所属网格"
:props="defaultProps" :show-all-levels="false" clearable @change="gridChangeOpt"></el-cascader> size="small"
:props="defaultProps" :show-all-levels="false" clearable
@change="gridChangeOpt"></el-cascader>
<ai-select v-model="search.integralType" placeholder="请选择类型" @change="current=1, getTableData()" <ai-select v-model="search.integralType" placeholder="请选择类型" @change="current=1, getTableData()"
:selectList="dict.getDict('integralType')"/> :selectList="dict.getDict('integralType')"/>
<el-date-picker v-model="time" size="small" type="daterange" value-format="yyyy-MM-dd" <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> </el-date-picker>
</template> </template>
<template #right> <template #right>
<el-input size="small" placeholder="请输入姓名" v-model="search.userName" clearable <el-input size="small" placeholder="请输入姓名" v-model="search.userName" clearable
@clear="current = 1, search.userName = '', getTableData()" suffix-icon="iconfont iconSearch" @clear="current = 1, search.userName = '', getTableData()" suffix-icon="iconfont iconSearch"
v-throttle="() => {(current = 1), getTableData();}" /> v-throttle="() => {(current = 1), getTableData();}"/>
</template> </template>
</ai-search-bar> </ai-search-bar>
<ai-table :tableData="tableData" :total="total" :current.sync="current" :size.sync="size" <ai-table :tableData="tableData" :total="total" :current.sync="current" :size.sync="size"
@getList="getTableData" :col-configs="colConfigs" :dict="dict"> @getList="getTableData" :col-configs="colConfigs" :dict="dict">
<el-table-column slot="eventDesc" label='事件' align="center" width="400px" show-overflow-tooltip> <el-table-column slot="eventDesc" label='事件' align="center" width="400px" show-overflow-tooltip>
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<span>{{ row.integralRuleName || row.eventDesc}}</span> <span>{{ row.integralRuleName || row.eventDesc }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column slot="changeIntegral" label="变动积分" align="center"> <el-table-column slot="changeIntegral" label="变动积分" align="center">
@@ -90,12 +103,13 @@
</ai-table> </ai-table>
</template> </template>
</ai-card> </ai-card>
</template>
</ai-detail>
<el-dialog title="详情" :visible.sync="dialog" customFooter width="700"> <el-dialog title="详情" :visible.sync="dialog" customFooter width="700">
<ai-detail> <ai-detail>
<template #content> <template #content>
<ai-wrapper> <ai-wrapper>
<ai-info-item label="姓名" :value="details.integralUserName" /> <ai-info-item label="姓名" :value="details.integralUserName"/>
<ai-info-item label="所属网格" :value="details.girdName"/> <ai-info-item label="所属网格" :value="details.girdName"/>
<ai-info-item label="事件" isLine :value="details.eventDesc"> <ai-info-item label="事件" isLine :value="details.eventDesc">
<span v-if="details.integralRuleId">{{ details.integralRuleName }}</span> <span v-if="details.integralRuleId">{{ details.integralRuleName }}</span>
@@ -116,7 +130,6 @@
<el-button @click="dialog = false" style="width: 92px">关闭</el-button> <el-button @click="dialog = false" style="width: 92px">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
<ai-dialog :visible.sync="dialogDate" title="选择时间" width="500px" customFooter> <ai-dialog :visible.sync="dialogDate" title="选择时间" width="500px" customFooter>
<el-date-picker v-model="timeList" size="small" type="daterange" value-format="yyyy-MM-dd" <el-date-picker v-model="timeList" size="small" type="daterange" value-format="yyyy-MM-dd"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期"> range-separator="" start-placeholder="开始日期" end-placeholder="结束日期">
@@ -127,11 +140,15 @@
</template> </template>
<script> <script>
import { mapState } from "vuex" import {mapState} from "vuex"
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import dayjs from 'dayjs' import dayjs from 'dayjs'
import AiDetail from "dui/packages/layout/AiDetail.vue";
import AiTitle from "dui/packages/basic/AiTitle.vue";
export default { export default {
name: "AppIntegralStatistics", name: "AppIntegralStatistics",
components: {AiTitle, AiDetail},
label: "积分统计", label: "积分统计",
props: { props: {
instance: Function, instance: Function,
@@ -151,13 +168,13 @@ export default {
startTime: '', startTime: '',
endTime: '', endTime: '',
}, },
girdIdArr:[], girdIdArr: [],
total: 0, total: 0,
size: 10, size: 10,
current: 1, current: 1,
girdList: [], girdList: [],
time: [], time: [],
timeCheck: ['昨日','近7天','近30天','自定义'], timeCheck: ['昨日', '近7天', '近30天', '自定义'],
dialog: false, dialog: false,
dialogDate: false, dialogDate: false,
timeList: [], timeList: [],
@@ -180,29 +197,28 @@ export default {
userSortListY: [], userSortListY: [],
girdSortListX: [], girdSortListX: [],
girdSortListY: [], girdSortListY: [],
sta: []
} }
}, },
computed: { computed: {
...mapState(['user']), ...mapState(['user']),
colConfigs() { colConfigs() {
return [ return [
{ prop: "integralUserName", label: '姓名', align: "left", width: "200px" }, {prop: "integralUserName", label: '姓名', align: "left", width: "200px"},
{ prop: "girdName", label: '所属网格', align: "center", width: "180px" }, {prop: "girdName", label: '所属网格', align: "center", width: "180px"},
{ slot: "eventDesc"}, {slot: "eventDesc"},
{ prop: "integralType", label: '类型', align: "center", dict: "integralType"}, {prop: "integralType", label: '类型', align: "center", dict: "integralType"},
{ slot: "changeIntegral", label: '积分变动', align: "center", }, {slot: "changeIntegral", label: '积分变动', align: "center",},
{ prop: "nowIntegral", label: '剩余积分', align: "center", }, {prop: "nowIntegral", label: '剩余积分', align: "center",},
{ prop: "createTime", label: '时间', align: "center", }, {prop: "createTime", label: '时间', align: "center",},
{ slot: "options" } {slot: "options"}
] ]
} },
}, },
created() { created() {
this.time = [dayjs().subtract(1,'week').format('YYYY-MM-DD'),dayjs().format('YYYY-MM-DD')] this.time = [dayjs().subtract(1, 'week').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
this.$dict.load('epidemicDangerousAreaLevel','integralType','integralRuleEvent','integralRuleEventType').then(() => { this.$dict.load('epidemicDangerousAreaLevel', 'integralType', 'integralRuleEvent', 'integralRuleEventType').then(() => {
this.getStatistics()
this.getGridList() this.getGridList()
this.getRanking()
this.search.startTime = this.time?.[0] this.search.startTime = this.time?.[0]
this.search.endTime = this.time?.[1] this.search.endTime = this.time?.[1]
this.getTableData() this.getTableData()
@@ -211,7 +227,8 @@ export default {
methods: { methods: {
// 统计接口 // 统计接口
getStatistics() { getStatistics() {
this.instance.post('/app/appintegraluser/allAppletUserIntegral',null, { return Promise.all([
this.instance.post('/app/appintegraluser/allAppletUserIntegral', null, {
params: { params: {
type: this.type, type: this.type,
girdId: this.girdId, girdId: this.girdId,
@@ -219,15 +236,35 @@ export default {
endTime: this.endTime, endTime: this.endTime,
} }
}).then(res => { }).then(res => {
if(res?.data) { 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() { getRanking() {
this.instance.post('/app/appintegraluser/userAndGirdIntegralSortByApplet',null,{ return this.instance.post('/app/appintegraluser/userAndGirdIntegralSortByApplet', null, {
params: { params: {
type: this.type, type: this.type,
girdId: this.girdId, girdId: this.girdId,
@@ -235,19 +272,21 @@ export default {
endTime: this.endTime endTime: this.endTime
} }
}).then((res) => { }).then((res) => {
if(res?.data) { if (res?.data) {
this.userSortListX = res.data.userSortList.map(e=> e.userName).reverse() this.userSortListX = res.data.userSortList.map(e => e.userName).reverse()
this.userSortListY = res.data.userSortList.map(e=> e.changeIntegral).reverse() this.userSortListY = res.data.userSortList.map(e => e.changeIntegral).reverse()
this.girdSortListX = res.data.girdSortList.map(e=> e.girdName).reverse() this.girdSortListX = res.data.girdSortList.map(e => e.girdName).reverse()
this.girdSortListY = res.data.girdSortList.map(e=> e.changeIntegral).reverse() this.girdSortListY = res.data.girdSortList.map(e => e.changeIntegral).reverse()
this.getColEcherts1(this.userSortListX,this.userSortListY) return 1;
this.getColEcherts2(this.girdSortListX,this.girdSortListY)
} }
}).then(() => {
this.getColEcherts1(this.userSortListX, this.userSortListY)
this.getColEcherts2(this.girdSortListX, this.girdSortListY)
}) })
}, },
// 积分明细 // 积分明细
getTableData() { getTableData() {
this.instance.post('/app/appintegraluser/girdIntegralDetailByApplet',null,{ this.instance.post('/app/appintegraluser/girdIntegralDetailByApplet', null, {
params: { params: {
...this.search, ...this.search,
current: this.current, current: this.current,
@@ -255,7 +294,7 @@ export default {
total: this.total, total: this.total,
} }
}).then(res => { }).then(res => {
if(res?.data) { if (res?.data) {
this.tableData = res.data.records this.tableData = res.data.records
this.total = res.data.total this.total = res.data.total
} }
@@ -269,7 +308,7 @@ export default {
this.getTableData() this.getTableData()
}, },
getColEcherts1(xData,yData) { getColEcherts1(xData, yData) {
let chartDom1 = document.getElementById('chart1'); let chartDom1 = document.getElementById('chart1');
chartDom1.style.width = (window.innerWidth - 435) / 2 + "px"; chartDom1.style.width = (window.innerWidth - 435) / 2 + "px";
this.myChart1 = echarts.init(chartDom1); this.myChart1 = echarts.init(chartDom1);
@@ -301,7 +340,6 @@ export default {
show: false, show: false,
}, },
}, },
series: [ series: [
{ {
data: yData, data: yData,
@@ -324,9 +362,8 @@ export default {
} }
] ]
}, true); }, true);
window.addEventListener("resize", this.onResize)
}, },
getColEcherts2(xData,yData) { getColEcherts2(xData, yData) {
let chartDom2 = document.getElementById('chart2'); let chartDom2 = document.getElementById('chart2');
chartDom2.style.width = (window.innerWidth - 435) / 2 + "px"; chartDom2.style.width = (window.innerWidth - 435) / 2 + "px";
this.myChart2 = echarts.init(chartDom2); this.myChart2 = echarts.init(chartDom2);
@@ -359,12 +396,12 @@ export default {
}, },
triggerEvent: true, triggerEvent: true,
//设置文本过长超出隐藏...表示 //设置文本过长超出隐藏...表示
axisLabel:{ axisLabel: {
margin: 8, margin: 8,
formatter: function(params){ formatter: function (params) {
var val="" var val = ""
if(params.length > 8) { if (params.length > 8) {
val = params.substr(0,8)+'...' val = params.substr(0, 8) + '...'
return val return val
} else { } else {
return params; return params;
@@ -394,14 +431,11 @@ export default {
} }
] ]
}, true); }, true);
window.addEventListener("resize", this.onResize2)
// this.extension(this.myChart2)
}, },
onResize1() { onResize() {
this.myChart1.resize() this.myChart1?.resize()
}, this.myChart2?.resize()
onResize2() { this.sta.map(e => e.chart?.resize())
this.myChart2.resize()
}, },
gridChange(val) { gridChange(val) {
this.girdArr = val this.girdArr = val
@@ -441,12 +475,13 @@ export default {
}, },
timeChange(index) { timeChange(index) {
if(index == 3) {
this.dialogDate = true
}
this.type = index this.type = index
if (index == 3) {
this.dialogDate = true
} else {
this.getStatistics() this.getStatistics()
this.getRanking() this.getRanking()
}
}, },
open(id) { open(id) {
@@ -461,13 +496,13 @@ export default {
}, },
getDetail(id) { getDetail(id) {
this.instance.post(`/app/appintegraldetail/queryDetailById?id=${id}`).then(res=> { this.instance.post(`/app/appintegraldetail/queryDetailById?id=${id}`).then(res => {
if(res?.data) { if (res?.data) {
this.details = res.data this.details = res.data
if(res.data.enclosure) { if (res.data.enclosure) {
let str = res.data.enclosure.split('/') let str = res.data.enclosure.split('/')
this.fileDownLoad = [{ this.fileDownLoad = [{
url:res.data.enclosure, url: res.data.enclosure,
name: str?.[str.length - 1] name: str?.[str.length - 1]
}] }]
} }
@@ -476,7 +511,7 @@ export default {
}, },
selectDete() { selectDete() {
if(!this.timeList || !this.timeList.length) { if (!this.timeList || !this.timeList.length) {
return this.$message.error('请选择自定义时间'); return this.$message.error('请选择自定义时间');
} }
this.startTime = this.timeList?.[0] this.startTime = this.timeList?.[0]
@@ -485,29 +520,42 @@ export default {
this.getStatistics() this.getStatistics()
this.getRanking() 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: { filters: {
formatTime(num) { formatTime(num) {
if(num > 0) { if (num > 0) {
return '+' + num return '+' + num
} else { } else {
return num return num
} }
} }
}, },
mounted() { mounted() {
this.getColEcherts1() window.addEventListener('resize', this.onResize)
this.getColEcherts2() this.getRanking()
this.getStatistics()
}, },
destroyed() {
destroyed () { window.removeEventListener('resize', this.onResize)
window.removeEventListener('resize', this.onResize1)
window.removeEventListener('resize', this.onResize2)
}, },
} }
</script> </script>
@@ -515,31 +563,8 @@ export default {
.AppIntegralStatistics { .AppIntegralStatistics {
height: 100%; height: 100%;
box-sizing: border-box; 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 { .shortcut {
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 {
display: inline-block; display: inline-block;
width: 70px; width: 70px;
height: 32px; height: 32px;
@@ -549,16 +574,29 @@ export default {
margin-right: 8px; margin-right: 8px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
}
.active { &.active {
color: #2266FF; color: #2266FF;
border: 1px solid #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 { .card_list {
display: flex; display: flex;
.card { .card {
flex: 1; flex: 1;
height: 96px; height: 96px;
@@ -567,81 +605,48 @@ export default {
margin-right: 20px; margin-right: 20px;
padding: 16px 24px; padding: 16px 24px;
box-sizing: border-box; box-sizing: border-box;
h2 { h2 {
color: #888888; color: #888888;
font-weight: 600; font-weight: 600;
font-size: 16px; font-size: 16px;
} }
p { p {
margin-top: 8px; margin-top: 8px;
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
} }
.color1 { .color1 {
color: #2891FF; color: #2891FF;
} }
.color2 { .color2 {
color: #22AA99; color: #22AA99;
} }
.color3 { .color3 {
color: #F8B425; color: #F8B425;
} }
} }
.card:last-child { .card:last-child {
margin-right: 0; 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 { :deep( .el-dialog__footer ) {
// position: absolute;
// color: black;
// background:white;
// font-family: Aril;
// font-size: 12px;
// padding: 5px;
// display: inline;
// }
:deep( .el-dialog__footer ){
text-align: center; text-align: center;
} }
:deep( .el-dialog__header ){
:deep( .el-dialog__header ) {
border-bottom: 1px solid #DDD; border-bottom: 1px solid #DDD;
} }
:deep( .ai-detail ){
:deep( .ai-detail ) {
background: #FFF; background: #FFF;
} }
} }
</style> </style>