Header.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div id="layoutHeader">
  3. <el-row>
  4. <el-col
  5. :span="8"
  6. v-if="$store.state.windowsSize.width >= 1300"
  7. class="logoBox"
  8. >
  9. <div class="logo"></div>
  10. <div class="title">
  11. {{
  12. systemInfo.system_name
  13. ? systemInfo.system_name
  14. : "浦东新区资源环境智慧审计平台"
  15. }}
  16. <span class="title_version"
  17. >Version:{{
  18. systemInfo.version ? systemInfo.version : "版本信息获取失败!"
  19. }}</span
  20. >
  21. </div>
  22. </el-col>
  23. <el-col
  24. :span="2"
  25. v-if="$store.state.windowsSize.width < 1300"
  26. class="logoBox"
  27. >
  28. <div class="logo"></div>
  29. </el-col>
  30. <el-col :span="$store.state.windowsSize.width < 1300 ? 18 : 13">
  31. <el-menu
  32. :default-active="ActiveIndex"
  33. class="el-menu-demo"
  34. mode="horizontal"
  35. active-text-color="#74FFFF"
  36. menu-trigger="hover"
  37. @select="select"
  38. >
  39. <el-menu-item index="1"
  40. ><i
  41. class="el-icon-s-home"
  42. v-show="$store.state.windowsSize.width <= 1700"
  43. ></i
  44. ><span v-show="$store.state.windowsSize.width > 1700"
  45. >首页</span
  46. ></el-menu-item
  47. >
  48. <el-submenu index="2">
  49. <template slot="title" class="submenu"
  50. ><i
  51. class="el-icon-s-order"
  52. v-show="$store.state.windowsSize.width <= 1700"
  53. ></i
  54. ><span v-show="$store.state.windowsSize.width > 1700"
  55. >疑点筛查</span
  56. ></template
  57. >
  58. <el-menu-item index="2-1">土地资源</el-menu-item>
  59. <el-menu-item index="2-2">水资源</el-menu-item>
  60. <el-menu-item index="2-3">林资源</el-menu-item>
  61. <el-menu-item index="2-4">生态资源</el-menu-item>
  62. <el-menu-item index="2-5">镇域专题</el-menu-item>
  63. </el-submenu>
  64. <el-menu-item index="3"
  65. ><i
  66. class="el-icon-s-order"
  67. v-show="$store.state.windowsSize.width <= 1700"
  68. ></i
  69. ><span v-show="$store.state.windowsSize.width > 1700"
  70. >综合分析</span
  71. ></el-menu-item
  72. >
  73. <el-menu-item index="4"
  74. ><i
  75. class="el-icon-s-management"
  76. v-show="$store.state.windowsSize.width <= 1700"
  77. ></i
  78. ><span v-show="$store.state.windowsSize.width > 1700"
  79. >全流程管理</span
  80. ></el-menu-item
  81. >
  82. <el-submenu index="5">
  83. <template slot="title"
  84. ><i
  85. class="el-icon-s-finance"
  86. v-show="$store.state.windowsSize.width <= 1700"
  87. ></i
  88. ><span v-show="$store.state.windowsSize.width > 1700"
  89. >智能辅助</span
  90. ></template
  91. >
  92. <el-menu-item index="5-1">法律法规</el-menu-item>
  93. <el-menu-item index="5-2">频发问题</el-menu-item>
  94. <el-menu-item index="5-3">指标体系</el-menu-item>
  95. </el-submenu>
  96. </el-menu>
  97. </el-col>
  98. <el-col :span="3">
  99. <div class="user">
  100. <!-- 我的任务快捷菜单 -->
  101. <div class="manage-icon" @click="goToMyMission()"></div>
  102. <!-- <div class="alert-icon">
  103. <div class="alert-info">12</div>
  104. </div> -->
  105. <div class="inner-user">
  106. <el-dropdown @command="handleCommand">
  107. <span class="el-dropdown-link">
  108. <el-avatar
  109. size="medium"
  110. :src="
  111. $store.state.userInfo && $store.state.userInfo.photo
  112. ? $store.state.userInfo.photo
  113. : 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
  114. "
  115. ></el-avatar>
  116. <!-- <div class="inner-user-icon"></div> -->
  117. <div class="inner-user-text">
  118. {{
  119. $store.state.userInfo && $store.state.userInfo.username
  120. ? $store.state.userInfo.username
  121. : userName
  122. }}
  123. </div>
  124. </span>
  125. <el-dropdown-menu slot="dropdown">
  126. <el-dropdown-item command="loginOut">注销登录</el-dropdown-item>
  127. </el-dropdown-menu>
  128. </el-dropdown>
  129. </div>
  130. </div>
  131. </el-col>
  132. </el-row>
  133. </div>
  134. </template>
  135. <script>
  136. export default {
  137. name: "Header",
  138. data() {
  139. return {
  140. systemInfo: {},
  141. userName: localStorage.getItem("_USER_NAME")
  142. ? localStorage.getItem("_USER_NAME")
  143. : "未登录",
  144. ActiveIndex: "0",
  145. navData: {
  146. 1: "首页",
  147. 2: "疑点筛查",
  148. "2-1": "土地资源",
  149. "2-2": "水资源",
  150. "2-3": "林资源",
  151. "2-4": "生态资源",
  152. "2-5": "镇域专题",
  153. 3: "综合分析",
  154. 4: "全流程管理",
  155. "5-1": "法律法规",
  156. "5-2": "频发问题",
  157. "5-3": "指标体系",
  158. },
  159. };
  160. },
  161. mounted() {
  162. this.getActiveIndex(true);
  163. // 验证是否存在版本更新
  164. this.getSystemInfo();
  165. },
  166. methods: {
  167. // 请求系统信息
  168. getSystemInfo() {
  169. let params = new FormData();
  170. params.append("columnId", "33");
  171. params.append("states", "2,3");
  172. params.append("pageSize", 10);
  173. params.append("page", 0);
  174. let sortparam = [{ field: "c_publish_time", orderByType: 2 }];
  175. params.append("orderBy", JSON.stringify(sortparam));
  176. this.$Post(this.urlsCollection.selectContentList, params).then(
  177. (res) => {
  178. if (res.code === 200 && res.content.data.length > 0) {
  179. let tableData = res.content.data;
  180. if (tableData.length > 0) {
  181. this.systemInfo = tableData[0];
  182. let systemVersion = localStorage.getItem("SYSTEM_VERSION");
  183. if (this.systemInfo.c_menus_list) {
  184. let menus = eval("(" + this.systemInfo.c_menus_list + ")");
  185. this.$emit("initMenu", menus);
  186. }
  187. if (systemVersion) {
  188. if (systemVersion != this.systemInfo.version) {
  189. this.$message.success("新版本已发布!自动更新中!");
  190. localStorage.setItem(
  191. "SYSTEM_VERSION",
  192. this.systemInfo.version
  193. );
  194. window.location.reload();
  195. }
  196. } else {
  197. localStorage.setItem("SYSTEM_VERSION", this.systemInfo.version);
  198. }
  199. }
  200. } else {
  201. this.systemInfo = {};
  202. this.$message.error(res.message);
  203. }
  204. },
  205. (error) => {
  206. this.systemInfo = {};
  207. this.$message.error(error);
  208. }
  209. );
  210. },
  211. // 菜单选择记忆(由于不使用路由,为了防止用户刷新页面后页面丢失,故保存并重新赋值当前页)
  212. getActiveIndex(status) {
  213. let _ActiveIndex = "";
  214. if (this.$store.state.navSelect) {
  215. if (this.$store.state.navSelect.subIndex) {
  216. _ActiveIndex =
  217. this.$store.state.navSelect.index +
  218. "-" +
  219. this.$store.state.navSelect.subIndex;
  220. } else {
  221. _ActiveIndex = this.$store.state.navSelect.index;
  222. }
  223. } else {
  224. _ActiveIndex = "1";
  225. }
  226. if (this.ActiveIndex != _ActiveIndex) {
  227. this.ActiveIndex = _ActiveIndex;
  228. if (status) {
  229. this.select(this.ActiveIndex);
  230. }
  231. }
  232. },
  233. // 快捷进入我的任务页面
  234. goToMyMission() {
  235. this.ActiveIndex = "3";
  236. this.select(this.ActiveIndex);
  237. setTimeout(() => {
  238. this.$bus.$emit("wdrw");
  239. });
  240. },
  241. // 切换菜单事件
  242. select: function (index) {
  243. var that = this;
  244. var name = that.navData[index];
  245. index = index.split("-");
  246. that.$emit("navSelect", {
  247. index: index[0],
  248. subIndex: index[1],
  249. name: name,
  250. });
  251. // let notFound = ["2-2", "2-3", "2-4", "5-3"];
  252. // let notFoundState = true;
  253. // notFound.forEach(item => {
  254. // if (item == index) {
  255. // this.$message.info("页面开发中,敬请期待!");
  256. // notFoundState = false;
  257. // }
  258. // });
  259. // if (notFoundState) {
  260. // index = index.split("-");
  261. // that.$emit("navSelect", {
  262. // index: index[0],
  263. // subIndex: index[1],
  264. // name: name
  265. // });
  266. // }
  267. },
  268. // 用户菜单
  269. handleCommand(command) {
  270. switch (command) {
  271. case "loginOut":
  272. this.loginOut();
  273. }
  274. },
  275. // 用户退出操作
  276. loginOut() {
  277. this.$store.commit("changeUserInfo", {});
  278. localStorage.removeItem("TOKEN");
  279. localStorage.removeItem("USER_ID");
  280. localStorage.removeItem("USER_NAME");
  281. this.$router.push("/login");
  282. const h = this.$createElement;
  283. this.$notify({
  284. title: "登出成功",
  285. message: h("i", { style: "color: teal" }, "用户退出!感谢使用!"),
  286. });
  287. },
  288. },
  289. watch: {
  290. "$store.state.navSelect": {
  291. handler() {
  292. this.getActiveIndex(false);
  293. },
  294. deep: true,
  295. },
  296. },
  297. };
  298. </script>
  299. <style lang="less" scoped>
  300. #layoutHeader {
  301. position: absolute;
  302. z-index: 2;
  303. width: 100%;
  304. height: 60px;
  305. left: 0px;
  306. top: 0px;
  307. // background: url("../../assets/home/header_background.png") no-repeat center;
  308. background: linear-gradient(180deg, #4279d2 0%, #0942c0 100%);
  309. background-size: 100% 100%;
  310. color: #ffffff;
  311. -moz-user-select: none;
  312. -webkit-user-select: none;
  313. -ms-user-select: none;
  314. -khtml-user-select: none;
  315. user-select: none;
  316. .logoBox {
  317. display: flex;
  318. transform: skew(-45deg);
  319. position: relative;
  320. left: -40px;
  321. height: 60px;
  322. background: linear-gradient(0deg, #4279d2 0%, #0942c0 100%);
  323. overflow: hidden;
  324. flex-wrap: nowrap;
  325. align-content: center;
  326. }
  327. .logo {
  328. position: relative;
  329. transform: skew(45deg);
  330. left: calc(1rem + 40px);
  331. top: 15px;
  332. width: 30px;
  333. height: 30px;
  334. background: url("../../assets/home/header_title_icon.png") no-repeat center;
  335. }
  336. .title {
  337. position: relative;
  338. width: 30vw;
  339. padding-left: 1.5rem;
  340. transform: skew(45deg);
  341. line-height: 60px;
  342. font-size: 32px;
  343. text-indent: 50px;
  344. font-weight: 400;
  345. font-family: YouSheBiaoTiHei;
  346. letter-spacing: 0.25rem;
  347. overflow: hidden;
  348. text-overflow: ellipsis;
  349. display: -webkit-box;
  350. -webkit-box-orient: vertical;
  351. -webkit-line-clamp: 1;
  352. &_version {
  353. position: absolute;
  354. right: 1.5rem;
  355. font-size: 12px;
  356. bottom: 0;
  357. line-height: 12px;
  358. padding: 3px 5px;
  359. border-radius: 2px;
  360. color: #ffffff;
  361. }
  362. }
  363. }
  364. .el-menu-demo /deep/ .el-menu-item,
  365. .el-submenu {
  366. padding: 0 30px;
  367. font-size: 24px;
  368. font-family: pingfangSC;
  369. font-weight: bold;
  370. color: #74ffff;
  371. line-height: 60px;
  372. border: none !important;
  373. }
  374. .el-menu-demo > .is-active {
  375. position: relative;
  376. &::before {
  377. position: absolute;
  378. content: "";
  379. box-sizing: border-box;
  380. left: 0;
  381. width: 100%;
  382. height: 100%;
  383. background: linear-gradient(0deg, #4279d2 0%, #0942c0 100%);
  384. border-bottom: 4px solid rgb(116, 255, 255);
  385. transform: skew(-45deg);
  386. z-index: -1;
  387. }
  388. }
  389. .el-menu-demo /deep/ .el-menu-item:hover,
  390. .el-menu-demo /deep/ .el-menu-item:focus {
  391. background: none !important;
  392. }
  393. #layoutHeader /deep/ .el-submenu__title {
  394. color: #ffffff !important;
  395. font-size: 24px !important;
  396. }
  397. #layoutHeader
  398. /deep/
  399. .el-menu--horizontal
  400. > .el-submenu
  401. .el-submenu__title:hover {
  402. background: none;
  403. }
  404. #layoutHeader /deep/ .el-submenu__title i {
  405. color: #fff;
  406. }
  407. #layoutHeader /deep/ .el-menu {
  408. background: transparent;
  409. border-bottom: 0px;
  410. }
  411. #layoutHeader /deep/ .el-menu-item {
  412. color: #ffffff;
  413. }
  414. #layoutHeader .user {
  415. float: right;
  416. margin-right: 30px;
  417. cursor: pointer;
  418. width: 95%;
  419. height: 100%;
  420. position: relative;
  421. display: flex;
  422. flex-direction: row;
  423. flex-wrap: nowrap;
  424. align-content: center;
  425. justify-content: space-around;
  426. align-items: center;
  427. .manage-icon {
  428. width: 28px;
  429. height: 28px;
  430. padding: 15px;
  431. background: url("../../assets/home/header_manage.png") no-repeat center;
  432. }
  433. .alert-icon {
  434. width: 26px;
  435. height: 30px;
  436. position: absolute;
  437. left: 80px;
  438. top: 14px;
  439. background: url("../../assets/home/header_alert.png") no-repeat center;
  440. .alert-info {
  441. width: 25px;
  442. height: 20px;
  443. position: absolute;
  444. background: red;
  445. border-radius: 10px;
  446. right: -20px;
  447. top: -10px;
  448. color: #fff;
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. }
  453. }
  454. .admin-icon {
  455. width: 41px;
  456. height: 41px;
  457. background: #74ffff;
  458. border: 1px solid #ffffff;
  459. border-radius: 50%;
  460. position: absolute;
  461. left: 80px;
  462. top: 8px;
  463. }
  464. .inner-user {
  465. width: 46px;
  466. height: 46px;
  467. position: absolute;
  468. right: 15px;
  469. top: 4px;
  470. color: #fff;
  471. &-icon {
  472. margin: 0 auto;
  473. width: 35px;
  474. height: 35px;
  475. background: #74ffff;
  476. border: 1px solid #ffffff;
  477. border-radius: 50%;
  478. }
  479. &-text {
  480. margin: 0 auto;
  481. width: 39px;
  482. height: 15px;
  483. color: #fff;
  484. display: flex;
  485. align-items: center;
  486. justify-content: center;
  487. font-size: 13px;
  488. }
  489. }
  490. }
  491. </style>