Ver código fonte

增加药房仅有一个隐藏控件配置

cc12458 1 ano atrás
pai
commit
4bd5a025c5
1 arquivos alterados com 6 adições e 5 exclusões
  1. 6 5
      src/layout/components/Navbar.vue

+ 6 - 5
src/layout/components/Navbar.vue

@@ -33,7 +33,7 @@
         <!--        </el-tooltip>el-tooltip-->
 
         <el-select
-          v-if="!hidePharmacyControl"
+          v-if="!hidePharmacyControl || (onePharmacyHideControl && pharmacyList.length === 1)"
           v-model="pharmacyId"
           placeholder="请选择药房"
           style="margin-right: 20px; width: 150px"
@@ -107,7 +107,8 @@ export default {
   data() {
     return {
       pharmacyId: "",
-      hidePharmacyControl: true,
+      hidePharmacyControl: false,
+      onePharmacyHideControl: true,
     };
   },
   created() {
@@ -116,11 +117,11 @@ export default {
       this.pharmacyId = '';
     } else {
       let pharmacyId = window.localStorage.getItem("pharmacyId");
-      if (pharmacyId == null) {
+      if (this.pharmacyList.find(item => item.id == pharmacyId)) {
+        this.pharmacyId = Number(pharmacyId);
+      } else {
         this.pharmacyId = this.pharmacyList[0].id;
         window.localStorage.setItem("pharmacyId", this.pharmacyId);
-      } else {
-        this.pharmacyId = Number(pharmacyId);
       }
     }