From 0e10e10157b90002b99996914eaf1e5574924ddf Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期一, 12 十月 2026 11:15:50 +0800
Subject: [PATCH] 修改了报销校验

---
 src/views/project/travelexpenseapply/index.vue |  362 +++++++++++++++++++++------------------------------
 1 files changed, 151 insertions(+), 211 deletions(-)

diff --git a/src/views/project/travelexpenseapply/index.vue b/src/views/project/travelexpenseapply/index.vue
index 8e19f52..a821dfb 100644
--- a/src/views/project/travelexpenseapply/index.vue
+++ b/src/views/project/travelexpenseapply/index.vue
@@ -142,8 +142,8 @@
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
         <el-row><el-col :span="5">
             <el-form-item label="鐢宠鏃ユ湡" prop="applyTime">
-              <el-date-picker style="width: 100%" v-model="form.applyTime" type="date"
-                value-format="yyyy-MM-dd HH:mm:ss" placeholder="鐢宠鏃ユ湡">
+              <el-date-picker style="width: 100%" v-model="form.applyTime" type="date" format="yyyy-MM-dd"
+                value-format="yyyy-MM-dd" placeholder="鐢宠鏃ユ湡">
               </el-date-picker>
             </el-form-item>
           </el-col>
@@ -351,8 +351,8 @@
                       );
                     }
                   }
-                }" clearable size="small" style="width: 100%" v-model="scope.row.starttime" type="date"
-                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="寮�濮嬫棩鏈�" @blur="getdays(scope.row)">
+                }" clearable size="small" style="width: 100%" v-model="scope.row.starttime" type="date" format="yyyy-MM-dd"
+                  value-format="yyyy-MM-dd" placeholder="寮�濮嬫棩鏈�" @blur="getdays(scope.row)">
                 </el-date-picker>
               </template>
             </el-table-column>
@@ -367,8 +367,8 @@
                       );
                     }
                   }
-                }" clearable size="small" style="width: 100%" v-model="scope.row.endtime" type="date"
-                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="缁撴潫鏃ユ湡" @blur="getdays(scope.row)">
+                }" clearable size="small" style="width: 100%" v-model="scope.row.endtime" type="date" format="yyyy-MM-dd"
+                  value-format="yyyy-MM-dd" placeholder="缁撴潫鏃ユ湡" @blur="getdays(scope.row)">
                 </el-date-picker>
               </template>
             </el-table-column>
@@ -562,8 +562,8 @@
               </template> </el-table-column><el-table-column prop="paiddate" slot="" label="鎵撴鏃ユ湡" fixed align="center"
               width="150">
               <template slot-scope="scope">
-                <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.paiddate" type="date"
-                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="鎵撴鏃ユ湡" :disabled="true">
+                <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.paiddate" type="date" format="yyyy-MM-dd"
+                  value-format="yyyy-MM-dd" placeholder="鎵撴鏃ユ湡" :disabled="true">
                 </el-date-picker>
               </template>
             </el-table-column>
@@ -642,7 +642,7 @@
         </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm" v-if="dialogType == 'edit'">淇� 瀛�</el-button>
+        <el-button type="primary" :loading="saveLoading" @click="submitForm" v-if="dialogType == 'edit'">淇� 瀛�</el-button>
         <el-button @click="cancel">鍙� 娑�</el-button>
       </div>
     </el-dialog>
@@ -687,6 +687,7 @@
 import { addorupdateFund } from "@/api/project/fund";
 import { listReportname, listUser } from "@/api/project/organization";
 import { getToken } from "@/utils/auth";
