diff --git a/src/views/details/closeDoc/index.vue b/src/views/details/closeDoc/index.vue index 932610b..b823bc0 100644 --- a/src/views/details/closeDoc/index.vue +++ b/src/views/details/closeDoc/index.vue @@ -52,8 +52,10 @@ const currentRowIndex = ref(-1); const previewFile = ref(null); // 预览文件弹框 const previewModal = ref(false); - +// 成员列表 const memberList = ref([]); +// 模板 +const currentTemplate = ref([]); // 审批流程抽屉 const approvalDrawer = ref(false); const flowList = ref([]); @@ -74,17 +76,8 @@ const SPECIALTIES = [ { label: '安全', value: '安全' }, { label: '质量', value: '质量' } ]; - -const list = ref([ - {id:1,status:null,name:'变更申请表及审批记录',files:[]}, - {id:2,status:null,name:'风险分析记录(风险预分析 / HAZOP / FMEA / 风险检查表)',files:[]}, - {id:3,status:null,name:'培训签到与考核记录',files:[]}, - {id:4,status:null,name:'PSSR 检查记录(含现场照片)',files:[]}, - {id:5,status:null,name:'验收报告与运行数据',files:[]}, - {id:6,status:null,name:'更新后的 P&ID / 操作规程(受控最新版)',files:[]}, - {id:7,status:null,name:'设备 / 联锁台账更新记录',files:[]}, - {id:8,status:null,name:'应急预案修订',files:[]}, -]); +// 变更关闭资料归档列表 +const list = ref([]); // 返回 const back = () => { @@ -101,22 +94,20 @@ const onUploadFile = async (type:string = '',files:any,index:number = -1) => { if(type==='3' || type==='4' || type==='5'){ formData.append('step', type); }else{ - formData.append('close_doc_id', currentId.value.toString()); + formData.append('close_doc_id', list.value[index]?.id?.toString()); } loading.value = true; const {data,error} = await uploadFileApi(currentId.value, formData); if(!error){ - // 是否是本地上传 - data.isLocalUpload = true; window.$message?.success('上传成功'); if(type==='3'){ - trainFiles.value=[data]; + trainFiles.value.push(data); }else if(type==='4'){ - pssrFiles.value=[data]; + pssrFiles.value.push(data); }else if(type==='5'){ - acceptFiles.value=[data]; + acceptFiles.value.push(data); }else{ - list.value[index].files.push(data); + list.value[index].attachments.push(data); list.value[index].status = 1; } } @@ -128,10 +119,10 @@ const downloadFile = (file:any,type:string) => { if(file){ downloadFileFun(file?.file_url, file?.doc_name || file?.file_name); }else{ - window.$message?.info('还差接口') + window.$message?.info('还差接口,空白模板') } } -// 删除文件(真删) +// 删除文件 const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => { let id = 0; if(type==='3'){ @@ -141,7 +132,7 @@ const removeFileReal = async (type:string, fileIndex:number,index:number = -1) = }else if(type==='5'){ id = acceptFiles.value[fileIndex].id; }else{ - id = list.value[index]?.files[fileIndex]?.id; + id = list.value[index]?.attachments[fileIndex]?.id; } loading.value = true; const {error} = await deleteFileApi(currentId.value,id); @@ -153,8 +144,8 @@ const removeFileReal = async (type:string, fileIndex:number,index:number = -1) = }else if(type==='5'){ acceptFiles.value.splice(fileIndex, 1); }else{ - list.value[index]?.files.splice(fileIndex, 1); - if(list.value[index]?.files.length === 0){ + list.value[index]?.attachments.splice(fileIndex, 1); + if(list.value[index]?.attachments.length === 0){ list.value[index].status = 2; } } @@ -162,18 +153,6 @@ const removeFileReal = async (type:string, fileIndex:number,index:number = -1) = } loading.value = false; } -// 删除文件(假删) -const removeFile = (index:number, fileIndex:number) => { - // 判断是否是本地上传 - if(list.value[index]?.files[fileIndex]?.isLocalUpload){ - removeFileReal(list.value[index]?.name, fileIndex, index); - }else{ - list.value[index]?.files.splice(fileIndex, 1); - if(list.value[index]?.files.length === 0){ - list.value[index].status = 2; - } - } -} // 打开预览 const preview = (file:any) => { previewFile.value = file; @@ -191,12 +170,12 @@ const chooseFiles = () => { const ids = new Set(checkedFiles.value); const result = fileList.value.filter((item:any) => ids.has(item.id)); // 合并文件列表 - let files = list.value[currentRowIndex.value]?.files.concat(result); + let files = list.value[currentRowIndex.value]?.attachments.concat(result); // 按id去重 const uniqueList = [ ...new Map(files.map((item:any) => [item.id, item])).values(), ]; - list.value[currentRowIndex.value].files = uniqueList; + list.value[currentRowIndex.value].attachments = uniqueList; if(uniqueList.length > 0){ list.value[currentRowIndex.value].status = 1; } @@ -247,6 +226,15 @@ const getDetail = async () => { const {data,error} = await getChangeDetailApi(currentId.value) if(!error){ currentInfo.value = data; + list.value = data.close_docs || []; + trainFiles.value = data?.train?.attachments || []; + pssrFiles.value = data?.pssr?.attachments || []; + acceptFiles.value = data?.accept_form?.attachments || []; + if(data?.close_approval_flow && data?.close_approval_flow?.steps?.length){ + flowList.value = data?.close_approval_flow?.steps; + }else{ + flowList.value = currentTemplate.value; + } } loading.value = false; }; @@ -378,18 +366,20 @@ const finishApprover = async () => { // 获取所有模板 const getTemplateList = async () => { - const {data,error} = await templateListApi(); - if(!error){ - const result = data.filter((item:any) => item.type === 3); - // ******审批模板******** - flowList.value = result[0]?.steps || []; - } + loading.value = true; + const {data,error} = await templateListApi(); + if(!error){ + const result = data.filter((item:any) => item.type === 3); + // ******审批模板******** + currentTemplate.value = result[0]?.steps || []; + } + loading.value = false; } -onMounted(() => { - getTemplateList(); - getAllMembers(); +onMounted(async () => { useDate.value = new Date().getTime(); + getAllMembers(); + await getTemplateList(); if(route.query){ if(route.query.key){ backKey.value = route.query.key.toString(); @@ -464,15 +454,13 @@ onMounted(() => { - - {{trainFiles.length?'重新上传':'上传'}} - + 上传
@@ -497,7 +485,7 @@ onMounted(() => { positive-text="确定" :positiveButtonProps="{ size: 'tiny' }" :negativeButtonProps="{ size: 'tiny' }" - @positive-click="pssrFiles.splice(fileIndex, 1)" + @positive-click="removeFileReal('4', Number(fileIndex))" >