Просмотр исходного кода

bug-711:非药物目录项目的单次数量应用错误

张田田 5 дней назад
Родитель
Сommit
13364435b1
1 измененных файлов с 59 добавлено и 39 удалено
  1. 59 39
      src/views/business/components/AcupointTable.vue

+ 59 - 39
src/views/business/components/AcupointTable.vue

@@ -176,7 +176,7 @@
                     ></el-input>
                     ></el-input>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="数量" width="60" align="center">
+                <el-table-column label="数量" width="80" align="center">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
                     <el-input-number
                     <el-input-number
                       size="mini"
                       size="mini"
@@ -283,7 +283,7 @@
                     ></el-input>
                     ></el-input>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="数量" width="60" align="center">
+                <el-table-column label="数量" width="80" align="center">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
                     <el-input-number
                     <el-input-number
                       size="mini"
                       size="mini"
@@ -681,7 +681,7 @@ export default {
       singlePrice: "0.00",
       singlePrice: "0.00",
       coursePrice: "0.00",
       coursePrice: "0.00",
       totalPrice: "0.00",
       totalPrice: "0.00",
-      // 处方 tab 
+      // 处方 tab
       activeIndex: 0,
       activeIndex: 0,
       prescriptionDataMap: {},
       prescriptionDataMap: {},
       // 新增处方弹窗
       // 新增处方弹窗
@@ -722,14 +722,39 @@ export default {
       const p = this.prescriptions[this.activeIndex];
       const p = this.prescriptions[this.activeIndex];
       return p?.pricingUnit || "";
       return p?.pricingUnit || "";
     },
     },
