qualityAnalyse.vue 9.56 KB
<template>
  <div class="analyse">
    <div class="statistics">
      <div class="s-item" v-for="(item, index) in sList" :key="index">
        <div class="title">{{ item.text }}</div>
        <div class="content" v-html="item.formatter && item.formatter(detailObj)"></div>
      </div>
    </div>
    <GLCombiForm ref="showSearch" class="show-search" :formObj="searchForm" :form-data="showFormData" @handleOk="handleSearch" @handleRest="handleReset">
      <div slot="firstClassify">
        <el-select v-model="searchForm.firstClassify" clearable placeholder="请选择" @change="changeClassify">
          <el-option v-for="item in baseData.firstClassifyList" :key="item" :label="item" :value="item"></el-option>
        </el-select>
      </div>
      <div slot="secondClassify">
        <el-select v-model="searchForm.secondClassify" clearable placeholder="请选择">
          <el-option v-for="item in baseData.secondClassifyList" :key="item" :label="item" :value="item"></el-option>
        </el-select>
      </div>
      <template slot="score">
        <el-input-range start-placeholder="请输入" end-placeholder="请输入" :displayValue="searchForm.qualityTestScore"></el-input-range>
      </template>
    </GLCombiForm>
    <div class="theader">
      <div class="title">话术列表</div>
      <el-radio-group v-model="searchForm.hitResult">
        <el-radio-button label="">全部</el-radio-button>
        <el-radio-button label="1">命中</el-radio-button>
        <el-radio-button label="0">未命中</el-radio-button>
      </el-radio-group>
    </div>
    <GLTable ref="analyseTable" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams" :before-search-fn="beforeSearchFn" :pageConf="pageConf" :noDataImg="url">
      <template slot="suggestions" slot-scope="scope"> 
        <div v-html="formatSrt(scope.scope.suggestions)"></div>
      </template>
      <template slot="hitResult" slot-scope="scope">
        <div :class="['tag', scope.scope.hitResult == 1 ? 'gre' : 'red']">
          {{ scope.scope.hitResult == 1 ? '是' : '否' }}
        </div>
      </template>
    </GLTable>
  </div>
