overview-enterprise.vue 18.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
<template>
  <div class="scrm-box-f scrm-p20-f">
    <div class="summary-customer-panel">
      <div class="summary-item">
        <div class="summary-item-title">
          <span>当日新增客户数</span>
          <el-popover placement="top" title="说明" width="400" trigger="hover" content="统计截止时间当天,本商户的新增客户数,1个客户仅计算1次。">
            <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
          </el-popover>
        </div>
        <div class="summary-item-total">
          <div @click="handleEmpDetail('当日新增客户详情', summaryTime, summaryTime)" v-if="this.$globalState.session.accountLevel == 4 && this.$globalState.session.userType == 1" class="custom-detail">
            {{ newCustomerCount }}
            <span>人</span>
          </div>
          <div v-else>
            {{ newCustomerCount }}
            <span>人</span>
          </div>
          <div class="summary-radio" :class="{ 'radio-green': totalCountDayToDayRadio > 0, 'radio-red': totalCountDayToDayRadio < 0 }">
            日环比:
            <span>{{ totalCountDayToDayRadio | valueF }}</span>
            <i class="el-icon-caret-top" v-if="totalCountDayToDayRadio > 0"></i>
            <i class="el-icon-caret-bottom" v-if="totalCountDayToDayRadio < 0"></i>
          </div>
        </div>
        <div class="summary-item-number">
          累计客户数:
          <span>{{ customerCount }}</span>
        </div>
      </div>
      <div class="summary-item">
        <div class="summary-item-title">
          <span>当日新增已加企微客户总数</span>
          <el-popover placement="top" title="说明" width="400" trigger="hover" content="累计至统计截止时间,本商户的客户数之和,1个客户仅计算1次。">
            <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
          </el-popover>
        </div>
        <div class="summary-item-total">
          <div @click="handleEmpDetail('当日新增已加企微客户详情', summaryTime, summaryTime, 1)" class="custom-detail" v-if="this.$globalState.session.accountLevel == 4 && this.$globalState.session.userType == 1">
            {{ newEntmicroCount }}
            <span>人</span>
          </div>
          <div v-else>
            {{ newEntmicroCount }}
            <span>人</span>
          </div>
          <div class="summary-radio" :class="{ 'radio-green': entmicroCountDayToDayRadio > 0, 'radio-red': entmicroCountDayToDayRadio < 0 }">
            日环比:
            <span>{{ entmicroCountDayToDayRadio | valueF }}</span>
            <i class="el-icon-caret-top" v-if="entmicroCountDayToDayRadio > 0"></i>
            <i class="el-icon-caret-bottom" v-if="entmicroCountDayToDayRadio < 0"></i>
          </div>
        </div>
        <div class="summary-item-number">
          累计企微客户总数:
          <span>{{ addEntmicroCount }}</span>
        </div>
      </div>
      <div class="summary-item">
        <div class="summary-item-title">
          <span>当日新增群客户数</span>
          <el-popover placement="top" title="说明" width="400" trigger="hover" content="统计截止时间当天,本商户企业微信群新增的客户数,内部员工除外,1个客户仅计算1次。">
            <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
          </el-popover>
        </div>
        <div class="summary-item-total">
          <div @click="handleEmpGroupDetail(summaryTime)" class="custom-detail" v-if="this.$globalState.session.accountLevel == 4 && this.$globalState.session.userType == 1">
            {{ todayAddPackmenberCount }}
            <span>人</span>
          </div>
          <div v-else>
            {{ todayAddPackmenberCount }}
            <span>人</span>
          </div>
          <div class="summary-radio" :class="{ 'radio-green': groupCustCountDayToDayRadio > 0, 'radio-red': groupCustCountDayToDayRadio < 0 }">
            日环比:
            <span>{{ groupCustCountDayToDayRadio | valueF }}</span>
            <i class="el-icon-caret-top" v-if="groupCustCountDayToDayRadio > 0"></i>
            <i class="el-icon-caret-bottom" v-if="groupCustCountDayToDayRadio < 0"></i>
          </div>
        </div>
        <div class="summary-item-number">
          累计群客户总数:
          <span>{{ packmenberCount }}</span>
        </div>
      </div>
      <div class="summary-item">
        <div class="summary-item-title">
          <span>当日企微流失客户数</span>
          <el-popover placement="top" title="说明" width="400" trigger="hover" content="统计截止时间当天,本商户企业微信流失客户数(包括删除和拉黑)。">
            <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
          </el-popover>
        </div>
        <div class="summary-item-total">
          <div @click="handleEmpDetail('当日企微流失客户详情', summaryTime, summaryTime, 0, summaryTime)" class="custom-detail" v-if="this.$globalState.session.accountLevel == 4 && this.$globalState.session.userType == 1">
            {{ todayEntmicroLoseCount }}
            <span>人</span>
          </div>
          <div v-else>
            {{ todayEntmicroLoseCount }}
            <span>人</span>
          </div>
          <div class="summary-radio" :class="{ 'radio-green': lostCountDayToDayRadio > 0, 'radio-red': lostCountDayToDayRadio < 0 }">
            日环比:
            <span>{{ lostCountDayToDayRadio | valueF }}</span>
            <i class="el-icon-caret-top" v-if="lostCountDayToDayRadio > 0"></i>
            <i class="el-icon-caret-bottom" v-if="lostCountDayToDayRadio < 0"></i>
          </div>
        </div>
        <div class="summary-item-number">
          累计企微流失客户:
          <span>{{ entmicroLoseCount }}</span>
        </div>
      </div>
      <div class="summary-item">
        <div class="summary-item-title">
          <span>累计未加企微客户数</span>
          <el-popover placement="top" title="说明" width="400" trigger="hover" content="累计至统计截止时间,本商户的所有客户中,未加企微客户总数之和。">
            <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
          </el-popover>
        </div>
        <div class="summary-item-total">
          <div @click="handleEmpDetail('累计未加企微客户详情', null, summaryTime, 0)" class="custom-detail" v-if="this.$globalState.session.accountLevel == 4 && this.$globalState.session.userType == 1">
            {{ notAddEntmicroCount }}
            <span>人</span>
          </div>
          <div v-else>
            {{ notAddEntmicroCount }}
            <span>人</span>
          </div>
        </div>
        <el-popover placement="top" width="200" trigger="click" content="敬请期待。">
          <div class="summary-item-number item-jump" slot="reference">
            批量邀请客户加企微
            <i class="el-icon-d-arrow-right"></i>
          </div>
        </el-popover>
      </div>
    </div>
    <div :class="{ 'expand-panel': expandStatus }" class="summary-line-panel">
      <div class="summary-title"></div>
      <div class="chart-empty" v-show="chartStatus">
        <img src="@/assets/img/empty.png" />
        <div class="chart-empty-d">暂无数据</div>
      </div>
      <div id="main-customer" v-show="!chartStatus"></div>
    </div>
    <div class="expand-more">
      <div v-if="expandStatus" class="expand-more-b" @click="handleExpand">
        <span>展开查看详情</span>
        <i class="el-icon-arrow-right"></i>
      </div>
      <div v-else class="expand-more-b" @click="handleExpand">
        <span>收起详情</span>
        <i class="el-icon-arrow-up"></i>
      </div>
    </div>

    <custom-detail ref="customForm"></custom-detail>
    <custom-group-detail ref="customGroupForm"></custom-group-detail>
  </div>
