From 410d5bf8bc5ef56be822105e71dac02f43aa9463 Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期四, 16 一月 2025 17:29:13 +0800
Subject: [PATCH] 1

---
 src/views/system/tijian/index.vue |  617 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 320 insertions(+), 297 deletions(-)

diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue
index 34c9c2f..f082f7c 100644
--- a/src/views/system/tijian/index.vue
+++ b/src/views/system/tijian/index.vue
@@ -353,10 +353,6 @@
                 ></el-option>
               </el-select>
             </el-form-item>
-
-            <!-- <el-form-item prop="ageUnit">
-              
-              </el-form-item> -->
           </el-form>
           <el-form
             :inline="true"
@@ -590,14 +586,6 @@
                   prop="allProName"
                   :show-overflow-tooltip="true"
                 />
-                <!-- :selectable="checkSelectable" -->
-                <!-- <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
-                <template slot-scope="scope">
-                  <el-button size="mini" type="text" icon="el-icon-circle-check" @click="handleSeach(scope.row)"
-                    v-hasPermi="['system:package:Seach']">濂楅璇︽儏
-                  </el-button>
-                </template>
-</el-table-column> -->
               </el-table>
             </div>
           </div>
@@ -715,18 +703,6 @@
         </el-tab-pane>
         <el-tab-pane label="鍗曢」" name="second">
           <div class="tab8">
-            <!-- <div class="tab7">
-              <v-tree-transfer
-                :treeData="treedataList"
-                :defaultProps="{ children: 'tjProjectList', label: 'proName' }"
-                :defaultKeys="defaultKeys"
-                @changeKeys="changeCategoryKeys"
-                :key="datekey"
-              ></v-tree-transfer> -->
-            <!-- <el-tree :data="data" show-checkbox node-key="proId" :props="defaultProps" :default-checked-keys="treeList"
-                @check-change="handleCurrentChecked">
-              </el-tree> -->
-            <!-- </div> -->
             <el-row :gutter="20">
               <el-col :span="6">
                 <div
@@ -953,17 +929,17 @@
                   style="width: 150px"
                 ></el-input>
               </el-form-item>
-              <el-form-item label="浼樻儬">
+              <el-form-item label="鎶樻墸">
                 <!-- {{ discount }} -->
                 <el-input-number
                   ref="inputNumber"
                   style="width: 150px"
                   v-model="discount"
-                  :precision="2"
+                  :precision="1"
                   :step="0.1"
                   :max="10"
                   :min="0"
-                  @change="numberChange"
+                  @change="debounceNumberChange"
                   :disabled="isfalse"
                 ></el-input-number>
               </el-form-item>
@@ -972,7 +948,9 @@
                   placeholder="瀹炴敹閲戦"
                   v-model="TotalPrice"
                   style="width: 206px"
-                ></el-input>
+                  @input="changeXianjia"
+                  @blur="numberChangeXianPrice(discount, discount)"
+                />
               </el-form-item>
               <br />
 
@@ -992,14 +970,14 @@
                   >閲嶇疆濂楅</el-button
                 >
                 <el-button
-  type="primary"
-  @click="submitPrice"
-  :loading="loadingSubmit"
-  :disabled="confirm || loadingSubmit"
-  v-if="showHidden.has_charge == 'N'"
-  size="mini"
->绛惧埌鐧昏</el-button>
-
+                  type="primary"
+                  @click="submitPrice"
+                  :loading="loadingSubmit"
+                  :disabled="confirm || loadingSubmit"
+                  v-if="showHidden.has_charge == 'N'"
+                  size="mini"
+                  >绛惧埌鐧昏</el-button
+                >
                 <el-button
                   type="primary"
                   @click="submitCheckinfee"
@@ -1108,17 +1086,18 @@
               <el-table-column label="鎶樻墸">
                 <template slot-scope="scope">
                   <!-- 鍙緭鍏ョ函鏁板瓧鎶樻墸 -->
