Header.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="v-header">
  3. <div class="v-header-left">
  4. <div class="left-img inlineBlock"></div>
  5. <div class="system-title">
  6. <div class="zh">智慧社区指挥调度中心</div>
  7. <div class="en">Smart Community Space Management System</div>
  8. </div>
  9. <div class="left-img rights inlineBlock"></div>
  10. </div>
  11. <div class="v-header-center">
  12. <div
  13. class="tabSelect"
  14. v-for="(item, index) in menuList"
  15. :key="index"
  16. :class="setINdex() == index ? 'active' : ''"
  17. @click="selectTab(item, index)"
  18. >
  19. {{ item.name }}
  20. </div>
  21. </div>
  22. <div class="v-header-right">
  23. <div class="right-imgs"></div>
  24. <div>
  25. <span class="selectIocn"></span>
  26. <el-cascader
  27. class="saveColumn-select"
  28. ref="multipleValue"
  29. :options="scOptions"
  30. :props="{ checkStrictly: true, label: 'name' }"
  31. collapse-tags
  32. :show-all-levels="false"
  33. clearable
  34. @change="selectChange"
  35. v-model="communityValue"
  36. ></el-cascader>
  37. </div>
  38. <div class="time">
  39. <div class="date">{{ time.date }}</div>
  40. <div class="dates">
  41. <div class="thisTime">{{ time.thisTime }}</div>
  42. <div class="week">{{ time.week }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import envConfig from '@/config';
  50. import { mapState } from 'vuex';
  51. export default {
  52. name: 'vheader',
  53. data() {
  54. return {
  55. name: '',
  56. envConfig: envConfig,
  57. tagTableArr: [
  58. {
  59. name: '指挥调度',
  60. path: '/homeIndex'
  61. },
  62. {
  63. name: '社区资产',
  64. path: '/communityAssets'
  65. },
  66. {
  67. name: '产业招商',
  68. path: '/industrialInvestment'
  69. },
  70. {
  71. name: '运营服务',
  72. path: '/operationalServices'
  73. },
  74. {
  75. name: '财务分析',
  76. path: '/financialAnalysis'
  77. },
  78. {
  79. name: '视频监控',
  80. path: '/videoSurveillance'
  81. }
  82. ],
  83. tagTabIndex: 0,
  84. time: {
  85. thisTime: '2000/01/01',
  86. week: '星期一',
  87. date: '00:00:00'
  88. },
  89. communityValue: [],
  90. scOptions: []
  91. };
  92. },
  93. computed: {
  94. ...mapState(['globalCommunity']),
  95. menuList() {
  96. return this.$store.getters['getMenuList'] || [];
  97. }
  98. },
  99. watch: {
  100. globalCommunity: {
  101. handler(newVal, oldVal) {
  102. console.log(newVal, oldVal);
  103. },
  104. deep: true
  105. }
  106. },
  107. methods: {
  108. getUserInfo() {
  109. this.$http.postForm('/sc-user-center/user/findLoginUserById').then(({ status, data, msg }) => {
  110. if (status === 0) {
  111. this.$store.commit('setcCruUserInfo', data);
  112. } else {
  113. this.$message.error('获取用户信息失败');
  114. }
  115. });
  116. },
  117. // 退出登录
  118. logOut() {
  119. var access_token = localStorage.getItem('SC_token');
  120. this.$http.postForm('/sc-user-auth/user/logout', { access_token: access_token }).then(({ status, data, msg }) => {
  121. if (0 === status) {
  122. this.$message({
  123. type: 'success',
  124. message: '您已退出登录'
  125. });
  126. localStorage.removeItem('SC_token');
  127. sessionStorage.removeItem('SC_listMuen');
  128. this.$store.commit('setloginInfo', '');
  129. this.$store.dispatch('tags', []);
  130. sessionStorage.removeItem('tabs');
  131. window.location.href = this.envConfig.loginUrl;
  132. } else {
  133. this.$message.error(msg);
  134. }
  135. });
  136. },
  137. getTime() {
  138. this.time.date = this.$moment().format('HH:mm:ss');
  139. this.time.week = this.$moment().format('dddd');
  140. this.time.thisTime = this.$moment().format('YYYY/MM/DD');
  141. },
  142. selectChange() {
  143. let thisValue = this.$refs.multipleValue.getCheckedNodes()[0];
  144. // 选择是否为公司
  145. if (!!thisValue && thisValue.data.type == 'org') {
  146. let arrs = [];
  147. let ids = [thisValue.value];
  148. this.fitersValue(arrs, thisValue.data);
  149. arrs.map((item) => {
  150. ids.push(item.value);
  151. });
  152. this.$store.commit('setGlobalCommunity', {
  153. type: 'org',
  154. value: ids
  155. });
  156. } else {
  157. this.$store.commit('setGlobalCommunity', {
  158. value: [thisValue.value]
  159. });
  160. }
  161. },
  162. fitersValue(arrs, value) {
  163. value.children.map((item) => {
  164. if (item.type == 'org') {
  165. arrs.push(item);
  166. if (!!item.children) {
  167. this.fitersValue(arrs, item);
  168. }
  169. }
  170. });
  171. },
  172. communityNameList() {
  173. this.$http.get('/sc-community/assets/tree/community/findCompanyCommunityTree').then(({ data, msg, status }) => {
  174. if (status == 0) {
  175. this.scOptions = data;
  176. this.communityValue = [data[0].value];
  177. if (data[0].type == 'org') {
  178. let arrs = [];
  179. let ids = [data[0].value];
  180. this.fitersValue(arrs, data[0]);
  181. arrs.map((item) => {
  182. ids.push(item.value);
  183. });
  184. this.$store.commit('setGlobalCommunity', {
  185. type: 'org',
  186. value: ids
  187. });
  188. } else {
  189. this.$store.commit('setGlobalCommunity', {
  190. value: [data[0].value]
  191. });
  192. }
  193. }
  194. });
  195. },
  196. selectTab(item, index) {
  197. this.tagTabIndex = index;
  198. this.$router.push({ name: item.linkPath });
  199. },
  200. setINdex() {
  201. let index = 0;
  202. this.menuList.map((item, inx) => {
  203. if (item.linkPath == this.$route.name) {
  204. index = inx;
  205. }
  206. });
  207. return index;
  208. }
  209. },
  210. mounted() {},
  211. created() {
  212. setInterval(() => {
  213. this.getTime();
  214. }, 1000);
  215. this.getUserInfo();
  216. this.communityNameList();
  217. }
  218. };
  219. </script>
  220. <style lang='scss' scoped>
  221. @import '@assets/css/public-style.scss';
  222. $name: v-header;
  223. $colorOption: rgba(250, 250, 250, 0.6);
  224. .inlineBlock {
  225. display: inline-block;
  226. }
  227. .#{$name} {
  228. width: 100%;
  229. height: 110px;
  230. position: absolute;
  231. top: 0;
  232. z-index: 10;
  233. display: flex;
  234. justify-content: space-between;
  235. background-image: url('~@/assets/img/homeTop/bg_top.png');
  236. background-size: cover;
  237. padding-top: 15px;
  238. &-left {
  239. width: 530px;
  240. display: flex;
  241. color: #fff;
  242. .left-img {
  243. width: 50px;
  244. height: 18px;
  245. background-image: url('~@/assets/img/homeTop/top_big.png');
  246. background-size: cover;
  247. margin: 20px;
  248. }
  249. .system-title {
  250. .zh {
  251. font-size: 30px;
  252. line-height: 42px;
  253. letter-spacing: 5px;
  254. text-shadow: 0px 4px 8px rgba(7, 80, 92, 0.5);
  255. }
  256. .en {
  257. font-size: 12px;
  258. letter-spacing: 2px;
  259. white-space: nowrap;
  260. overflow: hidden;
  261. text-overflow: ellipsis;
  262. }
  263. }
  264. }
  265. &-center {
  266. display: flex;
  267. column-gap: 20px;
  268. font-size: 20px;
  269. height: 32px;
  270. margin-left: 120px;
  271. color: $colorOption;
  272. .tabSelect {
  273. border: 1px solid $colorOption;
  274. cursor: pointer;
  275. box-sizing: border-box;
  276. background: #18344e;
  277. width: 100px;
  278. line-height: 30px;
  279. text-align: center;
  280. border-radius: 5px;
  281. &.active {
  282. border-color: #01b1fe;
  283. background: #01b1fe;
  284. color: rgb(250, 250, 250);
  285. }
  286. }
  287. }
  288. &-right {
  289. margin-right: 20px;
  290. display: flex;
  291. .right-imgs {
  292. width: 98px;
  293. height: 2px;
  294. background-image: url('~@/assets/img/homeTop/yuansu2@2x.png');
  295. background-size: cover;
  296. margin-top: 20px;
  297. margin-right: 60px;
  298. }
  299. .saveColumn-select {
  300. width: 125px;
  301. }
  302. .selectIocn {
  303. display: inline-block;
  304. width: 26px;
  305. height: 24px;
  306. background-image: url('~@/assets/img/homeTop/icon_shequ@2x.png');
  307. background-size: cover;
  308. vertical-align: text-bottom;
  309. }
  310. .time {
  311. display: flex;
  312. .date {
  313. line-height: 40px;
  314. font-size: 24px;
  315. color: #fff;
  316. }
  317. .dates {
  318. color: #01b1fe;
  319. text-align: center;
  320. line-height: 20px;
  321. margin-left: 10px;
  322. }
  323. }
  324. }
  325. }
  326. .saveColumn-select {
  327. /deep/ .el-input__inner {
  328. background: transparent;
  329. color: white;
  330. border: none;
  331. font-size: 20px;
  332. }
  333. }
  334. </style>