Header.vue 13 KB

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