homePage.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div class="homePage">
  3. <div class="frameMain" :style="allHeight">
  4. <div class="menuList">
  5. <el-menu
  6. :default-active="$route.path"
  7. router
  8. :unique-opened="true"
  9. :default-openeds="openeds"
  10. @select="handleNodeClick"
  11. text-color="#fff"
  12. background-color="#184FB4"
  13. active-text-color="#fff">
  14. <!-- 引入组件 -->
  15. <menu-tree :menuData="forecastDatas"></menu-tree>
  16. </el-menu>
  17. </div>
  18. <div class="homeMain" :style="mainHeight">
  19. <div class="homeMain_tag">
  20. <div style="width: 90%;overflow: hidden;">
  21. <el-tag
  22. v-for="tag in routeTags"
  23. :key="tag.name"
  24. closable
  25. size="large"
  26. class="tagArr"
  27. effect="dark"
  28. :type="tag.index === $route.path ? '': 'info'"
  29. @close="handleClose(tag)"
  30. @click="handleShowPage(tag)"
  31. >
  32. <span>{{ tag.name }}</span>
  33. </el-tag>
  34. </div>
  35. <div class="settingMsg">
  36. <span>{{userName}}</span>
  37. <img :src="closeBtn" @click="closeSys" >
  38. </div>
  39. </div>
  40. <div class="mainMessage" :style="$route.path === '/home' ? '': 'padding: 0 10px;'">
  41. <router-view></router-view>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import MenuTree from '../components/menuTreeconfig.vue'
  49. import homeImg from '../assets/menuImg/home.png'
  50. import taskImg from '../assets/menuImg/task.png'
  51. import yewuImg from '../assets/menuImg/yewu.png'
  52. import tixiImg from '../assets/menuImg/tixi.png'
  53. import zhishikuImg from '../assets/menuImg/zhishiku.png'
  54. import quanxianImg from '../assets/menuImg/quanxian.png'
  55. import closeBtn from '../assets/getwayImg/closeBtn.png'
  56. import { getToken, removeToken } from '../api/auth'
  57. import {apiPostremoveByToken, apiGetMenuData} from '../api/api'
  58. export default {
  59. components: {MenuTree},
  60. data() {
  61. return {
  62. forecastDatas: [],
  63. expendData: ['0'],
  64. openeds:[],
  65. routeTags: [],
  66. defaultProps: {
  67. children: 'children',
  68. label: 'label',
  69. },
  70. closeBtn: closeBtn,
  71. userName: ''
  72. }
  73. },
  74. created(){
  75. this.getMenuData()
  76. // this.forecastDatas = [
  77. // {
  78. // index: '/home',
  79. // name: '考评首页',
  80. // img: homeImg
  81. // },
  82. // {
  83. // index: '/taskCenter',
  84. // name: '任务中心',
  85. // img: taskImg
  86. // },
  87. // {
  88. // index: '1',
  89. // name: '考评业务',
  90. // img: yewuImg,
  91. // children: [
  92. // {
  93. // index: '/assessment/evaluationStart',
  94. // name: '考评目标启动',
  95. // },
  96. // {
  97. // index: '/assessment/monthQuarter',
  98. // name: '月/季度目标考评'
  99. // },
  100. // {
  101. // index: '/assessment/evaluationYear',
  102. // name: '年度目标考评'
  103. // },
  104. // {
  105. // index: '',
  106. // name: '考评项对标'
  107. // },
  108. // {
  109. // index: '',
  110. // name: '考评项预警'
  111. // },
  112. // {
  113. // index: '',
  114. // name: '人员考评'
  115. // },
  116. // {
  117. // index: '',
  118. // name: '任期考评'
  119. // },
  120. // {
  121. // index: '',
  122. // name: '考评监督'
  123. // },
  124. // {
  125. // index: '',
  126. // name: '考评评级'
  127. // },
  128. // {
  129. // index: '',
  130. // name: '考评报告'
  131. // },
  132. // {
  133. // index: '',
  134. // name: '考评公告'
  135. // },
  136. // {
  137. // index: '',
  138. // name: '单位考核结果应用'
  139. // },
  140. // {
  141. // index: '',
  142. // name: '部门考核结果应用'
  143. // }
  144. // ]
  145. // },
  146. // {
  147. // index: '2',
  148. // name: '考评体系配置',
  149. // img: tixiImg,
  150. // children: [
  151. // {
  152. // index: '/evaluationSystem/evaluationIndex',
  153. // name: '考评指标管理',
  154. // },
  155. // {
  156. // index: '/evaluationSystem/evaluationRules',
  157. // name: '考评规则配置',
  158. // },
  159. // {
  160. // index: '/evaluationSystem/company',
  161. // name: '单位权重配置',
  162. // },
  163. // {
  164. // index: '/evaluationSystem/department',
  165. // name: '考评部门配置',
  166. // },
  167. // {
  168. // index: '/evaluationSystem/personnel',
  169. // name: '考评人员配置',
  170. // },
  171. // {
  172. // index: '/evaluationSystem/achievementK',
  173. // name: '业绩考核系数配置',
  174. // },
  175. // {
  176. // index: '',
  177. // name: '党建考核系数配置',
  178. // },
  179. // ]
  180. // },
  181. // {
  182. // index: '3',
  183. // name: '考评知识库',
  184. // img: zhishikuImg,
  185. // children: [
  186. // {
  187. // index: '/knowledgePage/scoringRules',
  188. // name: '考评得分规则',
  189. // },
  190. // {
  191. // name: '考评评级规则',
  192. // },
  193. // {
  194. // name: '考评预警规则',
  195. // }
  196. // ]
  197. // },
  198. // {
  199. // index: '4',
  200. // name: '基础信息配置',
  201. // img: quanxianImg,
  202. // children: [
  203. // {
  204. // index: '',
  205. // name: '人员权限配置',
  206. // },
  207. // {
  208. // index: '',
  209. // name: '工作流程配置',
  210. // }
  211. // ]
  212. // }
  213. // ]
  214. if (window.sessionStorage.getItem('routeTags')) {
  215. this.routeTags = JSON.parse(window.sessionStorage.getItem('routeTags'))
  216. if (this.$route?.path === '/') {
  217. this.$router.push({ path: this.routeTags[0].index})
  218. }
  219. } else {
  220. this.routeTags = [
  221. {
  222. index: '/home',
  223. name: '考评首页'
  224. }
  225. ]
  226. this.$router.push({ path: this.routeTags[0].index})
  227. window.sessionStorage.setItem('routeTags', JSON.stringify(this.routeTags))
  228. }
  229. if (window.sessionStorage.getItem('user')) {
  230. let obj = JSON.parse(window.sessionStorage.getItem('user'))
  231. this.userName = obj.name
  232. }
  233. },
  234. mounted() {
  235. },
  236. computed:{
  237. mainHeight() {
  238. return {
  239. // 'height': document.documentElement.clientHeight-50 + 'px'
  240. 'height': '100vh'
  241. }
  242. },
  243. allHeight() {
  244. return {
  245. 'width': '100%',
  246. // 'height': document.documentElement.clientHeight-40 + 'px'
  247. 'height': '100vh'
  248. }
  249. },
  250. viewHeight() {
  251. return {
  252. 'width': '100%',
  253. // 'height': document.documentElement.clientHeight-40 + 'px'
  254. 'height': '91vh'
  255. }
  256. }
  257. },
  258. methods:{
  259. // 获取菜单数据
  260. getMenuData() {
  261. let that = this
  262. apiGetMenuData().then(datas =>{
  263. if (datas && datas.data) {
  264. let arr = []
  265. for(let i =0; i<datas.data.length; i++) {
  266. let item = datas.data[i]
  267. let obj = {
  268. index: item.href,
  269. name: item.name
  270. }
  271. if (item.name === '考评首页') {
  272. obj.img = homeImg
  273. } else if(item.name === '任务中心') {
  274. obj.img = taskImg
  275. } else if(item.name === '考评业务') {
  276. obj.img = yewuImg
  277. obj.children = that.changeMenuData(item.children)
  278. } else if(item.name === '考评体系配置') {
  279. obj.img = tixiImg
  280. obj.children = that.changeMenuData(item.children)
  281. } else if(item.name === '考评知识库') {
  282. obj.img = zhishikuImg
  283. obj.children = that.changeMenuData(item.children)
  284. } else if(item.name === '基础信息配置') {
  285. obj.img = quanxianImg
  286. obj.children = that.changeMenuData(item.children)
  287. }
  288. arr.push(obj)
  289. }
  290. that.forecastDatas = arr
  291. }
  292. })
  293. },
  294. changeMenuData(data) {
  295. let childArr = []
  296. data.forEach(item =>{
  297. let obj = {
  298. index: item.href,
  299. name: item.name
  300. }
  301. childArr.push(obj)
  302. })
  303. return childArr
  304. },
  305. getBac(val) {
  306. let strWea = ''
  307. debugger
  308. if (val) {
  309. strWea = 'changeBacksty'
  310. } else {
  311. strWea = 'defaultBacksty'
  312. }
  313. return strWea
  314. },
  315. changeRoute(item) {
  316. if (item.index) {
  317. this.$router.push({ path: item.index})
  318. }
  319. },
  320. closeSys() {
  321. let that = this
  322. apiPostremoveByToken(window.localStorage.getItem('token')).then(datas =>{
  323. if (datas.code === 200) {
  324. // removeToken('token')
  325. // removeToken('code')
  326. // removeToken('purview')
  327. window.localStorage.removeItem('code')
  328. window.localStorage.removeItem('purview')
  329. window.localStorage.removeItem('token')
  330. window.sessionStorage.clear()
  331. that.$router.push({ path: "/login"})
  332. }
  333. })
  334. },
  335. handleNodeClick(index, indexPath) {
  336. if (indexPath) {
  337. this.forecastDatas.forEach(it =>{
  338. if (it.index !== '') {
  339. if (it.index === indexPath[0]) {
  340. if (!it.children) {
  341. let showM = 0
  342. this.routeTags.forEach(item =>{
  343. if (item.name === it.name) {
  344. showM++
  345. }
  346. })
  347. if (showM === 0) {
  348. this.routeTags.push(it)
  349. }
  350. } else {
  351. it.children.forEach(iv =>{
  352. if (iv.index !== '') {
  353. if (iv.index === indexPath[1]) {
  354. let showM = 0
  355. this.routeTags.forEach(item =>{
  356. if (item.name === iv.name) {
  357. showM++
  358. }
  359. })
  360. if (showM === 0) {
  361. this.routeTags.push(iv)
  362. }
  363. }
  364. }
  365. })
  366. }
  367. }
  368. }
  369. })
  370. window.sessionStorage.setItem('routeTags', JSON.stringify(this.routeTags))
  371. }
  372. },
  373. handleClose(tag) {
  374. if (this.routeTags.length > 1) {
  375. this.routeTags.splice(this.routeTags.indexOf(tag), 1)
  376. window.sessionStorage.setItem('routeTags', JSON.stringify(this.routeTags))
  377. }
  378. },
  379. handleShowPage(tag) {
  380. this.$router.push({ path: tag.index})
  381. }
  382. }
  383. }
  384. </script>
  385. <style lang="less">
  386. .homePage{
  387. display: flex;
  388. .leftMenu{
  389. width: 70px;
  390. .logoSty{
  391. padding: 10px 0 0 10px;
  392. img{
  393. width: 35px;
  394. height: 35px;
  395. }
  396. }
  397. .firstLevel{
  398. margin-top: 30px;
  399. .firstLevel_icon{
  400. margin-bottom: 30px;
  401. cursor: pointer;
  402. .firstLevel_img{
  403. width: 35px;
  404. height: 37px;
  405. text-align: center;
  406. border-radius: 5px;
  407. position: relative;
  408. left: 10px;
  409. img{
  410. position: relative;
  411. top: 6px;
  412. width: 20px;
  413. height: 20px;
  414. }
  415. &:hover{
  416. background: rgba(255,255,255,.2);
  417. }
  418. }
  419. .changeBacksty{
  420. background: rgba(255,255,255,.2);
  421. }
  422. .defaultBacksty{
  423. background: rgba(255,255,255,0);
  424. }
  425. .firstLevel_title{
  426. margin-left: 5px;
  427. span{
  428. font-size: 12px;
  429. color: #fff;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. .frameMain{
  436. // background: #f3f7f8;
  437. border-radius: 30px;
  438. display: flex;
  439. .menuList{
  440. width: 13vw;
  441. height: 100vh;
  442. background-color: #184FB4;
  443. .el-menu{
  444. .el-sub-menu{
  445. .el-menu--inline{
  446. .el-menu-item{
  447. height: 30px;
  448. margin-bottom: 10px;
  449. border-radius: 15px 0 0 15px;
  450. width: 90%;
  451. position: relative;
  452. left: 12%;
  453. padding-left: 15px;
  454. }
  455. .el-menu-item:hover, .el-menu-item.is-active{
  456. background-color: #fff;
  457. border-radius: 15px 0 0 15px;
  458. color: #2778FF;
  459. width: 90%;
  460. position: relative;
  461. left: 12%;
  462. padding-left: 15px;
  463. }
  464. .el-sub-menu__title:hover{
  465. background-color: #1063CB !important;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. .homeMain{
  472. width: 86vw;
  473. .homeMain_tag{
  474. height:60px;
  475. border-bottom: 1px solid #D6DBEA;
  476. display: flex;
  477. .tagArr{
  478. height: 33px;
  479. margin-left: 10px;
  480. cursor: pointer;
  481. position: relative;
  482. top: 28px;
  483. }
  484. .el-tag--dark{
  485. background-color: #184FB4;
  486. border: 1px solid #184FB4;
  487. }
  488. .el-tag--info{
  489. background-color: #E6EBF5;
  490. border: 1px solid #E6EBF5;
  491. color: #9DA5BE;
  492. .el-tag__close{
  493. color: #9DA5BE;
  494. }
  495. }
  496. .settingMsg{
  497. width: 10%;
  498. padding-top:20px;
  499. span{
  500. // width: 80%;
  501. // display: inline-block;
  502. position: relative;
  503. top: -5px;
  504. font-size: 18px;
  505. font-family: '微软雅黑';
  506. font-weight: bold;
  507. color: #171e28;
  508. }
  509. img{
  510. position: relative;
  511. left: 10px;
  512. cursor:pointer
  513. }
  514. }
  515. }
  516. .mainMessage{
  517. width: 100%;
  518. height: 91vh;
  519. // padding: 0 10px;
  520. // background: #fff;
  521. border-radius: 20px;
  522. }
  523. }
  524. }
  525. }
  526. </style>