staffDetail.vue 8.58 KB
<!-- 员工详情 -->
<template>
  <div class="staff-detail-wrap">
    <div class="header">基础信息</div>
    <div class="baseInfo">
      <div class="form_div" v-if="infoData && infoData.length">
        <el-form class="edit-sub-block" label-width="128px" :inline="true">
          <el-row :gutter="20">
            <template v-for="(item, index) in infoData">
              <el-col :span="item.col ? item.col : 8" :key="index">
                <el-form-item :label="item.title">
                  <div
                    v-if="item.className"
                    :class="[item.className(baseInfo)]"
                  ></div>
                  <template
                    v-if="item.key == 'store' || item.key == 'regionManager'"
                  >
                    <template
                      v-if="
                        baseInfo[item.key] &&
                        baseInfo[item.key].split(',').length > 1
                      "
                    >
                      <span>{{
                        baseInfo[item.key].split(",").slice(0, 1).join("")
                      }}</span>
                      <el-popover
                        placement="top"
                        width="fit-content"
                        trigger="hover"
                      >
                        <div
                          :class="{
                            serverHeight:
                              baseInfo[item.key].split(',').length >= 10
                          }"
                        >
                          <div
                            v-for="(item, index) in baseInfo[item.key].split(
                              ','
                            )"
                            :key="index"
                          >
                            {{ item }}
                          </div>
                        </div>
                        <span class="more-info" slot="reference"
                          >...({{ baseInfo[item.key].split(",").length }})</span
                        >
                      </el-popover>
                    </template>
                    <template v-else>
                      <span>{{
                        baseInfo[item.key] ? baseInfo[item.key] : "-"
                      }}</span>
                    </template>
                  </template>
                  <template v-else>
                    {{
                      item.formatter
                        ? item.formatter(baseInfo)
                        : baseInfo[item.key]
                        ? baseInfo[item.key]
                        : "-"
                    }}
                  </template>
                </el-form-item></el-col
              >
            </template>
          </el-row>
        </el-form>
      </div>
    </div>
    <!-- 业绩状况 -->
    <performance-status :performanceInfo="performanceInfo"></performance-status>
    <!--  谈客能力-->
    <template v-if="queryData.brandId == 1 && queryData.scene == 1">
      <div class="header">谈客能力</div>
      <div class="presentation">
        <div
          v-for="(item, index) in capacityList"
          :key="index"
          class="capacity-line"
        >
          <div class="title">{{ item.title }}</div>
          <div class="capacity">
            <div
              :class="['capacity-item', item.key == 'ohterList' ? 'other' : '']"
              v-for="(child, chindIndex) of item.children"
              :key="chindIndex"
            >
              {{ child.label }}:{{ child.value }}
            </div>
          </div>
        </div>
      </div>
    </template>

    <!-- 学习情况 -->
    <learning-situation
      :learningProgress="learningProgress"
    ></learning-situation>
  </div>
</template>
<script>
import LearningSituation from "./learningSituation.vue"
import PerformanceStatus from "./performanceStatus.vue"
import { long_businessOpt } from "@/common/constants.js"
import { Util, deepClone } from "@/common/util"
import { findStoreEmployeePerformance } from "@/api/serviceCentre"
export default {
  components: {
    PerformanceStatus,
    LearningSituation
  },
  props: {
    staffItem: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    staffItem: {
      handler(val) {
        this.findStoreEmployeePerformanceData()
      },
      // immediate: true,
      deep: true
    }
  },
  data() {
    return {
      businessOpt: deepClone(long_businessOpt),
      aiJy: "",
      baseInfo: {},
      performanceInfo: [],
      consultationAbility: {},
      learningProgress: {},
      infoData: [
        {
          title: "入职时间:",
          key: "joinDateTag"
        },

        {
          title: "上级:",
          key: "regionManager"
        },
        {
          title: "导师:",
          key: "mentor"
        },
        {
          title: "门店:",
          key: "store"
        },
        {
          title: "归属业务:",
          key: "businessType",
          formatter: (cellValue) => {
            return (
              this.businessOpt.find(
                (item) => item.confId === cellValue.businessType
              )?.confValue || "-"
            )
          }
        }
      ],
      queryData: this.$route.query,
      capacityList: [
        {
          title: "弱项:",
          key: "badList",
          children: []
        },
        {
          title: "其他项:",
          key: "ohterList",
          children: []
        }
      ]
    }
  },
  methods: {
    //查询员工详情
    findStoreEmployeePerformanceData() {
      let { staffItem, queryData } = this
      findStoreEmployeePerformance({
        phone: staffItem.phone,
        scene: queryData.scene
      }).then((res) => {
        this.initBaseData(res)
      })
    },
    initBaseData(val) {
      this.baseInfo = val.baseInfo ? val.baseInfo : {}
      // this.aiJy = val.aiJy
      this.consultationAbility = val.consultationAbility
      val.learningProgress.courseRecords &&
        val.learningProgress.courseRecords.forEach((item) => {
          item.isCollapse = true
        })
      this.learningProgress = val.learningProgress
      this.performanceInfo = val.performance
      // 处理 otherList 数据
      const otherData = this.consultationAbility.ohterList || {}
      const ohterList = Object.keys(otherData).map((key) => ({
        label: key,
        value: otherData[key]
      }))
      const badData = this.consultationAbility.badList || {}
      const badList = Object.keys(badData).map((key) => ({
        label: key,
        value: badData[key]
      }))

      // 更新 capacityList.children
      this.capacityList = this.capacityList.map((item) => {
        if (item.key === "ohterList") {
          item.children = ohterList
        }
        if (item.key === "badList") {
          item.children = badList
        }
        return item
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.staff-detail-wrap {
  background: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100% - 45px);
  .header {
    color: #111111;
    font-size: 16px;
    font-weight: 500;
    padding: 8px 20px;
    border-bottom: 1px solid #e5e5e5;
  }
  .form_div {
    color: #1d1d1d;
    padding: 20px 30px;

    .edit-sub-block {
      .el-form-item {
        width: 100%;
        margin-bottom: 0px;
        display: flex;
      }
      .itemDiv {
        display: flex;
        .halfItem {
          width: 50%;
        }
      }
      .detail-txt {
        display: inline-block;
        width: 200px;
        vertical-align: bottom;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      ::v-deep .el-form-item__label {
        white-space: nowrap;
        color: #666666;
      }
      ::v-deep .el-form-item__content {
        // max-width: calc(100% - 1280px);
        word-break: break-all;
        width: 90%;
      }
    }

    .edit-sub-block-two {
      .el-form-item {
        margin-bottom: 0px;
      }
    }
  }
  .presentation {
    margin: 20px;
    .capacity-line {
      display: flex;
      align-items: center;
      margin-bottom: 16px;
      .title {
        color: #666666;
        font-size: 14px;
        font-weight: 400;
        width: 138px;
        text-align: right;
      }
      .capacity {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        .capacity-item {
          padding: 6px 12px;
          background: #f2f3f5;
          color: #eb4e4e;
          font-size: 14px;
          font-weight: 400;
          margin-left: 8px;
          margin-bottom: 4px;
        }
        .other {
          color: #333333 !important;
          font-size: 14px;
        }
      }
    }
  }
}
</style>