Procházet zdrojové kódy

bug-738: 适宜技术改了以后,切换到中药处方,再切回来没有保存已改信息

张田田 před 1 týdnem
rodič
revize
0e44d7f2f1

+ 15 - 0
src/views/business/components/AcupointTable.vue

@@ -879,6 +879,21 @@ export default {
         _manualSingleCount: this._manualSingleCount,
       });
     },
+    cacheCurrentData() {
+      this.saveCurrentTabData();
+      this._cachedPrescriptions = JSON.parse(JSON.stringify(this.prescriptions));
+      this._cachedPrescriptionDataMap = JSON.parse(JSON.stringify(this.prescriptionDataMap));
+    },
+    restoreCachedData() {
+      if (!this._cachedPrescriptions) return false;
+      this.prescriptions = this._cachedPrescriptions;
+      this.prescriptionDataMap = this._cachedPrescriptionDataMap;
+      this.activeIndex = 0;
+      this.loadTabData(0);
+      this._cachedPrescriptions = null;
+      this._cachedPrescriptionDataMap = null;
+      return true;
+    },
     loadTabData(index) {
       this._isLoadingTab = true;
       const data = this.prescriptionDataMap[index];

+ 13 - 2
src/views/diagnosis/Prescribing.vue

@@ -2501,6 +2501,12 @@ export default {
           return;
         }
 
+        // 优先恢复缓存数据
+        if (acupointTable.restoreCachedData()) {
+          loading.close();
+          return;
+        }
+
         // 兼容数组和对象两种格式,处理数组时合并所有treatmentList
         const dataArray = Array.isArray(data) ? data : [data];
         if (!dataArray.length) {
@@ -2995,14 +3001,19 @@ export default {
     },
     // 顶部tab 改变
     async changeContainer(item, type) {
+      // 切离适宜技术tab时,缓存当前数据
+      if (this.container_i === 2 && type !== 2) {
+        this.$refs.suitScience && this.$refs.suitScience.cacheCurrentData();
+      }
+
       this.container_i = type;
       item.check = true;
-      
+
       // 切换到适宜技术tab时,重置标志位以允许重新获取数据
       if (type === 2) {
         this.isTuiDaoSuit = false;
       }
-      
+
       await this.inferRecipe(3, item.businesstype);
 
       const child = this.$children.find(child => child.name === item.name);