appHeader.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <div id="appHeader">
  3. <div id="headerContent">
  4. <mu-appbar style="width: 100%;" color="primary">
  5. <mu-button icon slot="left">
  6. <mu-button ref="button" @click="open = !open">
  7. <img src="../static/images/comm/list.png" alt="" class="listBtn">
  8. </mu-button>
  9. <mu-popover cover :open.sync="open" :trigger="trigger">
  10. <mu-list>
  11. <mu-list-item button :class="[{'active':t == curLi},'modalLi' ]"
  12. v-for="(panel,t) in panelData" :key="panel.tabs" @click="goPage(panel)">
  13. <mu-list-item-title>
  14. <!--<span :class="panel.img"></span>-->
  15. <mu-icon :value="panel.img"></mu-icon>
  16. <s>{{panel.name}}</s>
  17. </mu-list-item-title>
  18. </mu-list-item>
  19. </mu-list>
  20. </mu-popover>
  21. </mu-button>
  22. {{curTitle}}
  23. <mu-menu slot="right">
  24. <img src="../static/images/comm/user.png" alt="" class="userBtn">
  25. </mu-menu>
  26. </mu-appbar>
  27. <div class="alertRed" v-show="alertState && title == '系统首页'">
  28. <em>
  29. <i class="curIcon yellowTri"></i>
  30. 发现危险设备{{dangerNum}} {{$t("item")}}
  31. </em>
  32. <span @click="goRuntime">{{$t("Suspicious device")}}MAC:{{mac}} 品牌:{{MacCom}} <i
  33. @click="closeAlert">×</i></span>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import axios from 'axios';
  40. let qs = require('qs');
  41. export default {
  42. data() {
  43. return {
  44. open: false,
  45. trigger: null,
  46. curLi: 0,
  47. curTitle: this.title,
  48. alertState: false,
  49. dangerNum: 0,
  50. mac: '',
  51. MacCom: '',
  52. panelData: [
  53. {name: this.$t('System home page'), path: '', img: 'home', tabs: 1},
  54. {name: this.$t('User list'), path: 'usermanage', img: 'account_box', tabs: 2},
  55. {name: this.$t('Enterprise list'), path: 'enterprisemanage', img: 'assignment', tabs: 3},
  56. {name: this.$t('Detection equipment'), path: 'detector', img: 'laptop', tabs: 4},
  57. {name: this.$t('Detection record'), path: 'record', img: 'reorder', tabs: 5},
  58. {name: this.$t('Statistical report forms'), path: 'statis', img: 'receipt', tabs: 6},
  59. {name: this.$t('System setup'), path: 'setting', img: 'settings', tabs: 7},
  60. {name: this.$t('whiteList'), path: 'white', img: 'view_list', tabs: 8},
  61. {name: this.$t('Real-time monitoring'), path: 'runtime', img: 'poll', tabs: 9},
  62. ]
  63. }
  64. },
  65. props: ['title'],
  66. mounted() {
  67. this.trigger = this.$refs.button.$el;
  68. this.timer = setInterval(() => {
  69. this.readAlert();
  70. }, 5000);
  71. },
  72. beforeDestroy() {
  73. clearInterval(this.timer);
  74. },
  75. methods: {
  76. goPage(panel) {
  77. console.log(panel);
  78. this.$emit('goNewpage', panel.path);
  79. this.open = false;
  80. },
  81. goRuntime() {
  82. this.alertState = false;
  83. this.$emit('goNewpage', 'runtime');
  84. this.open = false;
  85. },
  86. // 读取警告信息
  87. readAlert() {
  88. const that = this;
  89. let url = headapi + 'v1/Detector/DetectedMacs';
  90. // let url = headapi + 'v1/Detector/DetectedMacsTest';//test
  91. let param = {
  92. token: localStorage.token,
  93. };
  94. let postdata = qs.stringify(param);
  95. axios.post(url, postdata).then(function (data) {
  96. let json = data.data;
  97. if (json.Code == 0) {
  98. if (json.Rs) {
  99. if (localStorage.alertState == true) {
  100. that.alertState = true;
  101. } else {
  102. that.alertState = false;
  103. }
  104. that.dangerNum = json.Rs.length;
  105. that.mac = json.Rs[0].Mac;
  106. if (json.Rs[0].MacCom) {
  107. that.MacCom = json.Rs[0].MacCom.substr(0, 9) + '...';
  108. }
  109. }
  110. }
  111. if (json.Code == 1010) {
  112. that.$router.push({path: '/login'});
  113. }
  114. }, function (response) {
  115. that.$router.push({path: '/login'});
  116. console.info(response);
  117. })
  118. },
  119. closeAlert() {
  120. this.alertState = false
  121. }
  122. },
  123. }
  124. </script>
  125. <style scoped>
  126. #appHeader {
  127. width: 100%;
  128. height: 55px;
  129. z-index: 99999;
  130. }
  131. #headerContent {
  132. width: 100%;
  133. position: absolute;
  134. z-index: 99999;
  135. top: 0;
  136. }
  137. /deep/ .mu-appbar-title {
  138. text-align: center;
  139. }
  140. .mu-raised-button {
  141. background: none;
  142. box-shadow: none;
  143. }
  144. .listBtn {
  145. width: 20px;
  146. height: 14px;
  147. overflow: hidden;
  148. display: block;
  149. margin: 0 auto;
  150. margin-top: 0px;
  151. }
  152. .userBtn {
  153. width: 28px;
  154. height: 28px;
  155. margin-top: 15px;
  156. margin-right: 15px;
  157. }
  158. .mu-appbar {
  159. background: url("../static/images/comm/headerBg.png") top center no-repeat;
  160. background-size: 100%;
  161. }
  162. /*icon iconHome*/
  163. .iconHome {
  164. width: 20px;
  165. height: 20px;
  166. float: left;
  167. margin-right: 10px;
  168. background: url("../static/images/comm/iconHome.png") top center no-repeat;
  169. background-size: 100%;
  170. }
  171. .active .iconHome {
  172. width: 20px;
  173. height: 20px;
  174. float: left;
  175. margin-right: 10px;
  176. background: url("../static/images/comm/iconHome_a.png") top center no-repeat;
  177. background-size: 100%;
  178. }
  179. .iconUser {
  180. width: 20px;
  181. height: 20px;
  182. float: left;
  183. margin-right: 10px;
  184. background: url("../static/images/comm/iconUser.png") top center no-repeat;
  185. background-size: 100%;
  186. }
  187. .active .iconUser {
  188. width: 20px;
  189. height: 20px;
  190. float: left;
  191. margin-right: 10px;
  192. background: url("../static/images/comm/iconUser_a.png") top center no-repeat;
  193. background-size: 100%;
  194. }
  195. .iconProfile {
  196. width: 20px;
  197. height: 20px;
  198. float: left;
  199. margin-right: 10px;
  200. background: url("../static/images/comm/iconProfile.png") top center no-repeat;
  201. background-size: 100%;
  202. }
  203. .active .iconProfile {
  204. width: 20px;
  205. height: 20px;
  206. float: left;
  207. margin-right: 10px;
  208. background: url("../static/images/comm/iconProfile_a.png") top center no-repeat;
  209. background-size: 100%;
  210. }
  211. .iconEquipmanage {
  212. width: 20px;
  213. height: 20px;
  214. float: left;
  215. margin-right: 10px;
  216. background: url("../static/images/comm/iconEquipmanage.png") top center no-repeat;
  217. background-size: 100%;
  218. }
  219. .active .iconEquipmanage {
  220. width: 20px;
  221. height: 20px;
  222. float: left;
  223. margin-right: 10px;
  224. background: url("../static/images/comm/iconEquipmanage_a.png") top center no-repeat;
  225. background-size: 100%;
  226. }
  227. .iconRecord {
  228. width: 20px;
  229. height: 20px;
  230. float: left;
  231. margin-right: 10px;
  232. background: url("../static/images/comm/iconRecord.png") top center no-repeat;
  233. background-size: 100%;
  234. }
  235. .active .iconRecord {
  236. width: 20px;
  237. height: 20px;
  238. float: left;
  239. margin-right: 10px;
  240. background: url("../static/images/comm/iconRecord_a.png") top center no-repeat;
  241. background-size: 100%;
  242. }
  243. .iconStatis {
  244. width: 20px;
  245. height: 20px;
  246. float: left;
  247. margin-right: 10px;
  248. background: url("../static/images/comm/iconStatis.png") top center no-repeat;
  249. background-size: 100%;
  250. }
  251. .active .iconStatis {
  252. width: 20px;
  253. height: 20px;
  254. float: left;
  255. margin-right: 10px;
  256. background: url("../static/images/comm/iconStatis_a.png") top center no-repeat;
  257. background-size: 100%;
  258. }
  259. .iconMap {
  260. width: 20px;
  261. height: 20px;
  262. float: left;
  263. margin-right: 10px;
  264. background: url("../static/images/comm/iconMap.png") top center no-repeat;
  265. background-size: 100%;
  266. }
  267. .active .iconMap {
  268. width: 20px;
  269. height: 20px;
  270. float: left;
  271. margin-right: 10px;
  272. background: url("../static/images/comm/iconMap_a.png") top center no-repeat;
  273. background-size: 100%;
  274. }
  275. .iconRuntime {
  276. width: 20px;
  277. height: 20px;
  278. float: left;
  279. margin-right: 10px;
  280. background: url("../static/images/comm/iconRuntime.png") top center no-repeat;
  281. background-size: 100%;
  282. }
  283. .active .iconRuntime {
  284. width: 20px;
  285. height: 20px;
  286. float: left;
  287. margin-right: 10px;
  288. background: url("../static/images/comm/iconRuntime_a.png") top center no-repeat;
  289. background-size: 100%;
  290. }
  291. .modalLi span {
  292. width: 20px;
  293. height: 20px;
  294. margin-right: 0px !important;
  295. }
  296. .modalLi s {
  297. text-decoration: none;
  298. font-size: 14px;
  299. line-height: 30px;
  300. padding-left: 10px;
  301. float: right;
  302. }
  303. .alertRed {
  304. position: absolute;
  305. width: 100%;
  306. overflow: visible;
  307. display: block;
  308. margin: 0 auto;
  309. background: #FFF8DB;
  310. padding-left: 2%;
  311. padding-right: 2%;
  312. }
  313. .alertRed em {
  314. position: relative;
  315. top: -10px;
  316. width: 139px;
  317. height: 18px;
  318. line-height: 18px;
  319. background: red;
  320. color: #fff;
  321. margin: 0 auto;
  322. display: block;
  323. border-radius: 9px;
  324. text-align: center;
  325. font-size: 12px;
  326. }
  327. .yellowTri {
  328. width: 9px;
  329. height: 8px;
  330. float: left;
  331. margin-left: 15px;
  332. margin-top: 4px;
  333. background: url("../static/images/icon/triIcon.png") top center no-repeat;
  334. background-size: 100%;
  335. }
  336. .alertRed span {
  337. width: 100%;
  338. height: 30px;
  339. overflow: hidden;
  340. display: block;
  341. margin: 0 auto;
  342. text-align: center;
  343. color: red;
  344. font-size: 12px;
  345. }
  346. .alertRed span i {
  347. float: right;
  348. color: #ccc;
  349. font-size: 18px;
  350. line-height: 20px;
  351. }
  352. /deep/ .mu-item-title s {
  353. width: 65px;
  354. text-align: justify;
  355. text-align-last: justify;
  356. }
  357. </style>