</template>

<script>
import util from '@/utils/util'
import * as echarts from 'echarts'

import customDetail from './detail/customDetail.vue'
import customGroupDetail from './detail/customGroupDetail.vue'
export default {
  name: 'overviewEnterprise',

  props: {
    summaryTime: {
      type: String
    }
  },
  components: {
    customDetail,
    customGroupDetail
  },
  data() {
    return {
      customerCount: 0,
      newCustomerCount: 0,
      addEntmicroCount: 0,
      notAddEntmicroCount: 0,
      newEntmicroCount: 0,
      entmicroLoseCount: 0,
      todayEntmicroLoseCount: 0,
      packmenberCount: 0,
      todayAddPackmenberCount: 0,
      lostCountDayToDayRadio: 0,
      entmicroCountDayToDayRadio: 0,
      groupCustCountDayToDayRadio: 0,
      totalCountDayToDayRadio: 0,
      entmicroCountRadio: 0,

      expandStatus: false
    }
  },

  watch: {
    summaryTime() {
      this.getViewData()
      this.getChart()
    }
  },
  filters: {
    valueF(val) {
      if (val == null) {
        return '--'
      } else {
        return val + '%'
      }
    }
  },
  methods: {
    //客户列表
    handleEmpDetail(title, day1, day2, status, day3) {
      this.$refs.customForm.init(title, day1, day2, status, day3)
    },
    //客户群列表
    handleEmpGroupDetail(days) {
      this.$refs.customGroupForm.init(days)
    },
    handleExpand() {
      this.expandStatus = !this.expandStatus
    },
    getBackUp() {
      this.$alert('敬请期待', '提示')
    },
    //客户统计
    getViewData() {
      this.$apis.home.getStore({ date: this.summaryTime }).then(res => {
        this.customerCount = res.customerCount
        this.newCustomerCount = res.newCustomerCount
        this.addEntmicroCount = res.addEntmicroCount
        this.notAddEntmicroCount = res.notAddEntmicroCount
        this.newEntmicroCount = res.newEntmicroCount
        this.todayEntmicroLoseCount = res.todayEntmicroLoseCount
        this.packmenberCount = res.packmenberCount
        this.todayAddPackmenberCount = res.todayAddPackmenberCount
        this.entmicroCountRadio = res.entmicroCountRadio
        this.groupCustCountDayToDayRadio = res.groupCustCountDayToDayRadio
        this.lostCountDayToDayRadio = res.lostCountDayToDayRadio
        this.entmicroCountDayToDayRadio = res.entmicroCountDayToDayRadio
        this.totalCountDayToDayRadio = res.totalCountDayToDayRadio
        this.entmicroLoseCount = res.entmicroLoseCount
        this.$emit('getEntmicroRadio', this.entmicroCountRadio)
      })
    },
    //折线图
    async getChart() {
      this.$apis.home.getChart({ day: 30, date: this.summaryTime }).then(res => {
        const { custAddList, custEntmicroAdds, custLoseList } = res ? res : { custAddList: [], custEntmicroAdds: [], custLoseList: [] }
        let custAddListData = custAddList.map(item => {
          return item.customerCount
        })
        let custAddListAverg = custAddList.map(item => {
          return item.monthAverg
        })
        let custAddListRatio = custAddList.map(item => {
          return item.ratio
        })
        let custEntmicroAddsData = custEntmicroAdds.map(item => {
          return item.customerCount
        })
        let custEntmicroAddsAverg = custEntmicroAdds.map(item => {
          return item.monthAverg
        })
        let custEntmicroAddsRatio = custEntmicroAdds.map(item => {
          return item.ratio
        })
        let custLoseListData = custLoseList.map(item => {
          return item.customerCount
        })
        let custLoseListAverg = custLoseList.map(item => {
          return item.monthAverg
        })
        let custLoseListRatio = custLoseList.map(item => {
          return item.ratio
        })
        const dateTime = custAddList.map(item => item.dateTime)
        let chartDom = document.getElementById('main-customer')
        let myChart = echarts.init(chartDom)
        let option

        option = {
          tooltip: {
            trigger: 'item',
            formatter(params) {
              let circleColor
              let Averg
              let i_name
              if (params.seriesName == '总客户数') {
                circleColor = '#5850FF'
                Averg = custAddListAverg[params.dataIndex]
                i_name = custAddListRatio[params.dataIndex] ? 'el-icon-top' : 'el-icon-bottom'
              }
              if (params.seriesName == '已加企微客户数') {
                circleColor = '#2CCA74'
                Averg = custEntmicroAddsAverg[params.dataIndex]
                i_name = custEntmicroAddsRatio[params.dataIndex] == 1 ? 'el-icon-top' : custEntmicroAddsRatio[params.dataIndex] == -1 ? 'el-icon-bottom' : ''
              }
              if (params.seriesName == '企微流失客户') {
                circleColor = '#FF6D00'
                Averg = custLoseListAverg[params.dataIndex]
                i_name = custLoseListRatio[params.dataIndex] ? 'el-icon-top' : 'el-icon-bottom'
              }
              return params.name + '<br>' + `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${circleColor};"></span>` + params.seriesName + ':' + params.value + `<i class="${i_name}" style="color: ${circleColor}"></i>` + '<br>' + `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${circleColor};"></span>` + (new Date(params.name).getMonth() + 1) + '月均值:' + Averg
            }
          },
          legend: {
            data: ['总客户数', '已加企微客户数', '企微流失客户'],
            x: 'center',
            icon: 'stack',
            itemHeight: 2,
            itemWidth: 12
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: 0,
            containLabel: true
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            color: '#A3A3A3',
            data: dateTime
          },
          yAxis: {
            type: 'value',
            show: true,
            name: '单位:人',
            minInterval: 1
          },
          series: [
            {
              name: '总客户数',
              type: 'line',
              lineStyle: { color: '#5850FF ' },
              data: custAddListData,
              smooth: true
            },
            {
              name: '已加企微客户数',
              type: 'line',
              lineStyle: { color: '#2CCA74 ' },
              data: custEntmicroAddsData,
              smooth: true
            },
            {
              name: '企微流失客户',
              type: 'line',
              lineStyle: { color: '#FF6D00 ' },
              data: custLoseListData,
              smooth: true
            }
          ]
        }
        option && myChart.setOption(option)
        window.addEventListener('resize', myChart.resize)
        if (custAddListData.every(item => item == 0) && custEntmicroAddsData.every(item => item == 0) && custLoseListData.every(item => item == 0)) {
          this.chartStatus = true
        } else {
          this.chartStatus = false
        }
      })
    }
  },
  mounted() {
    this.getViewData()
    this.getChart()
  }
}
</script>

