homePage.vue 18 KB

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