permission.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. import {
  2. asyncRoutes,
  3. constantRoutes
  4. } from '@/router'
  5. import router from '@/router'
  6. import {
  7. getSilder
  8. } from '@/api/silder'
  9. import store from "@/store";
  10. import {
  11. Message
  12. } from 'element-ui'
  13. // import { stat } from 'fs'
  14. // import { removeToken } from '@/utils/auth'
  15. // import Layout from '@/layout'
  16. /**
  17. * 遍历接口菜单添加页面
  18. * @param asyncRoutes
  19. * @param getMenu
  20. */
  21. function generateAsyncRouter(asyncRoutes, data) {
  22. if (!data) {
  23. return []
  24. }
  25. data.forEach((item) => {
  26. item.component = asyncRoutes[item.component]
  27. if (item.children && item.children.length > 0) {
  28. generateAsyncRouter(asyncRoutes, item.children)
  29. }
  30. })
  31. return data
  32. }
  33. /**
  34. * 判断平台端添加首页
  35. * @param type
  36. */
  37. // const type = getters.type
  38. const state = {
  39. routes: [],
  40. addRoutes: [],
  41. type: '', // 登录的平台类型
  42. permission: [] // 权限
  43. }
  44. const mutations = {
  45. SET_ROUTES: (state, routes) => {
  46. state.addRoutes = routes
  47. state.routes = constantRoutes.concat(routes)
  48. },
  49. SET_PERMISSION: (state, permission) => {
  50. state.permission = permission
  51. }
  52. }
  53. function getFirstMenu(routes) {
  54. let firstMenu = null
  55. routes.forEach(item => {
  56. if (item.children?.length > 0 && !item.hidden) {
  57. firstMenu = pathErgodic(item)
  58. // console.log(firstMenu)
  59. item.redirect = firstMenu
  60. }
  61. })
  62. return routes
  63. }
  64. function pathErgodic(item) {
  65. // console.log(item)
  66. let firstMenu = null
  67. item.children.forEach(i => {
  68. if (!firstMenu && i.children?.length > 0 && !i.hidden) {
  69. let isChildrenList = false;
  70. i.children.forEach(ii => {
  71. if (!ii.hidden) {
  72. isChildrenList = true
  73. }
  74. })
  75. if (isChildrenList) {
  76. firstMenu = pathErgodic(i)
  77. } else {
  78. if (!firstMenu && checkPathUrl(i.path)) {
  79. firstMenu = i.path
  80. } else {
  81. if (!firstMenu && !i.hidden) {
  82. firstMenu = item.path + '/' + i.path
  83. }
  84. }
  85. }
  86. } else {
  87. if (!firstMenu && checkPathUrl(i.path)) {
  88. firstMenu = i.path
  89. } else {
  90. if (!firstMenu && !i.hidden) {
  91. firstMenu = item.path + '/' + i.path
  92. }
  93. }
  94. }
  95. })
  96. return firstMenu
  97. }
  98. // 判断path有没有带/,并且是第一个位置
  99. function checkPathUrl(path) {
  100. return path.indexOf('/') === 0 ? true : false
  101. }
  102. // 路由
  103. // 递归遍历数组
  104. function recursionRouter(arr) {
  105. // 这里来了
  106. if (arr.length > 0) {
  107. let newArr = [];
  108. for (let i = 0; i < arr.length; i++) {
  109. if (arr[i].type == 1) {
  110. continue
  111. }
  112. let obj = {};
  113. obj.component = arr[i].component;
  114. obj.name = arr[i].component;
  115. // if (item.type != '1' && item.component) {
  116. // if (!item.path.startsWith('/') && item.component != 'Layout') {
  117. // obj.names = item.name
  118. // }
  119. // }
  120. arr[i].hid == 0 ? obj.hidden = false : obj.hidden = true
  121. // console.log('高亮标签'+arr[i].parentPermission,'普通路径'+arr[i].path)
  122. obj.path = arr[i].path;
  123. obj.meta = {
  124. 'title': arr[i].name,
  125. 'icon': arr[i].icon,
  126. 'noCache': arr[i].keepAlive,
  127. 'activeMenu': arr[i].parentPermission,
  128. 'belongTopMenu': arr[i].belongTopMenu,
  129. 'id': arr[i].id
  130. }
  131. if (arr[i].sysMenus && arr[i].sysMenus.length > 0) {
  132. obj.children = recursionRouter(arr[i].sysMenus);
  133. }
  134. newArr.push(obj)
  135. }
  136. return newArr
  137. }
  138. }
  139. // 设置 belongTopMenu, 顶部菜单
  140. function addTopMenu(arr) {
  141. if (arr.length > 0) {
  142. let newArr = [];
  143. for (let i = 0; i < arr.length; i++) {
  144. if (arr[i].type == 1) {
  145. continue
  146. }
  147. let obj = arr[i]
  148. obj.belongTopMenu = obj.path
  149. if (arr[i].sysMenus && arr[i].sysMenus.length > 0) {
  150. obj.sysMenus = setTopMenu(arr[i].sysMenus, obj);
  151. }
  152. newArr.push(obj)
  153. }
  154. return newArr
  155. }
  156. }
  157. function setTopMenu(arr, topParentArr) {
  158. let newArr = [];
  159. for (let i = 0; i < arr.length; i++) {
  160. let obj = arr[i]
  161. obj.belongTopMenu = topParentArr.path
  162. if (arr[i].sysMenus && arr[i].sysMenus.length > 0) {
  163. obj.sysMenus = setTopMenu(arr[i].sysMenus, topParentArr);
  164. }
  165. newArr.push(obj)
  166. }
  167. return newArr
  168. }
  169. // 权限
  170. // 递归遍历数组
  171. let tempArr = []
  172. function recursionPermission(arr) {
  173. arr.map(item => {
  174. tempArr.push(item.memo)
  175. if (item.sysMenus && item.sysMenus.length > 0) {
  176. recursionPermission(item.sysMenus)
  177. }
  178. })
  179. }
  180. function setDetailRoute(accessedRoutes) {
  181. // console.log(accessedRoutes)
  182. accessedRoutes.forEach(route => {
  183. // console.log(route.path)
  184. if (route.path == '/main') {
  185. route.children = route.children.concat([{
  186. name: '日程安排',
  187. path: 'scheduleDetail',
  188. component: () => import('@/views/main/teamSchedule/scheduleDetail'),
  189. hidden: true,
  190. meta: {
  191. noCache: '1',
  192. title: '日程安排',
  193. belongTopMenu: "/main",
  194. activeMenu: '/main/main',
  195. id: 'xx1'
  196. }
  197. },
  198. {
  199. name: '未在班级学员',
  200. path: 'notClassStudent',
  201. component: () => import('@/views/main/notClassStudent'),
  202. hidden: true,
  203. meta: {
  204. noCache: '1',
  205. title: '未在班级学员',
  206. belongTopMenu: "/main",
  207. activeMenu: '/main/main',
  208. id: 'xx2'
  209. }
  210. },
  211. {
  212. name: '学员请假列表',
  213. path: 'studentLeaveList',
  214. component: () => import('@/views/main/studentLeaveList'),
  215. hidden: true,
  216. meta: {
  217. noCache: '1',
  218. title: '学员请假列表',
  219. belongTopMenu: "/main",
  220. activeMenu: '/main/main'
  221. }
  222. },
  223. {
  224. name: '乐团会员列表',
  225. path: 'teamMemberList',
  226. component: () => import('@/views/studentManager/memberList'),
  227. hidden: true,
  228. meta: {
  229. noCache: '1',
  230. title: '乐团会员列表',
  231. belongTopMenu: "/main",
  232. activeMenu: '/main/main'
  233. }
  234. },
  235. {
  236. name: '乐团展演列表',
  237. path: 'teamShowList',
  238. component: () => import('@/views/main/teamShowList'),
  239. hidden: true,
  240. meta: {
  241. noCache: '1',
  242. title: '乐团展演列表',
  243. belongTopMenu: "/main",
  244. activeMenu: '/main/main'
  245. }
  246. },
  247. {
  248. name: 'organDateDetail',
  249. path: 'organDateDetail',
  250. component: () => import('@/views/main/cloudDate/organDateDetail'),
  251. hidden: true,
  252. meta: {
  253. noCache: '1',
  254. title: '分部云教练数据详情',
  255. belongTopMenu: "/main",
  256. activeMenu: '/main/main'
  257. }
  258. },
  259. {
  260. name: 'organRankDetail',
  261. path: 'organRankDetail',
  262. component: () => import('@/views/main/cloudDate/organRankDetail'),
  263. hidden: true,
  264. meta: {
  265. noCache: '1',
  266. title: '分部云教练排行',
  267. belongTopMenu: "/main",
  268. activeMenu: '/main/main'
  269. }
  270. },
  271. //
  272. ])
  273. }
  274. if (route.path == '/business') {
  275. // import('@/views/resetTeaming/components/strudentPayInfo'),
  276. route.children = route.children.concat([{
  277. name: '学员缴费详情',
  278. path: 'strudentPayInfo',
  279. component: () => import('@/views/resetTeaming/components/strudentPayInfo'),
  280. hidden: true,
  281. meta: {
  282. noCache: '1',
  283. title: '学员缴费详情',
  284. belongTopMenu: "/business",
  285. activeMenu: '/teamList',
  286. id: 'xx3'
  287. }
  288. },
  289. {
  290. name: '乐团详情',
  291. path: 'resetTeaming',
  292. component: () => import('@/views/resetTeaming/index'),
  293. hidden: true,
  294. meta: {
  295. noCache: '1',
  296. title: '乐团详情',
  297. belongTopMenu: "/business",
  298. activeMenu: '/teamList',
  299. id: 'xx4'
  300. }
  301. },
  302. {
  303. name: '乐团档案',
  304. path: 'musicArchices',
  305. component: () => import('@/views/resetTeaming/components/musicArchices'),
  306. hidden: true,
  307. meta: {
  308. noCache: '1',
  309. title: '乐团档案',
  310. belongTopMenu: "/business",
  311. activeMenu: '/teamList',
  312. id: 'xx4'
  313. }
  314. },
  315. //musicArchices
  316. {
  317. name: '会员排课列表',
  318. path: 'memberClassList',
  319. component: () => import('@/views/teamDetail/components/memberClassList'),
  320. hidden: true,
  321. meta: {
  322. noCache: '1',
  323. title: '会员排课列表',
  324. belongTopMenu: "/business",
  325. activeMenu: '/teamList',
  326. id: 'xx28'
  327. }
  328. },
  329. {
  330. name: '相册详情',
  331. path: 'photo-detail',
  332. component: () => import('@/views/photo-detail'),
  333. hidden: true,
  334. meta: {
  335. noCache: '1',
  336. title: '相册详情',
  337. belongTopMenu: "/business",
  338. activeMenu: '/teamList',
  339. id: 'xxx28'
  340. }
  341. },
  342. // 相册详情
  343. {
  344. name: '全部证书',
  345. path: 'performance',
  346. component: () => import('@/views/photo-detail'),
  347. hidden: true,
  348. meta: {
  349. noCache: '1',
  350. title: '全部证书',
  351. belongTopMenu: "/business",
  352. activeMenu: '/teamList',
  353. id: 'xxx28'
  354. }
  355. },
  356. // 全部证书
  357. {
  358. name: '新建vip',
  359. path: 'buildVip',
  360. component: () => import('@/views/buildVip/index'),
  361. hidden: true,
  362. meta: {
  363. noCache: '1',
  364. title: 'VIP/乐理课申请',
  365. belongTopMenu: "/business",
  366. activeMenu: '/vipManager/vipList',
  367. id: 'xx5'
  368. }
  369. },
  370. {
  371. name: '网管课',
  372. path: 'newPractice',
  373. component: () => import('@/views/buildVip/index'),
  374. hidden: true,
  375. meta: {
  376. noCache: '1',
  377. title: '网管课申请',
  378. belongTopMenu: "/business",
  379. activeMenu: '/accompanyManager/accompany',
  380. id: 'xx5'
  381. }
  382. },
  383. {
  384. name: 'vip修改',
  385. path: 'vipReset',
  386. component: () => import('@/views/vipClass/vipReset'),
  387. hidden: true,
  388. meta: {
  389. noCache: '1',
  390. title: 'VIP/乐理课修改',
  391. belongTopMenu: "/business",
  392. activeMenu: '/vipManager/vipList',
  393. id: 'xx6'
  394. }
  395. },
  396. {
  397. name: 'vip详情',
  398. path: 'vipDetail',
  399. component: () => import('@/views/vipClass/vipDetail'),
  400. hidden: true,
  401. meta: {
  402. noCache: '1',
  403. title: 'vip详情',
  404. belongTopMenu: "/business",
  405. activeMenu: '/vipManager/vipList',
  406. id: 'xx7'
  407. }
  408. },
  409. {
  410. name: '网管课详情',
  411. path: 'accompanys',
  412. component: () => import('@/views/accompanyManager/accompanys'),
  413. hidden: true,
  414. meta: {
  415. noCache: '1',
  416. title: '网管课详情',
  417. belongTopMenu: "/business",
  418. activeMenu: '/accompanyManager/accompany',
  419. id: 'xx8'
  420. }
  421. },
  422. {
  423. name: '评价详情',
  424. path: 'evaluateDetail',
  425. component: () => import('@/views/evaluateManager/evaluateDetail'),
  426. hidden: true,
  427. meta: {
  428. noCache: '1',
  429. title: '评价详情',
  430. belongTopMenu: "/business",
  431. activeMenu: '/commentManager',
  432. id: 'xx9'
  433. }
  434. },
  435. {
  436. name: '课外训练详情',
  437. path: 'afterSchoolDetail',
  438. component: () => import('@/views/afterSchoolManager/afterSchoolDetail'),
  439. hidden: true,
  440. meta: {
  441. noCache: '1',
  442. title: 'VIP/乐理课详情',
  443. belongTopMenu: "/business",
  444. activeMenu: '/afterSchoolManager',
  445. id: 'xx10'
  446. }
  447. },
  448. {
  449. name: '学员详情',
  450. path: 'studentDetail',
  451. component: () => import('@/views/studentManager/index'),
  452. hidden: true,
  453. meta: {
  454. noCache: '1',
  455. title: '学员详情',
  456. belongTopMenu: "/business",
  457. activeMenu: '/studentManager/studentList',
  458. id: 'xx11'
  459. }
  460. },
  461. {
  462. name: '老师详情',
  463. path: 'teacherDetail',
  464. component: () => import('@/views/teacherManager/teacherDetail/index'),
  465. hidden: true,
  466. meta: {
  467. noCache: '1',
  468. title: '老师详情',
  469. belongTopMenu: "/business",
  470. activeMenu: '/teacherManager/teacherList',
  471. id: 'xx12'
  472. }
  473. },
  474. {
  475. name: '老师修改',
  476. path: 'teacherOperation',
  477. component: () => import('@/views/teacherManager/teacherOperation/index'),
  478. hidden: true,
  479. meta: {
  480. noCache: '1',
  481. title: '老师修改',
  482. belongTopMenu: "/business",
  483. activeMenu: '/teacherManager/teacherList',
  484. id: 'xx13'
  485. }
  486. },
  487. {
  488. name: '问答详情',
  489. path: 'answer',
  490. component: () => import('@/views/reaplceMusicPlayer/answerList'),
  491. hidden: true,
  492. meta: {
  493. noCache: '1',
  494. title: '问答详情',
  495. belongTopMenu: "/business",
  496. activeMenu: '/otherManager/reaplceMusicPlayer',
  497. id: 'xx4'
  498. }
  499. },
  500. {
  501. name: '活动详情',
  502. path: 'childrensdayDetail',
  503. component: () => import('@/views/childrensDay/detail'),
  504. hidden: true,
  505. meta: {
  506. noCache: '1',
  507. title: '活动详情',
  508. belongTopMenu: "/business",
  509. activeMenu: '/childrensDay'
  510. }
  511. },
  512. // /otherManager/reaplceMusicPlayer /reaplceMusicPlayer/answer
  513. ])
  514. }
  515. if (route.path == '/operateManager') {
  516. route.children = route.children.concat([{
  517. name: '服务指标(详情)',
  518. path: 'serverIndexDetail',
  519. component: () => import('@/views/operateManager/serverIndexDetail'),
  520. hidden: true,
  521. meta: {
  522. noCache: '1',
  523. title: '服务指标(详情)',
  524. belongTopMenu: "/operateManager",
  525. activeMenu: '/serverIndexManager/serverIndexList',
  526. id: 'xx15'
  527. }
  528. },
  529. {
  530. name: '新建活动方案',
  531. path: 'vipNewActive',
  532. component: () => import('@/views/categroyManager/vipNewActive'),
  533. hidden: true,
  534. meta: {
  535. noCache: '1',
  536. title: '新建活动方案',
  537. belongTopMenu: "/operateManager",
  538. activeMenu: '/vipActiveManager/vipActiveList',
  539. id: 'xx16'
  540. }
  541. },
  542. {
  543. name: '活动资格管理',
  544. path: 'activeSenior',
  545. component: () => import('@/views/categroyManager/activeSenior'),
  546. hidden: true,
  547. meta: {
  548. noCache: '1',
  549. title: '活动资格管理',
  550. belongTopMenu: "/operateManager",
  551. activeMenu: '/vipActiveManager/vipActiveList',
  552. id: 'xx16'
  553. }
  554. },
  555. // activeSenior
  556. {
  557. name: '添加分部活动',
  558. path: 'branchActiveOperationAdd',
  559. component: () => import('@/views/categroyManager/insideSetting/branchActiveOperation'),
  560. hidden: true,
  561. meta: {
  562. noCache: '1',
  563. title: '添加分部活动',
  564. belongTopMenu: "/operateManager",
  565. activeMenu: '/branchActiveManager/branchActive',
  566. id: 'xx17'
  567. }
  568. },
  569. {
  570. name: '修改分部活动',
  571. path: 'branchActiveOperation',
  572. component: () => import('@/views/categroyManager/insideSetting/branchActiveOperation'),
  573. hidden: true,
  574. meta: {
  575. noCache: '1',
  576. title: '修改分部活动',
  577. belongTopMenu: "/operateManager",
  578. activeMenu: '/branchActiveManager/branchActive',
  579. id: 'xx18'
  580. }
  581. },
  582. {
  583. name: '添加问卷',
  584. path: 'questionOperations',
  585. component: () => import('@/views/setQuestions/operation'),
  586. hidden: true,
  587. meta: {
  588. noCache: '1',
  589. title: '添加问卷',
  590. belongTopMenu: "/operateManager",
  591. activeMenu: '/operateManager/setQuestions',
  592. id: 'xx19'
  593. }
  594. },
  595. {
  596. name: '2021memeberActionManager',
  597. path: '/2021memeberActionManager',
  598. component: () => import('@/views/2021memeberActionManager'),
  599. hidden: true,
  600. meta: {
  601. noCache: '1',
  602. title: '2021会员活动',
  603. belongTopMenu: "/operateManager",
  604. activeMenu: '/activeMarketing',
  605. id: 'xx19'
  606. }
  607. },
  608. {
  609. name: 'memberActiveDetail',
  610. path: 'memberActiveDetail',
  611. component: () => import('@/views/2021memeberActionManager/memberActiveDetail'),
  612. hidden: true,
  613. meta: {
  614. noCache: '1',
  615. title: '2021十一活动详情',
  616. belongTopMenu: "/operateManager",
  617. activeMenu: '/activeMarketing',
  618. id: 'xx19'
  619. }
  620. },
  621. {
  622. name: '2021double11List',
  623. path: '/2021double11List',
  624. component: () => import('@/views/activityScheduling/2021double11List'),
  625. hidden: true,
  626. meta: {
  627. noCache: '1',
  628. title: '2021双十一活动',
  629. belongTopMenu: "/operateManager",
  630. activeMenu: '/activeMarketing',
  631. id: 'xx19'
  632. }
  633. },
  634. {
  635. name: '2021doubleDetail',
  636. path: '2021doubleDetail',
  637. component: () => import('@/views/activityScheduling/2021doubleDetail'),
  638. hidden: true,
  639. meta: {
  640. noCache: '1',
  641. title: '2021双十一活动详情',
  642. belongTopMenu: "/operateManager",
  643. activeMenu: '/activeMarketing',
  644. id: 'xx19'
  645. }
  646. },
  647. {
  648. name: '新增优惠券',
  649. path: 'couponUpdate',
  650. component: () => import('@/views/couponManager/couponUpdate'),
  651. hidden: true,
  652. meta: {
  653. noCache: '1',
  654. title: '新增优惠券',
  655. belongTopMenu: "/operateManager",
  656. activeMenu: '/couponManager',
  657. id: 'xx19'
  658. }
  659. },
  660. {
  661. name: '发放优惠券',
  662. path: 'couponGrant',
  663. component: () => import('@/views/couponManager/couponGrant'),
  664. hidden: true,
  665. meta: {
  666. noCache: '1',
  667. title: '发放优惠券',
  668. belongTopMenu: "/operateManager",
  669. activeMenu: '/couponManager',
  670. id: 'xx19'
  671. }
  672. },
  673. {
  674. name: '答题详情',
  675. path: 'userAskList',
  676. component: () => import('@/views/setQuestions/userAskList'),
  677. hidden: true,
  678. meta: {
  679. noCache: '1',
  680. title: '答题详情',
  681. belongTopMenu: "/operateManager",
  682. activeMenu: '/operateManager/setQuestions',
  683. id: 'xx19'
  684. }
  685. },
  686. ])
  687. }
  688. if (route.path == '/financialManager') {
  689. route.children = route.children.concat([{
  690. name: '经营报表详情',
  691. path: 'businessStatementDetail',
  692. component: () => import('@/views/businessManager/orderManager/businessStatementDetail'),
  693. hidden: true,
  694. meta: {
  695. noCache: '1',
  696. title: '经营报表详情',
  697. belongTopMenu: "/financialManager",
  698. activeMenu: '/businessStatement',
  699. id: 'xx20'
  700. }
  701. }, ])
  702. }
  703. if (route.path == '/contentManager') {
  704. route.children = route.children.concat([{
  705. name: '经营报表详情',
  706. path: 'helpCategory',
  707. component: () => import('@/views/helpCenter/helpCategory'),
  708. hidden: true,
  709. meta: {
  710. noCache: '1',
  711. title: '经营报表详情',
  712. belongTopMenu: "/contentManager",
  713. activeMenu: '/contentManager/helpContent',
  714. id: 'xx21'
  715. }
  716. },
  717. {
  718. name: '添加&修改内容管理',
  719. path: 'contentOperation',
  720. component: () => import('@/views/contentManager/contentOperation'),
  721. hidden: true,
  722. meta: {
  723. noCache: '1',
  724. title: '添加&修改内容管理',
  725. belongTopMenu: "/contentManager",
  726. activeMenu: '/contentManager/contentManager',
  727. id: 'xx22'
  728. }
  729. },
  730. ])
  731. }
  732. if (route.path == '/shopManager') {
  733. route.children = route.children.concat([{
  734. name: '进货清单',
  735. path: 'purchaseLlist',
  736. component: () => import('@/views/businessManager/shopManager/purchase-llist'),
  737. hidden: true,
  738. meta: {
  739. noCache: '1',
  740. title: '进货清单',
  741. belongTopMenu: "/shopManager",
  742. activeMenu: '/shopList',
  743. id: 'xx23'
  744. }
  745. },
  746. {
  747. name: '添加修改商品',
  748. path: 'shopOperation',
  749. component: () => import('@/views/businessManager/shopManager/shopOperation'),
  750. hidden: true,
  751. meta: {
  752. noCache: '1',
  753. title: '添加修改商品',
  754. belongTopMenu: "/shopManager",
  755. activeMenu: '/shopList',
  756. id: 'xx24'
  757. }
  758. },
  759. ])
  760. }
  761. if (route.path == '/systemManager') {
  762. route.children = route.children.concat([{
  763. name: '创建&修改汇付账号',
  764. path: 'adapayOperation',
  765. component: () => import('@/views/adapayAccount/form'),
  766. hidden: true,
  767. meta: {
  768. noCache: '1',
  769. title: '创建&修改汇付账号',
  770. belongTopMenu: "/systemManager",
  771. activeMenu: '/sysBasics/adapayManager',
  772. id: 'xx25'
  773. }
  774. },
  775. {
  776. name: '添加&查看时间充值活动',
  777. path: 'entryOperation',
  778. component: () => import('@/views/app/entryOperation'),
  779. hidden: true,
  780. meta: {
  781. noCache: '1',
  782. title: '添加&查看时间充值活动',
  783. belongTopMenu: "/systemManager",
  784. activeMenu: '/sysBasics/entryActivities',
  785. id: 'xx26'
  786. }
  787. },
  788. {
  789. name: '添加&修改系统权限',
  790. path: 'adminOperation',
  791. component: () => import('@/views/categroyManager/insideSetting/adminOperation'),
  792. hidden: true,
  793. meta: {
  794. noCache: '1',
  795. title: '添加&修改系统权限',
  796. belongTopMenu: "/systemManager",
  797. activeMenu: '/parameter/adminManager',
  798. id: 'xx27'
  799. }
  800. },
  801. // /parameter/adminManager adminOperation
  802. ])
  803. }
  804. if(route.path == '/platformManager') {
  805. route.children = route.children.concat([{
  806. name: '添加&修改',
  807. path: 'serviceOperation',
  808. component: () => import('@/views/platformManager/serviceManager/form'),
  809. hidden: true,
  810. meta: {
  811. noCache: '1',
  812. title: '添加&修改',
  813. belongTopMenu: "/platformManager",
  814. activeMenu: '/serviceManager/serviceList',
  815. id: 'xx28'
  816. }
  817. }])
  818. }
  819. if(route.path == '/federationManager') {
  820. if(!route.children) {
  821. route.children = []
  822. }
  823. route.children = route.children.concat([{
  824. name: '添加&修改',
  825. path: 'organOperation',
  826. component: () => import('@/views/organManager/organOperation'),
  827. hidden: true,
  828. meta: {
  829. noCache: '1',
  830. title: '添加&修改',
  831. belongTopMenu: "/federationManager",
  832. activeMenu: '/organManager/organList',
  833. id: 'xx29'
  834. }
  835. }])
  836. }
  837. })
  838. return accessedRoutes
  839. }
  840. const actions = {
  841. generateRoutes({
  842. commit
  843. }) {
  844. return new Promise(resolve => {
  845. // 获取接口返回的权限菜单
  846. getSilder().then(async res => {
  847. if (res.code == 200) {
  848. let result = addTopMenu(res.data)
  849. if (res.data?.length < 1) {
  850. // 一条权限都没有
  851. //退出 跳到登录页 提示'该账号无任何权限'
  852. // console.log(store.dispatch)
  853. await store.dispatch("user/logout");
  854. localStorage.removeItem("firstMenuUrl");
  855. // await this.$store.dispatch("permission/removePermission")
  856. Message.error('该用户无访问权限')
  857. router.push(`/login`);
  858. // window.location.reload();
  859. }
  860. let newData = recursionRouter(result);
  861. newData = getFirstMenu(newData)
  862. recursionPermission(res.data)
  863. let accessedRoutes
  864. // 生成异步路由表
  865. accessedRoutes = generateAsyncRouter(asyncRoutes, newData)
  866. accessedRoutes = setDetailRoute(accessedRoutes)
  867. // console.log('生成出来的异步路由', accessedRoutes)
  868. // var result = accessedRoutes.concat({ path: '*', redirect: '/404', hidden: true })
  869. commit('SET_ROUTES', accessedRoutes)
  870. // commit('SET_PERMISSION', recursionPermission(res.data).flat(Infinity))
  871. window.localStorage.removeItem('permission')
  872. window.localStorage.setItem('permission', tempArr)
  873. this.dispatch('app/setDotStatus')
  874. resolve(accessedRoutes)
  875. }
  876. })
  877. })
  878. },
  879. removePermission({
  880. commit
  881. }) {
  882. window.localStorage.removeItem('permission')
  883. commit('SET_PERMISSION', [])
  884. }
  885. }
  886. export default {
  887. namespaced: true,
  888. state,
  889. mutations,
  890. actions
  891. }