SystemReconciliation.vue 12.4 KB
Newer Older
liang ce committed
1 2
<template>
  <div class="SystemReconciliation">
liang ce committed
3
    <div class="searchBox">
liang ce committed
4
      <a-select allowClear placeholder="请选择年" v-model="year" style="width: 120px">
liang ce committed
5 6
        <a-select-option v-for="item in yearList" :key="item" :value="item">{{item}}</a-select-option>
      </a-select>
liang ce committed
7
      <a-select allowClear placeholder="请选择月" v-model="month" style="width: 120px;margin-left: 10px">
liang ce committed
8 9
        <a-select-option v-for="item in 12" :key="item" :value="item">{{item}}</a-select-option>
      </a-select>
liang ce committed
10
      <a-button type="primary" @click="init">查询</a-button>
liang ce committed
11
    </div>
liang ce committed
12
    <div class="chart">
liang ce committed
13 14
      <div id="rechargeLine" :style="{width: '100%', height: '300px'}"></div>
    </div>
liang ce committed
15
    <div class="chart" style="width: 100%;position: relative;border: 1px solid #dddddd;margin-bottom: 20px">
liang ce committed
16
      <div id="subsidyList" :style="{width: '100%', height: '300px'}"></div>
liang ce committed
17
      <a-select placeholder="津贴类型" v-model="sceneType" style="width: 120px;position: absolute;right: 10%;top: 20px;" @change="changeSceneType">
liang ce committed
18 19 20
        <a-select-option value="MEAL">餐补</a-select-option>
        <a-select-option value="TRAVEL">交通补贴</a-select-option>
      </a-select>
liang ce committed
21
    </div>
liang ce committed
22
    <div class="chart">
liang ce committed
23 24
      <div id="consumeLine" :style="{width: '100%', height: '300px'}"></div>
    </div>
liang ce committed
25 26 27 28
  </div>
</template>

<script>
liang ce committed
29
import { $http } from './../../../api/axios.js'
liang ce committed
30
export default {
liang ce committed
31 32 33
  name: 'systemReconciliation',
  data () {
    return {
liang ce committed
34 35 36 37 38
      year: '',
      month: '',
      SubsidyListDataList: [],
      ConsumeDataList: [],
      RechargeDataList: [],
liang ce committed
39
      yearList: [],
liang ce committed
40 41
      lineWidth: [],
      sceneType: 'MEAL'
liang ce committed
42 43 44
    }
  },
  created () {
liang ce committed
45 46 47 48 49 50
    let thisYear = new Date().getFullYear()
    for (let i = 2018; i <= thisYear; i++) {
      this.yearList.push(i)
    }
    this.year = new Date().getFullYear()
    this.month = new Date().getMonth() + 1
liang ce committed
51
    this.init()
liang ce committed
52 53 54
  },
  mounted () {
    // this.drawLine()
liang ce committed
55 56 57 58 59
    window.addEventListener('resize', () => {
      this.$echarts.init(document.getElementById('subsidyList')).resize()
      this.$echarts.init(document.getElementById('rechargeLine')).resize()
      this.$echarts.init(document.getElementById('consumeLine')).resize()
    })
liang ce committed
60 61
  },
  methods: {
liang ce committed
62
    init () {
liang ce committed
63 64 65 66
      if (!this.year) {
        this.$message.success('请选择年份')
        return
      }
liang ce committed
67 68 69 70
      this.getStatisticsSubsidyData()
      this.getStatisticsConsumeData()
      this.getStatisticsRechargeData()
    },
liang ce committed
71 72 73 74 75
    drawSubsidyListDataLine () {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('subsidyList'))
      // 绘制图表
      let xAxisData = []
liang ce committed
76
      let data = []
liang ce committed
77
      let dataAmount = 0
liang ce committed
78
      this.SubsidyListDataList.map(item => {
liang ce committed
79
        xAxisData.push(parseInt(item.abscissaKey))
liang ce committed
80
        data.push(item.subsidyTotalAmount ? item.subsidyTotalAmount : 0)
liang ce committed
81
        dataAmount = (dataAmount * 100 + item.subsidyTotalAmount * 100) / 100
liang ce committed
82
      })
liang ce committed
83
      let unit = this.month === undefined ? '月' : '日'
liang ce committed
84
      let color = this.sceneType === 'MEAL' ? ['#00CC66'] : [`#FADF33`]
liang ce committed
85
      myChart.setOption({
liang ce committed
86 87 88 89 90 91
        color: color,
        title: {
          text: '发放津贴金额',
          textStyle: {
            fontSize: 14,
            fontWeight: 'normal'
liang ce committed
92
          },
liang ce committed
93
          left: '5%'
liang ce committed
94
        },
liang ce committed
95 96 97 98
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
liang ce committed
99 100 101 102 103 104 105
          },
          formatter: function (params) {
            var res = `<div><p>时间:${params[0].name}${unit}</p></div>`
            for (var i = 0; i < params.length; i++) {
              res += '<p>' + params[i].seriesName + ':¥ ' + params[i].data.toFixed(2) + '</p>'
            }
            return res
liang ce committed
106 107 108
          }
        },
        legend: {
liang ce committed
109 110 111 112 113
          data: [`${this.sceneType === 'MEAL' ? '餐补' : '交通补贴'}`],
          formatter: function (name) {
            return `${name} ${dataAmount}元`
          },
          itemGap: 40
liang ce committed
114
        },
liang ce committed
115 116 117 118 119
        xAxis: [
          {
            name: `(${this.month === undefined ? '月' : '日'})`, // 给X轴加单位
            // nameLocation: 'middle',
            type: 'category',
liang ce committed
120
            data: xAxisData
liang ce committed
121 122 123 124 125
          }
        ],
        yAxis: {
          name: '(元)',
          type: 'value'
liang ce committed
126 127
        },
        series: [{
liang ce committed
128
          name: `${this.sceneType === 'MEAL' ? '餐补' : '交通补贴'}`,
liang ce committed
129
          type: 'bar',
liang ce committed
130
          data: data
liang ce committed
131 132
        }]
      })