<style lang="scss" scoped>
.summary-customer-panel {
  display: flex;
  padding: 0px 20px;
  .summary-item {
    width: 20%;
    height: 148px;
    padding: 0.5vw 1vw;
    box-sizing: border-box;
    margin-right: 20px;
    background: linear-gradient(360deg, #f7f7ff 0%, #f3f5f8 100%);
    &:last-of-type {
      margin-right: 0px;
    }
    .chart-empty-null {
      height: 60px;
      font-size: 14px;
      font-weight: 400;
      color: #000000;
      line-height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .summary-item-title {
      font-size: 16px;
      font-weight: 500;
      color: #333333;
      line-height: 24px;
      height: 48px;
      display: flex;
      // span {
      //   &:first-child {
      //     flex: 1;
      //   }
      // }
      .item {
        background: #ffffff;
        // box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
      }
      img {
        width: 14px;
        height: 14px;
        margin-left: 6px;
        vertical-align: revert;
      }
    }
    .summary-item-total {
      font-size: 26px;
      color: rgba(0, 0, 0, 0.85);
      line-height: 26px;
      margin: 10px 0px 10px 0px;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      .custom-detail {
        cursor: pointer;
      }
      .summary-radio {
        // background: rgba(127, 204, 162, 0.1);
        border-radius: 2px;
        color: #666666;
        line-height: 16px;
        font-size: 12px;
        &.radio-green {
          span,
          i {
            color: #e57272;
          }
        }
        &.radio-red {
          span,
          i {
            color: #2cca74;
          }
        }
        i {
          font-size: 14px;
        }
      }
      span {
        font-size: 14px;
      }
    }
    .summary-item-number {
      font-size: 12px;
      font-weight: 400;
      color: #666666;
      line-height: 20px;
      &.item-jump {
        cursor: pointer;
        font-size: 14px;
        font-weight: 400;
        color: #5850ff;
        line-height: 20px;
      }
    }
    #main-total {
      height: 60px;
    }
  }
}
.scrm-p20-f {
  padding-top: 20px;
}
.f26 {
  font-size: 26px !important;
}
.emp-btn {
  background: #999999;
  border: none;
}
.expand-more {
  margin: 20px 0px;
  text-align: center;
  height: 56px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0px 0px 2px 2px;
  font-size: 14px;
  line-height: 56px;
  color: #000000;
  &-b {
    cursor: pointer;
    display: inline-block;
  }
}
#main-customer {
  height: 300px;
}
.summary-line-panel {
  margin-top: 30px;
  height: 360px;
  overflow: hidden;
  transition: height 0.2s;
  .summary-title {
    color: #3a3a3a;
    line-height: 20px;
    letter-spacing: 1px;
    font-size: 20px;
    font-weight: 600;
    margin: 40px 0px 20px 0px;
  }
  .summary-tab {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    &-item {
      padding: 8px 32px;
      font-size: 14px;
      font-weight: 400;
      color: #999999;
      line-height: 16px;
      background: #f5f5f5;
      margin-right: 10px;
      cursor: pointer;
      &.selected {
        background: #e6e9ff;
        color: #5850ff;
      }
    }
  }
}
.summary-line-panel.expand-panel {
  height: 0px;
}
.chart-empty {
  width: 100px;
  height: 100px;
  margin: 100px auto;
  text-align: center;
  &-d {
    font-size: 14px;
    font-weight: 400;
    color: #000000;
    line-height: 32px;
  }
  img {
    width: 64px;
    height: 32px;
  }
}
@media screen and (max-width: 1560px) {
  .summary-item-total {
    font-size: 12px !important;
    span {
      font-size: 12px !important;
    }
  }
}
</style>