recepDetail.vue 10.4 KB
<template>
  <div class="recep-wrap">
    <div class="header">
      <h2>基础信息</h2>
      <div class="info-wrap">
        <div class="info-item flex">
          <label>员工:</label>
          <span>{{ queryData.employeeName }}</span>
        </div>
        <div class="info-item flex">
          <label>门店:</label>
          <template v-if="queryData.storeList">
            <el-tooltip effect="dark" :content="queryData.storeList.join('、')" placement="top-start">
              <span>{{ queryData.storeList.join('、') }}</span>
            </el-tooltip>
          </template>
          <span v-else>-</span>
        </div>
        <div class="info-item flex">
          <label>服务商:</label>
          <template v-if="queryData.serviceList">
            <el-tooltip effect="dark" :content="queryData.serviceList.join('、')" placement="top-start">
              <span>{{ queryData.serviceList.join('、') }}</span>
            </el-tooltip>
          </template>
          <span v-else>-</span>
        </div>
        <div class="info-item flex">
          <label>质检日期:</label>
          <span>{{ queryData.searchdate }}</span>
        </div>
        <div class="info-item flex">
          <label>接待批次/批:</label>
          <span>{{ queryData.batchNum }}</span>
        </div>
      </div>
    </div>
    <div class="content">
      <GLCombiForm ref="showSearch" class="show-search" labelWidth="110px" :formObj="searchForm" :form-data="showFormData" @handleOk="handleSearch" @handleRest="handleReset">
        <template slot="score">
          <el-input-range start-placeholder="请输入" end-placeholder="请输入" :displayValue="searchForm.qualityTestScore"></el-input-range>
        </template>
      </GLCombiForm>
      <GLTable ref="recepDetail" :get-list-api="getListApi" :hasNum="false" :search-form="searchFormSearch" :table-params="tableParams" :before-search-fn="beforeSearchFn" @setTableFinishFun="setTableFinishFun" :pageConf="pageConf">
        <div slot="durationHtml" slot-scope="scope">
          <template v-if="scope.scope.duration">
            {{ toMinutesAndSeconds(scope.scope.duration) }}
          </template>
          <template v-else>--</template>
        </div>
        <div slot="scoreHtml" slot-scope="scope">
          <template v-if="scope.scope.score || scope.scope.score === 0">
            {{ scope.scope.score }}
          </template>
          <template v-else>--</template>
        </div>
        <div slot="estimatedResult" slot-scope="scope" :class="['tag', scope.scope.estimatedResult == '成交' ? (scope.scope.estimatedResult == '战败' ? 'redBg' : 'greenBg') : 'grayBg']">
          {{ scope.scope.estimatedResult }}
        </div>
        <template slot="auth-button" slot-scope="scope">
          <el-button type="text" @click="qualitDetail(scope.scope)">质检详情</el-button>
        </template>
      </GLTable>
    </div>
    <quality-detail :isQualityVisible="isQualityVisible" v-if="isQualityVisible" :detailObj="detailObj" @closeDialog="closeDialog"></quality-detail>
  </div>
