homePage.vue 19 KB

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