zouyu
2025-03-18 bc44c8e3c9d85691ce3fa73ef1300a6fae46e365
src/views/performance/staffEvaluate/index.vue
@@ -1,9 +1,225 @@
<template>
  <div>人员考评</div>
  <div class="personnel-evaluation">
    <basicContainer>
      <div class="search">
      <div class="search_thing">
            <div class="search_label">月份:</div>
            <div class="search_input">
          <el-date-picker
            v-model="entity.month"
            format="yyyy-MM"
            placeholder="选择月"
            size="small"
            type="month"
            value-format="yyyy-MM"
            @change="refreshTable()">
          </el-date-picker>
        </div>
         </div>
      <div class="search_thing">
            <div class="search_label">实验室:</div>
            <div class="search_input">
          <el-select v-model="entity.departLims" placeholder="全部" size="small" @change="refreshTable()">
               <el-option v-for="item in laboratoryList" :key="item.value" :label="item.label" :value="item.value">
               </el-option>
            </el-select>
        </div>
         </div>
         <div class="search_thing">
            <div class="search_label">人员名称:</div>
            <div class="search_input"><el-input v-model="entity.name" clearable placeholder="请输入"
                  size="small" @keyup.enter.native="refreshTable()"></el-input></div>
         </div>
         <div class="search_thing" style="padding-left: 30px;">
            <el-button size="small" @click="refresh()">重 置</el-button>
            <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
         </div>
      </div>
    <div class="tabs" style="margin-top: 10px;">
      <el-radio-group v-model="tabValue" size="small" >
        <el-radio-button v-hasPermi="['staffEvaluate:evaluation:list']" label="evaluation">考评</el-radio-button>
        <el-radio-button v-hasPermi="['staffEvaluate:employeeMutualEvaluation:list']" label="employeeMutualEvaluation">员工互评</el-radio-button>
        <el-radio-button v-hasPermi="['staffEvaluate:leaderRate:list']" label="leaderRate">组长评分</el-radio-button>
        <el-radio-button v-hasPermi="['staffEvaluate:supervisorRate:list']" label="supervisorRate">主管打分</el-radio-button>
      </el-radio-group>
      <el-button :loading="outLoading" size="small" type="primary" @click="handleDown"  v-hasPermi="['staffEvaluate:evaluation:export']">导 出</el-button>
    </div>
    </basicContainer>
    <div class="table">
      <component :is="tabValue" v-if="laboratoryList.length>0" ref="component" :entity="entity"></component>
    </div>
  </div>
</template>
<script>
export default {};
 import evaluation from '../staffEvaluate/evaluation.vue'
import employeeMutualEvaluation from '../staffEvaluate/employee-mutual-evaluation.vue'
import leaderRate from '../staffEvaluate/leader-rate.vue'
import supervisorRate from '../staffEvaluate/supervisor-rate.vue'
import {
  obtainItemParameterList,
  exportEvaluate,
  exportEvaluateLeader,
  exportEvaluateCompetent
} from '../../../api/cnas/performance/staffEvaluate'
export default {
  components: {
     evaluation,
    employeeMutualEvaluation,
    leaderRate,
    supervisorRate,
  },
  data(){
    return{
      // isPermission: isPermission,
      entity:{
        month:new Date().getFullYear()+'-'+((new Date().getMonth() + 1) < 10 ? '0'+(new Date().getMonth() + 1):(new Date().getMonth() + 1)),
        departLims:'',
        name:''
      },
      tabValue:'evaluation',
      laboratoryList:[],
      outLoading:false,
      copyEntity:null
    }
  },
  created(){
    this.obtainItemParameterList()
    this.tabValue = this.initTabValueByPermissions()
  },
  methods: {
    initTabValueByPermissions(){
      // const per1 = this.isPermission('page')//查询考评
      // const per2 = this.isPermission('getEvaluateGroup')//员工互评
      // const per3 = this.isPermission('getEvaluateLeader')//组长评分
      // const per4 = this.isPermission('getEvaluateCompetent')//主管打分
      // return per1?'evaluation':per2?'employeeMutualEvaluation':per3?'leaderRate':per4?'supervisorRate':''
      return 'evaluation'
    },
    refreshTable(){
      this.$refs.component.refreshTable()
    },
    refresh(){
      this.entity = this.HaveJson(this.copyEntity)
      this.$refs.component.refresh()
    },
    obtainItemParameterList() {
      obtainItemParameterList().then(res => {
        let data = []
        res.data.forEach(a => {
          data.push({
            label: a.laboratoryName,
            value: a.laboratoryName
          })
        })
        this.laboratoryList = data
        this.entity.departLims = data[0].value
        this.copyEntity = this.HaveJson(this.entity)
      })
    },
    handleDown(){
      let url = null;
      let title = ''
      if(this.tabValue=='evaluation'){
        url = exportEvaluate
        title = '考评表'
      }else if(this.tabValue=='employeeMutualEvaluation'){
        url = exportEvaluate
        title = '考评表'
      }else if(this.tabValue=='leaderRate'){
        url = exportEvaluateLeader
        title = '组长评分表'
      }else if(this.tabValue=='supervisorRate'){
        url = exportEvaluateCompetent
        title = '主管评分表'
      }
      let entity = {...this.entity}
      this.outLoading = true
      url(entity).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/octet-stream' });
        //将Blob 对象转换成字符串
        let reader = new FileReader();
        reader.readAsText(blob, 'utf-8');
        reader.onload = () => {
          try {
            let result = JSON.parse(reader.result);
            if (result.message) {
              this.$message.error(result.message);
            } else {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = entity.departLims+'-'+entity.month+title+'.xlsx';
              link.click();
              this.$message.success('导出成功')
            }
          } catch (err) {
            console.log(err);
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = entity.departLims+'-'+entity.month+title+'.xlsx';
            link.click();
            this.$message.success('导出成功')
          }
        }
      })
    },
  }
}
</script>
<style></style>
<style scoped>
.personnel-evaluation {
  height: 100%;
  overflow-y: auto;
}
.title {
  height: 60px;
  line-height: 60px;
}
.search {
      background-color: #ffffff;
      height: 80px;
      display: flex;
      align-items: center;
    margin-top: 20px;
   }
   .search_thing {
      width: 350px;
      display: flex;
      align-items: center;
   }
   .search_label {
      width: 110px;
      font-size: 14px;
      text-align: right;
   }
   .search_input {
      width: calc(100% - 110px);
   }
  .tabs{
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .table {
      margin-top: 10px;
      background-color: #ffffff;
      width: calc(100% - 40px);
      height: calc(100% - 60px - 80px - 10px - 42px);
      padding: 20px;
   }
</style>