Преглед изворни кода

试验自检附件上传更改

duy пре 2 година
родитељ
комит
635fb2afbe

+ 9 - 0
src/api/modules/tentative/detect/test.js

@@ -17,6 +17,15 @@ export default {
             params: form
         }, msg);
     },
+    //试验自检记录附件删除接口:
+    async removedocuments(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-business/detection/self/remove-ancillary-documents',
+            method: 'post',
+            params: form
+        }, msg);
+    },
+ 
     //自检记录批量复制
     async copyData(form, msg = true) {
         return httpApi({

+ 4 - 2
src/views/tentative/detect/components/HcDragUpload.vue

@@ -1,7 +1,7 @@
 <template>
     <el-upload class="hc-upload-border" drag :action="action" :headers="getTokenHeader()" :data="uploadData" :accept="accept" :file-list="fileListData"  :disabled="uploadDisabled"
                :on-preview="uploadPreview"  :on-success="uploadSuccess" :on-exceed="uploadExceed" :on-error="uploadError" :before-upload="beforeUpload" :on-change="onChangeToolFile"
-               :on-progress="uploadprogress"   ref="upload">
+               :on-progress="uploadprogress" :on-remove="uploadRemove"  ref="upload">
         <div class="hc-upload-loading" v-loading="uploadDisabled" :element-loading-text="loadingText">
             <HcIcon name="backup" ui="text-5xl mt-4"/>
             <div class="el-upload__text">拖动文件到这里 或 <em>点击这里选择文件</em> 并上传</div>
@@ -148,9 +148,11 @@ const delUploadData = async ({id}) => {
     }
 }
 
-const uploadRemove = () => {
+const uploadRemove = ({code, data}) => {
     if(fileListData.value.length <= 0) {
         emit('change', {type: 'del'})
+         emit('delFile', {type: 'del'})
+        
     }
 }
 </script>

+ 73 - 72
src/views/tentative/detect/test.vue

@@ -153,21 +153,19 @@
             </template>
             <div class="hc-switch-tab-content" v-loading="viewAttachmentLoading">
                 <div class="h-full w-full flex">
-                    <div class="pdf-file-list-box">
+                    <div class="pdf-file-list-box" v-if="viewAttachmentData.length>0">
                         <template v-for="item in viewAttachmentData" >
-                            <div class="file-item" :class="[item.isCheck ? 'cur' : '']"  @click="viewCurFile(item)">{{item.name||''}}</div>
+                            <div class="file-item" :class="[item.isCheck ? 'cur' : '']"  @click="viewCurFile(item)">{{item.fileName||''}}</div>
                         </template>
-                        <!-- <div class="file-item">文件名称2.pdf</div>
-                        <div class="file-item">文件名称3.pdf</div>
-                        <div class="file-item">文件名称4.pdf</div>
-                        <div class="file-item">文件名称5.pdf</div> -->
                     </div>
-                   <!-- <iframe width='80%' height='100%' frameborder='1' :src="attachmentPdfUrl" v-if="attachmentPdfUrl"/> -->
+                    <div class="pdf-file-list-box" v-else>
+                      <HcNoData></HcNoData>
+                    </div>
+                   <iframe width='80%' height='100%' frameborder='1' :src="attachmentPdfUrl" v-if="attachmentPdfUrl"/>
                     <div class="hc-no-table-form" >
                         <div class="table-form-no">
-                            <HcDragUpload  @progress="uploadprogress" @finished="uploadFinished" :datas="uploadData"  :fileList="fileListData" v-if="listuploadref==='1'"/>
-                             <HcDragUpload  @progress="uploadprogress" @finished="uploadFinished" :datas="uploadData"  :fileList="fileListData" v-if="listuploadref==='2'"/>
-                             <HcDragUpload  @progress="uploadprogress" @finished="uploadFinished" :datas="uploadData"  :fileList="fileListData" v-if="listuploadref==='3'"/>
+                            <HcDragUpload  @progress="uploadprogress" @finished="uploadFinished" :datas="uploadData"  :fileList="fileListData" @delFile="delFileData"/>
+                            
                         </div>
                     </div>
                 </div>
@@ -199,6 +197,7 @@ import {getDictionary} from "~api/other";
 import { eVisaTaskCheckApi} from "~api/other"
 import wbsApi from "~api/data-fill/wbs"
 import { Loading } from "element-plus/es/components/loading/src/service";
+import notableform from '~src/assets/view/notableform.svg';
 
 //变量
 const router = useRouter()
@@ -641,32 +640,41 @@ const viewAttachmentId = ref('')
 const viewAttachmentData = ref([])
 const viewAttachmentModalClick = async ({id}) => {
     viewAttachmentId.value=id
-    viewAttachmentLoading.value = true
-    const { error, code, data } = await dataApi.ancillaryDocumentsList({id: id})
-    //处理数据
-    viewAttachmentLoading.value = false
-    if (!error && code === 200) {
+    viewAttachmentModal.value = true
+    getAttachmentModalClick( viewAttachmentId.value, '1')
+
+}
+const getCaption =(obj)=> {
+    const index = obj.lastIndexOf("pdf")
+   
+    return index
+}
+
+//获取附件
+const getAttachmentModalClick = async (id,type) => {
+     viewAttachmentLoading.value = true
+   const { error, code, data } = await dataApi.ancillaryDocumentsList({id: id,type:type})
+   console.log(data,'data');
+   viewAttachmentLoading.value = false
+        if (!error && code === 200) {
         viewAttachmentData.value = getArrValue(data)
-        if ( viewAttachmentData.value.length<1) {
-             window.$message?.warning('该条记录不存在附件')
-        }else{
-             viewAttachmentModal.value = true
-             viewCurFile( viewAttachmentData.value[0])
-        }
+        curFileData.value=viewAttachmentData.value[0]
+        viewCurFile(curFileData.value)
        
     } else {
         viewAttachmentData.value = []
          
     }
+   
 }
-const refeshAttachmentModalClick = async (id) => {
-    const { error, code, data } = await dataApi.ancillaryDocumentsList({id: id})
+const refeshAttachmentModalClick = async (id,type) => {
+    const { error, code, data } = await dataApi.ancillaryDocumentsList({id: id,type:type})
     //处理数据
     viewAttachmentLoading.value = false
     if (!error && code === 200) {
         viewAttachmentData.value = getArrValue(data)
         if ( viewAttachmentData.value.length<1) {
-             window.$message?.warning('该条记录不存在附件')
+            //  window.$message?.warning('该条记录不存在附件')
         }else{
              viewCurFile( viewAttachmentData.value[0])
         }
@@ -679,17 +687,20 @@ const refeshAttachmentModalClick = async (id) => {
 const attachmentPdfUrl = ref('')
 const curFileData =ref ({})
 //类型tab数据和相关处理
-const tabTypeKey = ref('productionCertificate')
+const tabTypeKey = ref('1')
 const tabTypeTab = ref([
-    {key:'productionCertificate',  name: '生产合格证'},
-    {key:'qualityInspectionReport', name: '厂家质检报告'},
-    {key:'otherAccessories', name: '其他文件'},
+    {key:'1',  name: '生产合格证'},
+    {key:'2', name: '厂家质检报告'},
+    {key:'3', name: '其他文件'},
 ]);
 const tabTypeChange = (item) => {
+    console.log(1111111111);
     tabTypeKey.value = item?.key
-    viewCurFile(curFileData.value)
-     fileListData.value=[]
-    refeshAttachmentModalClick(viewAttachmentId.value)
+    getAttachmentModalClick( viewAttachmentId.value, item?.key)
+    fileListData.value =[]
+    
+     
+    refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
 }
 
 //关闭查看附件
@@ -713,34 +724,19 @@ const splitFileName=(str)=>{
 }
 //查看当前文件pdf
 const viewCurFile = (item) => {
-    curFileData.value=item
-    viewAttachmentData.value.forEach((ele)=>{
-        if (ele.name===item.name) {
-            ele.isCheck=true
-        }else{
-            ele.isCheck=false
-        }
-    })
-   
-    if(tabTypeKey.value=='productionCertificate'&&item.productionCertificate.length>0){
+    console.log(item,'item');
+    if(item){
+         curFileData.value=item 
         let arr=[]
-        arr.push({name:splitFileName(item.productionCertificateName),url:item.productionCertificate})
+        arr.push({name:item.fileName,url:item.url})
         fileListData.value =getArrValue(arr)
-        listuploadref.value='1'
-    }else if(tabTypeKey.value=='qualityInspectionReport'&&item.qualityInspectionReport.length>0){
-         let arr=[]
-         arr.push({name:splitFileName(item.qualityInspectionReportName),url:item.qualityInspectionReport})
-         fileListData.value =getArrValue(arr)
-         listuploadref.value='2'
-    }else if(tabTypeKey.value=='otherAccessories'&&item.otherAccessories.length>0){
-          let arr=[]
-        arr.push({name:splitFileName(item.otherAccessoriesName),url:item.otherAccessories})
-        console.log(arr,'arr');
-         fileListData.value =getArrValue(arr)
-         listuploadref.value='3'
-    }else{
-         attachmentPdfUrl.value=''
-    }      
+        viewAttachmentData.value.forEach((ele)=>{
+            ele.isCheck=false
+        })
+        item.isCheck=true
+        
+    }
+    
 }
 
 //上传进度
@@ -748,26 +744,31 @@ const uploadprogress = (res) => {
  console.log('进度');
 }
 
-const productionCertificatefile=ref('')
-const qualityInspectionReportfile=ref('')
-const otherAccessoriesfile=ref('')
 //上传完成
 const uploadFinished = async(res) => {
-    if(tabTypeKey.value=='productionCertificate'){
-        productionCertificatefile.value =res
-    } else if (tabTypeKey.value=='qualityInspectionReport') {
-        qualityInspectionReportfile.value=res
-    }else{
-        otherAccessoriesfile.value=res
-    }
- 
     const { error, code, data } = await dataApi.updateAncillaryDocument(
         {
-            id:curFileData.value.id,
-            productionCertificate:productionCertificatefile.value.link,
-            qualityInspectionReport:qualityInspectionReportfile.value.link,
-            otherAccessories:otherAccessoriesfile.value.link
+            selfId:viewAttachmentId.value,
+            url:res.link,
+            type: tabTypeKey.value,
+            
         })
+        console.log(data,'data');
+     if (!error && code === 200) {
+       refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
+    }
+}
+//上传文件delFileData
+const delFileData = async(res) => {
+    console.log('删除文件',curFileData.value);
+    const { error, code, data } = await dataApi.removedocuments(
+        {
+            id:curFileData.value.id, 
+    })
+    if (!error && code === 200) {
+      window.$message.success('删除成功')
+       refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
+    }
 }
 
 //样品信息数据