Переглянути джерело

成本分配表-附件上传

jbb 2 роки тому
батько
коміт
737586e258

+ 3 - 1
src/api/document/cost-allocation-total.js

@@ -45,4 +45,6 @@ const seachPlanNum = params => getAction('/cost/syCostAllocation/queryByPlanNum'
 //保存 到单证汇总列表
 const addHalfInfo = params => postAction('/cost/syCostAllocation/add', params)
 
-export { costList, costByPlanNum, itemCheck, cancelItemCheck, seachPlanNum,addHalfInfo }
+const deleteFileDetail= params => deleteAction('/cost/syCostAllocation/deleteFile', params)
+
+export { costList, costByPlanNum, itemCheck, cancelItemCheck, seachPlanNum,addHalfInfo,deleteFileDetail }

+ 47 - 4
src/views/reportForms/cost-allocation-table.vue

@@ -276,7 +276,11 @@
               </h4>
               </a-form-model-item>
             </a-col>
-            
+            <a-col :md="6" :sm="8" class="noprint">
+              <a-upload  productName="file" :showUploadList="true" :file-list="fileList" :headers="tokenHeader" :multiple="false"   :action="importExcelUrl"  @change="handleImportExcel"  :data="{code:this.detailsPlanNum.planNum,name:this.fileName}"  :beforeUpload="uploadFlie" :remove="removeFile">
+                <a-button type="primary" >附件上传</a-button>
+              </a-upload>
+            </a-col>
         </a-form-model>
       </div>
       </a-row>
@@ -376,7 +380,7 @@ import mainTableExpenseCNYModal from '@views/cost-allocation-total/modal/mainTab
 import mainTableExpenseUSDModal from '@views/cost-allocation-total/modal/mainTableExpenseUSDModal.vue'
 import accidentListModal from '@views/cost-allocation-total/modal/accidentListModal.vue' // 事故单
 
-import { seachPlanNum, addHalfInfo } from '@api/document/cost-allocation-total.js'
+import { seachPlanNum, addHalfInfo,deleteFileDetail } from '@api/document/cost-allocation-total.js'
 
 export default {
   name: 'CostAllocationTable', // 成本分配 (新增)
@@ -490,6 +494,11 @@ export default {
       billstatus: '', // 单据状态
       color1:0,
       color2:0,
+      fileList:[],
+      url: {
+        list: '/sys/user/list',
+        importExcelUrl: 'cost/syCostAllocation/addFile' ,// 导入
+      }
       // dateFormat: 'YYYY-MM-DD',
     }
   },
@@ -610,7 +619,37 @@ export default {
         })
       })
     },
-
+    uploadFlie(file) {
+      this.fileName = file.name
+      },
+      handleImportExcel(data){
+        if(data.fileList.length>this.fileList.length&&data.file.status=='uploading'){ 
+          var that =this
+          setTimeout(()=>{
+            that.onSearch(this.detailsPlanNum.planNum,'query')
+        },1000)
+          
+        }
+        
+        
+      },
+      removeFile(data){
+        deleteFileDetail({code:this.detailsPlanNum.planNum,name:data.name}).then(res => {
+            if (res.success) {
+              var cc=[]
+              this.fileList.map(item=>{
+                if(item.name !== data.name){
+                  cc.push(item)
+                }
+              })
+              this.fileList = cc
+              this.loading =false
+              this.$message.success('删除成功');
+            }else{
+              this.$message.error(res.message);
+            }
+          })
+      },
     //调整表头格式
     adjustingHeader(){
       this.detailsPlanNum.outdata = ( this.detailsPlanNum.outdata==''||!this.detailsPlanNum.outdata)?'':moment( this.detailsPlanNum.outdata).format('YYYY-MM-DD')
@@ -906,7 +945,11 @@ export default {
     bb() {},
     cc() {}
   },
-  computed: {},
+  computed: {
+    importExcelUrl: function() {
+        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
+    },
+  },
   mounted() {}
 }
 </script>