+    // 当前处方的单次数量模式:"0"=默认1,"1"=详情累计/计数系数
+    currentSingleNumber() {
+      const p = this.prescriptions[this.activeIndex];
+      return p?.singleNumber || "0";
+    },
+    // 当前处方的计数系数
+    currentCountCoefficient() {
+      const p = this.prescriptions[this.activeIndex];
+      return Number(p?.countCoefficient) || 1;
+    },
+    // 当前处方的详情累计项名称列表,如 ["穴位", "耳穴"]
+    currentDetailCumulativeTypes() {
+      const p = this.prescriptions[this.activeIndex];
+      const val = p?.detailCumulative || "";
+      if (!val) return [];
+      const CUMULATIVE_MAP = {
+        "1": "穴位",
+        "2": "部位",
+        "3": "耳穴",
+        "4": "经络",
+        "5": "其他详情",
+      };
+      return String(val)
+        .split(/[,、]/)
+        .filter(Boolean)
+        .map((v) => CUMULATIVE_MAP[v.trim()])
+        .filter(Boolean);
+    },
   },
   },
   watch: {
   watch: {
-    singleCount() {
-      this.updatePrice();
-    },
     detailTables: {
     detailTables: {
       handler() {
       handler() {
-        this.calcPrice();
+        this.updatePrice();
       },
       },
       deep: true,
       deep: true,
     },
     },
@@ -742,7 +767,6 @@ export default {
     this.loadClassifyOptions();
     this.loadClassifyOptions();
   },
   },
   methods: {
   methods: {
-    // ========== 分类数据加载 ==========
     async loadClassifyOptions() {
     async loadClassifyOptions() {
       try {
       try {
         const res = await fetch(`${window.BASE_URL}data/classify.json`);
         const res = await fetch(`${window.BASE_URL}data/classify.json`);
@@ -809,6 +833,10 @@ export default {
       }
       }
       this.$nextTick(() => {
       this.$nextTick(() => {
         this._isLoadingTab = false;
         this._isLoadingTab = false;
+        // 加载完毕后,如果是自动计算模式,触发一次初始计算
+        if (this.currentSingleNumber !== "0") {
+          this.updatePrice();
+        }
       });
       });
     },
     },
     switchTab(index) {
     switchTab(index) {
@@ -818,7 +846,6 @@ export default {
       this.loadTabData(index);
       this.loadTabData(index);
     },
     },
 
 
-    // ========== 新增处方弹窗 ==========
     async openAddDialog() {
     async openAddDialog() {
       this.addForm = {
       this.addForm = {
         category: "",
         category: "",
@@ -841,7 +868,6 @@ export default {
           params.classify = this.addForm.category;
           params.classify = this.addForm.category;
         }
         }
         if (query) {
         if (query) {
-          // 拼音用 py,中文用 itemName
           if (/^[A-Za-z]+$/.test(query)) {
           if (/^[A-Za-z]+$/.test(query)) {
             params.py = query;
             params.py = query;
           } else {
           } else {
@@ -899,7 +925,7 @@ export default {
 
 
       // 检查项目是否已存在,不允许重复添加
       // 检查项目是否已存在,不允许重复添加
       const isDuplicate = this.prescriptions.some(
       const isDuplicate = this.prescriptions.some(
-        (p) => p.itemId === this.addForm.itemId
+        (p) => p.itemId === this.addForm.itemId,
       );
       );
       if (isDuplicate) {
       if (isDuplicate) {
         this.$message.warning("该项目已添加,不能重复添加");
         this.$message.warning("该项目已添加,不能重复添加");
@@ -1045,7 +1071,6 @@ export default {
         this.emitStatistics();
         this.emitStatistics();
         return;
         return;
       }
       }
-      // 只清空当前选中 tab 的内容,保留处方 tab 本身
       const p = this.prescriptions[this.activeIndex];
       const p = this.prescriptions[this.activeIndex];
       const unitPrice = p?.price || 0;
       const unitPrice = p?.price || 0;
       this.prescriptionDataMap[this.activeIndex] = createPrescriptionData({
       this.prescriptionDataMap[this.activeIndex] = createPrescriptionData({
@@ -1055,26 +1080,27 @@ export default {
         unitPrice,
         unitPrice,
       });
       });
       this.loadTabData(this.activeIndex);
       this.loadTabData(this.activeIndex);
-      this.calcPrice();
+      this.updatePrice();
       this.$emit("prescriptions-change", this.prescriptions);
       this.$emit("prescriptions-change", this.prescriptions);
     },
     },
 
 
-    // ========== 工具栏 change ==========
     onEditableChange(val) {
     onEditableChange(val) {
       this.$emit("update:isEditable", val);
       this.$emit("update:isEditable", val);
     },
     },
     onDetailTypesChange(val) {
     onDetailTypesChange(val) {
-      // 无详情 与其他选项不能同时选中
       const NO_DETAIL = "无详情";
       const NO_DETAIL = "无详情";
-      const lastSelected = val.length > this._prevDetailTypes?.length
-        ? val.find((v) => !this._prevDetailTypes.includes(v))
-        : null;
+      const lastSelected =
+        val.length > this._prevDetailTypes?.length
+          ? val.find((v) => !this._prevDetailTypes.includes(v))
+          : null;
 
 
       if (lastSelected === NO_DETAIL) {
       if (lastSelected === NO_DETAIL) {
-        // 选中了"无详情",取消其他所有选项
         val = [NO_DETAIL];
         val = [NO_DETAIL];
-      } else if (lastSelected && lastSelected !== NO_DETAIL && val.includes(NO_DETAIL)) {
-        // 选中了其他选项,取消"无详情"
+      } else if (
+        lastSelected &&
+        lastSelected !== NO_DETAIL &&
+        val.includes(NO_DETAIL)
+      ) {
         val = val.filter((v) => v !== NO_DETAIL);
         val = val.filter((v) => v !== NO_DETAIL);
       }
       }
       this.innerDetailTypes = val;
       this.innerDetailTypes = val;
@@ -1096,7 +1122,6 @@ export default {
       this.$emit("update:detailTypes", val);
       this.$emit("update:detailTypes", val);
     },
     },
 
 
-    // ========== 配穴表格(按详情类型) ==========
     getDetailTable(type) {
     getDetailTable(type) {
       if (!this.detailTables[type]) {
       if (!this.detailTables[type]) {
         this.$set(this.detailTables, type, [createEmptyRow(1)]);
         this.$set(this.detailTables, type, [createEmptyRow(1)]);
@@ -1287,9 +1312,10 @@ export default {
       });
       });
     },
     },
 
 
-    // ========== 底部统计 ==========
-    // 仅更新价格,不重新计算 singleCount(用于用户手动修改单次数量时)
     updatePrice() {
     updatePrice() {
+      if (this.currentSingleNumber !== "0" && !this._isLoadingTab) {
+        this.singleCount = this.calcTotalCount();
+      }
       const price = this.currentUnitPrice || this.unitPrice || 0;
       const price = this.currentUnitPrice || this.unitPrice || 0;
       this.singlePrice = (this.singleCount * price).toFixed(2);
       this.singlePrice = (this.singleCount * price).toFixed(2);
       this.coursePrice = (
       this.coursePrice = (
@@ -1303,18 +1329,10 @@ export default {
       this.totalPrice = total.toFixed(2);
       this.totalPrice = total.toFixed(2);
       this.emitStatistics();
       this.emitStatistics();
     },
     },
-    // 根据详情重新计算 singleCount 并更新价格(用于穴位详情变化时)
-    calcPrice() {
-      const totalFromDetails = this.calcTotalCount();
-      if (totalFromDetails > 0 && !this._isLoadingTab) {
-        this.singleCount = totalFromDetails;
-      }
-      this.updatePrice();
-    },
     calcTotalCount() {
     calcTotalCount() {
       let total = 0;
       let total = 0;
-      const validTypes = ["穴位", "经络", "耳穴", "部位", "其他详情"];
-      validTypes.forEach((type) => {
+      const types = this.activeDetailTypes;
+      types.forEach((type) => {
         const table = this.detailTables[type];
         const table = this.detailTables[type];
         if (table) {
         if (table) {
           table.forEach((row) => {
           table.forEach((row) => {
@@ -1324,7 +1342,8 @@ export default {
           });
           });
         }
         }
       });
       });
-      return total;
+      const coefficient = this.currentCountCoefficient;
+      return coefficient > 0 ? total / coefficient : total;
     },
     },
     emitStatistics() {
     emitStatistics() {
       this.$emit("update:statistics", {
       this.$emit("update:statistics", {
@@ -1478,10 +1497,11 @@ export default {
           itemName: item.treatItemName || "",
           itemName: item.treatItemName || "",
           price: unitPrice,
           price: unitPrice,
           pricingUnit: pricingUnit,
           pricingUnit: pricingUnit,
-          singleNumber: "",
-          countCoefficient: 1,
-          minTreatmentDuration: 0,
-          detailCumulative: "",
+          singleNumber: item.basisStitutionsnondrug?.singleNumber || "0",
+          countCoefficient: item.basisStitutionsnondrug?.countCoefficient || 1,
+          minTreatmentDuration:
+            item.basisStitutionsnondrug?.minTreatmentDuration || 0,
+          detailCumulative: item.basisStitutionsnondrug?.detailCumulative || "",
         });
         });
 
 
         const allDetails = [].concat(
         const allDetails = [].concat(