Jelajahi Sumber

修复从 hisEnter 进入导致 ableprescription 读取失败

cc12458 5 bulan lalu
induk
melakukan
5e5a52fd55
2 mengubah file dengan 32 tambahan dan 13 penghapusan
  1. 31 12
      src/views/diagnosis/Prescribing.vue
  2. 1 1
      src/views/hisEnter.vue

+ 31 - 12
src/views/diagnosis/Prescribing.vue

@@ -285,12 +285,11 @@
       </div>
       <div class="flex-vertical-between center-header">
         <div class="center-tab flex-vertical-center-l">
-          <template v-for="(item,index) in contentTabs">
-            <div v-if="!item.hide" :key="item.id" class="flex-center" :class="{active: container_i === index}"
-                 @click="changeContainer(item, index)">
-              <span :style="{color:item.color}">{{ item.name }}</span>
-            </div>
-          </template>
+          <div v-for="(item,index) in contentTabs" :key="index"
+               v-show="!item.hide" :data-tab-prescribing="item.id" class="flex-center" :class="{active: container_i === index}"
+               @click="changeContainer(item, index)">
+            <span :style="{color:item.color}">{{ item.name }}</span>
+          </div>
         </div>
         <div class="header-total flex-vertical-center-r flex-wrap" v-if="false">
           <div v-if="contentTabs[0].check">
@@ -1373,12 +1372,7 @@ export default {
     };
   },
   created() {
-    try {
-      const tabs = this.getuserinfo.ableprescription.split(',');
-      for (const id of tabs) try { this.contentTabs.find(item => item.id === id).hide = false; } catch (e) {}
-    } catch (e) {
-
-    }
+    try { this._updateContentTabs(this.getuserinfo.ableprescription); } catch (_) { }
     // console.log(this.getIsSee, 'issee');
     this.showSubmit = String(this.getIsSee) == "true" ? true : false;
 
@@ -1403,6 +1397,12 @@ export default {
   },
 
   watch: {
+    'getuserinfo.ableprescription': {
+      immediate: true,
+      handler(value) {
+        if (value) this._updateContentTabs(value);
+      },
+    },
     rationalMed10: {
       deep: true,
       immediate: true,
@@ -1449,6 +1449,25 @@ export default {
         else if (this.getEditPreNo()) await this.getRecipeDataByid(this.getEditPreNo());
       }
     },
+    _hackUpdateContentTab(id) {
+      setTimeout(() => {
+        try {
+          const el = this.$el.querySelector(`[data-tab-prescribing="${id}"]`);
+          el.style.display = 'flex'
+        } catch (_) {}
+      }, 1000);
+    },
+    _updateContentTabs(value) {
+      if (!value) return;
+      console.log('log:更新类别-开始', value, this.$el);
+      const tabs = value.split(',');
+      for (const id of tabs) {
+        const index = this.contentTabs.findIndex(item => item.id === id);
+        if (index !== -1) this.$set(this.contentTabs, index, {...this.contentTabs[index], hide: false});
+        this._hackUpdateContentTab(id);
+      }
+      console.log('log:更新类别-完成', this.contentTabs.map(item => `${item.id}: ${item.hide}`).join(','));
+    },
 
     // 中医诊断推导点击
     tcmClick(isauto = true) {

+ 1 - 1
src/views/hisEnter.vue

@@ -22,7 +22,7 @@ export default {
 
       if (token) {
         localStorage.setItem("token", token);
-        this.getDataByKey();
+        if (this.getuserinfo) this.getDataByKey();
       }
       if (!token) return;
       if (pid) {