commonHeaders.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="proheader">
  3. <el-container>
  4. <el-header :class="getStyle()">
  5. <div class="logoSty">
  6. <img src="../assets/logoG.png" alt="">
  7. </div>
  8. </el-header>
  9. </el-container>
  10. </div>
  11. </template>
  12. <script>
  13. import { apiGetpersonalInformation } from '../api/api'
  14. import { removeToken } from '../api/auth'
  15. export default {
  16. name:'headerCom',
  17. data() {
  18. return {
  19. leftIndex: '1',
  20. currentTime: '',
  21. showRole: true,
  22. menuData: [],
  23. rainW: false,
  24. userName: ''
  25. }
  26. },
  27. created() {
  28. this.menuData = [
  29. {
  30. index: '/index',
  31. icon: 'Menu',
  32. name: '概要',
  33. showBac: true
  34. },
  35. {
  36. index: '/panoramicPower',
  37. icon: 'Histogram',
  38. name: '全景功率'
  39. },
  40. {
  41. index: '/powerPrediction',
  42. icon: 'TrendCharts',
  43. name: '功率预测'
  44. },
  45. {
  46. index: '/batteryDiviner',
  47. icon: 'TrendCharts',
  48. name: '电量预测'
  49. },
  50. {
  51. index: '/powerControl',
  52. icon: 'Platform',
  53. name: '功率管控'
  54. },
  55. {
  56. index: '/weather',
  57. icon: 'PictureFilled',
  58. name: '天气预报'
  59. },
  60. {
  61. index: '/statisticalSummary',
  62. icon: 'List',
  63. name: '统计汇总'
  64. },
  65. {
  66. // index: 'http://120.46.129.85:7788/dashboard/marketBoundary',
  67. index: 'http://10.155.32.7:8084',
  68. icon: 'Connection',
  69. name: '智能营销'
  70. },
  71. // {
  72. // index: '/datasExport',
  73. // icon: 'Download',
  74. // name: '数据导出'
  75. // },
  76. {
  77. index: '/draggableTest',
  78. icon: 'Download',
  79. name: '拖拽测试'
  80. }
  81. ]
  82. },
  83. mounted() {
  84. let that = this;
  85. let userMes = JSON.parse(window.sessionStorage.getItem('userMessage'))
  86. that.userName = userMes ? userMes.role : 'administrator'
  87. if (this.$route.query.markKey) {
  88. that.userName = that.$route.query.userid
  89. }
  90. if (userMes && userMes.role === 'ordinaryUser') {
  91. that.showRole = false
  92. }
  93. // that.getUserMes(userMes.userId)
  94. },
  95. watch:{
  96. $route: {
  97. handler: function(route) {
  98. console.log(route)
  99. this.menuData.forEach(it =>{
  100. if (it.index === route.path) {
  101. it.showBac = true
  102. } else {
  103. it.showBac = false
  104. }
  105. })
  106. },
  107. immediate: true
  108. }
  109. },
  110. methods:{
  111. changeRoute(item) {
  112. if (item.name === '智能营销') {
  113. let url = ''
  114. if (location.origin.indexOf('10.15.32.7') !== -1) {
  115. url = location.origin + '/#/dashboard/marketBoundary' + `?userid=uuu&markKey=YXSSO`
  116. } else {
  117. url = item.index
  118. }
  119. window.open(url, '_self')
  120. } else {
  121. this.$router.push({ path: item.index})
  122. }
  123. },
  124. async backLogin() {
  125. let loginName = this.userName
  126. if (loginName) {
  127. await this.LogoutInfor(loginName)
  128. }
  129. },
  130. // 插入登出信息
  131. LogoutInfor(name) {
  132. let that = this
  133. let onlyData = JSON.parse(window.sessionStorage.getItem('userDatamsg'))
  134. let loginData = JSON.parse(window.sessionStorage.getItem('loginMsg'))
  135. if (onlyData) {
  136. let paramsLogin = onlyData ? onlyData.identifier : loginData.identific
  137. let params={
  138. identifier: paramsLogin,
  139. loginName: name
  140. }
  141. apiGetinsertLogoutInformation(params).then(datas=>{
  142. if (datas) {
  143. let url = location.origin + '/#/login'
  144. window.open(url, '_self')
  145. location.reload()
  146. removeToken()
  147. }
  148. })
  149. } else {
  150. let url = location.origin + '/#/login'
  151. window.open(url, '_self')
  152. location.reload()
  153. removeToken()
  154. }
  155. },
  156. changeSetting() {
  157. this.$router.push({ path: '/systemSettings/Overview'})
  158. },
  159. changePersonRole() {
  160. this.$router.push({ path: '/personnelRole'})
  161. },
  162. getStyle() {
  163. if (this.$route.path === '/weather') {
  164. if (this.rainW) {
  165. return 'weatherSty'
  166. } else {
  167. return 'headerSty'
  168. }
  169. }
  170. },
  171. getColor(val) {
  172. let strWea = ''
  173. if (val) {
  174. strWea = 'changeBacksty'
  175. } else {
  176. strWea = 'defaultBacksty'
  177. }
  178. return strWea
  179. },
  180. //获取个人信息
  181. getUserMes(id) {
  182. let params = {
  183. userId: id
  184. }
  185. apiGetpersonalInformation(params).then(datas =>{
  186. window.sessionStorage.setItem('userInfo', JSON.stringify(datas.data.user))
  187. })
  188. },
  189. changeDate(date) {
  190. var y = date.getFullYear();
  191. var m = date.getMonth() + 1;
  192. m = m < 10 ? ('0' + m) : m;
  193. var d = date.getDate();
  194. d = d < 10 ? ('0' + d) : d;
  195. var h = date.getHours();
  196. h=h < 10 ? ('0' + h) : h;
  197. var minute = date.getMinutes();
  198. minute = minute < 10 ? ('0' + minute) : minute;
  199. var second=date.getSeconds();
  200. second=second < 10 ? ('0' + second) : second;
  201. return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second
  202. },
  203. nowTime() {
  204. let that = this;
  205. let date = new Date()
  206. this.statusTimer = setInterval(function () {
  207. var y = date.getFullYear();
  208. var m = date.getMonth() + 1;
  209. m = m < 10 ? ('0' + m) : m;
  210. var d = date.getDate();
  211. d = d < 10 ? ('0' + d) : d;
  212. var h = date.getHours();
  213. h=h < 10 ? ('0' + h) : h;
  214. var minute = date.getMinutes();
  215. minute = minute < 10 ? ('0' + minute) : minute;
  216. var second=date.getSeconds();
  217. second=second < 10 ? ('0' + second) : second;
  218. that.currentTime = y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
  219. }, 1000)
  220. },
  221. handleSelect(index){
  222. if (this.leftIndex === index) return
  223. this.leftIndex = index
  224. // this.$router.push({path: index})
  225. console.log(index)
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="less">
  231. .proheader{
  232. position: fixed;
  233. top: 0;
  234. width: 100%;
  235. z-index: 1999;
  236. .weatherSty{
  237. background: rgb(74, 87, 100);
  238. }
  239. .el-header {
  240. padding: 0 10px;
  241. display:flex;
  242. justify-content: space-between;
  243. background: rgb(13, 104, 188);
  244. // background: rgba(96,103,105,.75);
  245. color: #fff;
  246. line-height: 60px;
  247. height: 60px !important;
  248. .logoSty{
  249. padding: 10px 0 0 0;
  250. img{
  251. width: 310px;
  252. }
  253. }
  254. .proMenu{
  255. display: flex;
  256. align-items: center;
  257. .el-button-group{
  258. .changeBacksty{
  259. background-color: #504bb5 !important;
  260. }
  261. .defaultBacksty{
  262. background-color: #373590 !important;
  263. }
  264. .defaultweathersty{
  265. background-color: #0d68bc !important;
  266. }
  267. .defaultweatherRainsty{
  268. background-color: #4a5764 !important;
  269. }
  270. .el-button{
  271. background-color: #373590;
  272. border-color: #8679df;
  273. padding: 0 20px;
  274. &:hover {
  275. background-color: #504bb5;
  276. }
  277. }
  278. }
  279. .userMsg{
  280. margin-left: 150px;
  281. .el-icon{
  282. cursor: pointer;
  283. }
  284. }
  285. .divider{
  286. position: relative;
  287. top: -3px;
  288. }
  289. .settingStop{
  290. .el-icon{
  291. cursor: pointer;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. </style>