homePage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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. let obj = {
  349. index: it.index,
  350. name: it.name
  351. }
  352. this.routeTags.push(obj)
  353. }
  354. } else {
  355. it.children.forEach(iv =>{
  356. if (iv.index !== '') {
  357. if (iv.index === indexPath[1]) {
  358. let showM = 0
  359. this.routeTags.forEach(item =>{
  360. if (item.name === iv.name) {
  361. showM++
  362. }
  363. })
  364. if (showM === 0) {
  365. this.routeTags.push(iv)
  366. }
  367. }
  368. }
  369. })
  370. }
  371. }
  372. }
  373. })
  374. window.sessionStorage.setItem('routeTags', JSON.stringify(this.routeTags))
  375. }
  376. },
  377. handleClose(tag) {
  378. if (this.routeTags.length > 1) {
  379. this.routeTags.splice(this.routeTags.indexOf(tag), 1)
  380. window.sessionStorage.setItem('routeTags', JSON.stringify(this.routeTags))
  381. }
  382. },
  383. handleShowPage(tag) {
  384. this.$router.push({ path: tag.index})
  385. }
  386. }
  387. }
  388. </script>
  389. <style lang="less">
  390. .homePage{
  391. display: flex;
  392. .leftMenu{
  393. width: 70px;
  394. .logoSty{
  395. padding: 10px 0 0 10px;
  396. img{
  397. width: 35px;
  398. height: 35px;
  399. }
  400. }
  401. .firstLevel{
  402. margin-top: 30px;
  403. .firstLevel_icon{
  404. margin-bottom: 30px;
  405. cursor: pointer;
  406. .firstLevel_img{
  407. width: 35px;
  408. height: 37px;
  409. text-align: center;
  410. border-radius: 5px;
  411. position: relative;
  412. left: 10px;
  413. img{
  414. position: relative;
  415. top: 6px;
  416. width: 20px;
  417. height: 20px;
  418. }
  419. &:hover{
  420. background: rgba(255,255,255,.2);
  421. }
  422. }
  423. .changeBacksty{
  424. background: rgba(255,255,255,.2);
  425. }
  426. .defaultBacksty{
  427. background: rgba(255,255,255,0);
  428. }
  429. .firstLevel_title{
  430. margin-left: 5px;
  431. span{
  432. font-size: 12px;
  433. color: #fff;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. .frameMain{
  440. // background: #f3f7f8;
  441. border-radius: 30px;
  442. display: flex;
  443. .menuList{
  444. width: 13vw;
  445. height: 100vh;
  446. background-color: #184FB4;
  447. .el-menu{
  448. .el-sub-menu{
  449. .el-menu--inline{
  450. .el-menu-item{
  451. height: 30px;
  452. margin-bottom: 10px;
  453. border-radius: 15px 0 0 15px;
  454. width: 90%;
  455. position: relative;
  456. left: 12%;
  457. padding-left: 15px;
  458. }
  459. .el-menu-item:hover, .el-menu-item.is-active{
  460. background-color: #fff;
  461. border-radius: 15px 0 0 15px;
  462. color: #2778FF;
  463. width: 90%;
  464. position: relative;
  465. left: 12%;
  466. padding-left: 15px;
  467. }
  468. .el-sub-menu__title:hover{
  469. background-color: #1063CB !important;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .homeMain{
  476. width: 86vw;
  477. .homeMain_tag{
  478. height:60px;
  479. border-bottom: 1px solid #D6DBEA;
  480. display: flex;
  481. .tagArr{
  482. height: 33px;
  483. margin-left: 10px;
  484. cursor: pointer;
  485. position: relative;
  486. top: 28px;
  487. }
  488. .el-tag--dark{
  489. background-color: #184FB4;
  490. border: 1px solid #184FB4;
  491. }
  492. .el-tag--info{
  493. background-color: #E6EBF5;
  494. border: 1px solid #E6EBF5;
  495. color: #9DA5BE;
  496. .el-tag__close{
  497. color: #9DA5BE;
  498. }
  499. }
  500. .settingMsg{
  501. width: 10%;
  502. padding-top:20px;
  503. span{
  504. // width: 80%;
  505. // display: inline-block;
  506. position: relative;
  507. top: -5px;
  508. font-size: 18px;
  509. font-family: '微软雅黑';
  510. font-weight: bold;
  511. color: #171e28;
  512. }
  513. img{
  514. position: relative;
  515. left: 10px;
  516. cursor:pointer
  517. }
  518. }
  519. }
  520. .mainMessage{
  521. width: 100%;
  522. height: 91vh;
  523. // padding: 0 10px;
  524. // background: #fff;
  525. border-radius: 20px;
  526. }
  527. }
  528. }
  529. }
  530. </style>