From 9f3a102f55f8d2b270cfd018af154021ef92fc95 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期二, 12 五月 2026 22:44:29 +0800
Subject: [PATCH] yxh

---
 src/views/project/travelexpenseapply/travelexpensedetail/index.vue |   86 +++++++++++++++++++++++++++++++-----------
 1 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/src/views/project/travelexpenseapply/travelexpensedetail/index.vue b/src/views/project/travelexpenseapply/travelexpensedetail/index.vue
index 347d718..6ba39af 100644
--- a/src/views/project/travelexpenseapply/travelexpensedetail/index.vue
+++ b/src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -1906,13 +1906,27 @@
         const index = this.getIndexInArray(this.fileListto, row);
         this.fileListto.splice(index, 1);
         console.log(this.rbDetails[this.atpresent].annexfilesList);
-        indexvalue = this.rbDetails[this.atpresent].annexfilesList.find(
-          (item, index) => {
-            return item.name == row.name;
-          }
-        );
-        console.log(indexvalue, "鍒犻櫎绱㈠紩");
-        this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1);
+        // indexvalue = this.rbDetails[this.atpresent].annexfilesList.find(
+        //   (item, index) => {
+        //     return item.name == row.name;
+        //   }
+        // );
+        // console.log(indexvalue, "鍒犻櫎绱㈠紩");
+        // this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1);
+        const targetIndex = this.rbDetails[
+          this.atpresent
+        ].annexfilesList.findIndex(item => {
+          return item.name === row.name; // 寤鸿浣跨敤涓ユ牸鐩哥瓑 ===
+        });
+        console.log(targetIndex, "鍒犻櫎绱㈠紩"); // 鐜板湪鎵撳嵃鐨勬槸绱㈠紩鍙凤紝渚嬪 0, 1, 2...
+
+        if (targetIndex > -1) {
+          // 纭繚鎵惧埌浜嗗厓绱�
+          this.rbDetails[this.atpresent].annexfilesList.splice(targetIndex, 1);
+          console.log("鍒犻櫎鎴愬姛");
+        } else {
+          console.log("鏈壘鍒板搴旈」鐩紝鏃犳硶鍒犻櫎");
+        }
       } else {
         const indexlist = this.getIndexInArray(
           this.invoicepdfimgsrcList,
@@ -1922,13 +1936,23 @@
         const index = this.getIndexInArray(this.invoicefileListto, row);
         this.invoicefileListto.splice(index, 1);
         console.log(this.rbDetails[this.atpresent].invoicefilesList);
-        indexvalue = this.rbDetails[this.atpresent].invoicefilesList.find(
-          (item, index) => {
-            return item.name == row.name;
-          }
-        );
-        console.log(indexvalue, "鍒犻櫎绱㈠紩");
-        this.rbDetails[this.atpresent].invoicefilesList.splice(indexvalue, 1);
+        const targetIndex = this.rbDetails[
+          this.atpresent
+        ].invoicefilesList.findIndex(item => {
+          return item.name === row.name; // 寤鸿浣跨敤涓ユ牸鐩哥瓑 ===
+        });
+        console.log(targetIndex, "鍒犻櫎绱㈠紩"); // 鐜板湪鎵撳嵃鐨勬槸绱㈠紩鍙凤紝渚嬪 0, 1, 2...
+
+        if (targetIndex > -1) {
+          // 纭繚鎵惧埌浜嗗厓绱�
+          this.rbDetails[this.atpresent].invoicefilesList.splice(
+            targetIndex,
+            1
+          );
+          console.log("鍒犻櫎鎴愬姛");
+        } else {
+          console.log("鏈壘鍒板搴旈」鐩紝鏃犳硶鍒犻櫎");
+        }
       }
     },
     // 鐐瑰嚮涓婄Щ
@@ -2625,21 +2649,37 @@
       this.$refs["form"].validate(valid => {
         if (valid) {
           //绁ㄦ嵁鏂囦欢澶勭悊
-          const addnumber = new Decimal(this.rbPayees.reduce(
-            (amount, item) => amount + Number(item.amount),
-            0
-          ));
-          console.log(this.form.amountrequested,addnumber);
-          //鏍¢獙璇锋閲戦鍚堣鏄惁绛変簬鎶ラ攢鍗曢噾棰�
-          if (this.form.amountrequested != addnumber) {
+          // const addnumber = new Decimal(this.rbPayees.reduce((amount, item) => amount + Number(item.amount), 0 ));  
+          // console.log(this.form.amountrequested,addnumber);
+          // //鏍¢獙璇锋閲戦鍚堣鏄惁绛変簬鎶ラ攢鍗曢噾棰�
+          // if (this.form.amountrequested != addnumber) {
+          //   this.$message({
+          //     message:
+          //       "鎶ラ攢璇锋琛ㄤ腑鍚堣閲戦涓嶇瓑浜庢姤閿�鍗曠殑鎶ラ攢閲戦锛岃鏇存鍚庡啀淇濆瓨锛侊紒",
+          //     type: "warning"
+          //   });
+          //   return;
+          // }
+          
+          // 1. 鍦� reduce 绱姞鏃讹紝鐩存帴浼犲叆瀛楃涓茬粰 Decimal锛屽苟浣跨敤 .plus() 鏂规硶杩涜绱姞
+          // 鍒濆鍊艰涓� new Decimal(0)锛岀‘淇濆叏绋嬮珮绮惧害杩愮畻
+          const addnumber = this.rbPayees.reduce((amount, item) => {
+            return amount.plus(new Decimal(item.amount.toString())); 
+          }, new Decimal(0));
+
+          console.log(this.form.amountrequested, addnumber.toString());
+
+          // 2. 浣跨敤 Decimal 鐨� .eq() 鏂规硶杩涜涓ユ牸鐩哥瓑姣旇緝
+          // 杩欐牱鏃㈣В鍐充簡绮惧害闂锛屼篃瑙e喅浜嗙被鍨嬭浆鎹㈡瘮杈冪殑闂
+          if (!addnumber.eq(this.form.amountrequested)) {
             this.$message({
-              message:
-                "鎶ラ攢璇锋琛ㄤ腑鍚堣閲戦涓嶇瓑浜庢姤閿�鍗曠殑鎶ラ攢閲戦锛岃鏇存鍚庡啀淇濆瓨锛侊紒",
+              message: "鎶ラ攢璇锋琛ㄤ腑鍚堣閲戦涓嶇瓑浜庢姤閿�鍗曠殑鎶ラ攢閲戦锛岃鏇存鍚庡啀淇濆瓨锛侊紒",
               type: "warning"
             });
             return;
           }
 
+
           const rbDetails = [...this.rbDetails];
           const rbPayees = [...this.rbPayees];
           //淇濆瓨鍓嶆牎楠屾暟鎹�

--
Gitblit v1.9.3