attackDetail.vue 9.88 KB
<template>
  <div v-loading="loading" class="container">
    <div class="attack-detail" v-if="defenceDetail">
      <div class="statistics-box">
        <div
          class="statistics-item"
          v-for="(item, index) in statisticsObj"
          :key="index"
        >
          <div class="text">{{ item.text }}</div>
          <div class="value">{{ item.value(defenceDetail) }}</div>
        </div>
      </div>
      <div class="dialog-box" @scroll="watchScrollTrack($event,'offense_and_defense_detail')">
        <div
          class="dialog-item"
          v-for="(item, index) in defenceDetail.detailList"
          :key="item.is"
        >
          <div class="dialog-head">
            <img
              class="attack-score"
              src="../../../assets/attack-score.png"
              alt=""
            />
            <div class="text">攻防得分</div>
            <div class="score">{{ item.defScore ? item.defScore : "-" }}</div>
            <div class="text" @click="handleMapping(item.mergedOffset)">
              对话开始时间
            </div>
            <div class="time" @click="handleMapping(item.mergedOffset)">
              {{ item.conStartTime ? item.conStartTime : "-" }}
            </div>
            <div class="attack-index">攻防回合{{ index + 1 }}</div>
            <img
              class="index-logo"
              src="../../../assets/index-logo.png"
              alt=""
            />
          </div>
          <div class="dialog">
            <div
              :class="{
                'dialog-detail': true
              }"
              :key="item.id"
            >
              <div class="name">
                <img class="role" src="@/assets/role-one.png" />
                客户
              </div>
              <div class="dig-content" @click="currentDialog(item)">
                {{ item.question }}
              </div>
            </div>
            <div class="dialog-detail nth-child" :key="item.id">
              <div class="name">
                销售
                <img class="role two" src="@/assets/role-two.png" />
              </div>
              <div class="dig-content" @click="currentDialog(item)">
                {{ item.answer }}
              </div>
              <br />
              <div class="suggest">
                <div class="improve">
                  <img src="@/assets/improve.png" class="improve-img" />
                  改进建议
                </div>
                <div
                  class="improve-text"
                  v-html="
                    regText(item.highlight, item.suggestionsForImprovement)
                  "
                ></div>
                <div class="line"></div>
                <div class="improve">
                  <img src="@/assets/polish.png" class="improve-img" />
                  润色表达
                </div>
                <div
                  class="improve-text"
                  v-html="regText(item.highlight, item.refineTheExpression)"
                ></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <template v-else>
      <div class="empty-box">
        <div class="icon">
          <img src="@/assets/empty-2.png" />
        </div>
        <div class="text">
          {{
            detailObj.defence === 1 ||
            detailObj.defence === 0 ||
            detailObj.defence === 4
              ? "数据分析中,请稍等"
              : detailObj.defence === 3
              ? "未发现攻防"
              : "未进行攻防识别"
          }}
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import { defenceDetail } from "@api/resident"
import watchScrollTrackMixin from '@/mixins/watchScrollTrackMixin'
export default {
  mixins: [watchScrollTrackMixin],
  props: {
    detailObj: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      statisticsObj: [
        {
          text: "攻防次数",
          value: (data) => {
            return data.defenceCount + "次"
          }
        },
        {
          text: "攻防平均得分",
          value: (data) => {
            return data.avgDefence + "分"
          }
        },
        {
          text: "客户类型",
          value: (data) => {
            return data.customerType ? data.customerType : "未知"
          }
        }
      ],
      defenceDetail: "",
      loading: true,
      isFlag: false
    }
  },
  created() {
    this.getDefenceDetail()
  },
  methods: {
    handleMapping(time) {
      Array.prototype.slice
        .call(this.$parent.$parent.$children)
        .forEach((dom) => {
          if (dom.currentDialog) {
            dom.currentDialog(time)
          }
        })
    },
    getDefenceDetail() {
      let params = {
        batchId: this.detailObj.id
      }
      defenceDetail(params).then((res) => {
        this.defenceDetail = res
        this.loading = false
      })
    },
    regText(highlight, value) {
      highlight = highlight ? JSON.parse(highlight):[]
      let replacedText = value
      if (value) {
        highlight.forEach((item) => {
          replacedText = replacedText.replace(item, function (match) {
            return '<span style="color: #FE9220;">' + match + "</span>"
          })
        })
      }
      return replacedText
    }
  }
}
</script>

