瀏覽代碼

Import Excel

wfg 1 月之前
父節點
當前提交
1de8d15b9a
共有 1 個文件被更改,包括 56 次插入24 次删除
  1. 56 24
      src/views/iosBasicData/SeafreightExportF/bills/billsDetails.vue

+ 56 - 24
src/views/iosBasicData/SeafreightExportF/bills/billsDetails.vue

@@ -26,7 +26,7 @@
                     </el-button>
                     <el-dropdown-menu slot="dropdown">
                         <el-dropdown-item v-for="item in imporiData" :key="item.id"
-                            @click.native="importData(item.id)">{{
+                            @click.native="importData(item)">{{
                                 item.name }}
                         </el-dropdown-item>
                     </el-dropdown-menu>
@@ -769,7 +769,13 @@ export default {
                     value: 'cyCnName',
                 },
             ],
-            imporiData: [{ id: 0, name: '导入 ONE 模板' }, { id: 1, name: '导入 PIL 订舱模板' }, { id: 2, name: '导入截单格式' }, { id: 3, name: '导入海信提单' }],
+            imporiData: [
+                { id: 0, name: '导入 ONE 模板', key: 'ONE', showCoverDlg: true, document: 'importOne' },
+                { id: 1, name: '导入 PIL 订舱模板', key: 'PIL-BOOKING', showCoverDlg: true, document: 'importPilBooking' },
+                { id: 2, name: '导入截单格式', key: 'PIL-CUTDOC', showCoverDlg: true, document: 'importPilCutOffOrders' },
+                { id: 3, name: '导入海信提单', key: 'HISENSE-BILL', showCoverDlg: false, document: 'importHisenseBill' }
+            ],
+            currentImportDataRow: null,
             excelForm: {},
             excelLoading: false,
             excelOption: {
@@ -970,16 +976,16 @@ export default {
         },
         //文档导入
         importData(row) {
-            if (row == 0) {
-                this.excelOption.column[0].action = `/api/blade-los/templateImport/importOne?billId=${this.form.id}`
-            } else if (row == 1) {
-                this.excelOption.column[0].action = `/api/blade-los/templateImport/importPilBooking?billId=${this.form.id}`
-            } else if (row == 2) {
-                this.excelOption.column[0].action = `/api/blade-los/templateImport/importPilCutOffOrders?billId=${this.form.id}`
-            } else if (row == 3) {
-                this.excelOption.column[0].action = `/api/blade-los/templateImport/importHisenseBill?billId=${this.form.id}`
-            }
+            if(!row) return
+
+            this.excelOption.column[0].action = `/api/blade-los/templateImport/${row.document}?billId=${this.form.id}`
+            // this.excelOption.column[0].action = `/api/blade-los/templateImport/${row.document}?billId=${this.form.id}`
+            // this.excelOption.column[0].action = `/api/blade-los/templateImport/${row.document}?billId=${this.form.id}`
+            // this.excelOption.column[0].action = `/api/blade-los/templateImport/${row.document}?billId=${this.form.id}`
+
+            this.currentImportDataRow = row
             this.excelBox = true
+            console.log('excelLoading', this.excelLoading)
         },
         uploadBefore(file, done, loading) {
             done();
@@ -996,11 +1002,41 @@ export default {
         // 上传成功
         onSuccess(res, done, loading, column) {
             if (Object.keys(res).length) {
-                this.$confirm('此操作将覆盖数据, 是否继续?', '提示', {
-                    confirmButtonText: '确定',
-                    cancelButtonText: '取消',
-                    type: 'warning'
-                }).then(() => {
+                if(this.currentImportDataRow.showCoverDlg===true) {
+                    this.$confirm('此操作将覆盖数据, 是否继续?', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                    }).then(() => {
+                        // this.form = res;
+                        Object.keys(res).forEach(key => {
+                            if (res[key]) {
+                                if (key != 'detail') {
+                                    // this.form[key] = res[key]
+                                    this.$set(this.form, key, res[key])
+                                }
+                                if (key == 'detail') {
+                                    Object.keys(res.detail).forEach(key => {
+                                        if (res.detail[key]) {
+                                            // this.form.detail[key] = res.detail[key]
+                                            this.$set(this.form.detail, key, res.detail[key])
+                                        }
+                                    });
+                                }
+
+                            }
+                        });
+                        this.excelBox = false;
+                        this.$message.success("导入成功!");
+                        loading = false;
+                        done();
+                    }).catch(() => {
+                        this.excelBox = false;
+                        loading = false;
+                        done();
+                    });
+                }else{
+                    console.log('onSuccess 1')
                     // this.form = res;
                     Object.keys(res).forEach(key => {
                         if (res[key]) {
@@ -1016,18 +1052,14 @@ export default {
                                     }
                                 });
                             }
-
                         }
-                    });
-                    this.excelBox = false;
-                    this.$message.success("导入成功!");
+                    })
                     loading = false;
                     done();
-                }).catch(() => {
                     this.excelBox = false;
-                    loading = false;
-                    done();
-                });
+                    this.$message.success("导入成功!");
+                    console.log('onSuccess 2')
+                }
             } else {
                 loading = false;
                 done();