succeed.vue 8.36 KB
<template>
  <div class="succeed-container">
    <div class="succeed-title  flex font-20 color-3 fw5">
      <span class="groupName text-hide">{{ groupName }}</span>
      <span class="color39 font-16 m-l-8">- {{ customeStatus == 2 ? '成功到店' : '战败分析' }}</span>
    </div>
    <div class="succeed-content">
      <div class="succeed-wrap m-b-16">
        <div class="title-info">客户分布</div>
        <div class="succeed-wrap-info">
          <template v-if="pieData.length > 0">
            <pieChart :color="styleColor" id="customerRef" :list="pieData" :centerData="centerData"></pieChart>
          </template>
          <template v-else>
            <empty></empty>
          </template>
        </div>
      </div>
      <div class="succeed-wrap m-b-16">
        <div class="title-info">跟进频次</div>
        <div class="succeed-wrap-frequency flex-between">
          <div class="succeed-wrap-frequency-single">
            <div class="font-16 color-3 bold line-24">{{ getFollowResultDetail.averageFollows ? getFollowResultDetail.averageFollows : 0 }}次/人</div>
            <div class="font-12 color-2f m-t-6 line-18">平均跟进</div>
          </div>
          <div class="succeed-wrap-frequency-single">
            <div class="font-16 color-3 bold line-24">{{ getFollowResultDetail.mostFollows ? getFollowResultDetail.mostFollows : 0 }}次</div>
            <div class="font-12 color-2f m-t-6 line-18">最多跟进</div>
          </div>
          <div class="succeed-wrap-frequency-single">
            <div class="font-16 color-3 bold line-24">{{ getFollowResultDetail.leastFollows ? getFollowResultDetail.leastFollows : 0 }}次</div>
            <div class="font-12 color-2f m-t-6">最少跟进</div>
          </div>
        </div>
      </div>
      <div class="succeed-wrap m-b-16" v-if="customeStatus == 2">
        <div class="title-info">
          预约与到店
          <div class="flex fact-wrap">
            <div class="fact flex">
              <div class="reserved"></div>
              预约到店
            </div>
            <div class="fact flex m-l-16">
              <div class="arrive"></div>
              实际到店
            </div>
          </div>
        </div>
        <div class="succeed-wrap-order-info">
          <template v-if="getFollowResultDetail.appointmentDailyCharts&&getFollowResultDetail.appointmentDailyCharts.length>0">
            <lineChart id="orderRef" :lineData="lineData"></lineChart>
          </template>
          <template v-else>
            <empty></empty>
          </template>
        </div>
      </div>
      <div class="succeed-wrap m-b-16" v-if="customeStatus == 1 && reasonBar.length">
        <div class="title-info">原因统计</div>
        <barChart color="#3975C6" id="reasonRef" :list="reasonBar"></barChart>
      </div>
      <div class="succeed-wrap m-b-16" v-if="markingBar.length">
        <div class="title-info">企微营销</div>
        <barChart color="#3975C6" id="markingRef" :list="markingBar"></barChart>
      </div>
    </div>
  </div>
