staffInfo.vue 4.01 KB
<!-- 员工编辑 -->
<template>
  <d2-container ref="staffInfoWrap">
    <div class="staffInfo-wrap" >
      <el-tabs v-model="activeName" type="card" @tab-click="tabClick">
        <el-tab-pane label="员工信息" name="staffInfo" v-if="editPermissionFlag">
          <edit-staff ref="editStaff" v-if="activeName == 'staffInfo'" :queryData="queryData"></edit-staff>
        </el-tab-pane>
        <el-tab-pane label="历史业绩" name="historyPerformance" v-if="historyPerformanceFlag">
          <historical-performance ref="historicalPerformance" v-if="activeName == 'historyPerformance'" :queryData="queryData"></historical-performance>
        </el-tab-pane>
      </el-tabs>
      <div class="btnCon">
        <el-button v-if="activeName == 'staffInfo'" type="primary" @click="handleConfirm">提交</el-button>
        <el-button v-if="activeName != 'staffInfo'" type="primary" @click="handleCancel">返回</el-button>
        <el-button v-if="activeName == 'staffInfo'" @click="handleCancel">返回</el-button>
      </div>
    </div>
  </d2-container>
</template>

<script>
import { mapActions } from "vuex"
import historicalPerformance from "./components/historicalPerformance.vue"
import editStaff from "./components/editStaff.vue"
export default {
  name: "StaffInfo",
  props: {
    queryData: Object
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      activeName: 'staffInfo',
      editPermissionFlag: false,
      historyPerformanceFlag: false
    }
  },

  components: {
    editStaff,
    historicalPerformance
  },

  computed: {},

  async mounted() {
    this.setActiveName(this.queryData)
    this.$nextTick(() => {
      const $store = this.$store.getters['d2admin/auth/curBtns']
      const btnId = '9120505' // 员工编辑权限
      const btnId2 = '9120508' // 历史业绩权限
      const _item = $store?.find(i => (i.authId === btnId))
      const _item2 = $store?.find(i => (i.authId === btnId2))
      if (_item) {
        this.editPermissionFlag = true
      }
      if (_item2) {
        this.historyPerformanceFlag = true
      }
    })
  },

  methods: {
    ...mapActions({
      get: "d2admin/base/get",
      close: "d2admin/page/close"
    }),
    async getBaseData() { },

    // tab选中项
    setActiveName(data) {
      this.activeName = data.activeName
      setTimeout(() => {
        // 将页面滚动回顶部
        if (this.$refs['staffInfoWrap'] && this.$refs['staffInfoWrap'].$refs['component'] && this.$refs['staffInfoWrap'].$refs['component'].$el) {
          this.$refs['staffInfoWrap'].$refs['component'].$el.scrollTop = 0
          // 重新请求页面接口
          let refs = data.activeName == 'staffInfo' ? 'editStaff' : 'historicalPerformance'
          this.$refs[refs].resetData()
        }
      })
    },

    tabClick() {
      this.setActiveName({ activeName: this.activeName })
    },

    handleCancel() {
      this.$emit("backIndex")
    },

    handleConfirm() {
      this.$refs.editStaff.handleConfirm().then(() => {
        this.$emit("backIndex")
      })
      
    }
  }
}
</script>
<style scoped  lang="scss" >
.btnCon {
  width: 100%;
  margin-top: 40px;
  text-align: center;
}
.staffInfo-wrap {
  height: 100%;
  // margin-left: 20px;
  // overflow-y: scroll;
  // height: calc(100vh - 40px);
  ::v-deep .el-tabs__header {
    position: sticky;
    top: 0;
    margin-bottom: 0;
    z-index: 10;
    .el-tabs__nav-scroll{
      background: #ffffff;
      padding: 16px 0;
      .el-tabs__nav{
        height: 38px;
        background: #E8E8E8;
        border-radius: 4px;
        margin-left: 22px;
        padding: 2px;
        .el-tabs__active-bar {
          display: none !important;
        }
        .el-tabs__item {
          height: 32px;
          line-height: 32px;
          width: 104px;
          color: #666666;
          padding: 0 24px;
        }
        .el-tabs__item.is-active {
          color: #2A58AD;
          font-weight: 600;
          background: #ffffff;
          border-radius: 3px;
          border: none;
        }
      }
    }
  }
}
</style>