133
    },
liang ce committed
134 135 136 137 138 139 140
    drawRechargeListDataLine () {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('rechargeLine'))
      // 绘制图表
      let xAxisData = []
      let data1 = []
      let data2 = []
liang ce committed
141 142
      let data1Amount = 0
      let data2Amount = 0
liang ce committed
143 144
      this.RechargeDataList.map(item => {
        xAxisData.push(parseInt(item.abscissaKey))
145
        data1.push(item.externalRechargeAmount ? item.externalRechargeAmount : 0)
liang ce committed
146
        data1Amount = (data1Amount * 100 + item.externalRechargeAmount * 100) / 100
147
        data2.push(item.internalRechargeAmount ? item.internalRechargeAmount : 0)
liang ce committed
148
        data2Amount = (item.internalRechargeAmount * 100 + data2Amount * 100) / 100
liang ce committed
149
      })
liang ce committed
150
      let unit = this.month === undefined ? '月' : '日'
liang ce committed
151
      myChart.setOption({
liang ce committed
152
        color: ['#3F9EFE', '#FF4A7A'],
liang ce committed
153 154 155 156 157
        title: {
          text: '充值金额',
          textStyle: {
            fontSize: 14,
            fontWeight: 'normal'
liang ce committed
158
          },
liang ce committed
159
          left: '5%'
liang ce committed
160
        },
liang ce committed
161
        legend: {
liang ce committed
162 163 164 165 166 167 168 169 170
          data: ['支付宝充值', '现金充值'],
          formatter: function (name) {
            if (name === '支付宝充值') {
              return `${name} ${data1Amount}元`
            } else {
              return `${name} ${data2Amount}元`
            }
          },
          itemGap: 40
liang ce committed
171 172
        },
        grid: {
liang ce committed
173 174
          left: '10%',
          right: '10%'
liang ce committed
175 176 177 178 179
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
liang ce committed
180 181 182 183 184 185 186
          },
          formatter: function (params) {
            var res = `<div><p>时间:${params[0].name}${unit}</p></div>`
            for (var i = 0; i < params.length; i++) {
              res += '<p>' + params[i].seriesName + ':¥ ' + params[i].data.toFixed(2) + '</p>'
            }
            return res
liang ce committed
187 188
          }
        },
liang ce committed
189 190 191 192
        xAxis: [
          {
            name: `(${unit})`, // 给X轴加单位
            type: 'category',
liang ce committed
193
            data: xAxisData
liang ce committed
194 195 196 197 198
          }
        ],
        yAxis: {
          name: '(元)',
          type: 'value'
liang ce committed
199 200 201 202 203 204 205 206 207 208 209
        },
        series: [{
          name: '支付宝充值',
          type: 'bar',
          data: data1
        }, {
          name: '现金充值',
          type: 'bar',
          data: data2
        }]
      })
