马宇豪
2024-12-03 1da948c1c8808077f10e3aa32fafd30939ee5c12
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
<template>
    <div class="notice">
        <el-dialog
            v-model="dialogVisible"
            :title="title"
            width="75%"
            @close="closeEvaluate"
        >
          <el-table :data="tableData" border style="width: 100%">
            <el-table-column type="index" width="55" align="center" />
            <el-table-column label="姓名" align="center" prop="name" />
            <el-table-column label="性别" align="center" prop="sex">
              <template #default="scope">
                {{scope.row.sex == 0?'男':scope.row.sex == 1?'女':'未知'}}
              </template>
            </el-table-column>
            <el-table-column label="身份证号" align="center" prop="idCard" />
            <el-table-column label="等级" align="center" prop="ratingLevel">
              <template #default="scope">
                {{scope.row.ratingLevel == 1?'一级':scope.row.ratingLevel == 2?'二级':scope.row.ratingLevel == 3?'三级':'暂无'}}
              </template>
            </el-table-column>
            <el-table-column label="专业领域" align="center" prop="domain"/>
            <el-table-column label="选用方式" align="center" prop="selectionMode">
              <template #default="scope">
                {{scope.row.selectionMode == 1?'固定':scope.row.selectionMode == 2?'随机':'其他'}}
              </template>
            </el-table-column>
            <el-table-column label="是否为组长" align="center" prop="teamLeader">
              <template #default="scope">
                {{scope.row.teamLeader == 0?'否':scope.row.teamLeader == 1?'是':'未知'}}
              </template>
            </el-table-column>
            <el-table-column label="评估状态" align="center" prop="evaluationState">
              <template #default="scope">
                <el-tag :type="scope.row.evaluationState == 0?'info':scope.row.evaluationState==1?'success':''">
                  {{scope.row.evaluationState ==0?'未评估':scope.row.evaluationState==1?'已评估':'--'}}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="考评总分" align="center" prop="score" />
            <el-table-column v-if="title == '专家评估'" label="操作" align="center" class-name="small-padding fixed-width">
              <template #default="scope">
                <el-button v-if="scope.row.evaluationState ==0" type="primary" link @click="openEvaluate('add',scope.row)">考评与报销</el-button>
                <el-button v-if="scope.row.evaluationState ==1" type="primary" link @click="openEvaluate('view',scope.row)">查看</el-button>
                <el-button v-if="scope.row.evaluationState ==1" type="success" link @click="downloadFile(scope.row)">导出考评表</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination
              v-show="total > 0"
              :total="total"
              v-model:page="queryParams.pageNum"
              v-model:limit="queryParams.pageSize"
              @pagination="getEvaluationList"
          />
            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" @click="closeEvaluate" size="default" v-preReClick>确认</el-button>
              </span>
            </template>
          <evaluate ref="evaluateRef" @getList="getEvaluationList()"></evaluate>
        </el-dialog>
    </div>
</template>
<script setup>
import {reactive, ref, toRefs} from 'vue'
import {ElMessage} from "element-plus";
import Evaluate from "./evaluate";
import {
  getExpertEvaDetail,
  getProjectExpertEvaluationList,
} from "@/api/backManage/evaluate";
import {generateWordDocument} from "@/views/safetyReview/projectManage/components/exportWord";
const dialogVisible = ref(false);
const evaluateRef = ref()
const emit = defineEmits(["getList"]);
const state = reactive({
  tableData: [],
  total: null,
  queryParams: {
    id: null,
    pageNum: 1,
    pageSize: 10
  },
  projectName: '',
  deptName: '',
  projectCheckTime: '',
  title: '',
  rateList: [
    {label: '优秀',value: 1},
    {label: '合格',value: 2},
    {label: '基本合格',value: 3},
    {label: '不合格',value: 4}
  ]
})
const {tableData,total,queryParams,projectName,title,projectCheckTime} = toRefs(state)
const openDialog = async (type,value) => {
  if(type == 'view'){
    state.title = '专家列表'
  }else{
    state.title = '专家评估'
  }
  state.queryParams.id = value.id
  state.projectName = value.projectName
  state.deptName = value.deptName
  state.projectCheckTime = value.projectCheckTime
  await getEvaluationList()
  dialogVisible.value = true;
}
 
const getEvaluationList = async () => {
  const res = await getProjectExpertEvaluationList(state.queryParams)
  if(res.code == 200){
    state.tableData = res.rows
    state.total = res.total
  }else{
    ElMessage.warning(res.msg)
  }
}
 
 
const downloadFile = async (val) => {
  const res = await getExpertEvaDetail({projectExpertId: val.id});
  if(res.code == 200){
    let outData = res.data
    outData.deptName = state.deptName
    outData.name = val.name
    outData.sex = val.sex == 0?'男':'女'
    outData.domain = val.domain
    outData.professionalEthics = state.rateList.find(i=>i.value == res.data.professionalEthics)?.label
    outData.impartialHonest = state.rateList.find(i=>i.value == res.data.impartialHonest)?.label
    outData.comprehensiveCoordination = state.rateList.find(i=>i.value == res.data.comprehensiveCoordination)?.label
    outData.professionalAbility = state.rateList.find(i=>i.value == res.data.professionalAbility)?.label
    outData.expressingOpinions = state.rateList.find(i=>i.value == res.data.expressingOpinions)?.label
    outData.comprehensiveEvaluation = state.rateList.find(i=>i.value == res.data.comprehensiveEvaluation)?.label
    try {
      generateWordDocument('/evaluateFile.docx',outData, outData.name + '专家考评表.docx');
    } catch (error){
      ElMessage({
        type: 'warning',
        message: '导出失败'
      });
    }
  }else{
    ElMessage.warning(res.msg)
  }
  // data.companyName = data.companyName != '' ? data.companyName: '-'
  // data.projectCheckTime = data.projectCheckTime != '' ? data.projectCheckTime: '-'
  // data.tableData = state.dataList.map(item => {
  //   return {
  //     ...item,
  //     ratingLevel: item.ratingLevel == 1 ? '一级' : item.ratingLevel == 2 ? '二级':item.ratingLevel == 3 ? '三级' : '',
  //     sex: item.sex == 0 ? '男' : '女',
  //     selectionMode: item.selectionMode == 1 ? '固定' : '随机',
  //     teamLeader: item.teamLeader == 1 ? '是' : '否',
  //   }
  // })
 
};
 
const openEvaluate = (type,value)=>{
  evaluateRef.value.openDialog(type,value,state.projectName,state.projectCheckTime)
}
 
const closeEvaluate = ()=>{
  dialogVisible.value = false
  emit('getList')
}
 
defineExpose({
  openDialog
})
</script>
 
<style scoped lang="scss">
.notice{
    :deep(.el-form .el-form-item__label) {
        font-size: 15px;
    }
    .file {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
}
</style>