Files
dvcp_v2_wxcp_app/src/project/pingchang/AppCommunityManagement/Statistics.vue
2022-09-29 09:04:28 +08:00

392 lines
10 KiB
Vue

<template>
<div class="Statistics">
<div class="header">
<img src="./components/img/header.png" alt="" />
<div class="content-info">
<div class="title">
<div class="time-select">
<span v-if="beginDate" @click="showDateSelect=true">{{ beginDate }} {{ endDate }}</span>
<span v-else @click="showDateSelect=true">日期选择</span>
<u-icon name="arrow-down" color="#666" size="28" style="margin-left: 4px" v-if="!beginDate" @click="showDateSelect=true"/>
<u-icon name="close-circle" color="#666" size="34" style="margin-left: 4px" v-else @click="clearDate" />
</div>
<div class="area-select">
<AiAreaPicker v-model="areaId" :areaId="user.areaId" @select="areaSelect" :name.sync="areaName" style="color: #666" selectRoot>
<span v-if="areaName" class="area-name">{{ areaName }}</span>
<span v-else>地区选择</span>
<u-icon name="arrow-down" color="#666" size="28" style="margin-left: 4px" />
</AiAreaPicker>
</div>
</div>
<div class="tab-content" v-if="info.numberMap && info.numberMap['累计排查']">
<div class="tab-item">
<h2 class="color-5AAD6A">{{info.numberMap['累计排查']}}</h2>
<p>累计排查</p>
</div>
<div class="tab-item">
<h2 class="color-4185F5">{{info.numberMap['今日排查']}}</h2>
<p>今日排查</p>
</div>
<div class="tab-item">
<h2 class="color-CD413A">{{info.numberMap['今日核酸']}}</h2>
<p>今日核酸</p>
</div>
<div class="tab-item">
<h2 class="color-5AAD6A">{{info.numberMap['我的排查']}}</h2>
<p>我的排查</p>
</div>
</div>
</div>
</div>
<div class="echart-content mar-t160">
<div class="title">排查数据统计</div>
<div class="echart" id="statistic"></div>
<div class="type-text"><span class="tips bg-32C5FF"></span>排查人数 <span class="tips bg-FFAA44"></span>已采核酸</div>
</div>
<div class="echart-content">
<div class="title">返乡数据统计</div>
<div class="chart-flex">
<div class="chart-box" id="statisticCircle" style="width: 200px;height: 200px;"></div>
<div class="type-num">
<div class="item status0">
<div class="label">
<span class="tips"></span>返乡登记
</div>
<div class="num">{{backVal}}</div>
</div>
<div class="item status1">
<div class="label">
<span class="tips"></span>卡口登记
</div>
<div class="num">{{pointVal}}</div>
</div>
</div>
</div>
</div>
<u-calendar v-model="showDateSelect" mode="range" min-year="2020" @change="dateConfirm"></u-calendar>
</div>
</template>
<script>
import { mapState } from 'vuex'
import echarts from 'echarts'
export default {
name: 'Statistics',
data() {
return {
info: {},
echartData: null,
echartDataClrcle: null,
areaId: '',
areaName: '',
beginDate: '',
endDate: '',
showDateSelect: false,
backVal: 0,
pointVal: 0,
firstGet: true, //第一次请求
}
},
computed: { ...mapState(['user']) },
onShow() {
document.title = '排查统计'
},
onLoad() {
this.areaId = this.user.areaId
this.areaName = this.user.areaName
this.getData()
},
methods: {
areaSelect(e) {
this.areaId = e
this.getData()
},
dateConfirm(e) {
console.log(11)
this.beginDate = e.startDate
this.endDate = e.endDate
this.getData()
},
clearDate() {
this.beginDate = ''
this.endDate = ''
this.getData()
},
getData() {
this.$http.post(`/app/appepidemicpreventioncommunitymanagement/statistics?areaId=${this.areaId}&beginTime=${this.beginDate}&endTime=${this.endDate}`).then((res) => {
if (res.code == 0) {
if(this.firstGet) {
var myDate = new Date();
this.beginDate = myDate.getFullYear() + res.data.trend[0].ymd
this.endDate = myDate.getFullYear() + res.data.trend[6].ymd
this.firstGet = false
}
this.info = res.data
var xData = [], yDataScreening = [], yDataNucleicAcid = []
res.data.trend.map((item) => {
xData.push(item.ymd)
yDataScreening.push(item['排查人数'])
yDataNucleicAcid.push(item['已采核酸'])
})
res.data.sourceMap.map((item) => {
if(item.type == 1) {
this.backVal = item.c
}else {
this.pointVal = item.c
}
})
this.chartInit(xData, yDataScreening, yDataNucleicAcid)
this.chartInitCircle(this.backVal, this.pointVal)
}
})
},
chartInit(xData, yDataBack, yDataError) {
this.echartData = echarts.init(document.getElementById('statistic'))
var option = {
grid: {
left: '6%',
right: '8%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: xData
},
yAxis: {
type: 'value'
},
series: [
{
type: 'line',
data: yDataBack,
lineStyle: {
normal: {
color: '#32c5ff'
}
},
itemStyle : {
normal : {
color:'#32c5ff',
}
}
},
{
type: 'line',
data: yDataError,
lineStyle: {
normal: {
color: '#ffaa44'
}
},
itemStyle : {
normal : {
color:'#ffaa44',
}
}
},
]
};
this.echartData.setOption(option)
},
chartInitCircle(backVal, pointVal) {
this.echartDataCircle = echarts.init(document.getElementById('statisticCircle'))
var option = {
color: ['#4185F5', '#5AAD6A'],
series: [
{
type: 'pie',
radius: '80%',
label: {
show: false,
position: 'center'
},
data: [
{ value: backVal, name: '返乡登记' },
{ value: pointVal, name: '卡口登记' },
],
}
]
};
this.echartDataCircle.setOption(option)
},
},
}
</script>
<style lang="scss" scoped>
.Statistics {
.header {
position: relative;
img {
width: 100%;
height: 504px;
}
.content-info {
width: calc(100% - 60px);
background: #fff;
box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.12);
border-radius: 8px;
position: absolute;
top: 368px;
left: 30px;
z-index: 99;
margin-bottom: 32px;
.title {
display: flex;
justify-content: space-between;
padding: 32px;
.time-select{
width: 400px;
}
.area-select {
width: calc(100% - 400px);
text-align: right;
}
h2 {
font-size: 36px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
line-height: 50px;
}
div {
font-size: 26px;
font-family: PingFangSC-Regular, PingFang SC;
color: #999;
line-height: 36px;
}
}
.tab-content {
padding-bottom: 20px;
.tab-item {
display: inline-block;
width: 25%;
text-align: center;
margin-bottom: 32px;
h2 {
font-size: 52px;
font-family: DINAlternate-Bold, DINAlternate;
font-weight: bold;
line-height: 60px;
margin-bottom: 10px;
letter-spacing: -4px;
}
p {
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
color: #999;
line-height: 40px;
}
.color-5AAD6A {
color: #5aad6a;
}
.color-4185F5 {
color: #4185f5;
}
.color-CD413A {
color: #cd413a;
}
}
}
}
}
.area-name {
display: inline-block;
width: calc(100% - 64px);
vertical-align: bottom;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.mar-t160 {
margin-top: 160px;
}
.echart-content {
width: 100%;
background-color: #fff;
padding: 0 32px 38px;
box-sizing: border-box;
margin-bottom: 32px;
.title {
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333;
line-height: 96px;
margin-bottom: 16px;
overflow: hidden;
.right-search {
float: right;
font-size: 28px;
color: #666;
}
}
.echart {
width: 100%;
height: 464px;
background: #f9f9f9;
border-radius: 8px;
margin-bottom: 32px;
}
.type-text {
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
color: #666;
line-height: 40px;
text-align: center;
.tips {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 2px;
margin-right: 20px;
}
.bg-32C5FF {
background: #32c5ff;
}
.bg-FFAA44 {
background: #ffaa44;
margin-left: 80px;
}
}
.chart-flex {
display: flex;
justify-content: space-between;
.type-num {
width: 240px;
margin-top: 120px;
.item {
width: 100%;
display: flex;
justify-content: space-between;
margin-bottom: 32px;
.tips {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 2px;
margin-right: 20px;
}
}
.status0 {
color: #4185F5;
.tips {
background-color: #4185F5;
}
}
.status1 {
color: #5AAD6A;
.tips {
background-color: #5AAD6A;
}
}
}
}
}
}
</style>