210
    },
liang ce committed
211 212 213 214 215 216 217 218
    drawConsumeListDataLine () {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('consumeLine'))
      // 绘制图表
      let xAxisData = []
      let data1 = []
      let data2 = []
      let data3 = []
liang ce committed
219 220 221
      let data1Amount = 0
      let data2Amount = 0
      let data3Amount = 0
liang ce committed
222 223 224
      // internalConsumeRealityAmount 员工现金
      // internalConsumeSubsidyAmount 津贴
      // externalConsumeRealityAmount 访客消费
liang ce committed
225 226 227 228 229
      // .toFixed(2) + '元'
      let unit = this.month === undefined ? '月' : '日'
      this.ConsumeDataList.map(item => {
        xAxisData.push(parseInt(item.abscissaKey))
        data1.push(item.internalConsumeRealityAmount ? item.internalConsumeRealityAmount : 0.00)
liang ce committed
230
        data1Amount = (data1Amount * 100 + item.internalConsumeRealityAmount * 100) / 100
liang ce committed
231
        data2.push(item.internalConsumeSubsidyAmount ? item.internalConsumeSubsidyAmount : 0.00)
liang ce committed
232
        data2Amount = (data2Amount * 100 + item.internalConsumeSubsidyAmount * 100) / 100
liang ce committed
233
        data3.push(item.externalConsumeRealityAmount ? item.externalConsumeRealityAmount : 0.00)
liang ce committed
234
        data3Amount = (data3Amount * 100 + item.externalConsumeRealityAmount * 100) / 100
liang ce committed
235
      })
liang ce committed
236
      myChart.setOption({
liang ce committed
237
        color: ['#B87EE5', '#0066CC', '#EB597B'],
liang ce committed
238 239 240 241 242
        title: {
          text: '消费金额',
          textStyle: {
            fontSize: 14,
            fontWeight: 'normal'
liang ce committed
243
          },
liang ce committed
244
          left: '5%'
liang ce committed
245
        },
liang ce committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
        legend: {
          data: [`员工现金消费`, `员工津贴消费`, `访客消费`],
          formatter: function (name) {
            if (name === '员工现金消费') {
              return `${name} ${data1Amount}元`
            } else if (name === '员工津贴消费') {
              return `${name} ${data2Amount}元`
            } else {
              return `${name} ${data3Amount}元`
            }
          },
          itemGap: 40
        },
        grid: {
          left: '10%',
          right: '10%'
        },
liang ce committed
263 264 265 266
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
liang ce committed
267 268 269 270 271 272 273
          },
          formatter: function (params) {
            var res = `<div><p>时间:${params[0].name}${unit}</p></div>`
            for (var i = 0; i < params.length; i++) {
              res += '<p>' + params[i].seriesName + ':¥ ' + params[i].data.toFixed(2) + '</p>'
            }
            return res
liang ce committed
274 275
          }
        },
liang ce committed
276
        xAxis: {
liang ce committed
277 278 279
          name: `(${this.month === undefined ? '月' : '日'})`, // 给X轴加单位
          // nameLocation: 'middle',
          type: 'category',
liang ce committed
280
          data: xAxisData
liang ce committed
281
        },
liang ce committed
282 283 284 285 286 287
        yAxis: {
          name: '(元)',
          type: 'value'
          // axisLabel: {
          //   formatter: '{value}元'
          // }
liang ce committed
288
        },