-                  <el-input
+                  <el-input-number
                     v-model.number="scope.row.discount"
                     @input="validateDiscount(scope.row)"
                     placeholder="杈撳叆鎶樻墸"
                     size="small"
                     type="number"
-                    min="0"
-                    step="1"
-                    max="10"
+                    :precision="1"
+                    :step="0.1"
+                    :max="10"
+                    :min="0"
                   >
-                  </el-input>
+                  </el-input-number>
                 </template>
               </el-table-column>
               <el-table-column prop="nowPrice" label="瀹炴敹閲戦">
@@ -1275,11 +1254,11 @@
                 <el-input-number
                   style="width: 140px"
                   v-model="discount"
-                  :precision="2"
+                  :precision="1"
                   :step="0.1"
                   :max="10"
                   :min="0"
-                  @change="numberChange"
+                  @change="debounceNumberChange"
                   :disabled="isfalse"
                 ></el-input-number>
               </el-form-item>
@@ -1462,6 +1441,7 @@
   },
   data() {
     return {
+      isSubmitting: false,
       open1: false,
       filterage: "",
       checkedkeys: [],
@@ -1495,7 +1475,6 @@
       ],
       isNow: 1,
       marryall: 0,
-      loadingSubmit: false,
       treeId: [],
       treeList: [],
       defaultKeys: [],
@@ -1524,12 +1503,12 @@
       taocan: false,
       top: true,
       value: "2",
-      getInfodis: "",
       srcUrl: "",
       hides: false,
       hide: true,
       beat: false,
       dialogVisibles: false,
+      loadingSubmit: false,
       charge: false,
       src: "",
       url: "",
@@ -1663,7 +1642,7 @@
         cusIsvip: null,
       },
       // 娣诲姞
-
+      lastXianPrice: 0,
       // 琛ㄥ崟鍙傛暟
       // 琛ㄥ崟鍙傛暟
       obj: {},
@@ -1679,7 +1658,27 @@
         firmId: "",
         firmDeptName: "",
       },
-      form1: {},
+      form1: {
+        cnName: "",
+        contactPerson: "",
+        contactPhone: "",
+        taxNumber: "",
+        legalPerson: "",
+        registerAddress: "",
+        mailingAddress: "",
+        bankAccount: "",
+        mailingAddress: "",
+        countNum: "",
+        bankAccount: "",
+        email: "",
+        principal: "",
+        url: "",
+        faxNumber: "",
+        areaName: "",
+        orderNum: "",
+        remark: "",
+        validTime: "",
+      },
       title: "",
       // 琛ㄥ崟鏍¢獙
       rules: {
@@ -1730,6 +1729,19 @@
   mounted() {},
 
   methods: {
+    debounceNumberChange(currentValue, oldValue) {
+      clearTimeout(this.debounceTimer);
+      this.debounceTimer = setTimeout(() => {
+        this.numberChange(currentValue, oldValue);
+      }, 300);
+    },
+    changeXianjia() {
+      // 鍘熷鎶樻墸鐜囪绠�
+      if (this.TotalPrice1 !== 0) {
+        this.discount =
+          (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+      }
+    },
     clear() {
       this.form.firmId = "";
     },
@@ -1765,13 +1777,17 @@
         })
         .catch(() => {});
     },
