configureCourse.vue 8.1 KB
<!-- 配置课程 -->
<template>
  <div class="configureCourse-wrap">
    <div class="configureCourse">
      <div class="left-wrap">
        <div class="header">
          <img class="staff-icon" src="../../images/staff-icon.png" alt="" />
          <div class="title">
            员工列表
            <div class="num">
              共{{ statisticsObj.total }}人,已配置{{
                statisticsObj.complete
              }}人
            </div>
          </div>
        </div>
        <div class="staff-list">
          <div
            v-for="(item, index) in staffList"
            :key="item.staffUUID"
            :class="['staff-item', staffIndex == index ? 'active' : '']"
            @click="handleClick(index)"
          >
            <div class="employeeName">{{ item.employeeName }}</div>
            <div class="config" v-if="item.courseConfigFlag == 1">已配置</div>
          </div>
        </div>
      </div>
      <div class="right-wrap">
        <div class="nav-tabs">
          <div
            :class="['nav-item', activeName == index ? 'active' : '']"
            v-for="(item, index) in tabPaneList"
            :key="index"
            @click="handleTabClick(index)"
          >
            {{ item.label }}
          </div>
        </div>
        <components
          :is="tabName"
          :staffDetailInfo="staffDetailInfo"
          :courseList="courseList"
          :staffItem="staffItem"
          @handleConfigureCourse="handleConfigureCourse"
          :staffList="staffList"
        ></components>
      </div>
    </div>
    <div class="end-configuration" @click="handleEndConfigure">结束配置</div>
  </div>
</template>
<script>
import staffDetail from "./staffDetail"
import couseAllocation from "./couseAllocation"

