From a886764374c7ee326bd632110fc6f518c5343e52 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期一, 18 十一月 2024 09:00:57 +0800 Subject: [PATCH] 项目管理 --- src/views/safetyReview/projectManage/components/projectArchive.vue | 142 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 138 insertions(+), 4 deletions(-) diff --git a/src/views/safetyReview/projectManage/components/projectArchive.vue b/src/views/safetyReview/projectManage/components/projectArchive.vue index 5d5a3e6..04c1d1f 100644 --- a/src/views/safetyReview/projectManage/components/projectArchive.vue +++ b/src/views/safetyReview/projectManage/components/projectArchive.vue @@ -1,10 +1,55 @@ - <template> - <div>项目归档</div> + <div class="archive"> + <el-form style="display: flex;flex-direction: column" :model="state.dataForm" ref="dataForm" :inline="true" :rules="state.rules" label-width="130px" > + <el-form-item prop="deptName" label="结束日期:"> + <el-date-picker + v-model="state.dataForm.endTime" + type="date" + placeholder="请选择结束日期" + /> + </el-form-item> + <el-form-item prop="deptName" label="总结描述:"> + <el-input + type="textarea" + :rows="8" + v-model.trim="state.dataForm.summarize" + size="large" + placeholder="请输入总结描述" + > + </el-input> + </el-form-item> + <el-form-item label="附件上传:"> + <el-upload :disabled="projectType==='view'" 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,5)"> + <el-button type="primary">上传附件PDF</el-button> + <template #tip> + <div class="el-upload__tip">上传文件尺寸小于5M,最多可上传1份</div> + </template> + </el-upload> + </el-form-item> + </el-form> + </div> </template> <script setup> +import {reactive, ref} from "vue"; +import {getToken} from "@/utils/auth"; +import {ElMessage, ElMessageBox} from "element-plus"; +import axios from "axios"; + const emit = defineEmits(["getNextStatus"]); +const projectType = ref('') +const state = reactive({ + dataForm: { + endTime: '', + summarize:'' + }, + rules: {}, + uploadUrl: import.meta.env.VITE_APP_BASE_API + '', + header: { + Authorization: getToken() + }, + fileList: [] +}); const riskOpen = async (type,val) => { console.log("type",type,val) //完结按钮 @@ -12,10 +57,97 @@ //成功后自动到下一步 项目id emit('getNextStatus', 4); - }else if(type === 'detail'){ - console.log("view4444441",type,val) + }else if(type === 'detail' || type === 'view'){ + if(type === 'view'){ + projectType.value = type + } + console.log("view333333",type,val) } } + +const handleAvatarSuccess = (res, uploadFile) => { + if(res.code == 200){ + state.fileList = res.data.map(i=>{ + return { + name: i.originName, + url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, + id: i.id, + projectId: i.projectId, + } + }) + }else{ + state.fileList = [] + ElMessage({ + type: 'warning', + message: 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.url,{headers:{'Content-Type': 'application/json','Authorization': `${getToken()}`,'uid':`${Cookies.get('uid')}`},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) => { + if(file && file.status == 'success') { + ElMessageBox.confirm( + '确定删除该附件?', + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(async () => { + state.fileList = [] + // const res = await delFile(file.id) + // if (res.code == 200) { + // ElMessage({ + // type: 'success', + // message: '文件已删除' + // }) + // } else { + // ElMessage({ + // type: 'warning', + // message: res.message + // }) + // } + }) + .catch(() => { + }) + } +} + defineExpose({ riskOpen @@ -24,5 +156,7 @@ <style scoped lang="scss"> +.archive{ +} </style> -- Gitblit v1.9.2