+    handleManualChange(row) {
+      console.log("杩欐槸涓诲姩鍑哄彂鐨�");
+      this.updateProPrice(row);
+    },
     validateDiscount(row) {
-      if (row.discount > 10) {
-        row.discount = 10; // 寮哄埗灏嗗�艰缃负鏈�澶у��
-      } else if (row.discount < 0) {
-        row.discount = 0; // 寮哄埗灏嗗�艰缃负鏈�灏忓��
+      console.log("杞簡")
+      if (this.TotalPrice !== undefined && !isNaN(this.TotalPrice) && this.TotalPrice !== this.lastXianPrice) {
+        console.log("杩涘叆浜�")
+        this.updateProPrice1(row);
+        this.lastXianPrice = this.TotalPrice;
       }
-      this.updateProPrice(row); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫
     },
     isAll(value) {
       return value === "" || value === null;
@@ -1789,7 +1805,33 @@
       this.discount =
         (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
     },
+    updateProPrice1(row) {
+      console.log("杩涘叆浜�1")
+      const ordPrice = new Big(row.ordPrice);
+      const discount = new Big(row.discount);
+      const result = ordPrice.times(discount.div(10));
+      row.nowPrice = result.toNumber();
+      const totalYsPrice = this.tableData1.reduce((sum, item) => {
+        return sum.plus(new Big(item.nowPrice || '0'));
+      }, new Big(0));
+      const totalYsPriceNum = totalYsPrice.toNumber();
+      if (this.TotalPrice !== undefined && !isNaN(this.TotalPrice)) {
+        const xianPrice = new Big(this.TotalPrice);
+        const diff = xianPrice.minus(totalYsPriceNum);
+        if (!diff.eq(0) && this.tableData1.length > 0) {
+          const lastItem = this.tableData1[this.tableData1.length - 1];
+          const newYsPrice = new Big(lastItem.nowPrice).plus(diff).toNumber();
+          this.$set(this.tableData1[this.tableData1.length - 1], 'nowPrice', newYsPrice);
+        }
+      }
 
+      // Update youhui calculation
+      if (this.TotalPrice1 !== 0 && this.TotalPrice !== 0) {
+        this.discount = (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+      } else {
+        this.discount = 0;
+      }
+    },
     openname() {
       this.$refs.bbb.open = true;
       this.$refs.bbb.title = "鎼滅储濮撳悕";
@@ -1913,11 +1955,9 @@
     },
     getList1() {
       getInfo().then((response) => {
-        this.getInfodis = response.user.discount;
+
         this.hospName = response.hospName;
-        if (this.getInfodis === null) {
-          this.isfalse = true;
-        }
+
       });
       getIsRequired().then((response) => {
         this.showHidden = response.data;
@@ -2130,25 +2170,6 @@
         this.srcUrl = response.url;
       });
     },
-    // base64杞枃浠�
-    // dataURLtoFile(image, filename) {
-    //   var arr = image.split(",");
-    //   var mime = arr[0].match(/:(.*?);/)[1];
-    //   var bstr = atob(arr[1]);
-    //   var n = bstr.length;
-    //   var u8arr = new Uint8Array(n);
-    //   while (n--) {
-    //     u8arr[n] = bstr.charCodeAt(n);
-    //   }
-    //   return new File([u8arr], filename, { type: mime });
-    // },
-
-    // 鍏抽棴鎽勫儚澶�
-
-    // stopNavigator() {
-    //   this.thisVideo.srcObject.getTracks()[0].stop();
-    //   this.beat = false;
-    // },
 
     handleClose(done) {
       this.$confirm("纭鍏抽棴锛�")
@@ -2160,16 +2181,9 @@
 
     /** 鏌ヨ淇℃伅鍒楄〃 */
     getList() {
-      // listCustomer(this.queryParams).then((response) => {
-      //   this.customerList = response.rows;
-      //   this.total = response.total;
-      //   this.loading = false;
-      // });
       getInfo().then((response) => {
-        this.getInfodis = response.user.discount;
-        if (this.getInfodis === null) {
-          this.isfalse = true;
-        }
+
+
       });
       let cusSex = this.form.cusSex;
       //鍏ㄩ儴濂楅
@@ -2221,8 +2235,6 @@
     },
     /** 閲嶇疆鎸夐挳鎿嶄綔 */
     resetQuery() {
-      // this.resetForm("form");
-      // this.form = {};
       if (this.confirm === true) {
         this.$tab.refreshPage();
       } else {
@@ -2255,27 +2267,66 @@
       })
         .then(() => {
           this.discount = currentValue;
-          if (this.discount < this.getInfodis) {
-            this.discount = this.getInfodis;
-            // this.$modal.msgError(`璇ヤ汉鍛樻渶楂樹紭鎯犳潈闄愪负${this.getInfodis}鎶榒);
-          }
+
           this.tableData1.forEach((item) => {
             item.discount = this.discount;
             const ordPrice = new Big(item.ordPrice);
             const discount = new Big(item.discount);
-            const result = ordPrice.times(discount.div(10)); // ordPrice * (discount / 10)
+            const result = ordPrice.times(discount.div(10));
             item.nowPrice = result.toNumber();
             this.TotalPrice = this.tableData1.reduce((sum, item) => {
               return sum.plus(new Big(item.nowPrice || "0"));
             }, new Big(0));
           });
-          // ----------------------------------------------------------
         })
         .catch(() => {
           this.discount = oldValue;
         });
     },
-
+    numberChangeXianPrice(currentValue, oldValue) {
+      this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.discount = currentValue;
+          if (this.discount < this.getInfodis) {
+            this.discount = this.getInfodis;
+          }
+          let totalYsprice = new Big(0);
+          this.tableData1.forEach((item) => {
+            item.discount = this.discount;
+            const ordPrice = new Big(item.ordPrice);
+            const discount = new Big(item.discount);
+            const result = ordPrice.times(discount.div(10));
+            item.nowPrice = result.toNumber();
+            totalYsprice = totalYsprice.plus(new Big(item.nowPrice));
+          });
+          if (!totalYsprice.eq(this.TotalPrice)) {
+            const diff = new Big(this.TotalPrice).minus(totalYsprice);
+            if (this.tableData1.length > 0) {
+              const lastItem = this.tableData1[this.tableData1.length - 1];
+              const newYsPrice = new Big(lastItem.nowPrice)
+                .plus(diff)
+                .toNumber();
+              console.log(
+                "hhh",
+                this.tableData1[this.tableData1.length - 1].nowPrice,
+                newYsPrice
+              );
+              this.$set(
+                this.tableData1[this.tableData1.length - 1],
+                "nowPrice",
+                newYsPrice
+              );
+            }
+          }
+        })
+        .catch(() => {
+          this.discount = oldValue;
+        });
+    },
     /** 鐧昏鎻愪氦鎸夐挳 */
     submitForm() {
       let _this = this;
@@ -2324,6 +2375,7 @@
       let cusIdcard = this.form.cusIdcard;
       if (cusIdcard) {
         getCusIdcard(cusIdcard).then((response) => {
+          _this.top = false;
           if (response.data) {
             this.form = response.data;
             if (this.form.discount === null) {
@@ -2364,11 +2416,11 @@
                     this.list1 = false;
                     this.list2 = true;
                     this.list3 = false;
-                    this.top = false;
+                    _this.top = false;
                   } else {
                     this.list1 = true;
                     this.TotalPrice = 0;
-                    this.top = false;
+                    _this.top = false;
                   }
                 });
               } else {
@@ -2524,15 +2576,7 @@
         }
       } else {
         this.$message.warning("璇锋斁缃韩浠借瘉鍚庡啀鐐瑰嚮璇诲彇");
-      } /* if (resultObj.resultFlag == "-1") {
-          if (resultObj.errorMsg == "绔彛鎵撳紑澶辫触") {
-            //alert("璇诲崱鍣ㄦ湭杩炴帴");
-          } else {
-            //alert(resultObj.errorMsg);
-          }
-        } else if (resultObj.resultFlag == "-2") {
-          //alert(resultObj.errorMsg);
-        } */
+      }
     },
     // TODO 浠ヤ笅浠g爜鍙兘鏄尘宸濅娇鐢ㄧ殑
     jingChuanHandlerWebSocketResult(resultObj) {
@@ -2684,23 +2728,9 @@
           alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
         };
       } else {
-        // if (_this.inputSSS.indexOf(":1") != -1) {
-
-        //   var str1 = _this.inputSSS.indexOf(":1");
-        //   var result1 = _this.inputSSS.substring(0, str1);
-
-        //   var str2 = _this.inputSSS.indexOf(":1");
-        //   var result2 = _this.inputSSS.substring(
-        //     str2 + 2,
-        //     _this.inputSSS.length
-        //   );
-
-        //   _this.inputSSS = result1 + result2;
-        // }
         _this.inputSSS = _this.inputSSS.replace(":1", "");
         var websocket = null;
         var url = this.valueUrls;
-        // var url = 'ws://'+ getIp() +':6789/websocket'
         if ("WebSocket" in window) {
           websocket = new WebSocket(url);
         } else if ("MozWebSocket" in window) {
@@ -2873,53 +2903,6 @@
       }
     },
 
