Ver código fonte

feat: 优化发票详情获取逻辑,支持多个发票号的处理

xieyong 5 dias atrás
pai
commit
51d97831bf

+ 3 - 2
src/views/financialManage/invoiceManage/components/addOrEditDialogNew.vue

@@ -1133,8 +1133,9 @@
       },
       //获取详情
       async getInfo(id) {
-        this.form = await invoiceApplyInfoV2API(id);
-        this.form.relatedList = [this.form.relatedVO];
+        this.form = (await invoiceApplyInfoV2API(id)) || {};
+        //来源清单没有数据时给空数组,避免表格因空行报错
+        this.form.relatedList = this.form.relatedVO ? [this.form.relatedVO] : [];
         this.form.type = Number(this.form.type);
         if(this.form.ifRedReversalInvoice){
           // 冲红发票标记:1 是 / 0 否。仅在 1 时禁止编辑金额相关字段

+ 3 - 2
src/views/financialManage/invoiceManage/components/detailDialog.vue

@@ -436,8 +436,9 @@
       },
       //获取详情
       async getInfo(id) {
-        this.form = await invoiceApplyInfoV2API(id);
-        this.form.relatedList = [this.form.relatedVO];
+        this.form = (await invoiceApplyInfoV2API(id)) || {};
+        //来源清单没有数据时给空数组,避免表格因空行报错
+        this.form.relatedList = this.form.relatedVO ? [this.form.relatedVO] : [];
         // this.$refs.tableInfoRef.setValue(this.form);
         this.$nextTick(() => {
           // this.$refs.tableInfoNewRef && this.$refs.tableInfoNewRef.putValue(this.form);

+ 26 - 9
src/views/financialManage/paidManagement/index.vue

@@ -73,13 +73,16 @@
           </template>
           <!-- 开票信息 -->
           <template v-slot:invoiceCode="{ row }">
-            <el-link
-              type="primary"
-              :underline="false"
-              @click="handleInvoiceDetail(row, 'view')"
-            >
-              {{ row.invoiceCode }}
-            </el-link>
+            <div v-for="(code, index) in splitInvoiceCodes(row.invoiceCode)" :key="`code-${index}`">
+              <span v-if="index > 0">,</span>
+              <el-link
+                type="primary"
+                :underline="false"
+                @click="handleInvoiceDetail(row, code, 'view')"
+              >
+                {{ code }}
+              </el-link>
+            </div>
           </template>
         </ele-pro-table>
       </div>
@@ -483,11 +486,25 @@
           this.$refs.detailDialogRef.init(row.id);
         });
       },
-      handleInvoiceDetail(row = {}, type) {
+      splitInvoiceCodes(invoiceCode) {
+        if (!invoiceCode) {
+          return [];
+        }
+        return String(invoiceCode)
+          .split(',')
+          .map((item) => item.trim())
+          .filter(Boolean);
+      },
+      handleInvoiceDetail(row = {}, invoiceCode, type) {
+        const code = row.invoiceInfoList ? row.invoiceInfoList[invoiceCode] : row.invoiceId;
+        if (!code) {
+          this.$message.warning(`未找到发票${invoiceCode}的详情`);
+          return;
+        }
         this.invoiceDetailDialogFlag = true;
         this.$nextTick(() => {
           let params = {
-            id: row.invoiceId
+            id: code
           };
           this.$refs.invoiceDetailDialogRef.init(params, type);
         });

+ 26 - 9
src/views/financialManage/payableManage/index.vue

@@ -73,13 +73,16 @@
           </template>
           <!-- 开票信息 -->
           <template v-slot:invoiceCode="{ row }">
-            <el-link
-              type="primary"
-              :underline="false"
-              @click="handleInvoiceDetail(row, 'view')"
-            >
-              {{ row.invoiceCode }}
-            </el-link>
+            <div v-for="(code, index) in splitInvoiceCodes(row.invoiceCode)" :key="`code-${index}`">
+              <span v-if="index > 0">,</span>
+              <el-link
+                type="primary"
+                :underline="false"
+                @click="handleInvoiceDetail(row, code, 'view')"
+              >
+                {{ code }}
+              </el-link>
+            </div>
           </template>
         </ele-pro-table>
       </div>
@@ -482,11 +485,25 @@
           this.$refs.detailDialogRef.init(row.id, type);
         });
       },
