فهرست منبع

bug-713:协定方单次数量修改不成功

张田田 5 روز پیش
والد
کامیت
9e6e008e1f
1فایلهای تغییر یافته به همراه24 افزوده شده و 3 حذف شده
  1. 24 3
      src/views/business/components/AcupointTable.vue

+ 24 - 3
src/views/business/components/AcupointTable.vue

@@ -405,7 +405,7 @@
                   :min="1"
                   :controls="false"
                   style="width: 60px"
-                  @change="calcPrice"
+                  @change="updatePrice"
                   placeholder="请输入"
                 ></el-input-number>
                 <span class="stat-unit">{{ currentPricingUnit }}</span>
@@ -419,7 +419,7 @@
                   :controls="false"
                   style="width: 60px"
                   :disabled="isLocked"
-                  @change="calcPrice"
+                  @change="updatePrice"
                 ></el-input-number>
               </div>
               <div class="stat-field flex-vertical-center-l">
@@ -724,6 +724,7 @@ export default {
       detailData: {},
       detailType: "",
       saveLoading: false,
+      _isLoadingTab: false,
       merTypeMap: {
         1: "十二经脉",
         2: "奇经八脉",
@@ -792,6 +793,7 @@ export default {
       });
     },
     loadTabData(index) {
+      this._isLoadingTab = true;
       const data = this.prescriptionDataMap[index];
       if (data) {
         this.detailTables = JSON.parse(JSON.stringify(data.detailTables));
@@ -825,6 +827,9 @@ export default {
         this.totalPrice = def.totalPrice;
         this.currentUnitPrice = def.currentUnitPrice || 0;
       }
+      this.$nextTick(() => {
+        this._isLoadingTab = false;
+      });
     },
     switchTab(index) {
       if (this.activeIndex === index) return;
@@ -1295,10 +1300,26 @@ export default {
     },
 
     // ========== 底部统计 ==========
+    // 仅更新价格,不重新计算 singleCount(用于用户手动修改单次数量时)
+    updatePrice() {
+      const price = this.currentUnitPrice || this.unitPrice || 0;
+      this.singlePrice = (this.singleCount * price).toFixed(2);
+      this.coursePrice = (
+        this.treatCount * parseFloat(this.singlePrice)
+      ).toFixed(2);
+      this.saveCurrentTabData();
+      let total = 0;
+      Object.values(this.prescriptionDataMap).forEach((d) => {
+        total += parseFloat(d.coursePrice) || 0;
+      });
+      this.totalPrice = total.toFixed(2);
+      this.emitStatistics();
+    },
+    // 根据详情重新计算 singleCount 并更新价格(用于穴位详情变化时)
     calcPrice() {
       const price = this.currentUnitPrice || this.unitPrice || 0;
       const totalFromDetails = this.calcTotalCount();
-      if (totalFromDetails > 0) {
+      if (totalFromDetails > 0 && !this._isLoadingTab) {
         this.singleCount = totalFromDetails;
       }
       this.singlePrice = (this.singleCount * price).toFixed(2);