-    // 鐐瑰嚮澶氶�夋鑾峰彇閫変腑鏁版嵁
-    // handleSelectionChange(selection, row) {
-    //   this.tableData = selection;
-    //   if (selection.length > 1) {
-    //     let del_row = selection.shift();
-    //     this.$refs.tb.toggleRowSelection(del_row, false); //璁剧疆杩欎竴琛屽彇娑堥�変腑
-    //   }
-    // this.single = selection.length !== 1;
-    // this.multiple = !selection.length;
-    // this.tableData.forEach((item) => {
-    //   this.fData = item.tjProjectList;
-    // });
-    // if (selection[0]) {
-    //   this.DataList = [];
-    // this.data = JSON.parse(JSON.stringify(this.dXData));
-    //     if (selection[0].tjProjectList) {
-    //       selection[0].tjProjectList.forEach((selectionitem) => {
-    //         this.treedataList.forEach((item) => {
-    //           if (selectionitem.proName == item.proName) {
-    //             item.disabled = true;
-    //             item.tjProjectList = [];
-    //           }
-    //           if (item.tjProjectList) {
-    //             item.tjProjectList.forEach((item1) => {
-    //               if (selectionitem.proName == item1.proName) {
-    //                 item1.disabled = true;
-    //                 item1.tjProjectList = [];
-    //               }
-    //               if (item1.tjProjectList) {
-    //                 item1.tjProjectList.forEach((item2) => {
-    //                   if (selectionitem.proName == item2.proName) {
-    //                     item2.disabled = true;
-    //                     item2.tjProjectList = [];
-    //                   }
-    //                 });
-    //               }
-    //             });
-    //           }
-    //         });
-    //       });
-    //     }
-    //   } else {
-    //     this.treedataList = JSON.parse(JSON.stringify(this.dXData));
-    //     return;
-    //   }
-    // },
-
     resetpackage() {
       this.discount = 10;
       if (this.form.cusIdcard) {
@@ -2931,6 +2914,13 @@
       _this.pacId = "";
       this.proIds = [];
       this.tjCategory = "12";
+
+      this.DataList = []; // 娓呯┖宸查�夐」鐩垪琛�
+      this.checkedkey = []; // 娓呯┖鏍戠殑閫変腑鐘舵��
+      this.checkedListkey = [];
+      this.TreedataList = [];
+      this.$refs.tree.setCheckedKeys([]); // 閲嶇疆鏍戦�変腑鐘舵��
+
       let data = {
         cusId,
         pacId: _this.pacId,
@@ -3388,116 +3378,99 @@
         var cusId = this.form.cusIdcard;
       } else {
         this.$message.warning("璇峰厛濉啓淇℃伅锛屽啀閫変綋妫�鍐呭");
+        return; // 濡傛灉娌℃湁韬唤璇佸彿鐮侊紝鍋滄鎵ц
       }
+
       let _this = this;
+
+      // 鍒濆鍖栧彉閲�
+      this.isSubmitting = true; // 寮�濮嬫彁浜ゆ椂璁剧疆鏍囧織
+      this.TotalPrice1 = 0; // 鍒濆鍖栧簲鏀堕噾棰�
+      this.TotalPrice = 0; // 鍒濆鍖栧疄鏀堕噾棰�
+      this.discount = 10; // 鍒濆鍖栨姌鎵d负10锛�100%锛�
+
+      // 鍒ゆ柇鏄惁鏈夐�変腑鐨勫椁�
       if (this.tableData.length != 0) {
-        this.tableData.forEach((item) => {
-          _this.pacId = item.pacId;
-        });
+        _this.pacId = this.tableData[0].pacId;
       } else {
         _this.pacId = "";
       }
+
       this.proIds = [];
-      if (this.DataList.length != 0) {
-        this.DataList.forEach((item) => {
+
+      // 澶勭悊閫変腑鐨勯」鐩�
+      const newItemsToAdd = [];
+      const allItems = [...this.DataList, ...this.DataLists]; // 鍚堝苟鎵�鏈夐」鐩�
+
+      allItems.forEach((item) => {
+        if (!this.proIds.includes(item.proId)) {
+          newItemsToAdd.push(item);
           this.proIds.push(item.proId);
-        });
-      }
-      if (this.DataLists.length != 0) {
-        this.DataLists.forEach((item) => {
-          this.proIds.push(item.proId);
-        });
-      }
+        }
+      });
+
+      // 鍑嗗鏁版嵁
       let data = {
         cusId,
         pacId: _this.pacId,
         proIds: this.proIds,
       };
+
+      // 鏍规嵁浣撴绫诲瀷閫夋嫨涓嶅悓鐨勫鐞嗘柟娉�
       if (this.form.tjType == 1) {
         tuantiqueren(data).then((response) => {
           if (response.code == 200) {
-            let cusId = this.form.cusIdcard;
-            this.proIds = [];
-            getTransitionList1(cusId).then((response) => {
-              this.tableData1 = response.data;
-              this.TotalPrice1 = 0;
-              if (this.tableData1) {
-                this.tableData1.forEach((item) => {
-                  if (item.tjCategory != null) {
-                    this.tjCategory = item.tjCategory;
-                  }
-                  if (item.pacName == "鍗曢」") {
-                    item.list.forEach((item9) => {
-                      this.treeList.push(item9.proId);
-                    });
-                  }
-                  this.TotalPrice1 += item.ordPrice;
-                  this.TotalPrice += item.nowPrice;
-
-                  this.pacName = item.pacName;
-                });
-
-                this.TotalPrice = this.tableData1.reduce((sum, item) => {
-                  return sum.plus(new Big(item.nowPrice || "0"));
-                }, new Big(0));
-                this.discount =
-                  (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) /
-                    100) *
-                  10;
-                this.list1 = false;
-                this.list3 = true;
-                this.list2 = false;
-              } else {
-                this.list1 = true;
-                this.TotalPrice = 0;
-              }
-            });
-          } else {
+            this.processOrderItems(cusId);
           }
+          this.isSubmitting = false; // 鎻愪氦瀹屾垚鍚庨噸缃爣蹇�
+        }).catch(() => {
+          this.isSubmitting = false; // 纭繚鍦ㄩ敊璇儏鍐典笅涔熼噸缃爣蹇�
         });
       } else {
         getaddtTransition(data).then((response) => {
           if (response.code == 200) {
-            let cusId = this.form.cusIdcard;
-            this.proIds = [];
-            getTransitionList1(cusId).then((response) => {
-              this.tableData1 = response.data;
-              this.TotalPrice1 = 0;
-              if (this.tableData1) {
-                this.tableData1.forEach((item) => {
-                  if (item.tjCategory != null) {
-                    this.tjCategory = item.tjCategory;
-                  }
-                  if (item.pacName == "鍗曢」") {
-                    item.list.forEach((item9) => {
-                      this.treeList.push(item9.proId);
-                    });
-                  }
-                  this.TotalPrice1 += item.ordPrice;
-                  this.TotalPrice += item.nowPrice;
-
-                  this.pacName = item.pacName;
-                });
-                this.discount =
-                  (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) /
-                    100) *
-                  10;
-
-                this.list1 = false;
-                this.list3 = true;
-                this.list2 = false;
-              } else {
-                this.list1 = true;
-                this.TotalPrice = 0;
-              }
-            });
-          } else {
+            this.processOrderItems(cusId);
           }
+          this.isSubmitting = false; // 鎻愪氦瀹屾垚鍚庨噸缃爣蹇�
+        }).catch(() => {
+          this.isSubmitting = false; // 纭繚鍦ㄩ敊璇儏鍐典笅涔熼噸缃爣蹇�
         });
       }
