overview.vue 6.49 KB
<template>
  <div class="overview-container" v-if="flag">
    <div class="overview-wrap m-b-16">
      <div class="title-info">客户招揽概况</div>
      <div class="overview-content">
        <template v-if="chart.pieData.length > 0">
          <pieChart :color="chart.pieColor" id="overviewRef" :list="chart.pieData" :centerData="chart.centerData" :specialData="chart.specialData"></pieChart>
        </template>
        <template v-else>
          <empty></empty>
        </template>
      </div>
    </div>
    <div class="overview-wrap m-b-16">
      <div class="title-info">客户分群</div>
      <div class="overview-group">
        <template v-if="chart.barData.length > 0">
          <barChart :color="chart.barColor" :tickCount="7" id="groupingRef" :list="chart.barData"></barChart>
        </template>
        <template v-else>
          <empty></empty>
        </template>
      </div>
    </div>
    <div class="overview-wrap m-b-16">
      <div class="title-info">工作简报</div>

      <div class="bulletin flex">
        <template v-for="(item, index) in bulletinList">
          <div class="bulletin-single flex-top m-b-16" :key="index">
            <div :class="['logo', 'sprite-icon', item.icon]"></div>
            <div class="bulletin-info">
              <div class="color-2f font-12">{{ item.todayText }}</div>
              <div class="number color-3 font-24 fw7">{{ item.todayValue(overviewInfo) }}</div>
              <div class="color-2f font-12 m-t-8">
                {{ item.currentMonth }}
                <span class="font-14 color-3 fw5">{{ item.currentValue(overviewInfo) }}</span>
              </div>
            </div>
          </div>
        </template>
      </div>
    </div>
  </div>
</template>
<script>
import pieChart from '../solicit/components/pie.vue'
import barChart from '../solicit/components/bar.vue'
import { solicitApi } from '@/api'
import { mapState, mapActions } from 'vuex'
import { util } from '../../utils'
import { Notify } from 'vant'
export default {
  components: {
    pieChart,
    barChart
  },
  data() {
    return {
      flag: true,
      bulletinList: [],
      activityId: '',
      chart: {
        pieColor: ['#3975C6', '#E6E7EB'],
        pieData: [],
        specialData:[],
        centerData: {},
        barData: [],
        barColor: '#3975C6'
      },
      overviewInfo: {
        followedUpCount: 0,
        notFollowedUpCount: 0,
        followedUpPercent: '',
        customerGroupList: [],
        workBriefingFollowUpTodayCount: 0,
        workBriefingFollowUpMonthCount: 0,
        workBriefingAddedTodayCount: 0,
        workBriefingAddedMonthCount: 0,
        workBriefingAppointmentTodayCount: 0,
        workBriefingAppointmentMonthCount: 0,
        workBriefingReturnFactoryTodayCount: 0,
        workBriefingReturnFactoryMonthCount: 0
      }
    }
  },
  created() {
    this.bulletinList = this.$constants.BULLETINLIST
    let { taskId } = this.getQuery()
    if (taskId) {
      this.findActivityIdByUUID({
        uuid: taskId,
        success: res => {
          this.activityId = res
          this.getStaffId({
            success: res => {
              this.getTaskOverviewData()
            }
          })
        },
        fail: () => {
          this.hideLoading()
          this.reLogin()
        }
      })
    } else {
      this.activityId = window.localStorage.getItem('dj_scrm_activityId') ? JSON.parse(window.localStorage.getItem('dj_scrm_activityId')) : ''
      this.getStaffId({
        success: res => {
          this.getTaskOverviewData()
        }
      })
    }
  },
  computed: {
    ...mapState({
      staffId: state => state.solicit.staffId
    })
  },
  methods: {
    ...mapActions({
      getStaffId: 'solicit/getStaffId',
      findActivityIdByUUID: 'solicit/findActivityIdByUUID',
      navigation: 'navigation'
    }),
    //重新登录
    reLogin() {
      /**登录过期 重新登录 */
      util.clearSessionId()
      this.navigation()
    },
    getTaskOverviewData() {
      let params = {
        activityId: this.activityId,
        staffId: this.staffId
      }
      this.showLoading()
      solicitApi.taskOverviewData(params).then(({ code, data, message }) => {
        this.hideLoading()
        if (code == '0') {
          this.overviewInfo = data
          this.$emit('getCountInfo', {
            tabPageFollowUpCount: data.tabPageFollowUpCount,
            tabPageResultCount: data.tabPageResultCount
          })
          this.initChartData()
        } else {
          Notify(message)
        }
        this.flag = true
      })
    },
    initChartData() {
      let { overviewInfo } = this
      //   legendData
      if (overviewInfo.followedUpCount != 0 || overviewInfo.notFollowedUpCount != 0) {
        this.chart.pieData = [
          {
            const: 'const',
            text: ' 已跟进 (人)',
            value: overviewInfo.followedUpCount
          },
          {
            const: 'const',
            text: '本月指标 (人)',
            value: overviewInfo.notFollowedUpCount
          }
        ]
        this.chart.specialData = [
            {
            const: 'const',
            text: ' 已跟进 (人)',
            value: overviewInfo.followedUpCount
          },
          {
            const: 'const',
            text: '未跟进',
            value: parseInt(overviewInfo.notFollowedUpCount-overviewInfo.followedUpCount)
          }
        ]
        this.chart.centerData = {
          text: '达成率',
          rate: overviewInfo.followedUpPercent ? parseInt(overviewInfo.followedUpPercent * 100) + '%' : 0
        }
        overviewInfo.customerGroupList.length > 0 &&
          overviewInfo.customerGroupList.forEach(item => {
            this.chart.barData.push({
              text: item.groupName.slice(0, 10),
              value: item.groupCount
            })
          })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.overview-container {
  .overview-wrap {
    background: #fff;
    box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
    border-radius: 4px;
    .overview-content {
      height: 160px;
      box-sizing: border-box;
    }

    .overview-group {
      box-sizing: border-box;
    }

    .bulletin {
      height: 236px;
      padding: 16px 0;
      box-sizing: border-box;
      flex-wrap: wrap;

      &-single {
        width: 50%;
        height: 98px;
        padding-left: 16px;
        box-sizing: border-box;

        .bulletin-info {
          margin-left: 12px;
        }

        .number {
          height: 36px;
          line-height: 36px;
        }
      }
    }
  }
}
</style>