qualityDetail.vue 6.36 KB
<!-- 关联活动订单弹窗 -->
<template>
  <div class="quality-box">
    <template v-if="qualityDetailList.length">
      <div class="overview">
        <template v-for="(i,index) in overviewObject">
          <div
            :key="index"
            class="overview-item"
          >
            <div class="label">{{i.label}}</div>
            <div class="value">
              <template v-if="i.formatter">
                <div v-html="i.formatter(qualityDetailList[currentNum])">
                </div>
              </template>
              <template v-else>
                {{qualityDetailList[currentNum][i.key] || '-'}}
              </template>
            </div>
          </div>
        </template>
      </div>

      <div
        class="content"
        :key="currentNum"
      >
        <div class="dialogue-box">
          <dialogue-detail :detailObj="qualityDetailList[currentNum]" />
        </div>
        <div class="analyse-box">
          <quality-analyse :detailObj="qualityDetailList[currentNum]" />
        </div>
      </div>
    </template>
    <div class="footer-box">
      <el-button
        size="small"
        :class="{opacity:currentNum == 0}"
        @click="jump(-1)"
      >上一条</el-button>
      <div class="text">{{currentNum + 1}}/{{qualityDetailList.length}}</div>
      <el-button
        type="primary"
        size="small"
        :class="{opacity:currentNum == qualityDetailList.length - 1}"
        @click="jump(1)"
      >下一条</el-button>
    </div>
  </div>
</template>
  
  <script>
import QualityAnalyse from './qualityAnalyse'
import DialogueDetail from './dialogueDetail'
const toMinutesAndSeconds = (seconds) => {
  seconds = Math.floor(seconds / 1000)
  let formattedTime = ''
  if (seconds < 60) {
    return seconds + '<span class="unit">秒</span>'
  } else if (seconds > 3600) {
    let hours = Math.floor(seconds / 3600),
      minutes = Math.floor((seconds % 3600) / 60)
    if (hours > 0) formattedTime += hours + '<span class="unit">小时</span>'
    if (minutes > 0 || hours > 0) formattedTime += minutes + '<span class="unit">分钟</span>'
    return formattedTime
  } else {
    let hours = Math.floor(seconds / 3600),
      minutes = Math.floor((seconds % 3600) / 60),
      remainingSeconds = seconds % 60
    if (hours > 0) formattedTime += hours + '<span class="unit">小时</span>'
    if (minutes > 0 || hours > 0) formattedTime += minutes + '<span class="unit">分钟</span>'
    if (remainingSeconds > 0) formattedTime += remainingSeconds + '<span class="unit">秒</span>'
    return formattedTime
  }
}
export default {
  name: '',
  components: {
    QualityAnalyse,
    DialogueDetail
  },
  data () {
    return {
      overviewObject: [
        {
          label: '客户姓名',
          key: 'customerName',
        },
        {
          label: '车型',
          key: 'carModel',
        },
        {
          label: 'APP接待结果',
          formatter (row) {
            const val = {
              1: '成交',
              0: '战败'
            }[row.receptionStatus],
              color = {
                1: '#2CCA74',
                0: '#EB4E4E'
              }[row.receptionStatus]
            return `<span style="font-size:22px;color:${color}">${val || '-'}</span>`
          }
        },
        {
          label: '预计营销结果',
          formatter (row) {
            const color = {
              '成交': '#2CCA74',
              '战败': '#EB4E4E'
            }[row.estimatedResult] || '#999999'
            return `<span style="font-size:22px;color:${color}">${row.estimatedResult || '分析中'}</span>`
          }
        },
        {
          label: '话术评分',
          formatter (row) {
            return row.score != null
              ? `<div class="num">${row.score}<span class="unit">分</span></div>`
              : `<span style="font-size:22px;color:#999">分析中</span>`
          }
        },
        {
          label: '接待时长',
          formatter (row) {
            return `<div class="num">${row.duration ? toMinutesAndSeconds(row.duration) : '-'}</div>`
          }
        }
      ],
      activeName: 'analyse',
      currentNum: 0,
      qualityDetailList: []
    }
  },


  mounted () {
    const { key } = this.$route.query
    if (key) {
      const quality_detail_object = JSON.parse(sessionStorage.getItem(key) || '{}')
      if (!quality_detail_object?.list) return this.$router.push({
        path: '/qualityManage/index'
      })
      this.currentNum = quality_detail_object.currentNum || 0
      this.qualityDetailList = quality_detail_object.list || []
    } else this.$router.go(-1)

  },

  methods: {
    jump (num) {
      try {
        const { qualityDetailList, currentNum } = this,
          max = qualityDetailList.length - 1
        if ((currentNum == 0 && num == -1) || (currentNum == max && num == 1)) throw '无更多接待记录'
        this.currentNum += num
      } catch (error) {
        if (error) this.$message.error(error)
      }
    }
  }
}
</script>
<style scoped lang='scss'>
.quality-box {
  .overview {
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 20px;
    justify-content: space-between;
    &-item {
      width: calc((100% - 40px) / 6);
      background: #f7f9fa;
      border-radius: 4px;
      box-sizing: border-box;
      height: 92px;
      padding: 16px;
      font-size: 14px;
      color: #333333;
      .label {
        line-height: 20px;
      }
      .value {
        font-weight: 600;
        font-size: 20px;
        color: #333333;
        margin-top: 8px;
        line-height: 32px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        /deep/.num {
          font-weight: 700;
          font-size: 26px;
          .unit {
            font-weight: 400;
            font-size: 14px;
            color: #333333;
          }
        }
      }
    }
  }
  .content {
    display: flex;
    margin-top: 16px;
    height: calc(100vh - 276px);
    overflow: hidden;
    .dialogue-box {
      width: 40%;
    }
    .analyse-box {
      width: calc(60% - 16px);
      margin-left: auto;
    }
  }
  .footer-box {
    position: fixed;

    left: 0;
    bottom: 0;
    width: 100%;
    height: 64px;
    font-size: 14px;
    color: #666666;
    display: flex;
    align-items: center;
    justify-content: center;
    .text {
      margin: 0 16px;
    }
    .opacity {
      opacity: 0.5;
    }
  }
}
</style>