فهرست منبع

feat: payment record 在保存是上传原始表格文件作记录.

peter 1 سال پیش
والد
کامیت
cb9abcb9d5
2فایلهای تغییر یافته به همراه43 افزوده شده و 9 حذف شده
  1. 6 2
      src/pages/payment-record/components/upload.vue
  2. 37 7
      src/pages/payment-record/index.vue

+ 6 - 2
src/pages/payment-record/components/upload.vue

@@ -242,14 +242,18 @@ const stop = (e: any) => {
   e.preventDefault()
   e.stopPropagation()
 }
+const fileContainer = ref(null as any)
 const processExcel = (event: any) => {
   const files = event.target.files || event.dataTransfer.files
-  // console.log('files:', files)
+
   let str = ''
   let arr: IPoItem[] = []
   tableData.value = []
   try {
     for (let i = 0; i < files.length; i++) {
+      if (i === files.length - 1) {
+        fileContainer.value = files[i]
+      }
       if (
         ![
           'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
@@ -335,7 +339,7 @@ const next = (formEl: FormInstance | undefined) => {
           }
         }),
       }
-      emit('update-table-data', result)
+      emit('update-table-data', result, fileContainer.value)
       handleClose(false)
       // })
       // .finally(() => {

+ 37 - 7
src/pages/payment-record/index.vue

@@ -41,6 +41,9 @@
           >
             Save
           </el-button>
+          <!-- <el-button @click="uploadStatementFile">
+            uploadStatementFile
+          </el-button> -->
         </div>
         <div class="logo-area">
           <img
@@ -281,17 +284,23 @@ const downloadSample = function () {
 
 const tableData = ref([] as IPoItem[])
 const computedSum = computed(() => {
-  return utils.toFixed(tableData.value.reduce((total, current) => {
-    total = total + Number(current.total)
-    return total
-  }, 0), 1000)
+  return utils.toFixed(
+    tableData.value.reduce((total, current) => {
+      total = total + Number(current.total)
+      return total
+    }, 0),
+    1000,
+  )
 })
-const updateTableData = (p: { data: IPoItem[]; mode: string }) => {
+
+const fileContainer = ref(null as any)
+const updateTableData = (p: { data: IPoItem[]; mode: string }, file: any) => {
   if (p.mode === 'Append') {
     tableData.value = tableData.value.concat(p.data)
   } else {
     tableData.value = p.data
   }
+  fileContainer.value = file
 }
 
 const currentDisableFlag = computed(() => {
@@ -388,12 +397,34 @@ const createStatement = function () {
       statementID.value = response.data.result.data[0].details.id
 
       save()
+      uploadStatementFile()
     })
     .catch(() => {
       loading.value = false
     })
 }
-
+// 上传原文件保存副本. 业务要求.
+const uploadStatementFile = function () {
+  const fileForm = new FormData()
+  fileForm.append('id', statementID.value)
+  fileForm.append('file', fileContainer.value)
+  request
+    .post('/payment_request/uploadOriginalFile', fileForm, {
+      headers: {
+        'Content-Type': 'multipart/form-data',
+      },
+    })
+    .then((res: any) => {
+      if (res.data.code === 1) {
+        ElNotification({
+          duration: 0,
+          title: '上传原始表格成功',
+          type: 'success',
+          message: '上传原始表格成功',
+        })
+      }
+    })
+}
 const save = function () {
   const formData = tableData.value.map((i, index) => {
     const result: any = {
@@ -471,7 +502,6 @@ const send = (
           return
         }
         const res = response.data.result
-
         if (Array.isArray(res.data)) {
           const temp = res.data.map((i: any, index: number) => {
             return {