-      handleInvoiceDetail(row = {}, type) {
+      splitInvoiceCodes(invoiceCode) {
+        if (!invoiceCode) {
+          return [];
+        }
+        return String(invoiceCode)
+          .split(',')
+          .map((item) => item.trim())
+          .filter(Boolean);
+      },
+      handleInvoiceDetail(row = {}, invoiceCode, type) {
+        const code = row.invoiceInfoList ? row.invoiceInfoList[invoiceCode] : row.invoiceId;
+        if (!code) {
+          this.$message.warning(`未找到发票${invoiceCode}的详情`);
+          return;
+        }
         this.invoiceDetailDialogFlag = true;
         this.$nextTick(() => {
           let params = {
-            id: row.invoiceId
+            id: code
           };
           this.$refs.invoiceDetailDialogRef.init(params, type);
         });

+ 27 - 9
src/views/financialManage/receivableManage/index.vue

@@ -84,13 +84,16 @@
           </template>
           <!-- 开票信息 -->
           <template v-slot:invoiceCode="{ row }">
-            <el-link
-              type="primary"
-              :underline="false"
-              @click="handleInvoiceDetail(row, 'view')"
-            >
-              {{ row.invoiceCode }}
-            </el-link>
+            <div v-for="(code, index) in splitInvoiceCodes(row.invoiceCode)" :key="`code-${index}`">
+              <span v-if="index > 0">,</span>
+              <el-link
+                type="primary"
+                :underline="false"
+                @click="handleInvoiceDetail(row, code, 'view')"
+              >
+                {{ code }}
+              </el-link>
+            </div>
           </template>
         </ele-pro-table>
       </div>
@@ -518,11 +521,26 @@
           this.$refs.detailDialogRef.init(row.id, type);
         });
       },
-      handleInvoiceDetail(row = {}, type) {
+      //发票号可能是多个,逗号分隔
+      splitInvoiceCodes(invoiceCode) {
+        if (!invoiceCode) {
+          return [];
+        }
+        return String(invoiceCode)
+          .split(',')
+          .map((item) => item.trim())
+          .filter(Boolean);
+      },
+      handleInvoiceDetail(row = {}, invoiceCode, type) {
+        const code = row.invoiceInfoList ? row.invoiceInfoList[invoiceCode] : row.invoiceId;
+        if (!code) {
+          this.$message.warning(`未找到发票${invoiceCode}的详情`);
+          return;
+        }
         this.invoiceDetailDialogFlag = true;
         this.$nextTick(() => {
           let params = {
-            id: row.invoiceId
+            id: code
           };
           this.$refs.invoiceDetailDialogRef.init(params, type);
         });

+ 27 - 9
src/views/financialManage/receivedManaged/index.vue

@@ -73,13 +73,16 @@
           </template>
           <!-- 开票信息 -->
           <template v-slot:invoiceCode="{ row }">
-            <el-link
-              type="primary"
-              :underline="false"
-              @click="handleInvoiceDetail(row, 'view')"
-            >
-              {{ row.invoiceCode }}
-            </el-link>
+            <div v-for="(code, index) in splitInvoiceCodes(row.invoiceCode)" :key="`code-${index}`">
+              <span v-if="index > 0">,</span>
+              <el-link
+                type="primary"
+                :underline="false"
+                @click="handleInvoiceDetail(row, code, 'view')"
+              >
+                {{ code }}
+              </el-link>
+            </div>
           </template>
         </ele-pro-table>
       </div>
@@ -497,11 +500,26 @@
           this.$refs.detailDialogRef.init(row.id);
         });
       },
-      handleInvoiceDetail(row = {}, type) {
+      //发票号可能是多个,逗号分隔
+      splitInvoiceCodes(invoiceCode) {
+        if (!invoiceCode) {
+          return [];
+        }
+        return String(invoiceCode)
+          .split(',')
+          .map((item) => item.trim())
+          .filter(Boolean);
+      },
+      handleInvoiceDetail(row = {}, invoiceCode, type) {
+        const code = row.invoiceInfoList ? row.invoiceInfoList[invoiceCode] : row.invoiceId;
+        if (!code) {
+          this.$message.warning(`未找到发票${invoiceCode}的详情`);
+          return;
+        }
         this.invoiceDetailDialogFlag = true;
         this.$nextTick(() => {
           let params = {
-            id: row.invoiceId
+            id: code
           };
           this.$refs.invoiceDetailDialogRef.init(params, type);
         });