p-header.vue 7.1 KB

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