licp
2024-12-24 e4bb381c896015c4b87faa002ba6875c06a2fd16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<template>
  <div class="personnel-evaluation">
    <!-- <el-row class="title">
      <el-col :span="12" style="padding-left: 20px;">人员考评
      </el-col>
    </el-row> -->
    <div class="search">
      <div class="search_thing">
                <div class="search_label">月份:</div>
                <div class="search_input">
          <el-date-picker
            size="small"
            v-model="entity.month"
            type="month"
            placeholder="选择月"
            format="yyyy-MM"
            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 size="small" placeholder="请输入" clearable
                        v-model="entity.name" @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 label="evaluation">考评</el-radio-button>
        <el-radio-button label="employeeMutualEvaluation">员工互评</el-radio-button>
        <el-radio-button label="leaderRate">组长评分</el-radio-button>
        <el-radio-button label="supervisorRate">主管打分</el-radio-button>
      </el-radio-group>
      <el-button type="primary" size="small" :loading="outLoading" @click="handleDown">导 出</el-button>
    </div>
    <div class="table">
      <component :is="tabValue" ref="component" :entity="entity" v-if="laboratoryList.length>0"></component>
    </div>
  </div>
</template>
 
<script>
import evaluation from '../do/b3-personnel-evaluation/evaluation.vue'
import employeeMutualEvaluation from '../do/b3-personnel-evaluation/employee-mutual-evaluation.vue'
import leaderRate from '../do/b3-personnel-evaluation/leader-rate.vue'
import supervisorRate from '../do/b3-personnel-evaluation/supervisor-rate.vue'
export default {
  components: {
    evaluation,
    employeeMutualEvaluation,
    leaderRate,
    supervisorRate
  },
  data(){
    return{
      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()
  },
  methods: {
    refreshTable(){
      this.$refs.component.refreshTable()
    },
    refresh(){
      this.entity = this.HaveJson(this.copyEntity)
      this.$refs.component.refresh()
    },
    obtainItemParameterList() {
      this.$axios.get(this.$api.laboratoryScope.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 = ''
      let title = ''
      if(this.tabValue=='evaluation'){
        url = this.$api.evaluate.exportEvaluate
        title = '考评表'
      }else if(this.tabValue=='employeeMutualEvaluation'){
        url = this.$api.evaluate.exportEvaluate
        title = '考评表'
      }else if(this.tabValue=='leaderRate'){
        url = this.$api.evaluate.exportEvaluateLeader
        title = '组长评分表'
      }else if(this.tabValue=='supervisorRate'){
        url = this.$api.evaluate.exportEvaluateCompetent
        title = '主管评分表'
      }
      let entity = {...this.entity}
      this.outLoading = true
      this.$axios.post(url,{
        ...entity
      },{responseType: "blob"}).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 scoped>
.personnel-evaluation {
  height: 100%;
  overflow-y: auto;
}
.title {
  height: 60px;
  line-height: 60px;
}
.search {
        background-color: #fff;
        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: #fff;
        width: calc(100% - 40px);
        height: calc(100% - 60px - 80px - 10px - 42px);
        padding: 20px;
    }
</style>