</template>
<script>
import { solicitApi } from '@/api'
import pieChart from '../solicit/components/pie.vue'
import lineChart from '../solicit/components/line.vue'
import barChart from '../solicit/components/bar.vue'
export default {
  components: {
    pieChart,
    lineChart,
    barChart
  },
  data() {
    return {
      styleColor: ['#3975C6', '#FDB757'],
      appointmentDailyCharts: '',
      pieData: [],
      centerData: {},
      followList: [],
      customeStatus: 1,
      getFollowResultDetail: {},
      groupId: '',
      groupName: '',
      reasonBar: [],
      markingBar: [],
      lineData: []
    }
  },
  created() {
    this.followList = this.$constants.FOLLOWLIST
    this.customeStatus = this.$route.query.status
    this.groupId = this.$route.query.groupId
    this.groupName = this.$route.query.groupName
    this.getFollowResult()
    this.deliveredStatistics()
  },
  methods: {
    deliveredStatistics() {
      const { activityId, staffId } = this.$store.state.solicit
      var params = {
        id: activityId,
        groupId: this.groupId,
        typeFlag: this.customeStatus,
        staffId
      }
      solicitApi.deliveredStatistics(params).then(res => {
        const { delivered, received, undelivered, viewed } = res.data
        this.markingBar = [
          { value: +received, text: '已领取' },
          { value: +viewed, text: '已查阅' },
          { value: +delivered, text: '已送达' },
          { value: +undelivered, text: '未送达' }
        ]
      })
    },
    // 跟进结果-成功到店与战败分析
    getFollowResult() {
      const { activityId, staffId } = this.$store.state.solicit
      var params = {
        activityId,
        groupId: this.groupId,
        customerFollowStatus: this.customeStatus == 2 ? 1 : 0,
        staffId
      }
      solicitApi.getFollowResult(params).then(res => {
        this.getFollowResultDetail = res.data
        const { joinEntmicroCustomerNums, notYetJoinEntmicroCustomerNums, followResultsAnalyzeVos, appointmentDailyCharts, successDailyCharts } = this.getFollowResultDetail
    
    if (joinEntmicroCustomerNums || notYetJoinEntmicroCustomerNums) {
          this.pieData = [
            {
              const: 'const',
              text: ' 企微客户 (人)',
              value: joinEntmicroCustomerNums
            },
            {
              const: 'const',
              text: '非企微客户 (人)',
              value: notYetJoinEntmicroCustomerNums
            }
          ]
          this.centerData = {
            text: '企微占比',
            rate: parseInt((joinEntmicroCustomerNums / (joinEntmicroCustomerNums + notYetJoinEntmicroCustomerNums)) * 100) + '%'
          }
        }
      
        if (appointmentDailyCharts) {
          const appointmentDaily = appointmentDailyCharts.map((item, index) => {
            return {
              date: item.dailyDate,
              value: item.times,
              type: '预约到店'
            }
          })
          const successDaily = successDailyCharts.map((item, index) => {
            return {
              date: item.dailyDate,
              value: item.times,
              type: '实际到店'
            }
          })
          this.lineData = [...appointmentDaily, ...successDaily]
        }
        if (followResultsAnalyzeVos) {
          const followResultList = window.localStorage.getItem('followResultList') ? JSON.parse(window.localStorage.getItem('followResultList'), '', null) : []
          this.reasonBar = followResultsAnalyzeVos.map(item => {
            return { value: item.times, text: followResultList.find(follow => follow.dictValue == item.followResult).dictLabel }
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.succeed-container {
  .succeed-title {
    height: 52px;
    background: #ffffff;
    box-shadow: 0px 1px 0px 0px #e9e9e9;
    padding: 11px 16px;
    box-sizing: border-box;
    .groupName{
      max-width: 200px;
       display: inline-block;
    }
  }
  .succeed-content {
    padding: 12px;
    .succeed-wrap {
      background: #fff;
      box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
      border-radius: 4px;
      .title-info {
        position: relative;
      }
      .title-info::before {
        content: '';
        width: 3px;
        height: 14px;
        background: #fff;
        border-radius: 1.5px;
        margin-right: 13px;
        display: inline-block;
      }
      &-order-info {
        height: 180px;
        box-sizing: border-box;
      }
      &-info {
        height: 160px;
        box-sizing: border-box;
      }
      &-frequency {
        padding: 24px 45px;
        height: 96px;
        box-sizing: border-box;
        &-single {
          width: auto;
          div {
            text-align: center;
          }
        }
      }
      .fact-wrap {
        position: absolute;
        right: 16px;
        top: 13px;
        .fact {
          font-size: 12px;
          font-weight: 400;
          color: rgba(47, 64, 86, 0.7);
          line-height: 18px;
        }

        .reserved {
          width: 8px;
          height: 3px;
          background: #fa7c0b;
          border-radius: 2px;
          margin-right: 6px;
        }

        .arrive {
          width: 8px;
          height: 3px;
          background: #3975c6;
          border-radius: 2px;
          margin-right: 6px;
          display: inline-block;
        }
      }
    }
  }
}
</style>