import {
  customizeList,
  findStaffByMerchantNo,
  findStoreEmployeePerformance,
  getStaffTagCourseList
} from "@/api/serviceCentre"
export default {
  name: "configureCourse",
  components: { staffDetail, couseAllocation },
  data() {
    return {
      staffIndex: 0,
      activeName: "0",
      tabPaneList: [
        {
          label: "员工详情"
        },
        {
          label: "课程配置"
        }
      ],
      tabName: "staffDetail",
      staffItem: {},
      staffList: [],
      courseList: [],
      staffDetailInfo: {},
      statisticsObj: {
        total: 0,
        complete: 0
      }
    }
  },
  created() {
    //课程搜索功能
    this.$EventBus.$on("fromAllocation", (courseForm) => {
      console.log("父组件接收到孙组件事件:", courseForm)
      this.getStaffTagCourseList(courseForm)
    })
  },
  async mounted() {
    this.queryData = this.$route.query
    //获取员工列表
    this.staffList = await this.getStaffInfoData()
    this.staffItem = this.staffList[this.staffIndex]
    //查询员工详情
    this.findStoreEmployeePerformanceData()
  },
  methods: {
    //提交本员工配置回调
    async handleConfigureCourse() {
      this.staffIndex = 0

      //获取员工列表
      this.staffList = await this.getStaffInfoData()
      this.handleTabClick(0)
    },
    //查询员工详情
    findStoreEmployeePerformanceData() {
      let { staffItem, queryData } = this
      findStoreEmployeePerformance({
        // phone: "18978849947",
        phone: staffItem.phone,
        scene: queryData.scene
      }).then((res) => {
        this.staffDetailInfo = res
      })
    },
    getStaffTagCourseList(courseForm = {}) {
      console.log(this.staffItem, " this.staffItem")
      let params = {
        staffPhone: this.staffItem.phone,
        currentPage: 1,
        pageSize: 99999,
        queryAll: false,
        ...courseForm
      }
      getStaffTagCourseList(params).then((res) => {
        this.courseList = res ? res.list : []
      })
    },
    handleStatistics(res) {
      let total = 0,
        complete = 0
      res.forEach((item) => {
        if (item.courseConfigFlag == 1) {
          complete++
        }
        total++
      })
      this.statisticsObj = {
        total,
        complete
      }
      console.log(this.statisticsObj)
    },
    getStaffInfoData() {
      return new Promise((resolve, reject) => {
        let { unionOrAndType } = this.queryData
        let methods = unionOrAndType ? customizeList : findStaffByMerchantNo
        methods(this.queryData).then((res) => {
          console.log(res)
          if (res) {
            resolve(res)
          }
          //员工统计
          this.handleStatistics(res)
        })
      })
    },
    handleClick(index) {
      this.staffIndex = index
      this.staffItem = this.staffList[this.staffIndex]
      if (this.activeName == 0) {
        //查询员工详情
        this.findStoreEmployeePerformanceData()
      } else {
        //获取配置课程列表
        this.getStaffTagCourseList()
      }
    },
    handleTabClick(index) {
      this.activeName = index
      const arr = {
        0: "staffDetail",
        1: "couseAllocation"
      }
      this.tabName = arr[+this.activeName]
      if (index == 0) {
        //查询员工详情
        this.findStoreEmployeePerformanceData()
      } else {
        //获取配置课程列表
        this.getStaffTagCourseList()
      }
    },
    handleEndConfigure() {
      if (this.statisticsObj.total != this.statisticsObj.complete) {
        this.$confirm("还有员工未完成课程配置,是否确定结束配置?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.$router.push({
              name: "longCourse"
            })
          })
          .catch(() => {})
      } else {
        this.$router.push({
          name: "longCourse"
        })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.configureCourse {
  height: calc(100vh - 190px);
  display: flex;
  margin: 0 20px;
  margin-bottom: 16px;
  .left-wrap {
    min-width: 200px;
    width: 200px;
    height: 100%;
    min-height: 760px;
    background: #ffffff;
    margin-right: 16px;
    .header {
      display: flex;
      align-items: flex-start;
      margin: 12px 0 8px 13px;
      .staff-icon {
        width: 16px;
        height: 16px;
        margin-right: 8px;
        margin-top: 3px;
      }
      .title {
        color: #333333;
        font-size: 16px;
        font-weight: 400;
        .num {
          color: #999999;
          font-size: 12px;
          font-weight: 400;
          margin-top: 2px;
        }
      }
    }
    .staff-list {
      height: calc(100% - 62px);
      overflow-y: auto;
      .staff-item {
        color: #666666;
        font-size: 16px;
        font-weight: 400;
        padding: 10px 12px 10px 36px;
        position: relative;
        .employeeName {
          width: 90px;
          white-space: wrap;
        }
        .config {
          position: absolute;
          border-radius: 2px;
          border: 1px solid #2cca74;
          background: #e9eef7;
          padding: 4px 8px;
          color: #2cca74;
          font-size: 12px;
          font-weight: 500;
          top: 10px;
          right: 12px;
        }
      }
      .active {
        color: #2a58ad;
        background: #e9eef7;
        border-right: 3px solid #2a58ad;
      }
    }
  }
  .right-wrap {
    min-height: 760px;
    width: calc(100% - 216px);
    min-width: 984px;
    overflow-x: auto;
    .nav-tabs {
      display: flex;
      align-items: center;
      .nav-item {
        width: 112px;
        height: 44px;
        border-radius: 4px 4px 0 0;
        color: #666666;
        font-size: 16px;
        font-weight: 400;
        line-height: 44px;
        box-sizing: border-box;
        text-align: center;
        margin-right: 2px;
        border: 1px solid #e5e5e5;
        background: #f8f8f8;
      }
      .active {
        color: #2a58ad;
        font-size: 16px;
        font-weight: 500;
        border: 1px solid #e5e5e5;
        background: #ffffff;
      }
    }
    // background: #ffffff;
  }
}
.end-configuration {
  width: 120px;
  height: 36px;
  border-radius: 4px;
  background: #2a58ad;
  color: #ffffff;
  font-size: 16px;
  font-weight: 400;
  text-align: center;
  line-height: 36px;
  margin: 0 auto;
}
</style>