Bladeren bron

feat: 添加对账池发起对账成功后的跳转功能,支持直接打开指定对账单的修改弹窗

xieyong 1 week geleden
bovenliggende
commit
c86de09e35

+ 8 - 0
src/views/purchasingManage/purchaseOrder/accountstatement/index.vue

@@ -406,6 +406,14 @@
           this.$refs.accountDialogRef.open(type, row, '2');
         });
       },
+      /**
+       * 对账池发起对账成功后跳转过来时用:直接打开指定对账单的修改弹窗。
+       * 编辑弹窗只用 row.id 去拉详情,不需要列表整行数据。
+       */
+      openEditById(id) {
+        if (!id) return;
+        this.handleAddOrEditAccount('edit', { id });
+      },
       accountstatementSubmit(res) {
         this.processSubmitDialogFlag = true;
         this.$nextTick(() => {

+ 14 - 0
src/views/purchasingManage/purchaseOrder/index.vue

@@ -256,6 +256,7 @@
         </div>
         <div v-if="activeComp == 'accountstatement'">
           <accountstatement
+            ref="accountStatementRef"
             @getToDoReminder="getToDoReminder"
           ></accountstatement>
         </div>
@@ -264,6 +265,7 @@
           <account-pool
             :sourceType="2"
             @getToDoReminder="getToDoReminder"
+            @goto-statement-edit="handleGotoStatementEdit"
           ></account-pool>
         </div>
         <div v-if="activeComp == 'adjustmentNote'">
@@ -738,6 +740,18 @@
       clearInterval(this.timeR);
     },
     methods: {
+      /**
+       * 对账池发起对账成功后跳转【对账单-修改】:
+       * 先切到「对账单」页签,再让对账单列表打开该单的修改弹窗。
+       * 对账单这里用的是 v-if(没有 keep-alive),切页签会重建组件,必须等 DOM 更新后再取 ref 调用
+       */
+      handleGotoStatementEdit(row) {
+        this.activeComp = 'accountstatement';
+        this.$nextTick(() => {
+          this.$refs.accountStatementRef &&
+            this.$refs.accountStatementRef.openEditById(row.id);
+        });
+      },
       getSummaries(param) {
         return getSummaries(
           param,

+ 30 - 1
src/views/saleManage/saleOrder/accountPool/index.vue

@@ -644,8 +644,9 @@
         } else {
           this.batchSubmitting = true;
         }
+        let statementId = null;
         try {
-          const statementId = await createStatementByPoolIds(
+          statementId = await createStatementByPoolIds(
             list.map((r) => r.id)
           );
           this.$message.success(
@@ -661,6 +662,34 @@
           this.submittingId = '';
           this.batchSubmitting = false;
         }
+        // 放在 finally 之后发起询问:按钮 loading 立即恢复,不被弹窗挡住。
+        // statementId 为空说明提交失败,已经提示过错误,不再追问
+        if (statementId) {
+          this.confirmGotoStatementEdit(statementId);
+        }
+      },
+      /**
+       * 发起对账成功后询问是否前往【对账单-修改】。
+       *
+       * 对账单不是独立路由页面,而是销售订单 / 采购订单页里的一个页签,
+       * 本组件同样只是页签之一,所以这里不自己改路由,只把对账单 id 抛给宿主页,
+       * 由宿主页切到对账单页签后调用其 openEditById(id) 打开修改弹窗。
+       */
+      async confirmGotoStatementEdit(statementId) {
+        try {
+          await this.$confirm(
+            `是否前往对账单 ${statementId} 的信息修改页面?`,
+            '提示',
+            {
+              confirmButtonText: '是',
+              cancelButtonText: '否',
+              type: 'info'
+            }
+          );
+        } catch (e) {
+          return; // 用户选择「否」
+        }
+        this.$emit('goto-statement-edit', { id: statementId });
       },
       /** 行操作「发起对账」:按当前这一条发起 */
       handleReconOne(row) {

+ 8 - 0
src/views/saleManage/saleOrder/accountstatement/index.vue

@@ -456,6 +456,14 @@
           this.$refs.accountDialogRef.open(type, row, '1');
         });
       },
+      /**
+       * 对账池发起对账成功后跳转过来时用:直接打开指定对账单的修改弹窗。
+       * 编辑弹窗只用 row.id 去拉详情(见 addAccountDialog.open),不需要列表整行数据。
+       */
+      openEditById(id) {
+        if (!id) return;
+        this.handleAddOrEditAccount('update', { id });
+      },
       //导出
       async handleExport(row) {
         let data = await accountStatementExportAPI(row.id);

+ 13 - 0
src/views/saleManage/saleOrder/index.vue

@@ -351,7 +351,9 @@
           <component
             v-if="currentTabComponent"
             :is="currentTabComponent"
+            ref="tabComp"
             @getToDoReminder="getToDoReminder"
+            @goto-statement-edit="handleGotoStatementEdit"
           ></component>
         </keep-alive>
       </div>
@@ -1099,6 +1101,17 @@ export default {
     }
   },
   methods: {
+    /**
+     * 对账池发起对账成功后跳转【对账单-修改】:
+     * 先切到「对账单」页签,再让对账单列表打开该单的修改弹窗。
+     * 动态组件包在 keep-alive 里,切页签只是换实例(不重建),所以必须等 DOM 更新后再取 ref 调用
+     */
+    handleGotoStatementEdit(row) {
+      this.activeComp = 'accountstatement';
+      this.$nextTick(() => {
+        this.$refs.tabComp && this.$refs.tabComp.openEditById(row.id);
+      });
+    },
     handleStockUnlock() {
       console.log('库存解锁', this.selection);