p-header.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="p-header">
  3. <div class="title" @click="menuClose">
  4. <i v-if="this.$store.state.collapse" class="el-icon-s-fold"></i
  5. ><i v-else class="el-icon-s-unfold"></i>
  6. </div>
  7. <!-- <div
  8. class="title"
  9. v-for="(item, index) in routeChecked"
  10. :key="index"
  11. :style="item.rountPath == $store.state.defaultActive ? 'color:white' : ''"
  12. @click="change(index, item)"
  13. >
  14. <span :class="item.icon"></span>{{ item.name }}
  15. </div> -->
  16. <div class="bars">
  17. <div class="bars-item user-info">Hello,{{ username }}</div>
  18. <div class="bars-item" @click="handleHelp">
  19. <i class="el-icon-time"></i>
  20. {{ $formatDate(date, "YYYY-MM-DD") }}
  21. </div>
  22. <div class="bars-item" @click="handleCall">
  23. <i class="el-icon-chat-dot-round"></i>
  24. 知识库
  25. </div>
  26. <div class="bars-item" @click="handleLogout">
  27. <i class="el-icon-guide"></i>
  28. 退出
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. username: {
  37. required: false,
  38. type: String,
  39. default: "admin",
  40. },
  41. },
  42. data() {
  43. return {
  44. currentIndex: "5",
  45. date: new Date(),
  46. routeChecked: [
  47. {
  48. name: "数据视图",
  49. icon: "iconfont icon-icon_huabanfuben",
  50. rountPath: "/funcInit",
  51. },
  52. {
  53. name: "网格视图",
  54. icon: "iconfont icon-wanggeshezhi",
  55. rountPath: "/loginInit",
  56. },
  57. {
  58. name: "工作台",
  59. icon: "iconfont icon-gongzuotai",
  60. rountPath: "/excel",
  61. },
  62. ],
  63. };
  64. },
  65. created() {
  66. this.runInitDate();
  67. // if (!this.collapse) {
  68. // this.$store.commit("setCollapse");
  69. // }
  70. //this.menuClose();
  71. },
  72. methods: {
  73. handleCall() {
  74. this.$switchTab(this, { rountPath: "/knowledgetop", name: "知识库" },'knowledgetop');
  75. },
  76. change(index, item) {
  77. this.currentIndex = index;
  78. let set = new Set(this.$store.state.tabList);
  79. set.add(item);
  80. this.$store.commit("setDefaultActive", item.rountPath);
  81. this.$store.commit("setTabList", Array.from(set));
  82. },
  83. initDate() {
  84. this.date = new Date();
  85. },
  86. runInitDate() {
  87. let _this = this;
  88. let rn = setTimeout(() => {
  89. _this.initDate();
  90. _this.runInitDate();
  91. clearTimeout(rn);
  92. }, 500);
  93. },
  94. handleLogout() {
  95. this.$confirm("正在退出登录,是否继续", "提示", {
  96. type: "warning",
  97. })
  98. .then((res) => {
  99. if (res === "confirm") {
  100. this.$store.commit("setUserInfo", undefined);
  101. this.$store.commit("setToken", undefined);
  102. this.$store.commit("setMenus", undefined);
  103. this.$store.commit("setTabList", []);
  104. this.$cookie.delete("userInfo");
  105. this.$cookie.delete("menus");
  106. this.$cookie.delete("token");
  107. window.sessionStorage.agileauthtoken = undefined;
  108. window.sessionStorage.menus = undefined;
  109. window.sessionStorage.userInfo = undefined;
  110. window.sessionStorage.childrenMenus = undefined;
  111. window.opener=null;
  112. window.open('','_self');
  113. window.close();
  114. // window.parent.close();
  115. //返回到登录页面
  116. // this.$router.push("/login");
  117. // this.$http({
  118. // url: "http://cas.hl.cmcc/cas/logout",
  119. // method: "get",
  120. // headers: {
  121. // "Access-Control-Allow-Origin": "http://cas.hl.cmcc/cas/logout",
  122. // },
  123. // }).then((res) => {
  124. // //TODO先执行退出登录
  125. // this.$store.commit("setUserInfo", undefined);
  126. // this.$store.commit("setToken", undefined);
  127. // this.$store.commit("setMenus", undefined);
  128. // this.$store.commit("setTabList", []);
  129. // this.$cookie.delete("userInfo");
  130. // this.$cookie.delete("menus");
  131. // this.$cookie.delete("token");
  132. // window.sessionStorage.agileauthtoken = undefined;
  133. // window.sessionStorage.menus = undefined;
  134. // window.sessionStorage.userInfo = undefined;
  135. // window.sessionStorage.childrenMenus = undefined;
  136. //
  137. // window.location.href = " http://cas.hl.cmcc/cas/login?service=http%3A%2F%2F10.230.26.15%3A8000%2Fspfm%2Fsysmgr%2FssLogin%3FsysFlag%3D0";
  138. // });
  139. }
  140. })
  141. .catch((err) => {
  142. throw err;
  143. });
  144. },
  145. handleSetting() {},
  146. handleHelp() {},
  147. menuClose() {
  148. this.$store.commit("setCollapse");
  149. this.$emit("collapse");
  150. },
  151. },
  152. computed: {
  153. collapse() {
  154. return this.$store.state.collapse;
  155. },
  156. },
  157. };
  158. </script>
  159. <style scoped="scoped" lang="scss">
  160. .p-header {
  161. color: #fff;
  162. height: 100%;
  163. background-color: #0b82ff;
  164. .active {
  165. color: #0b82ff;
  166. }
  167. .iconfont {
  168. vertical-align: bottom;
  169. font-size: 21px;
  170. }
  171. .title {
  172. padding-top: 16px;
  173. padding-left: 15px;
  174. color: rgba(255, 255, 255, 0.6);
  175. font-size: 14px;
  176. float: left;
  177. cursor: pointer;
  178. span {
  179. font-size: 15px;
  180. }
  181. i {
  182. font-size: 20px;
  183. }
  184. }
  185. .bars {
  186. float: right;
  187. padding-top: 16px;
  188. padding-right: 31px;
  189. .bars-item {
  190. display: inline-block;
  191. margin-left: 30px;
  192. cursor: pointer;
  193. font-family: SourceHanSansCN-Normal;
  194. font-size: 14px;
  195. color: #ffffff;
  196. letter-spacing: 0;
  197. }
  198. .user-info {
  199. font-size: 18px;
  200. }
  201. }
  202. }
  203. </style>