+
       this.taocan = false;
       this.defaultKeys = [];
       this.DataLists = [];
+    },
+
+    // 澶勭悊璁㈠崟椤圭洰
+    processOrderItems(cusId) {
+      getTransitionList1(cusId).then((response) => {
+        this.tableData1 = response.data;
+        if (this.tableData1) {
+          this.tableData1.forEach((item) => {
+            if (item.tjCategory != null) {
+              this.tjCategory = item.tjCategory;
+            }
+            if (item.pacName == "鍗曢」") {
+              item.list.forEach((item9) => {
+                this.treeList.push(item9.proId);
+              });
+            }
+            this.TotalPrice1 += item.ordPrice || 0; // 绱姞搴旀敹閲戦
+            this.TotalPrice += item.nowPrice || 0; // 绱姞瀹炴敹閲戦
+          });
+          // 璁$畻鎶樻墸
+          this.discount = this.TotalPrice1 > 0 ?
+            (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10 : 0;
+
+          this.list1 = false;
+          this.list3 = true;
+          this.list2 = false;
+        } else {
+          this.list1 = true;
+          this.TotalPrice = 0;
+        }
+      });
     },
     submitCheckinfee() {
       let _this = this;
@@ -3663,9 +3636,7 @@
             }
             this.discount =
               (this.formInline.paidIn / this.formInline.price) * 10;
-            if (this.discount <= this.getInfodis) {
-              this.discount = this.getInfodis;
-            }
+
           } else {
             this.discount = 10;
             this.formInline.paidIn = "0.00";
@@ -3746,8 +3717,6 @@
     listgetOrder(data) {
       getOrder(data).then((res) => {
         this.$modal.msgSuccess("鎻愪氦鎴愬姛");
-        // this.dialogVisibles = true;
-        // this.url = window.webkitURL.createObjectURL(res); //灏嗗悗绔繑鍥炵殑blob鏂囦欢璇诲彇鍑簎rl
         //璋冩帴鍙f樉绀哄妫�鍗�
         const tjNumber = res.msg;
         const viewNum = "792931586196398080";
@@ -3757,55 +3726,109 @@
       });
       this.$tab.refreshPage();
     },
+
+    // 鏈�鍚庢彁浜ゆ寜閽�
     submitPrice() {
-  let _this = this;
-  
-  if (_this.tjCategory !== "") {
-    this.loadingSubmit = true; // Start loading
-
-    // Your existing code here...
-
-    gaibianzhekou(newArray).then((res) => {
-      if (res.code === 200) {
-        let data;
-
-        if (pacId || this.tjOrderList.length > 0) {
-          data = {
-            photo: this.srcUrl,
-            pacId,
-            tjOrderList: this.tjOrderList,
-            tjFlowingWater: this.tjFlowingWater,
-            userId,
-            tjType,
-            tjCategory: this.tjCategory,
-            firmId: this.form.firmId,
-            firmName: this.form.firmName,
-            firmDeptName: this.form.firmDeptName,
-          };
-
-          this.listgetOrder(data).finally(() => {
-            this.loadingSubmit = false; // End loading
-          });
+      let _this = this;
+      if (_this.tjCategory !== "") {
+        this.loadingSubmit = true;
+        let List = _this.tableData1; //鍗曚釜椤圭洰淇℃伅
+        if (this.responseList.cusId) {
+          var userId = this.responseList.cusId;
         } else {
-          // Handle case where pacId or tjOrderList is not available
-          this.loadingSubmit = false; // End loading
-          this.$message({
-            type: "warning",
-            message: "璇烽�夋嫨濂楅!",
-          });
+          var userId = _this.form.cusId;
         }
+        let tjType = _this.form.tjType;
+        if (this.tableData[0]) {
+          var pacId = this.tableData[0].pacId;
+        }
+
+        //tjOrderList//杩欎釜鏄鐞嗗畬鐨勬瘡涓�椤瑰椁愪俊鎭�
+        List.forEach((item) => {
+          if (item.list) {
+            item.list.forEach((item1) => {
+              this.tjOrderList.push({
+                proName: item1.proName,
+                proPrice: item1.nowPrice,
+                proId: item1.proId,
+              });
+            });
+          } else if (item.tjProjectList) {
+            item.tjProjectList.forEach((item1) => {
+              this.tjOrderList.push({
+                proName: item1.proName,
+                proPrice: item1.priceNow,
+                proId: item1.proId,
+              });
+            });
+          } else {
+            this.tjOrderList.push({
+              proName: item.proName,
+              proPrice: item.ysPrice,
+              proId: item.proId,
+            });
+          }
+        });
+        let copeWith = this.TotalPrice1;
+        let paidIn = this.TotalPrice.toString();
+        let discount = this.discount;
+        this.tjFlowingWater = { copeWith, paidIn, discount };
+        const newArray = this.tableData1
+          .filter((item) => item.discount < 10) // 杩囨护鍑� discount < 10 鐨勯」
+          .map((item) => ({
+            discount: item.discount,
+            parentProId: item.parentProId,
+            cusIdCard: item.cusId,
+          })); // 鍒涘缓鏂扮殑瀵硅薄锛屽寘鍚� discount 鍜� id
+        gaibianzhekou(newArray).then((res) => {
+          if (res.code === 200) {
+            this.loadingSubmit = false;
+            let data;
+
+            if (pacId || this.tjOrderList.length > 0) {
+              data = {
+                photo: this.srcUrl,
+                pacId,
+                tjOrderList: this.tjOrderList,
+                tjFlowingWater: this.tjFlowingWater,
+                userId,
+                tjType,
+                tjCategory: this.tjCategory,
+                firmId: this.form.firmId,
+                firmName: this.form.firmName,
+                firmDeptName: this.form.firmDeptName,
+              };
+
+              this.listgetOrder(data);
+            } else if (pacId || this.tjOrderList.length > 0) {
+              data = {
+                photo: this.srcUrl,
+                tjOrderList: this.tjOrderList,
+                tjFlowingWater: this.tjFlowingWater,
+                userId,
+                tjType,
+                tjCategory: this.tjCategory,
+                firmId: this.form.firmId,
+                firmName: this.form.firmName,
+                firmDeptName: this.form.firmDeptName,
+              };
+              this.listgetOrder(data);
+            } else {
+              this.$message({
+                type: "warning ",
+                message: "璇烽�夋嫨濂楅!",
+              });
+            }
+          } else {
+            this.loadingSubmit = false;
+            this.$modal.msgError("鏀瑰彉鎶樻墸閿欒");
+          }
+        });
       } else {
-        this.loadingSubmit = false; // End loading on error
-        this.$modal.msgError("鏀瑰彉鎶樻墸閿欒");
+        this.loadingSubmit = false;
+        this.$modal.msgError("璇烽�夋嫨浣撴绫诲埆");
       }
-    }).catch(() => {
-      this.loadingSubmit = false; // Ensure loading stops even on error
-    });
-  } else {
-    this.loadingSubmit = false; // End loading if tjCategory is empty
-    this.$modal.msgError("璇烽�夋嫨浣撴绫诲埆");
-  }
-},
+    },
   },
 };
 </script>

--
Gitblit v1.8.0