</template>
<script>
import { Util, deepClone } from '@/common/util'
import ElInputRange from './el-input-range'
import QualityDetail from './qualityDetail.vue'
export default {
  data() {
    return {
      queryData: JSON.parse(this.$route.query.data),
      isQualityVisible: false,
      searchForm: {
        recepTime: [],
        qualityTestScore: [],
        estimatedResultId: ''
      },
      detailObj: {},
      searchFormSearch: {},
      getListApi: this.$apis.quality.conversationPage,
      showFormData: [
        {
          label: '接待时间',
          type: 'datePicker',
          name: 'recepTime',
          // addHtml:'recepTime',
          isClear: true,
          pickerOptions: 'afterRangePickerOptions'
        },
        {
          label: '质检评分',
          name: 'qualityTestScore',
          addHtml: 'score'
        },
        {
          label: '预计营销结果',
          name: 'estimatedResultId',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'estimatedResultList'
        }
      ],
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '接待批次',
            prop: 'key'
          },
          {
            label: '开始接待时间',
            prop: 'startTime'
          },
          {
            label: '结束接待时间',
            prop: 'endTime'
          },
          {
            label: '录音时长',
            prop: 'duration',
            addHtml: 'durationHtml'
          },
          {
            label: '预计营销结果',
            prop: 'estimatedResult',
            addHtml: 'estimatedResult'
          },
          {
            label: '话术质检评分/分',
            prop: 'score',
            addHtml: 'scoreHtml'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      baseData: {
        estimatedResultList: [
          {
            confId: '1',
            confLabel: '成交'
          },
          {
            confId: '2',
            confLabel: '战败'
          },
          {
            confId: '3',
            confLabel: '未知'
          }
        ]
      }
    }
  },
  components: {
    ElInputRange,
    QualityDetail
  },
  mounted() {
    this.getOptionsList()
  },
  methods: {
    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
      }
    },
    handleSearch() {
      this.$refs.recepDetail.refreshTable(true, true)
    },
    handleReset() {
      this.searchForm = {
        recepTime: [],
        qualityTestScore: [],
        estimatedResultId: ''
      }
      this.$refs.recepDetail.refreshTable()
    },
    closeDialog() {
      console.log(this.isQualityVisible)
      this.isQualityVisible = false
    },
    qualitDetail(row) {
      console.log(row)
      this.detailObj = row
      this.isQualityVisible = true
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        this.searchFormSearch.conversationDateId = this.queryData.id
        this.searchFormSearch.pageNum = this.searchFormSearch.currentPage
        if (this.searchFormSearch.qualityTestScore) {
          this.searchFormSearch.qualityTestScoreBegin = this.searchFormSearch.qualityTestScore[0]
          this.searchFormSearch.qualityTestScoreEnd = this.searchFormSearch.qualityTestScore[1]
        }
        if (this.searchFormSearch.recepTime.length > 0) {
          this.searchFormSearch.startTime = Util.dateFormate(this.searchFormSearch.recepTime[0], 'YYYY-MM-DD HH:mm:ss')
          this.searchFormSearch.endTime = Util.dateFormate(this.searchFormSearch.recepTime[1], 'YYYY-MM-DD') + ' 23:59:59'
        }

        if (this.searchFormSearch.estimatedResultId) {
          this.searchFormSearch.estimatedResult = this.baseData.estimatedResultList.find(item => item.confId == this.searchFormSearch.estimatedResultId).confLabel
        }

        delete this.searchFormSearch.qualityTestScore
        delete this.searchFormSearch.recepTime
        delete this.searchFormSearch.estimatedResultId
        delete this.searchFormSearch.currentPage
        resolve()
      })
    },
    setTableFinishFun(data) {
      for (let i = 0; i < data.length; i++) {
        data[i].key = i + 1
      }
    },
    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.recep-wrap {
  margin: 0 16px;

  .header {
    width: 100%;
    background: #ffffff;

    h2 {
      font-size: 16px;
      font-weight: 600;
      color: #333333;
      text-align: left;
      line-height: 56px;
      height: 56px;
      border-bottom: 1px solid #e5e5e5;
      padding-left: 20px;
      box-sizing: border-box;
    }

    .info-wrap {
      display: flex;
      flex-wrap: wrap;
      padding: 32px 20px 12px 20px;

      .info-item {
        width: 50%;
        margin-bottom: 20px;
        display: flex;
        align-items: flex-start;

        label {
          width: 154px;
          text-align: right;
          font-size: 14px;
          color: #666666;
          display: inline-block;
        }

        span {
          font-size: 14px;
          color: #1d1d1d;
          display: inline-block;
          cursor: pointer;
          max-width: 500px;
          overflow: hidden;
          /* 防止文本换行 */
          white-space: nowrap;

          /* 使用省略号表示被截断的文本 */
          text-overflow: ellipsis;
        }
      }
    }
  }
.show-search{
margin-bottom:-52px;
}
  .content {
    background: #ffffff;
    padding: 20px;
    box-sizing: border-box;
    margin-top: 16px;
    width: 100%;
    height: auto;
  }
  .tag {
    padding: 0 8px;
    height: 24px;
    background: #e9f9f1;
    border-radius: 2px;
    font-size: 14px;
    color: #2cca74;
    line-height: 24px;
    display: inline-block;
  }
  .greenbg {
    background: #e9f9f1;
    color: #2cca74;
  }
  .redBg {
    background: #fdeded;
    color: #eb4e4e;
  }
  .grayBg {
    background: #f2f2f2;
    color: #999999;
  }
}
</style>