+import { moneySum, moneyAdd } from "@/utils/money";
 export default {
   components: {
     Treeselect,
@@ -738,6 +739,8 @@
       loading: true,
       // 瀵煎嚭閬僵灞�
       exportLoading: false,
+      // 淇濆瓨鎸夐挳 loading锛岄槻姝㈤噸澶嶆彁浜�
+      saveLoading: false,
       // 閫変腑鏁扮粍
       ids: [],
       // 闈炲崟涓鐢�
@@ -1335,19 +1338,26 @@
 
       //鑾峰彇鎶ラ攢涓讳俊鎭�
       const id = row.id || this.ids;
-      getReimbursement(id).then(response => {
-        this.form = response.data;
-        this.fileList = this.form.annexfiles
-          ? this.form.annexfiles
-            .split(",")
-            .map(item => ({ url: item, name: item }))
-          : [];
-        this.form.recordstatus = response.data.recordstatus + "";
+      getReimbursement(id)
+        .then(async response => {
+          this.form = response.data;
+          this.fileList = this.form.annexfiles
+            ? this.form.annexfiles
+              .split(",")
+              .map(item => ({ url: item, name: item }))
+            : [];
+          this.form.recordstatus = response.data.recordstatus + "";
 
-        let ids = response.data.id;
-        //鑾峰彇鎶ラ攢鏄庣粏淇℃伅
-        getReimbursementdetaillist(ids).then(res => {
-          this.rbDetails = res.data;
+          const ids = response.data.id;
+          this.queryParamsPayee.rbid = ids;
+
+          //鏄庣粏涓庢墦娆句俊鎭簰涓嶄緷璧栵紝骞跺彂鑾峰彇锛屽噺灏戠瓑寰呮椂闂�
+          const [detailRes, payeeRes] = await Promise.all([
+            getReimbursementdetaillist(ids),
+            listReimbursementpayee(this.queryParamsPayee)
+          ]);
+
+          this.rbDetails = detailRes.data;
           if (this.rbDetails.length == 0) {
             this.addDetailRow(0);
           }
@@ -1366,17 +1376,15 @@
 
           //瀹炴椂鍚堣閲戦
           //this.sumTotalFee();
-        });
 
-        //鑾峰彇鎶ラ攢鎵撴淇℃伅
-        this.queryParamsPayee.rbid = ids;
-        listReimbursementpayee(this.queryParamsPayee).then(res => {
-          this.rbPayees = res.rows;
+          this.rbPayees = payeeRes.rows;
           if (this.rbPayees.length == 0) {
             this.addPayeeRow(0);
           }
+        })
+        .catch(() => {
+          this.$modal.msgError("鎶ラ攢鍗曚俊鎭姞杞藉け璐ワ紝璇烽噸璇曪紒");
         });
-      });
     },
 
     /** 鏌ョ湅鎸夐挳鎿嶄綔 */
@@ -1393,59 +1401,56 @@
       this.open = true;
       const id = row.id || this.ids;
 
-      getReimbursement(id).then(response => {
-        this.form = response.data;
-        //闄勪欢
-        this.fileList = this.form.annexfiles
-          ? this.form.annexfiles
-            .split(",")
-            .map(item => ({ url: item, name: item }))
-          : [];
+      getReimbursement(id)
+        .then(async response => {
+          this.form = response.data;
+          //闄勪欢
+          this.fileList = this.form.annexfiles
+            ? this.form.annexfiles
+              .split(",")
+              .map(item => ({ url: item, name: item }))
+            : [];
 
-        //瀹℃牳鐘舵��
-        this.form.recordstatus = response.data.recordstatus + "";
+          //瀹℃牳鐘舵��
+          this.form.recordstatus = response.data.recordstatus + "";
 
-        let ids = response.data.id;
-        let listFundflowparams = {
-          fundid: row.id,
-          fundtype: 1
-        };
-        listFundflow(listFundflowparams).then(res => {
-          this.fundflowList = res.rows;
-        });
+          const ids = response.data.id;
+          const listFundflowparams = {
+            fundid: row.id,
+            fundtype: 1
+          };
+          this.queryParamsPayee.rbid = ids;
 
-        //鎶ラ攢鏄庣粏
-        getReimbursementdetaillist(ids).then(res => {
-          this.rbDetails = res.data;
-          /*
-          for (let i = 0; i < this.rbDetails.length; i++) {
-            this.rbDetails[i].index = i;
-            this.rbDetails[i].searchAddress = {
-              sheng: this.rbDetails[i].travelprovincename,
-              shi: this.rbDetails[i].travelcityname,
-              qu: this.rbDetails[i].traveltownname,
-            };
-          }
-          */
-        });
+          //璧勯噾娴佹按銆佹姤閿�鏄庣粏銆佹墦娆句俊鎭簰涓嶄緷璧栵紝骞跺彂鑾峰彇
+          const [fundflowRes, detailRes, payeeRes] = await Promise.all([
+            listFundflow(listFundflowparams),
+            getReimbursementdetaillist(ids),
+            listReimbursementpayee(this.queryParamsPayee)
+          ]);
 
-        if (this.rbDetails.length > 0) this.sumTotalFee();
+          this.fundflowList = fundflowRes.rows;
+          this.rbDetails = detailRes.data;
 
-        //浠樻淇℃伅
-        this.queryParamsPayee.rbid = ids;
-        listReimbursementpayee(this.queryParamsPayee).then(res => {
-          this.rbPayees = res.rows;
+          //鏄庣粏鍔犺浇瀹屾垚鍚庡啀璁$畻鍚堣锛屼慨澶嶅師浠g爜鍦ㄦ槑缁嗚繑鍥炲墠灏� sumTotalFee 鐨勭珵鎬侀棶棰�
+          if (this.rbDetails.length > 0) this.sumTotalFee();
+
+          //浠樻淇℃伅
+          this.rbPayees = payeeRes.rows;
           if (this.rbPayees.length == 0) {
             this.addPayeeRow(0);
           }
+        })
+        .catch(() => {
+          this.$modal.msgError("鎶ラ攢鍗曚俊鎭姞杞藉け璐ワ紝璇烽噸璇曪紒");
         });
-      });
     },
 
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
+      //闃叉閲嶅鎻愪氦锛氫繚瀛樹腑鐩存帴蹇界暐鍐嶆鐐瑰嚮
+      if (this.saveLoading) return;
+      this.$refs["form"].validate(async valid => {
+        if (!valid) return;
           /**
            let indexErrTime = this.rbDetails.findIndex((item) => {
              if (item.endtime && item.starttime) {
@@ -1502,6 +1507,8 @@
           }
           */
 
+          try {
+          this.saveLoading = true;
           //闄勪欢鏂囦欢澶勭悊
           let list = this.fileList;
           if (list.length > 0) {
@@ -1527,71 +1534,75 @@
           const rbDetails = [...this.rbDetails];
           const rbPayees = [...this.rbPayees];
           if (this.form.id != null) {
-            updateReimbursement(this.form)
-              .then(res => {
-                //淇濆瓨鏄庣粏
-                for (let i = 0; i < rbDetails.length; i++) {
-                  if (rbDetails[i].rbid != null) {
-                    updateReimbursementdetail(rbDetails[i]);
-                  } else {
-                    //rbid鍏宠仈涓昏〃Id
-                    rbDetails[i].rbid = this.form.id;
-                    addReimbursementdetail(rbDetails[i]);
-                  }
-                }
+            //绗�1姝ワ細鏇存柊涓昏〃锛屾垚鍔熷悗鍐嶅鐞嗗瓙琛�
+            await updateReimbursement(this.form);
 
-                //淇濆瓨璐︽埛
-                for (let i = 0; i < rbPayees.length; i++) {
-                  if (rbPayees[i].rbid != null) {
-                    updateReimbursementpayee(rbPayees[i]);
-                  } else {
-                    //rbid鍏宠仈涓昏〃Id
-                    rbPayees[i].rbid = this.form.id;
-                    addReimbursementpayee(rbPayees[i]);
-                  }
+            //绗�2姝ワ細骞跺彂淇濆瓨鏄庣粏锛岀瓑寰呭叏閮ㄥ畬鎴愶紝浠讳竴澶辫触鍒欒蛋 catch 鎻愮ず
+            await Promise.all(
+              rbDetails.map(detail => {
+                if (detail.rbid != null) {
+                  return updateReimbursementdetail(detail);
                 }
-
-                this.$modal.msgSuccess("淇敼鎶ラ攢鍗曚繚瀛樻垚鍔�!");
-                this.open = false;
-                this.getList();
+                //rbid鍏宠仈涓昏〃Id
+                detail.rbid = this.form.id;
+                return addReimbursementdetail(detail);
               })
-              .catch(err => {
-                this.$modal.msgError("淇敼鎶ラ攢鍗曚繚瀛樺け璐ワ紒");
-              });
+            );
+
+            //绗�3姝ワ細骞跺彂淇濆瓨璐︽埛
+            await Promise.all(
+              rbPayees.map(payee => {
+                if (payee.rbid != null) {
+                  return updateReimbursementpayee(payee);
+                }
+                //rbid鍏宠仈涓昏〃Id
+                payee.rbid = this.form.id;
+                return addReimbursementpayee(payee);
+              })
+            );
+
+            this.$modal.msgSuccess("淇敼鎶ラ攢鍗曚繚瀛樻垚鍔�!");
           } else {
             this.form.recordstatus = -1;
-            addReimbursement(this.form)
-              .then(response => {
-                //淇濆瓨鏄庣粏
-                for (let i = 0; i < rbDetails.length; i++) {
-                  //rbid鍏宠仈涓昏〃Id
-                  rbDetails[i].rbid = response.data;
-                  addReimbursementdetail(rbDetails[i]);
-                }
+            //绗�1姝ワ細鏂板涓昏〃锛岃繑鍥炰富琛↖d
+            const response = await addReimbursement(this.form);
 
-                //淇濆瓨璐﹀彿
-                for (let i = 0; i < rbPayees.length; i++) {
-                  //rbid鍏宠仈涓昏〃Id
-                  rbPayees[i].rbid = response.data;
-                  addReimbursementpayee(rbPayees[i]);
-                }
-
-                this.$modal.msgSuccess("鏂板鎶ラ攢鍗曚繚瀛樻垚鍔�!");
-                this.open = false;
-                this.getList();
+            //绗�2姝ワ細骞跺彂淇濆瓨鏄庣粏
+            await Promise.all(
+              rbDetails.map(detail => {
+                //rbid鍏宠仈涓昏〃Id
+                detail.rbid = response.data;
+                return addReimbursementdetail(detail);
               })
-              .catch(err => {
-                this.$modal.msgError("鏂板鎶ラ攢鍗曚繚瀛樺け璐ワ紒");
-              });
+            );
+
+            //绗�3姝ワ細骞跺彂淇濆瓨璐﹀彿
+            await Promise.all(
+              rbPayees.map(payee => {
+                //rbid鍏宠仈涓昏〃Id
+                payee.rbid = response.data;
+                return addReimbursementpayee(payee);
+              })
+            );
+
+            this.$modal.msgSuccess("鏂板鎶ラ攢鍗曚繚瀛樻垚鍔�!");
+          }
+
+          //鎵�鏈変繚瀛樻楠ゅ叏閮ㄦ垚鍔熷悗鎵嶅叧闂脊绐楀苟鍒锋柊鍒楄〃
+          this.open = false;
+          this.getList();
+          } catch (err) {
+            this.$modal.msgError("鎶ラ攢鍗曚繚瀛樺け璐ワ紝璇烽噸璇曪紒");
+          } finally {
+            this.saveLoading = false;
           }
         }
-      });
+      );
     },
 
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const ids = row.id || this.ids;
-      console.log(ids);
       this.$modal
         .confirm("鏄惁纭鍒犻櫎璇ユ潯璁板綍锛�")
         .then(function () {
@@ -1599,7 +1610,10 @@
           return delReimbursement(ids);
         })
         .then(() => {
-          delReimbursementdetail(ids);
+          //绛夊緟鏄庣粏鍒犻櫎瀹屾垚鍚庡啀鍒锋柊鍒楄〃锛岄伩鍏嶅垪琛ㄥ埛鏂版椂鏄庣粏灏氭湭鍒犻櫎
+          return delReimbursementdetail(ids);
+        })
+        .then(() => {
           this.getList();
           this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
         })
@@ -1619,7 +1633,10 @@
           this.$download.name(response.msg);
           this.exportLoading = false;
         })
-        .catch(() => { });
+        .catch(() => {
+          //澶辫触鏃朵篃瑕佸浣� loading锛屽惁鍒欐寜閽案涔呰浆鍦�
+          this.exportLoading = false;
+        });
     },
 
     //鏂板涓�琛�
@@ -1800,107 +1817,30 @@
     },
 
     //璁$畻涓�琛屽悎璁�
-    //璁$畻褰撳墠琛屾姤閿�鍐呭璐圭敤鍚堣
+    //璁$畻褰撳墠琛屾姤閿�鍐呭璐圭敤鍚堣锛堥噾棰濅竴寰嬭蛋绮剧‘杩愮畻锛�
     sumRowFee(row) {
-      let totalFee = 0;
-      if (!isNaN(parseFloat(row.trafficexpense))) {
-        totalFee += parseFloat(row.trafficexpense);
-      }
-      if (!isNaN(parseFloat(row.cityfee))) {
-        totalFee += parseFloat(row.cityfee);
-      }
-      if (!isNaN(parseFloat(row.hotelexpense))) {
-        totalFee += parseFloat(row.hotelexpense);
-      }
-      if (!isNaN(parseFloat(row.otherexpense))) {
-        totalFee += parseFloat(row.otherexpense);
-      }
-      if (!isNaN(parseFloat(row.foodexpenses))) {
-        totalFee += parseFloat(row.foodexpenses);
-      }
-      if (!isNaN(parseFloat(row.foodallowance))) {
-        totalFee += parseFloat(row.foodallowance);
-      }
-      if (!isNaN(parseFloat(row.otherfeeamount))) {
-        totalFee += parseFloat(row.otherfeeamount);
-      }
-      row.total = totalFee;
+      row.total = moneySum([
+        row.trafficexpense,
+        row.cityfee,
+        row.hotelexpense,
+        row.otherexpense,
+        row.foodexpenses,
+        row.foodallowance,
+        row.otherfeeamount
+      ]);
 
-      /*
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].trafficexpense))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].trafficexpense);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].cityfee))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].cityfee);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].hotelexpense))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].hotelexpense);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].otherexpense))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].otherexpense);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].foodexpenses))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].foodexpenses);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].foodallowance))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].foodallowance);
-      }
-      if (!isNaN(parseFloat(this.rbDetails[rowIndex].otherfeeamount))) {
-        totalFee += parseFloat(this.rbDetails[rowIndex].otherfeeamount);
-      }
-      this.rbDetails[rowIndex].total = parseFloat(totalFee).toFixed(2);
-      this.$set(this.rbDetails, rowIndex, this.rbDetails[rowIndex]);
-      */
       //閲嶆柊璁$畻鏁翠釜鎶ラ攢鍗曠殑鍚堣
       this.sumTotalFee();
     },
 
     //璁$畻璐圭敤鍚堣
     sumTotalFee() {
-      let allSum = 0;
-
-      //鎹愮尞鑰呭灞炶垂鐢�
-      if (!isNaN(parseFloat(this.form.donoramount))) {
-        allSum += parseFloat(this.form.donoramount);
-      }
-
       //鎶ラ攢鏄庣粏璐圭敤
       try {
-        for (let i = 0; i < this.rbDetails.length; i++) {
-          /*
-          let totalFee = 0;
-          //璁$畻褰撳墠鎶ラ攢鍐呭璐圭敤鍚堣
-          if (!isNaN(parseFloat(this.rbDetails[i].total))) {
-            totalFee += parseFloat(this.rbDetails[i].total);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].cityfee))) {
-            totalFee += parseFloat(this.rbDetails[i].cityfee);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].hotelexpense))) {
-            totalFee += parseFloat(this.rbDetails[i].hotelexpense);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].otherexpense))) {
-            totalFee += parseFloat(this.rbDetails[i].otherexpense);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].foodexpenses))) {
-            totalFee += parseFloat(this.rbDetails[i].foodexpenses);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].foodallowance))) {
-            totalFee += parseFloat(this.rbDetails[i].foodallowance);
-          }
-          if (!isNaN(parseFloat(this.rbDetails[i].otherfeeamount))) {
-            totalFee += parseFloat(this.rbDetails[i].otherfeeamount);
-          }
-          this.rbDetails[i].total = parseFloat(totalFee).toFixed(2);
-          this.$set(this.rbDetails, i, this.rbDetails[i]);
-          */
-
-          if (!isNaN(parseFloat(this.rbDetails[i].total))) {
-            allSum += parseFloat(this.rbDetails[i].total);
-          }
-        }
-
-        this.form.amountrequested = allSum.toFixed(2);
+        this.form.amountrequested = moneyAdd(
+          moneySum(this.rbDetails, "total"),
+          this.form.donoramount
+        ).toFixed(2);
         this.form.bigstrmoney = this.convertCurrency(this.form.amountrequested);
       } catch { }
     },

--
Gitblit v1.9.3