</template>
<script>
import ElInputRange from './el-input-range'
import url from '@/assets/empty.png'
import { Util, deepClone } from '@/common/util'
export default {
  components: {
    ElInputRange
  },
  props: {
    detailObj: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      url: url,
      sList: [
        {
          text: '话术评分',
          formatter: data => {
            return `<span style="font-weight:700;font-size:20px;">${data.score ? data.score : '0'}</span>分`
          }
        },
        {
          text: '预计营销结果',
          formatter: data => {
            let classStr = data.estimatedResult == '成交' ? (data.estimatedResult == '战败' ? 'redStr' : 'greenStr') : 'grayStr'
            return `<span  class="${classStr}" style="font-weight:700;font-size:20px;">${data.estimatedResult ? data.estimatedResult : '--'}</span>`
          }
        },
        {
          text: '开始录音时间',
          formatter: data => {
            return `<span style="font-weight:700;font-size:20px;">${data.startTime ? data.startTime : '--'}</span>`
          }
        },
        {
          text: '对话时长',
          formatter: data => {
            return `<span style="font-weight:700;font-size:20px;">${data.duration?this.toMinutesAndSeconds(data.duration):'--'}</span>`
          }
          // formatter: data => {

          //   let strHtml = this.toMinutesAndSeconds(data.duration).h
          //     ? `<span style="font-weight:700;font-size:20px">${this.toMinutesAndSeconds(data.duration).h}</span>小时
          //   <span style="font-weight:700;font-size:20px;">${this.toMinutesAndSeconds(data.duration).m}</span>分钟
          //   `
          //     : ` <span style="font-weight:700;font-size:20px;">${this.toMinutesAndSeconds(data.duration).m}</span>分钟`
          //   return strHtml
          // }
        }
      ],
      searchForm: {
        // firstClassify: '',
        // secondClassify: '',
        qualityTestScore: [],
        hitResult: ''
      },
      searchFormSearch: {},
      showFormData: [
        // {
        //   label: '一级分类',
        //   name: 'firstClassify',
        //   addHtml: 'firstClassify'
        // },
        // {
        //   label: '二级分类',
        //   name: 'secondClassify',
        //   addHtml: 'secondClassify'
        // },
        {
          label: '质检评分',
          name: 'qualityTestScore',
          addHtml: 'score'
        }
      ],
      select: '全部',
      getListApi: this.$apis.quality.conversationCheckList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '一级分类',
            prop: 'firstClassify',
            width: '120px'
          },
          {
            label: '二级分类',
            prop: 'secondClassify',
            width: '140px'
          },
          {
            label: '质检得分',
            prop: 'score',
            width: '100px'
          },
          {
            label: '是否命中',
            prop: 'hitResult',
            width: '100px',
            addHtml: 'hitResult'
          },
          {
            label: '命中文本',
            prop: 'hitText'
          },
          {
            label: '话术建议',
            prop: 'suggestions',
            addHtml:'suggestions'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      baseData: {
        firstClassifyList: [],
        secondClassifyList: []
      }
    }
  },
  watch: {
    'searchForm.hitResult'() {
      this.$refs.analyseTable.refreshTable(true, true)
    }
  },
  mounted() {
    // this.getPointCategory()
  },
  methods: {
    formatSrt(str) {
      return str.replace(/\n/g, "<br/>")
    },
    toMinutesAndSeconds(seconds) {
      seconds = Math.floor(seconds / 1000)
      let formattedTime = ''
      if (seconds < 60) return seconds + '秒'
      else if (seconds > 3600) {
        let hours = Math.floor(seconds / 3600),
          minutes = Math.floor((seconds % 3600) / 60)
        if (hours > 0) formattedTime += hours + '小时'
        if (minutes > 0 || hours > 0) formattedTime += minutes + '分'
        return formattedTime
      } else {
        let hours = Math.floor(seconds / 3600),
          minutes = Math.floor((seconds % 3600) / 60),
          remainingSeconds = seconds % 60
        if (hours > 0) formattedTime += hours + '小时'
        if (minutes > 0 || hours > 0) formattedTime += minutes + '分'
        if (remainingSeconds > 0) formattedTime += remainingSeconds + '秒'
        return formattedTime
      }
    },
    // toMinutesAndSeconds(time) {
    //   time = time / 1000
    //   const h = Math.floor(time / 3600)
    //   const m = parseInt((time % 3600) / 60)
    //   return {
    //     h,
    //     m
    //   }
    // },
    getPointCategory() {
      this.classifyMap = new Map()
      this.$apis.quality.getPointCategory().then(res => {
        // console.log(res)
        this.baseData.firstClassifyList = Object.keys(res)
        for (let item in res) {
          this.classifyMap.set(item, res[item])
        }
      })
    },
    changeClassify() {
      this.searchForm.secondClassify = ''
      this.baseData.secondClassifyList = this.classifyMap.get(this.searchForm.firstClassify)
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        this.searchFormSearch.batchId = this.detailObj.id
        if (this.searchFormSearch.qualityTestScore) {
          this.searchFormSearch.qualityTestScoreBegin = this.searchFormSearch.qualityTestScore[0]
          this.searchFormSearch.qualityTestScoreEnd = this.searchFormSearch.qualityTestScore[1]
        }
        delete this.searchFormSearch.qualityTestScore

        resolve()
      })
    },
    handleSearch() {
      this.$refs.analyseTable.refreshTable(true, true)
    },
    handleReset() {
      this.searchForm = {
        // firstClassify: '',
        // secondClassify: '',
        qualityTestScore: [],
        hitResult: ''
      }
      this.baseData.secondClassifyList = []
      this.$refs.analyseTable.refreshTable()
    }
  }
}
</script>
<style lang="scss" scoped>
.analyse {
  .statistics {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    .s-item {
      flex: 1;
      //   min-width: 248px;
      background: #f7f9fa;
      border-radius: 4px;
      padding: 12px 20px;
      box-sizing: border-box;
      margin-right: 16px;
      .title {
        font-size: 14px;
        color: #333333;
        margin-bottom: 8px;
      }
      .content {
        color: #333333;
        line-height: 32px;
      }
      .greenStr {
        color: #2cca74;
      }
      .redStr {
        color: #eb4e4e;
      }
      .grayStr {
        color: #999999;
      }
    }
  }
  .show-search{
    margin-bottom:-68px;
  }
  .theader {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    .title {
      font-size: 16px;
      color: #333333;
      font-weight: 600;
    }
  }
  .tag {
    width: 30px;
    height: 24px;
    border-radius: 2px;
    padding: 0 8px;
    line-height: 24px;
    box-sizing: border-box;
    font-size: 14px;
    margin: 0 auto;
  }
}
</style>
<style>

.redStr {
  color: #eb4e4e;
}
.greenStr {
  color: #2cca74;
}
.grayStr{
  color: #999999;
}
</style>