Head.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="head-wrapper">
  3. <div class="head-logo">
  4. <svg-icon icon-class="zhihui-logo" @click="topHome()" />
  5. </div>
  6. <div v-for="item in headList" :key="item.path" class="nav-tag" :class="{'active-nav-tag':activeNavTag === item.name}" @click="changeNavTag(item)">
  7. <div v-if="item.icon" class="icon">
  8. <div v-show="notice && item.name.search(/个人工作台/)>=0" class="if-notice" />
  9. <svg-icon :icon-class="item.icon" />
  10. </div>
  11. <div class="name">{{ item.name }}</div>
  12. </div>
  13. <div @mouseleave="target = true">
  14. <div :class="[target ? 'nav-div1' : 'nav-div2']">
  15. <el-tooltip v-if="!target" class="item" effect="dark" content="工具集合" placement="right">
  16. <div class="div-child" @click="goto('Interface')"><svg-icon icon-class="b_工具集合" /></div>
  17. </el-tooltip>
  18. <el-tooltip v-if="!target" class="item" effect="dark" content="环境平台" placement="right">
  19. <div class="div-child" @click="goto('env')"><svg-icon icon-class="b_环境平台" /></div>
  20. </el-tooltip>
  21. </div>
  22. <div class="nav-div3 nav-circular" />
  23. <div class="nav-div4 nav-circular" @mouseenter="target = false" />
  24. </div>
  25. <!-- <div v-show="navTagType === 2" class="nav-tag-type" @click="setNavTagType(1)">
  26. <i class="el-icon-notebook-2" style="transform: rotate(90deg);" />
  27. </div>
  28. <div v-show="navTagType === 1" class="nav-tag-type" @click="setNavTagType(2)">
  29. <i class="el-icon-notebook-2" />
  30. </div> -->
  31. <el-tooltip class="item" effect="dark" content="用户指导手册" placement="right">
  32. <el-link class="user-tip" href="https://base3.xiaojukeji.com/docs/zhihui/" target="_blank">
  33. <svg-icon style="width: 24px; height: 24px;" icon-class="question" />
  34. </el-link>
  35. </el-tooltip>
  36. <div v-if="userInfo" class="user-info">
  37. <a-popover placement="rightBottom" trigger="click" overlay-class-name="head-popover">
  38. <template #content>
  39. <div class="user-admin-one">
  40. <div class="title line">
  41. <svg-icon icon-class="setting" class="icon" />
  42. <span class="label">设置</span>
  43. </div>
  44. <div class="item mb16">
  45. <div class="label line">
  46. <el-switch
  47. :value="navTagType === 1"
  48. :size="size"
  49. class="mr10"
  50. @change="setNavTagType(navTagType === 2 ? 1: 2)"
  51. />
  52. <span class="text">左侧导航</span>
  53. <el-tooltip effect="dark" content="可设置为“左侧导航”或“顶部导航”'" placement="top-start">
  54. <i class="el-icon-info" style="vertical-align: text-bottom;" />
  55. </el-tooltip>
  56. </div>
  57. <div class="label line">
  58. <el-switch
  59. :value="openPageHandle === 'blank'"
  60. :size="size"
  61. class="mr10"
  62. @change="setOpenPageHandle(openPageHandle === 'blank' ? 'self' : 'blank')"
  63. />
  64. <span class="text">详情页新标签页打开</span>
  65. <el-tooltip effect="dark" content="可设置详情页在新标签页打开,或当前标签页打开。" placement="top-start">
  66. <i class="el-icon-info" style="vertical-align: text-bottom;" />
  67. </el-tooltip>
  68. </div>
  69. </div>
  70. <div class="title line clickText" @click="administratorsJump()">
  71. <span v-if="memberCheck">
  72. <svg-icon icon-class="admin" class="icon" />
  73. <span class="label">管理员</span>
  74. </span>
  75. </div>
  76. <div class="item">
  77. <div class="label">
  78. {{ userInfo.name }} {{ userInfo.idap }}
  79. </div>
  80. <div class="label">
  81. <span class="outLogin">
  82. <!-- <svg-icon icon-class="admin" class="icon mr10" /> -->
  83. <i class="el-icon-switch-button icon" style="margin-right:4px" />
  84. <span class="label">退出</span>
  85. </span>
  86. <!-- <el-button type="primary" plain size="small" @click="layout()">退出登录</el-button> -->
  87. </div>
  88. </div>
  89. <!-- <div class="user-name">{{ userInfo.name }}</div>
  90. <div class="line" />
  91. <div class="user-logout">
  92. <el-button v-if="navTagType === 1" type="primary" plain size="small" @click="setNavTagType(2)">顶部导航</el-button>
  93. <el-button v-if="navTagType === 2" type="primary" plain size="small" @click="setNavTagType(1)">侧边导航</el-button>
  94. </div>
  95. <div class="line" />
  96. <div v-if="memberCheck" class="user-logout">
  97. <el-button type="primary" plain size="small" @click="administratorsJump()"> 管 理 员 </el-button>
  98. </div>
  99. <div v-if="memberCheck" class="line" />
  100. <div class="user-logout">
  101. <el-button type="primary" plain size="small" @click="layout()">退出登录</el-button>
  102. </div> -->
  103. </div>
  104. </template>
  105. <img :src="userInfo.phoneUrl">
  106. </a-popover>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { mapGetters } from 'vuex'
  112. import routes from '@/router/newRouter'
  113. import websocket from '@/views/workbench/mixins/websocket'
  114. import { memberGetLoginInMemberInfoByLdap } from '@/api/projectIndex'
  115. import { logoutUrl } from '@/apiConfig/requestIP.js'
  116. import { verifyIsAdmin } from '@/api/configure.js'
  117. export default {
  118. mixins: [websocket],
  119. data() {
  120. return {
  121. size: 'small',
  122. headList: routes.filter(item => item.name !== '业务线'),
  123. userInfo: null,
  124. memberCheck: false,
  125. target: true,
  126. openPageHandle: localStorage.getItem('openPageHandle') || 'blank'
  127. }
  128. },
  129. computed: {
  130. ...mapGetters(['activeNavTag', 'navTagType', 'notice'])
  131. },
  132. watch: {
  133. $route: {
  134. handler(to) {
  135. this.findRoute(to.name)
  136. },
  137. immediate: true
  138. }
  139. },
  140. created() {
  141. this.getLoginUser()
  142. this.verifyIsAdmin()
  143. },
  144. methods: {
  145. goto(name) {
  146. window.log({ c: 'project', d: `goto_${name}` })
  147. this.$router.push({ name })
  148. },
  149. getTarget() {
  150. this.target = !this.target
  151. },
  152. findRoute(routeName) {
  153. for (const element of routes) {
  154. if (element.name === routeName) {
  155. // 先对父元素进行查找
  156. this.$store.dispatch('global/setActiveNavTag', element.name)
  157. } else if (element.children) {
  158. const child = element.children.find(item => item.name === routeName) // 对子元素进行查找
  159. child ? this.$store.dispatch('global/setActiveNavTag', element.name) : '' // 父元素的名字设为路径
  160. }
  161. }
  162. },
  163. // 切换二级导航
  164. changeNavTag(nav) {
  165. this.$store.dispatch('global/setActiveNavTag', nav.name) // 设置二级导航的类别
  166. this.$router.push({ name: nav.name }) // 跳转
  167. },
  168. // 设置二级导航类型
  169. setNavTagType(type) {
  170. if (type === 2) {
  171. window.log({ c: 'sys_setting', d: 'change_nav_bar_top' })
  172. } else {
  173. window.log({ c: 'sys_setting', d: 'change_nav_bar_side' })
  174. }
  175. this.$store.dispatch('global/setNavTagType', type)
  176. localStorage.setItem('navTagType', type)
  177. },
  178. setOpenPageHandle(type) {
  179. this.openPageHandle = type
  180. localStorage.setItem('openPageHandle', type)
  181. },
  182. // 获取登录人员信息
  183. async getLoginUser() {
  184. const res = await memberGetLoginInMemberInfoByLdap()
  185. if (res && res.data) this.userInfo = res.data || null
  186. console.log(res.data)
  187. },
  188. // 查看是否为管理员
  189. async verifyIsAdmin() {
  190. const res = await verifyIsAdmin()
  191. if (res.code === 200) this.memberCheck = res.data
  192. },
  193. // 退出登录
  194. layout() {
  195. window.location.href = logoutUrl
  196. },
  197. topHome() {
  198. this.$router.push({ path: '/' })
  199. },
  200. administratorsJump() {
  201. if (this.memberCheck) {
  202. this.$router.push({ name: '管理员' })
  203. }
  204. },
  205. // websocket数据接收
  206. websocketonmessage(e) {
  207. const { hasReminding } = JSON.parse(e.data)
  208. if (hasReminding) {
  209. this.$store.dispatch('data/setNotice', true)
  210. const link = document.querySelector('link')
  211. link.href = link.href.replace(/favicon.ico/, 'favicon-tips.ico')
  212. } else {
  213. this.$store.dispatch('data/setNotice', false)
  214. const link = document.querySelector('link')
  215. link.href = link.href.replace(/favicon-tips.ico/, 'favicon.ico')
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .mr10 {
  223. margin-right: 10px;
  224. }
  225. .mb16 {
  226. margin-bottom: 16px;
  227. }
  228. .head-wrapper {
  229. display: flex;
  230. flex-direction: column;
  231. flex-shrink: 0;
  232. z-index: 99;
  233. width: 80px;
  234. align-items: center;
  235. background: #409eff;
  236. font-size: 20px;
  237. color: #333;
  238. padding-top: 17px;
  239. }
  240. .head-logo {
  241. height: 40px;
  242. width: 40px;
  243. margin-bottom: 42px;
  244. .svg-icon {
  245. cursor: pointer;
  246. width: 100%;
  247. height: 100%;
  248. }
  249. }
  250. .nav-tag {
  251. width: 100%;
  252. font-size: 14px;
  253. color: #ffffff;
  254. text-align: center;
  255. margin-bottom: 20px;
  256. padding: 5px 0 9px 0;
  257. cursor: pointer;
  258. .icon {
  259. position: relative;
  260. color: #ffffff;
  261. height: 27px;
  262. width: 33px;
  263. margin: 7px auto;
  264. font-size: 32px;
  265. }
  266. .svg-icon {
  267. position: absolute;
  268. top: 0;
  269. left: 0;
  270. width: 100%;
  271. height: 100%;
  272. }
  273. .if-notice {
  274. position: absolute;
  275. z-index: 1;
  276. height: 8px;
  277. width: 8px;
  278. background-color: #E02020;
  279. border-radius: 50%;
  280. top: 0;
  281. right: 0;
  282. transform: translateY(-50%);
  283. }
  284. }
  285. .active-nav-tag {
  286. background-color: #1E89F7;
  287. }
  288. .nav-tag-type {
  289. margin-top: auto;
  290. color: #ffffff;
  291. cursor: pointer;
  292. }
  293. .user-tip {
  294. margin-top: auto;
  295. margin-bottom: 20px;
  296. }
  297. .user-info {
  298. height: 30px;
  299. width: 30px;
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. background-color: #fff;
  304. border-radius: 50%;
  305. overflow: hidden;
  306. // margin-top: auto;
  307. margin-bottom: 30px;
  308. img {
  309. height: 30px;
  310. }
  311. }
  312. .user-admin-one {
  313. // height: 190px;
  314. .title {
  315. cursor: no-drop;
  316. .icon {
  317. margin-right: 5px;
  318. font-size: 12px;
  319. color: #409EFF;
  320. }
  321. .label {
  322. color: #444;
  323. font-size: 14px;
  324. }
  325. }
  326. .line {
  327. margin-bottom: 10px;
  328. min-height: 21px;
  329. &.clickText {
  330. cursor: pointer;
  331. margin-bottom: 16px;
  332. .label {
  333. color: #409EFF;
  334. }
  335. }
  336. }
  337. .item {
  338. margin-left: 18px;
  339. cursor: pointer;
  340. .label {
  341. color: #444;
  342. font-size: 12px;
  343. .text {
  344. display: inline-block;
  345. vertical-align: bottom;
  346. margin-right: 4px
  347. }
  348. }
  349. }
  350. .outLogin {
  351. display: inline-block;
  352. margin-top: 5px;
  353. .icon {
  354. display: inline-block;
  355. color: #409EFF;
  356. font-size: 14px;
  357. }
  358. .label {
  359. color: #409EFF;
  360. font-size: 14px;
  361. }
  362. }
  363. // width: 95px;
  364. // display: flex;
  365. // flex-direction: column;
  366. // display: grid;
  367. // grid-template-rows: 47px 1px 47px 1px 47px;
  368. // justify-items: center;
  369. // align-items: center;
  370. // .line {
  371. // width: 100%;
  372. // height: 1px;
  373. // background-color: rgba(112, 112, 112, 0.2);
  374. // }
  375. }
  376. // .user-control {
  377. // width: 95px;
  378. // display: flex;
  379. // flex-direction: column;
  380. // display: grid;
  381. // grid-template-rows: 47px 1px 47px 1px 47px;
  382. // justify-items: center;
  383. // align-items: center;
  384. // .line {
  385. // width: 100%;
  386. // height: 1px;
  387. // background-color: rgba(112, 112, 112, 0.2);
  388. // }
  389. // }
  390. </style>
  391. <style lang="scss" scoped>
  392. .head-popover {
  393. box-shadow: 10px 0px 11px #dedede;
  394. /deep/ .ant-popover-inner-content {
  395. padding: 0;
  396. }
  397. }
  398. .nav-div1 {
  399. width:25px;height:50px;border-radius: 0 50px 50px 0;line-height:50px;background: #6cb5ff; position: absolute; bottom: 172px; left: 0;border: 1px solid #6cb5ff;animation:myfirsts 0.5s;
  400. }
  401. .nav-div2 {
  402. bottom: 137px; width:60px; height:120px; line-height:120px;border-radius: 0 80px 80px 0;;background: #6cb5ff; position: absolute; left: 0;animation:myfirst 1s;
  403. }
  404. @keyframes myfirst
  405. {
  406. from {bottom: 172px; width:25px; height:50px; line-height:50px;}
  407. to {bottom: 137px; width:60px; height:120px; line-height:120px;}
  408. }
  409. @keyframes myfirsts
  410. {
  411. from {bottom: 137px; width:60px; height:120px; line-height:120px;}
  412. to {bottom: 172px; width:25px; height:50px; line-height:50px;}
  413. }
  414. .nav-div3 {
  415. width:25px;
  416. height:50px;
  417. line-height:50px;
  418. background: #FFF;
  419. bottom: 172px;
  420. border: 1px solid #FFF;
  421. opacity: 0.63;
  422. }
  423. .nav-div4 {
  424. width:20px;
  425. height:40px;
  426. line-height:45px;
  427. background: #FFF;
  428. bottom: 177px;
  429. border: 1px solid #FFF;
  430. }
  431. .div-child {
  432. text-align: right;
  433. margin-right: 19px;
  434. line-height: 61px;
  435. cursor: pointer;
  436. opacity: 1;
  437. animation:myfirs 3s;
  438. }
  439. @keyframes myfirs
  440. {
  441. from {opacity: 0}
  442. to {opacity: 1}
  443. }
  444. .nav-circular {
  445. position: absolute;
  446. left: 0;
  447. border-radius: 0 50px 50px 0;
  448. cursor: pointer;
  449. }
  450. </style>