<style scoped lang="scss">
.container {
  height: 100%;
}
.attack-detail {
  height: calc(100% - 55px);
  overflow: hidden;
  .statistics-box {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    .statistics-item {
      flex: 1;
      padding: 12px 16px;
      background: #f7f9fa;
      color: #333333;
      height: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-right: 8px;
      .value {
        font-weight: 600;
      }
    }
  }
  .dialog-box {
    height: calc(100% - 68px);
    overflow-y: scroll;
    .dialog-item {
      width: 100%;
      background: #f7f9fa;
      margin-bottom: 12px;
      .dialog-head {
        padding: 12px 16px;
        height: 24px;
        position: relative;
        line-height: 24px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid #e5e5e5;
        // cursor: pointer;
        .attack-score {
          width: 24px;
          // height: 24px;
          margin-right: 8px;
        }
        .text {
          font-weight: 400;
          font-size: 14px;
          color: #666666;
        }
        .score {
          font-weight: 500;
          font-size: 15px;
          color: #fe9220;
          margin: 0 24px 0 6px;
        }
        .time {
          font-weight: 400;
          font-size: 14px;
          color: #2a58ad;
          margin-left: 6px;
          cursor: pointer;
        }
        .index-logo {
          width: 86px;
          height: 32px;
          position: absolute;
          right: 0;
        }
        .attack-index {
          font-weight: 400;
          font-size: 14px;
          color: #ffffff;
          position: absolute;
          right: 12px;
          z-index: 999;
        }
      }
      .dialog {
        width: 100%;
        height: 100%;
        background: #f7f9fa;
        border-radius: 4px;
        overflow-y: scroll;
        padding: 12px 8px 12px 16px;
        box-sizing: border-box;
        .dialog-detail {
          margin-bottom: 8px;
          text-align: left;
          .name {
            font-size: 12px;
            color: #666666;
            letter-spacing: 0;
            line-height: 16px;
            .role {
              width: 32px;
              height: 32px;
              vertical-align: top;
              margin-right: 10px;
            }
            .two {
              margin-right: 0;
            }
          }
          .dig-content {
            width: fit-content;
            max-width: 70%;
            background: #e4ecf7;
            border-radius: 4px;
            font-size: 14px;
            color: #333333;
            padding: 10px 12px;
            white-space: pre-wrap;
            text-align: left;
            margin: -14px 0 0 40px;
            line-height: 20px;
          }
          .suggest {
            width: fit-content;
            max-width: 70%;
            background: #fff;
            border-radius: 4px;
            font-size: 14px;
            color: #333333;
            padding: 10px 12px;
            white-space: pre-wrap;
            text-align: left;
            line-height: 20px;
            margin-top: 12px;
            margin-right: 40px;
            display: inline-block;
            .improve {
              width: 94px;
              height: 28px;
              background: #f2f7fc;
              border-radius: 4px;
              padding: 4px 8px;
              display: flex;
              align-items: center;
              font-weight: 500;
              font-size: 14px;
              color: #333333;
              margin-bottom: 6px;
              box-sizing: border-box;
              white-space: nowrap;
              .improve-img {
                width: 14px;
                height: 14px;
                margin-right: 8px;
              }
            }
            .improve-text {
              margin: 0 8px;
            }
            .line {
              width: 100%;
              height: 1px;
              margin: 12px 8px;
              background-color: #ebedff;
            }
          }
        }
        .nth-child {
          text-align: right;
          .dig-content {
            display: inline-block;
            background: #ffffff;
            margin-right: 38px;
            line-height: 22px;
          }
        }
      }
    }
  }
}
.empty-box {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #999999;
  padding-top: 184px;
  text-align: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 0 4px 4px 4px;
  .icon {
    width: 270px;
    height: 120px;
    margin: 0 auto 8px;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>