QualityTable.vue 4.13 KB
<template>
  <div class="quality-table-box">
    <div class="title">话术标签</div>
    <div class="tag-box" ref="tagBox">
      <div class="tag-item" v-for="item in tagList" :key="item.tagId">
        {{ item.tagGroupName }} - {{ item.tagName }}
      </div>
    </div>
    <div class="title">质检明细</div>
    <div class="quality-table">
      <div class="quality-content">
        <el-table 
          :data="processedQualityList" 
          border 
          style="width: 100%"
          :height="tableHeight"
          :max-height="tableHeight">
          <el-table-column type="index" label="序号" align="center" width="80">
          </el-table-column>
          <el-table-column prop="tagGroupName" label="一级分类" align="center" width="120">
          </el-table-column>
          <el-table-column label="质检得分" align="center" width="100">
            <template slot-scope="scope">
              {{ scope.row.score }}/{{ scope.row.sumScore }}
            </template>
          </el-table-column>
          <el-table-column prop="processedScriptRec" label="命中文本" align="center">
            <template slot-scope="scope">
              <template v-if="scope.row.processedScriptRec">
                <el-tooltip placement="top" effect="light" popper-class="quality-tooltip">
                  <div slot="content" v-html="scope.row.processedScriptRec"></div>
                  <div class="text-ellipsis" v-html="scope.row.processedScriptRec"></div>
                </el-tooltip>
              </template>
              <template v-else>
                <div class="text-ellipsis">暂无命中文本</div>
              </template>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import {getRecordTagList, getQualityList} from '@/api/resident'
export default {
  props: ['batchId', 'qualityData'],
  data() {
    return {
      qualityList: [],
      tagList: [],
      tableHeight: 430
    }
  },
  computed: {
    processedQualityList() {
      return this.qualityData.map(item => {
        let hitTextArr = ''
        try {
          hitTextArr = JSON.parse(item.hitText);
        } catch (e) {
          hitTextArr = '';
        }
        return {
          ...item,
          processedScriptRec: (hitTextArr && hitTextArr.length)
            ? hitTextArr.map(text => text.replace(/\n/g, '<br>')).join('')
            : ''
        }
      })
    }
  },
  mounted() {
    this.getRecordTagList()
    this.calculateTableHeight()
    // this.getQualityList()
  },
  methods: {
    async getRecordTagList() {
      this.tagList = await getRecordTagList({
        batchId: this.batchId
      })
      this.$nextTick(() => {
        this.calculateTableHeight()
      })
    },
    calculateTableHeight() {
      // 获取屏幕高度
      const screenHeight = window.innerHeight
      // 获取话术标签box的高度
      const tagBoxHeight = this.$refs.tagBox ? this.$refs.tagBox.offsetHeight : 0
      // 其他固定元素的高度(标题、间距等)
      const otherHeight = 260 // 标题高度 + 间距
      // 计算表格高度 = 屏幕高度 - 话术标签box高度 - 其他固定元素高度
      this.tableHeight = screenHeight - tagBoxHeight - otherHeight
    },
    // async getQualityList() {
    //   this.qualityList = await getQualityList({
    //     batchId: this.batchId
    //   })
    // }
  }
}
</script>

<style scoped lang='scss'>
.quality-table-box {
  font-size: 16px;
  color: #1D1D1D;
  .title {
    font-size: 16px;
    color: #1D1D1D;
    font-weight: 500;
    margin-bottom: 10px;
  }
  .tag-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    .tag-item {
      padding: 8px 12px;
      border-radius: 4px;
      background-color: #EAEEF7;
      border: 1px solid #2A58AD;
      color: #333;
      font-size: 14px;
    }
  }
}
.text-ellipsis {
  text-align: left;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  /* 定义文本的行数 */
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
<style lang="scss">
.quality-tooltip {
  width: 640px !important;
}
</style>