liang ce committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302
        series: [{
          name: '员工现金消费',
          type: 'bar',
          data: data1
        }, {
          name: '员工津贴消费',
          type: 'bar',
          data: data2
        }, {
          name: '访客消费',
          type: 'bar',
          data: data3
        }]
      })
303
    },
liang ce committed
304 305 306
    changeSceneType (value) {
      this.sceneType = value
      this.getStatisticsSubsidyData()
liang ce committed
307
    },
liang ce committed
308 309 310 311
    getStatisticsSubsidyData () {
      let that = this
      let SubsidyListData = {
        year: this.year,
liang ce committed
312 313
        month: this.month,
        sceneType: this.sceneType
liang ce committed
314
      }
liang ce committed
315 316 317 318 319 320 321 322
      $http.get(`/mingpay/v1/isv/account/statisticsSubsidy`, SubsidyListData).then((res) => {
        if (res.data.resultCode === 0) {
          that.SubsidyListDataList = res.data.data
          that.drawSubsidyListDataLine()
        } else {
          this.$message.error(res.data.message)
        }
      })
liang ce committed
323
    },
liang ce committed
324 325 326 327 328
    getStatisticsConsumeData () {
      let that = this
      let ConsumeData = {
        year: this.year,
        month: this.month
liang ce committed
329
      }
liang ce committed
330 331 332 333 334 335 336 337 338
      $http.get(`/mingpay/v1/isv/account/statisticsConsume`, ConsumeData).then((res) => {
        console.log(res.data.data)
        if (res.data.resultCode === 0) {
          that.ConsumeDataList = res.data.data
          that.drawConsumeListDataLine()
        } else {
          this.$message.error(res.data.message)
        }
      })
liang ce committed
339
    },
liang ce committed
340 341 342 343 344
    getStatisticsRechargeData () {
      let that = this
      let RechargeData = {
        year: this.year,
        month: this.month
liang ce committed
345
      }
liang ce committed
346
      $http.get(`/mingpay/v1/isv/account/statisticsRecharge`, RechargeData).then((res) => {
liang ce committed
347
        console.log(res.data.data)
348
        if (res.data.resultCode === 0) {
liang ce committed
349 350
          that.RechargeDataList = res.data.data
          that.drawRechargeListDataLine()
liang ce committed
351 352 353 354 355 356
        } else {
          this.$message.error(res.data.message)
        }
      })
    }
  }
liang ce committed
357 358 359 360
}
</script>

<style lang="less" scoped>
liang ce committed
361 362 363 364 365 366 367
.title{
  font-weight: bold;
  margin-top: 20px;
  margin-bottom: 20px;
}
.searchBox button{
  margin-left: 10px;
liang ce committed
368
  margin-bottom: 20px
liang ce committed
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
}
.SystemReconciliationContent{
  border: 1px solid #f6f6f6;
  width: 100%;
}
.contentItem{
  width: 100%;
  display: flex;
  padding: 20px;
  overflow: hidden;
  border-bottom: 1px solid #f6f6f6;
}
.contentItem>div{
  display: flex;
  flex-direction: column;
}
.contentItem>div:nth-of-type(2){
  flex: 1;
  padding-left: 72px;
  box-sizing: border-box;
}
.contentItem>div:nth-of-type(3){
  width: 300px;
  flex-direction: column-reverse;
}
.contentItem>div:nth-of-type(1){
  font-weight: bold;
  justify-content: center;
  width: 150px;
}
.recordsBox>div{
  display: flex;
}
.contentItem>.recordsBox{
  padding-left: 0 !important;
}
.recordsBox>div>div:nth-of-type(1){
  width: 80px;
  text-align: right;
  margin-right: 20px;
}
.contentItem span {
  color: #1890ff;
}
.contentItem label{
  width: 70px;
  display: inline-block;
  text-align: right;
}
liang ce committed
418 419 420 421
.chart{
  width: 100%;
  border: 1px solid #dddddd;
  margin-bottom: 20px;
liang ce committed
422
  padding-top: 20px;
liang ce committed
423 424
  box-sizing: border-box;
}
liang ce committed
425
</style>