CpmdHeader.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import { useRouter } from 'vue-router'
  4. const router = useRouter()
  5. import { menuStatusStore, userInfoStore } from '@/stores';
  6. import CpdmLeave from '../components/CpdmLeave.vue'
  7. const leave = ref()
  8. // import url from '../assets/home/trademark.png';
  9. //选中的索引
  10. const userInfo = userInfoStore()
  11. const menuStatus = menuStatusStore()
  12. const activeIndex = ref<string>()
  13. activeIndex.value = menuStatus.activeIndex
  14. const visible = ref<boolean>(false)
  15. //选中菜单事件
  16. const handleSelect = (key: string, keyPath: []) => {
  17. menuStatus.saveActiveIndex(key)
  18. activeIndex.value = key;
  19. if (key == '1') {
  20. router.push({ name: 'homeView' })
  21. } else if (key == '2') {
  22. router.push({ name: 'popularizationScience' })
  23. } else if (key == '3') {
  24. router.push({ name: 'community', })
  25. } else if (key == '4') {
  26. router.push({ name: 'plan', })
  27. } else if (key == '5') {
  28. router.push({ name: 'testRecord' })
  29. }
  30. // menuStatus.saveActiveIndex(key)
  31. }
  32. //点击登录按钮
  33. const login = () => {
  34. menuStatus.saveActiveIndex('6')
  35. router.push({ name: 'login', params: {} })
  36. }
  37. const falgMenu = ref<boolean>(false)
  38. //鼠标移入事件
  39. const comeMenu = () => {
  40. falgMenu.value = true
  41. }
  42. //鼠标移出事件
  43. const leaveMenu = () => {
  44. falgMenu.value = false
  45. }
  46. const updatePassFun = () => {
  47. menuStatus.saveActiveIndex('6')
  48. router.push({ name: 'updatePas' })
  49. }
  50. const exitFun = () => {
  51. //退出登录清除缓存
  52. visible.value = true
  53. // userInfo.clearUserInfo()
  54. //跳转到首页
  55. }
  56. const comT = () => {
  57. visible.value = false
  58. userInfo.clearUserInfo()
  59. //跳转到首页
  60. router.push({ name: 'homeView' })
  61. }
  62. //设置显示字段长度
  63. const formatterName = (val: string) => {
  64. if (val == undefined) {
  65. return ''
  66. }
  67. if (val.length > 4) {
  68. return val.substring(0, 3) + '...'
  69. } else {
  70. return val
  71. }
  72. }
  73. //打开弹出框--显示弹出框
  74. const leaveFun = () => {
  75. leave.value.open()
  76. }
  77. </script>
  78. <template>
  79. <!-- :style="{ backgroundColor: activeIndex == '1' ? '#ffffff' : '' }" -->
  80. <div class="header_qp" :style="{ backgroundColor: activeIndex == '1' ? '#ffffff' : '' }">
  81. <div class="header_p">
  82. <div class="header_image">
  83. <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
  84. <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
  85. <div>郑大计智心理测评系统</div>
  86. </div>
  87. <el-menu :default-active="activeIndex" class="el-menu-demo" style="display: flex;" mode="horizontal"
  88. :ellipsis="false" @select="handleSelect">
  89. <el-menu-item index="1">首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页</el-menu-item>
  90. <!-- <el-badge :value="200" :max="99" class="item">
  91. <el-menu-item index="4">测试计划</el-menu-item>
  92. </el-badge> -->
  93. <el-menu-item index="4">
  94. <div class="badge_custom" v-show="userInfo.planCurrentNum != 0">
  95. {{ userInfo.planCurrentNum }}
  96. </div>
  97. <span>测试计划</span>
  98. </el-menu-item>
  99. <el-menu-item index="5">
  100. <div class="badge_custom" v-show="userInfo.unreadNum != 0">
  101. {{ userInfo.unreadNum }}
  102. </div>
  103. <span>测试记录</span>
  104. </el-menu-item>
  105. <el-menu-item index="2">更多测试</el-menu-item>
  106. <el-menu-item index="3">留言社区</el-menu-item>
  107. </el-menu>
  108. <div class="login_button_bg" @mouseenter="comeMenu" @mouseleave="leaveMenu"
  109. v-show="userInfo.userInfo.userName">
  110. <img width="20px" src="../assets/home/button_login.png" />
  111. &nbsp;&nbsp;&nbsp;&nbsp;
  112. <span :title="userInfo.userInfo.userName">{{ formatterName(userInfo.userInfo.userName) }}</span>
  113. <transition>
  114. <div class="login_user" v-show="falgMenu">
  115. <div class="update_pass" @click="updatePassFun">
  116. 修改密码
  117. </div>
  118. <div class="exit_login" @click="leaveFun">
  119. 我的请假
  120. </div>
  121. <div class="exit_login" @click="exitFun">
  122. 退出登录
  123. </div>
  124. </div>
  125. </transition>
  126. </div>
  127. <div class="login_button_bg" v-show="!userInfo.userInfo.userName" @click="login">
  128. <img width="20px" src="../assets/home/button_login.png" />
  129. &nbsp;&nbsp;&nbsp;&nbsp;
  130. <span v-if="!userInfo.userInfo?.userName">登录账号</span>
  131. </div>
  132. <el-dialog v-model="visible" :show-close="true" width="500" style="border-radius: 20px;" class="dig_kg">
  133. <template #header="{ close, titleId, titleClass }">
  134. <div class="my-header" style="text-align: center;">
  135. <div class="exit_login_title">退出登录</div>
  136. <div class="exit_login_info">是否退出当前账号?</div>
  137. <div class="start_button_out">
  138. <div class="start_button_self" @click="comT">
  139. 确定
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. </el-dialog>
  145. </div>
  146. </div>
  147. <CpdmLeave ref="leave" />
  148. </template>
  149. <style scoped>
  150. :deep(.dig_kg> .el-dialog__header) {
  151. padding-right: 0px !important;
  152. }
  153. </style>
  154. <style lang="scss" scoped>
  155. .el-menu {
  156. background-color: transparent !important
  157. }
  158. .exit_login_title {
  159. text-align: center;
  160. color: #222222;
  161. font-weight: 700;
  162. font-size: 20px;
  163. letter-spacing: 3px;
  164. }
  165. .exit_login_info {
  166. text-align: center;
  167. letter-spacing: 3px;
  168. font-size: 18px;
  169. margin-top: 20px;
  170. }
  171. .start_button_out {
  172. margin-top: 40px;
  173. // margin-bottom: 40px;
  174. display: flex;
  175. flex-direction: row;
  176. justify-content: center;
  177. .start_button_self {
  178. cursor: pointer;
  179. // width: 100px;
  180. border-radius: 12px;
  181. border: 3px solid #48D68E;
  182. color: #ffffff;
  183. background-color: #000000;
  184. // margin-right: 20px;
  185. padding: 5px 50px;
  186. cursor: pointer;
  187. display: flex;
  188. align-items: center;
  189. }
  190. }
  191. .badge_custom {
  192. position: absolute;
  193. background-color: #48D68E;
  194. left: 90px;
  195. top: 0px;
  196. line-height: 18px;
  197. color: 10px;
  198. padding: 0px 8px;
  199. font-weight: 300;
  200. font-size: 10px;
  201. color: #ffffff;
  202. border-top-left-radius: 20px;
  203. border-top-right-radius: 20px;
  204. border-bottom-right-radius: 20px;
  205. }
  206. //整个菜单底部样式
  207. .el-menu--horizontal.el-menu {
  208. border-bottom: 0px solid var(--el-menu-border-color);
  209. display: flex;
  210. align-items: center;
  211. }
  212. .el-menu--horizontal>.el-menu-item {
  213. width: 120px;
  214. height: 40px;
  215. align-items: center;
  216. border-bottom: 0px solid transparent;
  217. color: var(--el-menu-text-color);
  218. display: inline-flex;
  219. // height: 100%;
  220. justify-content: center;
  221. align-items: center;
  222. border-radius: 12px;
  223. margin: 0;
  224. }
  225. .el-menu--horizontal .el-menu-item:not(.is-disabled):focus,
  226. .el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
  227. background-color: #48D68E;
  228. color: #000000 !important;
  229. border-radius: 12px;
  230. }
  231. //激活某个菜单时 底部样式
  232. .el-menu--horizontal>.el-menu-item.is-active {
  233. border-bottom: 0px solid var(--el-menu-active-color);
  234. // color: var(--el-menu-active-color) !important;
  235. color: #000000 !important;
  236. background: #48D68E;
  237. border-radius: 12px;
  238. height: 40px;
  239. font-weight: 700;
  240. }
  241. .header_qp {
  242. display: flex;
  243. justify-content: center;
  244. width: 100%;
  245. .header_p {
  246. // background-color: #ffffff;
  247. padding-top: 20px;
  248. display: flex;
  249. flex-direction: row;
  250. align-items: center;
  251. justify-content: space-between;
  252. width: 1200px;
  253. .header_image {
  254. // flex: 1
  255. // margin-right: 100px;
  256. div {
  257. color: #48D68E;
  258. font-weight: 700;
  259. font-size: 26px;
  260. -webkit-transform: skew(-10deg);
  261. letter-spacing: 2px;
  262. /* for Chrome||Safari */
  263. -ms-transform: skew(-10deg);
  264. /* for IE */
  265. -moz-transform: skew(-10deg);
  266. /* for Firefox */
  267. -o-transform: skew(-10deg);
  268. /* for Opera */
  269. }
  270. }
  271. .login_button_bg {
  272. position: relative;
  273. background-color: #000000;
  274. border-radius: 12px;
  275. border: 3px solid #48D68E;
  276. color: #ffffff;
  277. padding: 8px 20px;
  278. cursor: pointer;
  279. display: flex;
  280. align-items: center;
  281. .login_user {
  282. border-bottom-left-radius: 20px;
  283. border-bottom-right-radius: 20px;
  284. width: 80%;
  285. position: absolute;
  286. background-color: #ffffff;
  287. // bottom: -105px;
  288. bottom: -145px;
  289. margin-left: calc(10% - 20px);
  290. z-index: 200;
  291. color: #000000;
  292. .update_pass {
  293. text-align: center;
  294. margin-top: 20px;
  295. // padding: 5px;
  296. color: #999999
  297. }
  298. .update_pass:hover {
  299. text-align: center;
  300. margin-top: 20px;
  301. color: #48D68E // padding: 5px;
  302. }
  303. .exit_login {
  304. text-align: center;
  305. // padding: 5px;
  306. margin-top: 20px;
  307. margin-bottom: 20px;
  308. color: #999999
  309. }
  310. .exit_login:hover {
  311. text-align: center;
  312. // padding: 5px;
  313. margin-top: 20px;
  314. margin-bottom: 20px;
  315. color: #48D68E // padding: 5px;
  316. }
  317. }
  318. }
  319. .flex-grow {
  320. flex: 1;
  321. }
  322. .menu_gen {
  323. width: 80px;
  324. height: 20px;
  325. font-family: Alibaba PuHuiTi 2.0;
  326. font-weight: normal;
  327. font-size: 20px;
  328. color: #333333;
  329. line-height: 26px
  330. }
  331. }
  332. }
  333. </style>