资料关闭修改

This commit is contained in:
2026-10-10 13:07:10 +08:00
parent a188aae60d
commit a27168bbb0
+50 -66
View File
@@ -52,8 +52,10 @@ const currentRowIndex = ref<number>(-1);
const previewFile = ref<any>(null); const previewFile = ref<any>(null);
// 预览文件弹框 // 预览文件弹框
const previewModal = ref<boolean>(false); const previewModal = ref<boolean>(false);
// 成员列表
const memberList = ref<any[]>([]); const memberList = ref<any[]>([]);
// 模板
const currentTemplate = ref<any[]>([]);
// 审批流程抽屉 // 审批流程抽屉
const approvalDrawer = ref<boolean>(false); const approvalDrawer = ref<boolean>(false);
const flowList = ref<any[]>([]); const flowList = ref<any[]>([]);
@@ -74,17 +76,8 @@ const SPECIALTIES = [
{ label: '安全', value: '安全' }, { label: '安全', value: '安全' },
{ label: '质量', value: '质量' } { label: '质量', value: '质量' }
]; ];
// 变更关闭资料归档列表
const list = ref<any>([ const list = ref<any>([]);
{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 back = () => { const back = () => {
@@ -101,22 +94,20 @@ const onUploadFile = async (type:string = '',files:any,index:number = -1) => {
if(type==='3' || type==='4' || type==='5'){ if(type==='3' || type==='4' || type==='5'){
formData.append('step', type); formData.append('step', type);
}else{ }else{
formData.append('close_doc_id', currentId.value.toString()); formData.append('close_doc_id', list.value[index]?.id?.toString());
} }
loading.value = true; loading.value = true;
const {data,error} = await uploadFileApi(currentId.value, formData); const {data,error} = await uploadFileApi(currentId.value, formData);
if(!error){ if(!error){
// 是否是本地上传
data.isLocalUpload = true;
window.$message?.success('上传成功'); window.$message?.success('上传成功');
if(type==='3'){ if(type==='3'){
trainFiles.value=[data]; trainFiles.value.push(data);
}else if(type==='4'){ }else if(type==='4'){
pssrFiles.value=[data]; pssrFiles.value.push(data);
}else if(type==='5'){ }else if(type==='5'){
acceptFiles.value=[data]; acceptFiles.value.push(data);
}else{ }else{
list.value[index].files.push(data); list.value[index].attachments.push(data);
list.value[index].status = 1; list.value[index].status = 1;
} }
} }
@@ -128,10 +119,10 @@ const downloadFile = (file:any,type:string) => {
if(file){ if(file){
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name); downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
}else{ }else{
window.$message?.info('还差接口') window.$message?.info('还差接口,空白模板')
} }
} }
// 删除文件(真删) // 删除文件
const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => { const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => {
let id = 0; let id = 0;
if(type==='3'){ if(type==='3'){
@@ -141,7 +132,7 @@ const removeFileReal = async (type:string, fileIndex:number,index:number = -1) =
}else if(type==='5'){ }else if(type==='5'){
id = acceptFiles.value[fileIndex].id; id = acceptFiles.value[fileIndex].id;
}else{ }else{
id = list.value[index]?.files[fileIndex]?.id; id = list.value[index]?.attachments[fileIndex]?.id;
} }
loading.value = true; loading.value = true;
const {error} = await deleteFileApi(currentId.value,id); 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'){ }else if(type==='5'){
acceptFiles.value.splice(fileIndex, 1); acceptFiles.value.splice(fileIndex, 1);
}else{ }else{
list.value[index]?.files.splice(fileIndex, 1); list.value[index]?.attachments.splice(fileIndex, 1);
if(list.value[index]?.files.length === 0){ if(list.value[index]?.attachments.length === 0){
list.value[index].status = 2; list.value[index].status = 2;
} }
} }
@@ -162,18 +153,6 @@ const removeFileReal = async (type:string, fileIndex:number,index:number = -1) =
} }
loading.value = false; 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) => { const preview = (file:any) => {
previewFile.value = file; previewFile.value = file;
@@ -191,12 +170,12 @@ const chooseFiles = () => {
const ids = new Set(checkedFiles.value); const ids = new Set(checkedFiles.value);
const result = fileList.value.filter((item:any) => ids.has(item.id)); 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去重 // 按id去重
const uniqueList = [ const uniqueList = [
...new Map(files.map((item:any) => [item.id, item])).values(), ...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){ if(uniqueList.length > 0){
list.value[currentRowIndex.value].status = 1; list.value[currentRowIndex.value].status = 1;
} }
@@ -247,6 +226,15 @@ const getDetail = async () => {
const {data,error} = await getChangeDetailApi(currentId.value) const {data,error} = await getChangeDetailApi(currentId.value)
if(!error){ if(!error){
currentInfo.value = data; 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; loading.value = false;
}; };
@@ -378,18 +366,20 @@ const finishApprover = async () => {
// 获取所有模板 // 获取所有模板
const getTemplateList = async () => { const getTemplateList = async () => {
const {data,error} = await templateListApi(); loading.value = true;
if(!error){ const {data,error} = await templateListApi();
const result = data.filter((item:any) => item.type === 3); if(!error){
// ******审批模板******** const result = data.filter((item:any) => item.type === 3);
flowList.value = result[0]?.steps || []; // ******审批模板********
} currentTemplate.value = result[0]?.steps || [];
}
loading.value = false;
} }
onMounted(() => { onMounted(async () => {
getTemplateList();
getAllMembers();
useDate.value = new Date().getTime(); useDate.value = new Date().getTime();
getAllMembers();
await getTemplateList();
if(route.query){ if(route.query){
if(route.query.key){ if(route.query.key){
backKey.value = route.query.key.toString(); backKey.value = route.query.key.toString();
@@ -464,15 +454,13 @@ onMounted(() => {
</NButton> </NButton>
<NUpload <NUpload
class="w-auto" class="w-auto"
:key="trainFiles.length?'train_'+trainFiles[0]?.id:'train'" :key="trainFiles.length?'train_'+trainFiles.length+1:'train'"
accept="image/*,.pdf,.docx,.xlsx,.pptx" accept="image/*,.pdf,.docx,.xlsx,.pptx"
:default-upload="false" :default-upload="false"
:show-file-list="false" :show-file-list="false"
@change="(files) => onUploadFile('3', files)" @change="(files) => onUploadFile('3', files)"
> >
<NButton type="primary" size="small" class="text-xs" :disabled="loading"> <NButton type="primary" size="small" class="text-xs" :disabled="loading">上传</NButton>
{{trainFiles.length?'重新上传':'上传'}}
</NButton>
</NUpload> </NUpload>
</div> </div>
<div class="border rounded-lg py-3 px-4 flex items-center gap-3"> <div class="border rounded-lg py-3 px-4 flex items-center gap-3">
@@ -497,7 +485,7 @@ onMounted(() => {
positive-text="确定" positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }" :positiveButtonProps="{ size: 'tiny' }"
:negativeButtonProps="{ size: 'tiny' }" :negativeButtonProps="{ size: 'tiny' }"
@positive-click="pssrFiles.splice(fileIndex, 1)" @positive-click="removeFileReal('4', Number(fileIndex))"
> >
<template #trigger> <template #trigger>
<NButton text type="error" class="text-11px">删除</NButton> <NButton text type="error" class="text-11px">删除</NButton>
@@ -513,15 +501,13 @@ onMounted(() => {
</NButton> </NButton>
<NUpload <NUpload
class="w-auto" class="w-auto"
:key="pssrFiles.length?'pssr_'+pssrFiles[0]?.id:'pssr'" :key="pssrFiles.length?'pssr_'+pssrFiles.length+1:'pssr'"
accept="image/*,.pdf,.docx,.xlsx,.pptx" accept="image/*,.pdf,.docx,.xlsx,.pptx"
:default-upload="false" :default-upload="false"
:show-file-list="false" :show-file-list="false"
@change="(files) => onUploadFile('4', files)" @change="(files) => onUploadFile('4', files)"
> >
<NButton type="primary" size="small" class="text-xs" :disabled="loading"> <NButton type="primary" size="small" class="text-xs" :disabled="loading">上传</NButton>
{{pssrFiles.length?'重新上传':'上传'}}
</NButton>
</NUpload> </NUpload>
</div> </div>
</div> </div>
@@ -569,7 +555,7 @@ onMounted(() => {
positive-text="确定" positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }" :positiveButtonProps="{ size: 'tiny' }"
:negativeButtonProps="{ size: 'tiny' }" :negativeButtonProps="{ size: 'tiny' }"
@positive-click="acceptFiles.splice(fileIndex, 1)" @positive-click="removeFileReal('5', Number(fileIndex))"
> >
<template #trigger> <template #trigger>
<NButton text type="error" class="text-11px">删除</NButton> <NButton text type="error" class="text-11px">删除</NButton>
@@ -585,15 +571,13 @@ onMounted(() => {
</NButton> </NButton>
<NUpload <NUpload
class="w-auto" class="w-auto"
:key="acceptFiles.length?'accept_'+acceptFiles[0]?.id:'accept'" :key="acceptFiles.length?'accept_'+acceptFiles.length+1:'accept'"
accept="image/*,.pdf,.docx,.xlsx,.pptx" accept="image/*,.pdf,.docx,.xlsx,.pptx"
:default-upload="false" :default-upload="false"
:show-file-list="false" :show-file-list="false"
@change="(files) => onUploadFile('5', files)" @change="(files) => onUploadFile('5', files)"
> >
<NButton type="primary" size="small" class="text-xs" :disabled="loading"> <NButton type="primary" size="small" class="text-xs" :disabled="loading">上传</NButton>
{{acceptFiles.length?'重新上传':'上传'}}
</NButton>
</NUpload> </NUpload>
</div> </div>
<div class="border rounded-lg py-3 px-4 flex flex-col gap-2"> <div class="border rounded-lg py-3 px-4 flex flex-col gap-2">
@@ -635,10 +619,10 @@ onMounted(() => {
<tbody> <tbody>
<tr v-for="(item, index) in list" :key="index"> <tr v-for="(item, index) in list" :key="index">
<td> <td>
<p>{{item.name}}</p> <p>{{item.doc_name}}</p>
<div v-if="item.files.length" class="flex flex-wrap gap-2"> <div v-if="item.attachments.length" class="flex flex-wrap gap-2">
<div <div
v-for="(file, fileIndex) in item.files" v-for="(file, fileIndex) in item.attachments"
:key="fileIndex" :key="fileIndex"
class="text-11px flex items-center gap-2 border py-0.5 px-1.5 rounded-md text-[#17407F] border-[#ACC6E5] bg-[#EAF0F9]" class="text-11px flex items-center gap-2 border py-0.5 px-1.5 rounded-md text-[#17407F] border-[#ACC6E5] bg-[#EAF0F9]"
> >
@@ -650,7 +634,7 @@ onMounted(() => {
positive-text="确定" positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }" :positiveButtonProps="{ size: 'tiny' }"
:negativeButtonProps="{ size: 'tiny' }" :negativeButtonProps="{ size: 'tiny' }"
@positive-click="removeFile(Number(index), Number(fileIndex))" @positive-click="removeFileReal(item.doc_name, Number(fileIndex), Number(index))"
> >
<template #trigger> <template #trigger>
<NButton text type="error" class="text-11px">删除</NButton> <NButton text type="error" class="text-11px">删除</NButton>
@@ -675,7 +659,7 @@ onMounted(() => {
accept="image/*,.pdf,.docx,.xlsx,.pptx" accept="image/*,.pdf,.docx,.xlsx,.pptx"
:default-upload="false" :default-upload="false"
:show-file-list="false" :show-file-list="false"
@change="(files) => onUploadFile(item.name, files, Number(index))" @change="(files) => onUploadFile(item.doc_name, files, Number(index))"
> >
<NButton type="primary" size="small" ghost class="text-xs" :disabled="loading"> <NButton type="primary" size="small" ghost class="text-xs" :disabled="loading">
本地上传 本地上传