Reception.vue 7.05 KB
<template>
  <div class="behavior-layout">
    <el-carousel
      :autoplay="false"
      indicator-position="none"
      :loop="false"
      class="staff-list"
      :height="'253px'"
      v-if="staffList.length"
    >

      <template v-for="(i,index) in staffList">
        <el-carousel-item
          :key="index"
          class="staff-flex"
        >
          <template v-for="(i,ind) in i">
            <div
              :key="ind"
              class="staff-item"
            >
              <div
                class="new"
                v-if="i.isNewemployee"
              >新人</div>
              <div class="name-box">
                <div class="name text-hide">{{i.staffName || '-'}}</div>
                <div class="join">{{i.entryTime}}</div>
              </div>
              <template v-for="(e,eind) in infoList">
                <div
                  class="info-box"
                  :key="eind"
                >
                  <template v-for="k in e">
                    <div
                      class="info-item"
                      :key="`${eind}_${k.key}`"
                    >
                      <div class="info-label">{{k.label}}</div>
                      <div class="info-value">{{i[k.key] || 0}}<template v-if="i[k.key] > -1">
                        {{k.keyUnit||''}}
                      </template></div>
                      <div :class="['info-percent',`${percentColor(i[k.percentSJ])}`]">
                        环比<span>{{i[k.percent] != null ? formatted(i[k.percent]) : '--'}}</span>
                        <template v-if="i[k.percent] != null && i[k.percent] != '--'">
                          <div :class="['icon',`${percentClass(i[k.percentSJ])}`]"></div>
                        </template>
                      </div>
                    </div>
                  </template>
                </div>
              </template>
            </div>
          </template>
        </el-carousel-item>
      </template>
    </el-carousel>
    <div class="table">
      <div class="table-title">接待明细</div>
      <reception-table
        v-if="initStatus"
        :searchTime="searchTime"
        :pageData="pageData"
        :show="show"
        @openReceptionDialog="$emit('openReceptionDialog',$event)"
      />
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import ReceptionTable from './ReceptionTable.vue'
import { getPersonStaffReception } from '@api/earlyWarningManager'
import onShowMixin from '../onShowMixin'
import dayjs from 'dayjs'
export default {
  mixins: [onShowMixin],
  components: {
    ReceptionTable
  },
  name: '',
  data () {
    return {
      staffList: [],
      infoList: [
        [
          {
            label: '接待数',
            key: 'receptionNum',
            percent: 'receptionNumhb',
            percentSJ: 'receptionNumhbsj'

          },
          {
            label: '成交数',
            key: 'succeedNum',
            percent: 'succeedNumhb',
            percentSJ: 'succeedNumhbsj'
          },
          {
            label: '转化率',
            key: 'zhuanhuanlv',
            keyUnit:'%',
            percent: 'zhuanhuanlvhb',
            percentSJ: 'zhuanhuanlvhbsj'
          }
        ],
        [
          {
            label: '质检平均分',
            key: 'avgzj',
            percent: 'avgzjhb',
            percentSJ: 'avgzjhbsj'
          },
          {
            label: '攻防平均分',
            key: 'avggf',
            percent: 'avggfhb',
            percentSJ: 'avggfhbsj'
          },
        ]
      ]
    }
  },
  mounted () {
  },
  methods: {
    async getData () {
      this.staffList = []
      let { businessType, merchantId } = this.pageData
      const res = await getPersonStaffReception({
        ...this.searchTime,
        merchantId,
        businessType
      })
      if (res && res.length) {
        res.map(e => {
          e.entryTime = e.entryTime ? `${dayjs(e.entryTime).format('YYYY-MM')}入职` : '-'
        })
        this.staffList = this.chunkArray(res)
      }
    },
    chunkArray (array, size = 4) {
      const result = [];
      for (let i = 0; i < array.length; i += size) {
        const chunk = array.slice(i, i + size);
        result.push(chunk);
      }
      return result;
    },
    formatted (num) {
      return num != '--' ? num + '%' : '--'
    },
    percentClass (num) {
      if (num > 0) {
        return 'el-icon-caret-top'
      } else if (num == 0) {
        return 'minus'
      } else if (num < 0) {
        return 'el-icon-caret-bottom'
      } else {
        return ''
      }
    },
    percentColor (num) {
      if (num > 0) {
        return 'red'
      } else if (num < 0) {
        return 'green'
      } else {
        return ''
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.behavior-layout {
  .staff-list {
    padding: 0 20px;
    ::v-deep.el-carousel__arrow {
      width: 30px;
      height: 30px;
      background: #fff;
      color: #333;
      opacity: 1;
      box-shadow: 0 2px 6px 0 #10101014;
    }
    ::v-deep.el-carousel__arrow--left {
      left: 0;
    }
    ::v-deep.el-carousel__arrow--right {
      right: 0;
    }
    .staff-flex {
      display: flex;
      gap: 0 16px;
      .staff-item {
        width: 25%;
        height: 100%;
        background: #fafafa;
        border-radius: 4px;
        position: relative;
        padding: 20px;
        box-sizing: border-box;
        .new {
          position: absolute;
          width: 40px;
          height: 20px;
          background: #e8ffea;
          top: 20px;
          right: 20px;
          font-size: 12px;
          color: #00b42a;
          line-height: 20px;
          text-align: center;
        }
        .name-box {
          display: flex;
          align-items: flex-end;
          .name {
            max-width: 120px;
            color: inherit;
            font-size: 20px;
            font-weight: 700;
            line-height: 29px;
          }
          .join {
            color: #20202080;
            font-size: 12px;
            line-height: 15px;
            margin-left: 8px;
          }
        }
        .info-box {
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding-top: 24px;
          .info-item{
            flex-shrink: 0;
          }
          .info-label,
          .info-percent {
            color: #20202080;
            font-size: 12px;
            line-height: 15px;
            display: flex;
            align-items: center;
          }
          .info-value {
            color: #202020;
            font-size: 16px;
            font-weight: 700;
            line-height: 19px;
            margin: 8px 0;
          }
        }
      }
    }
  }
  .table {
    box-sizing: border-box;
    padding: 32px 20px 0;
    &-title {
      color: #000000d9;
      font-size: 14px;
      font-weight: 500;
    }
  }
  .green {
    span,
    .icon {
      color: #43cf7c;
    }
  }
  .red {
    span,
    .icon {
      color: #eb4e4e;
    }
  }
  .minus {
    width: 6px;
    height: 2px;
    border-radius: 0.6px;
    background: #20202080;
    margin-left: 2px;
  }
}
</style>