header.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <transition
  3. appear
  4. name="animate__animated animate__move"
  5. enter-active-class="animate__slideInDown"
  6. leave-active-class="animate__slideOutUp"
  7. >
  8. <div class="widget-bigScreenHeader">
  9. <div class="header">
  10. <div class="title">
  11. <div class="sysIcon"></div>
  12. <div class="titleInfo">
  13. <div class="maintitle">
  14. <div class="caption">{{ title }}</div>
  15. <div class="splitLine"></div>
  16. <el-select
  17. ref="stlectTree"
  18. v-model="treeSelectText"
  19. placeholder=""
  20. :popper-append-to-body="false"
  21. :title="treeSelectText"
  22. >
  23. <el-option
  24. :value="treeValue.value"
  25. :label="treeValue.label"
  26. style="max-width: 260px; height: auto; padding: 0"
  27. >
  28. <el-tree
  29. :data="datas"
  30. :props="defaultProps"
  31. :expand-on-click-node="false"
  32. default-expand-all=""
  33. node-key="pbsTree"
  34. highlight-current
  35. @node-click="nodeClick"
  36. ref="tree"
  37. />
  38. </el-option>
  39. </el-select>
  40. </div>
  41. <div class="subtitle">{{ subtitle }}</div>
  42. </div>
  43. </div>
  44. <div class="menu" v-show="treeValue.pid === 2">
  45. <ul class="main">
  46. <li v-for="item in menuList" :key="item.name">
  47. <a
  48. :name="item.name"
  49. :class="currentProjectActive === item.name ? 'pick-on' : ''"
  50. @click="currentProjectActive = item.name"
  51. >{{ item.label }}</a
  52. >
  53. </li>
  54. </ul>
  55. </div>
  56. <div class="otherItem">
  57. <div class="specificTime">{{ specificTime }}</div>
  58. <div class="entrySys" @click="enterSys()">{{ operationName }}</div>
  59. </div>
  60. </div>
  61. <div class="underline"></div>
  62. </div>
  63. </transition>
  64. </template>
  65. <script>
  66. import Config from './config.json'
  67. import { getUserMenu } from '@/api/user'
  68. export default {
  69. name: 'bigScreenHeader', //大屏头部菜单栏
  70. data() {
  71. return {
  72. title: null, //标题
  73. subtitle: null, //副标题
  74. menuList: [], //菜单栏配置
  75. currentActive: '', //当前激活模块版块
  76. currentProjectActive: '', //当前项目级激活功能模块
  77. specificTime: null, //系统当前时间
  78. operationName: null,
  79. //
  80. treeSelectText: '三峡发展',
  81. treeValue: {
  82. value: null,
  83. label: null
  84. },
  85. datas: [
  86. {
  87. name: '三峡发展',
  88. value: '1',
  89. pid: 0,
  90. children: [
  91. {
  92. name: '三峡分公司',
  93. value: '2',
  94. pid: 1,
  95. children: [
  96. {
  97. name: '宜昌两网二期',
  98. value: '3',
  99. pid: 2
  100. }
  101. ]
  102. }
  103. ]
  104. }
  105. ],
  106. defaultProps: {
  107. children: 'children',
  108. label: 'name'
  109. }
  110. }
  111. },
  112. computed: {
  113. config() {
  114. return Config
  115. },
  116. routerData() {
  117. return this.$store.state.routeSetting.addRoutes
  118. },
  119. currentX() {
  120. return this.$store.state.bigScreen.currentActive
  121. }
  122. },
  123. mounted() {
  124. this.getUserActiveModule()
  125. this.title = this.config.title
  126. this.subtitle = this.config.subtitle
  127. this.showCurrentTime()
  128. this.getEnterText()
  129. },
  130. watch: {
  131. treeValue: {
  132. handler(val, oval) {
  133. const { label, pid } = val
  134. if (pid == 2) {
  135. this.$parent.showGroupPage = false
  136. this.$parent.showDistrictPage = true
  137. } else {
  138. this.$store.state.bigScreen.groupName = label
  139. this.$parent.showGroupPage = true
  140. this.$parent.showDistrictPage = false
  141. }
  142. },
  143. deep: true
  144. },
  145. currentProjectActive: {
  146. handler(n, o) {
  147. this.activeModule(n)
  148. this.$store.state.bigScreen.currentActive = n
  149. }
  150. // immediate:true
  151. },
  152. currentX: {
  153. handler(n, o) {
  154. this.currentProjectActive = n
  155. }
  156. }
  157. },
  158. methods: {
  159. captionClick() {
  160. this.currentProjectActive = ''
  161. },
  162. // 点击tree节点
  163. nodeClick(item) {
  164. const { name, value, pid } = item
  165. this.$set(this.treeValue, 'value', value)
  166. this.$set(this.treeValue, 'label', name)
  167. this.$set(this.treeValue, 'pid', pid)
  168. this.treeSelectText = name
  169. this.$refs.stlectTree.blur()
  170. },
  171. //获取用户激活模块
  172. getUserActiveModule() {
  173. const userId = sessionStorage.getItem('userId') || this.$store.state.user.userId
  174. getUserMenu(userId)
  175. .then((res) => {
  176. let arr = res.result.filter((item) => item.type === 'groupPage')
  177. let sort = 0
  178. arr[0].childrens.forEach((item) => {
  179. if (item.statusFlag === '1') {
  180. if (item.sort > sort) {
  181. this.menuList.push({
  182. name: item.name,
  183. label: item.label
  184. })
  185. } else {
  186. this.menuList.unshift({
  187. name: item.name,
  188. label: item.label
  189. })
  190. }
  191. sort = item.sort
  192. }
  193. })
  194. this.currentProjectActive = this.menuList[0].name
  195. })
  196. .catch((err) => {
  197. console.log(err)
  198. })
  199. },
  200. //进入系统
  201. enterSys() {
  202. if (
  203. !this.routerData.some((item) => item.label === '首页') &&
  204. !this.routerData.some((item) => item.label === '地图')
  205. ) {
  206. this.logout()
  207. } else {
  208. this.$router.push({ path: '/' })
  209. }
  210. },
  211. async logout() {
  212. await this.$store.dispatch('user/logout')
  213. this.$router.push('/login')
  214. },
  215. getEnterText() {
  216. if (
  217. !this.routerData.some((item) => item.label === '首页') &&
  218. !this.routerData.some((item) => item.label === '地图')
  219. ) {
  220. this.operationName = '退出系统'
  221. } else {
  222. this.operationName = '进入系统'
  223. }
  224. },
  225. //当前项目级页面激活模块
  226. activeModule(module) {},
  227. //系统时间显示
  228. showCurrentTime() {
  229. this.specificTime = getnow()
  230. //时间显示
  231. function getnow() {
  232. let mynow = new Date() //默认的获取的是当前时间
  233. //通过调用日期对象的方法来重新获取当前的日期时间
  234. //mynow.setFullYear(2016);
  235. let year = mynow.getFullYear() //获取年
  236. let month = mynow.getMonth() + 1 //获取月
  237. let day = mynow.getDate() //获取日
  238. let hour = mynow.getHours() //获取小时
  239. let minute = mynow.getMinutes() //获取分钟
  240. let second = mynow.getSeconds() //获取秒
  241. let strdate =
  242. year +
  243. '年' +
  244. (month < 0 ? '00' : ('0' + month).slice(-2)) +
  245. '月' +
  246. (day < 0 ? '00' : ('0' + day).slice(-2)) +
  247. '日 ' +
  248. (hour < 0 ? '00' : ('0' + hour).slice(-2)) +
  249. ':' +
  250. (minute < 0 ? '00' : ('0' + minute).slice(-2)) +
  251. ':' +
  252. (second < 0 ? '00' : ('0' + second).slice(-2)) +
  253. ''
  254. return strdate
  255. }
  256. //动态显示时间
  257. setInterval(() => {
  258. this.specificTime = getnow()
  259. }, 100)
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang='scss' scoped>
  265. .animate__slideInDown,
  266. .animate__slideOutUp {
  267. animation-duration: 3s; //动画持续时间
  268. animation-delay: 0s; //动画延迟时间
  269. }
  270. .widget-bigScreenHeader {
  271. width: 100%;
  272. position: absolute;
  273. z-index: 3;
  274. background: linear-gradient(#021a2a, rgba(2, 26, 42, 0.3));
  275. font-family: Source Han Sans CN;
  276. //public size
  277. $size30: 0.15625rem /* 30/192 */;
  278. $size28: 0.145833rem /* 28/192 */;
  279. $size20: 0.104167rem /* 20/192 */;
  280. $size17: 0.088542rem /* 17/192 */;
  281. $size16: 0.083333rem /* 16/192 */;
  282. $size14: 0.072917rem /* 14/192 */;
  283. $size10: 0.052083rem /* 10/192 */;
  284. $size8: 0.041667rem /* 8/192 */;
  285. $size3: 0.015625rem /* 3/192 */;
  286. $size1: 0.005208rem /* 1/192 */;
  287. .header {
  288. width: 100%;
  289. height: 0.375rem /* 72/192 */;
  290. display: flex;
  291. flex-flow: row nowrap;
  292. .title {
  293. padding: 0 $size20;
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. filter: hue-rotate(0deg);
  298. transition: all 1s linear;
  299. .sysIcon {
  300. background: url('~@/views/groupPage/images/标题/sysIcon.png') no-repeat;
  301. background-size: 100% 100%;
  302. width: 0.239583rem /* 46/192 */;
  303. height: 0.239583rem /* 46/192 */;
  304. margin-right: 0.052083rem /* 10/192 */;
  305. }
  306. .titleInfo {
  307. display: flex;
  308. flex-flow: column;
  309. justify-content: space-around;
  310. height: 60%;
  311. .maintitle {
  312. display: flex;
  313. align-items: center;
  314. .caption {
  315. white-space: nowrap;
  316. font-size: $size20;
  317. font-weight: bold;
  318. color: #ffffff;
  319. text-shadow: 0 0 10px rgba(65, 105, 225, 0.3), 0 0 20px rgba(65, 105, 225, 0.3),
  320. 0 0 30px rgba(65, 105, 225, 0.3), 0 0 40px rgba(65, 105, 225, 0.3);
  321. }
  322. .splitLine {
  323. width: 0.005208rem /* 1/192 */;
  324. height: 60%;
  325. background: #ffffff;
  326. opacity: 0.6;
  327. margin: 0 0.0625rem /* 12/192 */;
  328. }
  329. /deep/ .el-select {
  330. display: block;
  331. width: 0.78125rem /* 150/192 */;
  332. font-size: 0.104167rem /* 20/192 */;
  333. font-weight: 500;
  334. font-family: Source Han Sans CN-MEDIUM;
  335. .el-input__inner {
  336. font-family: Source Han Sans CN-MEDIUM;
  337. padding-left: 0;
  338. padding-right: 0.260417rem /* 50/192 */;
  339. background: transparent;
  340. border: none;
  341. color: #2ba7ff;
  342. }
  343. .el-input {
  344. font-size: inherit;
  345. }
  346. .el-input__suffix {
  347. right: 0.15625rem /* 30/192 */;
  348. }
  349. .el-select__caret {
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. }
  354. .el-icon-arrow-up:before {
  355. content: '';
  356. display: block;
  357. width: 0;
  358. height: 0;
  359. border-top: 10px solid #2ba7ff;
  360. border-right: 7px solid transparent;
  361. border-left: 7px solid transparent;
  362. transform: rotate(180deg);
  363. }
  364. }
  365. /deep/ .el-tree {
  366. background: #023c5d;
  367. color: #f9fdff;
  368. .el-tree-node__content {
  369. background: transparent;
  370. }
  371. .el-tree-node__content:hover {
  372. background: transparent;
  373. color: #2ba7ff;
  374. }
  375. }
  376. /deep/ .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  377. background: transparent;
  378. color: #2ba7ff;
  379. }
  380. }
  381. .subtitle {
  382. font-size: 0.057292rem /* 11/192 */;
  383. font-weight: 400;
  384. color: #feffff;
  385. }
  386. }
  387. }
  388. .menu {
  389. // width: 60%;
  390. white-space: nowrap;
  391. ul {
  392. list-style: none;
  393. padding: $size10;
  394. margin: 0 0 0 $size10;
  395. }
  396. .main {
  397. width: 100%;
  398. display: flex;
  399. }
  400. .main > li {
  401. margin: $size8 $size20;
  402. float: left;
  403. }
  404. .main > li a {
  405. text-align: center;
  406. }
  407. a {
  408. text-decoration: none;
  409. color: #fefefe;
  410. text-transform: capitalize;
  411. display: block;
  412. padding: $size10 0;
  413. transition: background-color 0.5s ease-in-out;
  414. font-size: $size16;
  415. font-weight: 400;
  416. }
  417. a:hover,
  418. .pick-on {
  419. cursor: pointer;
  420. color: #0ea7ff;
  421. font-weight: bold;
  422. border-bottom: 2px solid;
  423. }
  424. }
  425. .otherItem {
  426. width: 20%;
  427. height: 100%;
  428. font-size: $size14;
  429. font-weight: 400;
  430. display: flex;
  431. align-items: center;
  432. position: absolute;
  433. right: 20px;
  434. .specificTime {
  435. flex: 2;
  436. top: 25%;
  437. text-align: center;
  438. font-weight: 400;
  439. color: #a8d3f1;
  440. }
  441. .entrySys {
  442. flex: 0.6;
  443. color: #a8d3f1;
  444. background: url('~@/views/groupPage/images/entrySys.png') no-repeat;
  445. background-size: 100% 100%;
  446. height: 50%;
  447. display: flex;
  448. align-items: center;
  449. justify-content: center;
  450. white-space: nowrap;
  451. }
  452. .entrySys:hover {
  453. cursor: pointer;
  454. color: #a8d3f1;
  455. background: url('~@/views/groupPage/images/entrySysHover.png') no-repeat;
  456. background-size: 100% 100%;
  457. }
  458. }
  459. }
  460. .underline {
  461. width: 9.796875rem /* 1881/192 */;
  462. height: 0.010417rem /* 2/192 */;
  463. background: url('~@/views/groupPage/images/标题/顶部线.png') no-repeat center center;
  464. background-size: 100% 100%;
  465. margin: 0 $size20;
  466. }
  467. }
  468. </style>