Navbar.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="navbar">
  3. <!-- <hamburger
  4. id="hamburger-container"
  5. :is-active="sidebar.opened"
  6. class="hamburger-container"
  7. @toggleClick="toggleSideBar"
  8. /> -->
  9. <!-- <breadcrumb
  10. id="breadcrumb-container"
  11. class="breadcrumb-container"
  12. v-if="!topNav"
  13. /> -->
  14. <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav" />
  15. <div class="right-menu">
  16. <template v-if="device !== 'mobile'">
  17. <!-- <search id="header-search" class="right-menu-item" />-->
  18. <!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">-->
  19. <!-- <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />-->
  20. <!-- </el-tooltip>-->
  21. <!-- <el-tooltip content="文档地址" effect="dark" placement="bottom">-->
  22. <!-- <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />-->
  23. <!-- </el-tooltip>-->
  24. <!-- <screenfull id="screenfull" class="right-menu-item hover-effect" />-->
  25. <!-- <el-tooltip content="布局大小" effect="dark" placement="bottom">-->
  26. <!-- <size-select id="size-select" class="right-menu-item hover-effect" />-->
  27. <!-- </el-tooltip>el-tooltip-->
  28. <el-select
  29. v-if="!hidePharmacyControl || (onePharmacyHideControl && pharmacyList.length === 1)"
  30. v-model="pharmacyId"
  31. placeholder="请选择药房"
  32. style="margin-right: 20px; width: 150px"
  33. @change="handleChange"
  34. >
  35. <el-option
  36. v-for="dict in pharmacyList"
  37. :key="dict.id"
  38. :label="dict.name"
  39. :value="dict.id"
  40. ></el-option>
  41. </el-select>
  42. <el-dropdown class="avatar-container hover-effect" trigger="click">
  43. <div class="avatar-wrapper">
  44. <img
  45. :src="avatar"
  46. class="user-avatar"
  47. style="vertical-align: middle; margin: 0 7px 0 0px"
  48. />
  49. <span style="vertical-align: middle; color: #fff">{{ name }}</span>
  50. <!-- <i class="el-icon-caret-bottom" />-->
  51. </div>
  52. <!-- <el-dropdown-menu slot="dropdown">-->
  53. <!-- <router-link to="/user/profile">-->
  54. <!-- <el-dropdown-item>个人中心</el-dropdown-item>-->
  55. <!-- </router-link>-->
  56. <!-- <el-dropdown-item @click.native="setting = true">-->
  57. <!-- <span>布局设置</span>-->
  58. <!-- </el-dropdown-item>-->
  59. <!-- <el-dropdown-item divided @click.native="logout">-->
  60. <!-- <span>退出登录</span>-->
  61. <!-- </el-dropdown-item>-->
  62. <!-- </el-dropdown-menu>-->
  63. <el-dropdown-menu></el-dropdown-menu>
  64. </el-dropdown>
  65. <el-button
  66. divided
  67. @click.native="logout"
  68. style="margin-right: 10px; color: #17c7b1"
  69. >安全退出</el-button
  70. >
  71. </template>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import { mapGetters } from "vuex";
  77. import Breadcrumb from "@/components/Breadcrumb";
  78. import TopNav from "@/components/TopNav";
  79. import Hamburger from "@/components/Hamburger";
  80. import Screenfull from "@/components/Screenfull";
  81. import SizeSelect from "@/components/SizeSelect";
  82. import Search from "@/components/HeaderSearch";
  83. import RuoYiGit from "@/components/RuoYi/Git";
  84. import RuoYiDoc from "@/components/RuoYi/Doc";
  85. export default {
  86. components: {
  87. Breadcrumb,
  88. TopNav,
  89. Hamburger,
  90. Screenfull,
  91. SizeSelect,
  92. Search,
  93. RuoYiGit,
  94. RuoYiDoc,
  95. },
  96. data() {
  97. return {
  98. pharmacyId: "",
  99. hidePharmacyControl: false,
  100. onePharmacyHideControl: true,
  101. };
  102. },
  103. created() {
  104. if (this.hidePharmacyControl) {
  105. window.localStorage.removeItem("pharmacyId");
  106. this.pharmacyId = '';
  107. } else {
  108. let pharmacyId = window.localStorage.getItem("pharmacyId");
  109. if (this.pharmacyList.find(item => item.id == pharmacyId)) {
  110. this.pharmacyId = Number(pharmacyId);
  111. } else {
  112. this.pharmacyId = this.pharmacyList[0].id;
  113. window.localStorage.setItem("pharmacyId", this.pharmacyId);
  114. }
  115. }
  116. },
  117. computed: {
  118. ...mapGetters(["sidebar", "avatar", "name", "device", "pharmacyList"]),
  119. setting: {
  120. get() {
  121. return this.$store.state.settings.showSettings;
  122. },
  123. set(val) {
  124. this.$store.dispatch("settings/changeSetting", {
  125. key: "showSettings",
  126. value: val,
  127. });
  128. },
  129. },
  130. topNav: {
  131. get() {
  132. return this.$store.state.settings.topNav;
  133. },
  134. },
  135. },
  136. methods: {
  137. handleChange(e) {
  138. window.localStorage.setItem("pharmacyId", e);
  139. window.location.reload();
  140. },
  141. toggleSideBar() {
  142. this.$store.dispatch("app/toggleSideBar");
  143. },
  144. async logout() {
  145. this.$confirm("确定注销并退出系统吗?", "提示", {
  146. confirmButtonText: "确定",
  147. cancelButtonText: "取消",
  148. type: "warning",
  149. })
  150. .then(() => {
  151. this.$store.dispatch("LogOut").then(() => {
  152. location.href = "/index";
  153. });
  154. })
  155. .catch(() => {});
  156. },
  157. },
  158. };
  159. </script>
  160. <style lang="scss" scoped>
  161. .navbar {
  162. height: 50px;
  163. overflow: hidden;
  164. position: relative;
  165. background: #17c7b1;
  166. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  167. .hamburger-container {
  168. line-height: 50px;
  169. height: 100%;
  170. float: left;
  171. cursor: pointer;
  172. transition: all 0.3s;
  173. -webkit-tap-highlight-color: transparent;
  174. &:hover {
  175. background: rgba(0, 0, 0, 0.025);
  176. }
  177. }
  178. .breadcrumb-container {
  179. float: left;
  180. }
  181. .topmenu-container {
  182. position: absolute;
  183. left: 50px;
  184. }
  185. .errLog-container {
  186. display: inline-block;
  187. vertical-align: top;
  188. }
  189. .right-menu {
  190. float: right;
  191. height: 100%;
  192. //line-height: 50px;
  193. &:focus {
  194. outline: none;
  195. }
  196. .right-menu-item {
  197. display: inline-block;
  198. padding: 0 8px;
  199. height: 100%;
  200. font-size: 18px;
  201. color: #5a5e66;
  202. vertical-align: text-bottom;
  203. &.hover-effect {
  204. cursor: pointer;
  205. transition: background 0.3s;
  206. &:hover {
  207. background: rgba(0, 0, 0, 0.025);
  208. }
  209. }
  210. }
  211. .avatar-container {
  212. margin-right: 30px;
  213. line-height: 50px;
  214. .avatar-wrapper {
  215. // margin-top: 5px;
  216. position: relative;
  217. .user-avatar {
  218. cursor: pointer;
  219. width: 27px;
  220. height: 27px;
  221. border-radius: 50%;
  222. }
  223. .el-icon-caret-bottom {
  224. cursor: pointer;
  225. position: absolute;
  226. right: -20px;
  227. top: 25px;
  228. font-size: 12px;
  229. }
  230. }
  231. }
  232. .el-button--medium {
  233. padding: 7px 16px;
  234. }
  235. }
  236. }
  237. </style>