| | |
| | | |
| | | <template> |
| | | <div>项目审批</div> |
| | | <div class="approval"> |
| | | <el-form :model="state.dataForm" ref="dataForm" :inline="true" style="margin-top: 10px" label-width="130px" > |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="项目名称:"> |
| | | <span>{{state.dataForm.projectName}}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="被检查/对接单位:"> |
| | | <span>{{state.dataForm.companyName ? state.dataForm.companyName: '--'}}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="计划实行时间:"> |
| | | <span>{{state.dataForm.projectDateStart}}—{{state.dataForm.projectDateEnd}}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="项目地点:"> |
| | | <span>{{state.dataForm.projectAddress}}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="项目概况:"> |
| | | <span>{{state.dataForm.remark}}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <el-table v-loading="state.loading" row-key="id" :data="state.dataList" :border="true" ref="tableRef" style="width: 100%;"> |
| | | <el-table-column label="姓名" prop="name" align="center" /> |
| | | <el-table-column label="性别" prop="sex" align="center" > |
| | | <template #default="scope"> |
| | | {{scope.row.sex === 0 ? '男' : '女' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="身份证号" prop="idCard" align="center" /> |
| | | <el-table-column label="等级" prop="ratingLevel" align="center" > |
| | | <template #default="scope"> |
| | | <span>{{scope.row.ratingLevel == 1 ?'一级':scope.row.ratingLevel == 2?'二级':scope.row.ratingLevel == 3 ?'三级':''}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="专业领域" prop="domain" align="center" /> |
| | | <el-table-column label="选用方式" prop="selectionMode" align="center" > |
| | | <template #default="scope"> |
| | | {{scope.row.selectionMode === 1 ? '固定' : '随机' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="是否为组长" prop="teamLeader" align="center" > |
| | | <template #default="scope"> |
| | | <span v-if="scope.row.teamLeader === 1" style="color: red">是</span> |
| | | <span v-else>否</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="180"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" :disabled="state.dataForm.state == 2" v-if="scope.row.teamLeader === 1" @click="scope.row.teamLeader = 0">取消组长</el-button> |
| | | <el-button link type="primary" :disabled="state.dataForm.state == 2" v-else @click="scope.row.teamLeader = 1">设为组长</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | width="600px" |
| | | > |
| | | <div> |
| | | <div style="display: flex;align-items: center"> |
| | | <span style="font-size: 18px;font-weight: 600">审批填报:</span> |
| | | <div style="display: flex;align-items: flex-end;margin-top: 15px"> |
| | | <img :src="wordSvg" style="width: 30px;height: 35px" /> |
| | | <el-button style="width: 110px;margin-left: 10px" type="primary" @click="startGeneration">下载审批单word</el-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="margin-top: 30px"> |
| | | <div style="display: flex"> |
| | | <span style="font-size: 18px;font-weight: 600">审批记录附件:</span> |
| | | <el-upload :disabled="projectType==='view' || isView" accept=".pdf" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='1' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)"> |
| | | <el-button type="primary">上传附件PDF</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">上传文件尺寸小于5M,最多可上传1份</div> |
| | | </template> |
| | | </el-upload> |
| | | </div> |
| | | </div> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="success" v-if="!isView" @click="nextStatus">线下审批通过并进行下一步</el-button> |
| | | <el-button type="warning" v-if="!isView" style="margin-left: 40px;" @click="back">线下审批不通过返回上一步</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | const emit = defineEmits(["getNextStatus"]); |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import wordSvg from '@/assets/images/word.svg' |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import {getToken} from "@/utils/auth"; |
| | | import axios from "axios"; |
| | | import {generateWordDocument} from "@/views/safetyReview/projectManage/components/exportWord"; |
| | | import {addProject, checkProject, choose, getCheckInfo, getFileInfo, getProjectList} from "@/api/projectManage"; |
| | | const emit = defineEmits(["getNextStatus","backStatus"]); |
| | | const prop = defineProps(['projectId']) |
| | | const tableRef = ref() |
| | | const dialogVisible = ref(false); |
| | | const state = reactive({ |
| | | dataForm: { |
| | | deptName: '', |
| | | projectName: '', |
| | | companyName: '', |
| | | projectDateStart: '', |
| | | projectDateEnd: '', |
| | | projectAddress: '', |
| | | remark: '', |
| | | projectCheckTime: '', |
| | | state: '' |
| | | }, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 20, |
| | | }, |
| | | loading: false, |
| | | dataList: [], |
| | | total: 0, |
| | | uploadUrl: import.meta.env.VITE_APP_BASE_API + '/common/upload', |
| | | header: { |
| | | Authorization: getToken() |
| | | }, |
| | | fileList: [], |
| | | projectId: null |
| | | }); |
| | | const projectType = ref('') |
| | | onMounted(async () => { |
| | | if(prop.projectId){ |
| | | state.projectId = prop.projectId |
| | | await getList() |
| | | |
| | | } |
| | | |
| | | }) |
| | | const isView = ref(false) |
| | | |
| | | const riskOpen = async (type,val) => { |
| | | state.fileList = [] |
| | | console.log("type",type,val) |
| | | //保存按钮 |
| | | if(type === 'add'){ |
| | | //成功后自动到下一步 项目id |
| | | emit('getNextStatus', 3); |
| | | |
| | | }else if(type === 'clickEdit'){ |
| | | //变更按钮 |
| | | |
| | | }else if(type === 'detail'){ |
| | | console.log("view333333",type,val) |
| | | //生成审批按钮 |
| | | if(type === 'confirmApproval'){ |
| | | isView.value = false |
| | | if(state.dataForm.state == 2){ |
| | | dialogVisible.value = true |
| | | }else { |
| | | const data = { |
| | | id: state.projectId, |
| | | step: 3, |
| | | saveData: state.dataList |
| | | } |
| | | const res = await choose(data); |
| | | if(res.code == 200){ |
| | | dialogVisible.value = true |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | }else if(type === 'viewWord'){ |
| | | //查看审批单 |
| | | isView.value = true |
| | | await getFile() |
| | | dialogVisible.value = true |
| | | }else if(type === 'detail' || type === 'view'){ |
| | | if(type === 'view'){ |
| | | projectType.value = type |
| | | } |
| | | await getFile() |
| | | } |
| | | } |
| | | |
| | | const nextStatus = async () =>{ |
| | | if(state.fileList && state.fileList.length ===0){ |
| | | state.fileList = [] |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '请上传审批记录附件' |
| | | }) |
| | | return; |
| | | } |
| | | const param = { |
| | | id: state.projectId, |
| | | projectFile: state.fileList, |
| | | state: 3 |
| | | } |
| | | const res = await checkProject(param); |
| | | if(res.code == 200){ |
| | | ElMessage.success('审批通过') |
| | | emit('getNextStatus', state.projectId); |
| | | dialogVisible.value = false |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | |
| | | } |
| | | const back = async () => { |
| | | const param = { |
| | | id: state.projectId, |
| | | projectFile: state.fileList, |
| | | state: 1 |
| | | } |
| | | const res = await checkProject(param); |
| | | if(res.code == 200){ |
| | | ElMessage.warning('审批不通过') |
| | | emit('backStatus', state.projectId); |
| | | dialogVisible.value = false |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const getList = async () => { |
| | | state.loading = true; |
| | | const param = { |
| | | id:state.projectId |
| | | } |
| | | const res = await getCheckInfo(param); |
| | | if(res.code == 200){ |
| | | state.dataList = res.data.projectExpertCheckResp.map(item => { |
| | | return { |
| | | ...item, |
| | | teamLeader: item.teamLeader ? item.teamLeader : 0 |
| | | } |
| | | }) |
| | | if(res.data) { |
| | | const val = res.data |
| | | for(let i in state.dataForm) { |
| | | if (validKey(i, val)) { |
| | | state.dataForm[i] = val[i] |
| | | } |
| | | } |
| | | state.dataForm.projectCheckTime = res.data.projectCheckTime ?res.data.projectCheckTime : '' |
| | | } |
| | | state.loading = false; |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | const validKey=(key,obj)=>{ |
| | | return key in obj |
| | | } |
| | | const handleAvatarSuccess = async (res, uploadFile) => { |
| | | if(res.code == 200){ |
| | | |
| | | state.fileList = state.fileList.map(item => { |
| | | return { |
| | | name: item.name, |
| | | filePath: item.response.url, |
| | | fileName:item.response.fileName, |
| | | projectId: state.projectId, |
| | | module: 1 |
| | | } |
| | | }) |
| | | }else{ |
| | | state.fileList = [] |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.message |
| | | }) |
| | | } |
| | | } |
| | | const getFile = async () =>{ |
| | | const param = { |
| | | projectId: state.projectId, |
| | | module: 1 |
| | | } |
| | | const res = await getFileInfo(param); |
| | | if(res.code == 200){ |
| | | state.fileList = res.data.map(item => { |
| | | return { |
| | | ...item, |
| | | name: item.originalFileName |
| | | } |
| | | }) |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | |
| | | const showTip =()=>{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '超出文件上传数量' |
| | | }); |
| | | } |
| | | |
| | | const picSize = async (rawFile) => { |
| | | if(rawFile.size / 1024 / 1024 > 5){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件大小不能超过5M' |
| | | }); |
| | | return false |
| | | } |
| | | }; |
| | | |
| | | const handlePictureCardPreview = (uploadFile) => { |
| | | axios.get(uploadFile.filePath,{headers:{'Content-Type': 'application/json','Authorization': `${getToken()}`},responseType: 'blob'}).then(res=>{ |
| | | if (res) { |
| | | const link = document.createElement('a') |
| | | let blob = new Blob([res.data],{type: res.data.type}) |
| | | link.style.display = "none"; |
| | | link.href = URL.createObjectURL(blob); // 创建URL |
| | | window.open(link.href) |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件读取失败' |
| | | }); |
| | | } |
| | | }) |
| | | }; |
| | | |
| | | const handleRemove = async (file, uploadFile) => { |
| | | } |
| | | |
| | | const templatePath = '/example.docx'; |
| | | const startGeneration = async () => { |
| | | const data = state.dataForm |
| | | 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 ? '是' : '否', |
| | | } |
| | | }) |
| | | try { |
| | | generateWordDocument(templatePath, data); |
| | | } catch (error){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '失败' |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | defineExpose({ |
| | | riskOpen |
| | |
| | | |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | .approval{ |
| | | .pag-container{ |
| | | float: right; |
| | | margin-top: 10px; |
| | | } |
| | | :deep(.el-dialog__footer) { |
| | | display: flex; |
| | | justify-content: center; |
| | | } |
| | | } |
| | | </style> |