permission.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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: 'studentPaySet',
  292. component: () => import('@/views/resetTeaming/components/payInfoDetail'),
  293. hidden: true,
  294. meta: {
  295. noCache: '1',
  296. title: '学员缴费设置',
  297. belongTopMenu: "/business",
  298. activeMenu: '/teamList',
  299. id: 'xx3'
  300. }
  301. },
  302. {
  303. name: '乐团详情',
  304. path: 'resetTeaming',
  305. component: () => import('@/views/resetTeaming/index'),
  306. hidden: true,
  307. meta: {
  308. noCache: '1',
  309. title: '乐团详情',
  310. belongTopMenu: "/business",
  311. activeMenu: '/teamList',
  312. id: '3953'
  313. }
  314. },
  315. {
  316. name: '乐团档案',
  317. path: 'musicArchices',
  318. component: () => import('@/views/resetTeaming/components/musicArchices'),
  319. hidden: true,
  320. meta: {
  321. noCache: '1',
  322. title: '乐团档案',
  323. belongTopMenu: "/business",
  324. activeMenu: '/teamList',
  325. id: 'xx4'
  326. }
  327. },
  328. //musicArchices
  329. {
  330. name: '会员排课列表',
  331. path: 'memberClassList',
  332. component: () => import('@/views/teamDetail/components/memberClassList'),
  333. hidden: true,
  334. meta: {
  335. noCache: '1',
  336. title: '会员排课列表',
  337. belongTopMenu: "/business",
  338. activeMenu: '/teamList',
  339. id: 'xx28'
  340. }
  341. },
  342. {
  343. name: '相册详情',
  344. path: 'photo-detail',
  345. component: () => import('@/views/photo-detail'),
  346. hidden: true,
  347. meta: {
  348. noCache: '1',
  349. title: '相册详情',
  350. belongTopMenu: "/business",
  351. activeMenu: '/teamList',
  352. id: 'xxx28'
  353. }
  354. },
  355. // 相册详情
  356. {
  357. name: '全部证书',
  358. path: 'performance',
  359. component: () => import('@/views/photo-detail'),
  360. hidden: true,
  361. meta: {
  362. noCache: '1',
  363. title: '全部证书',
  364. belongTopMenu: "/business",
  365. activeMenu: '/teamList',
  366. id: 'xxx28'
  367. }
  368. },
  369. // 全部证书
  370. {
  371. name: '新建vip',
  372. path: 'buildVip',
  373. component: () => import('@/views/buildVip/index'),
  374. hidden: true,
  375. meta: {
  376. noCache: '1',
  377. title: 'VIP/乐理课申请',
  378. belongTopMenu: "/business",
  379. activeMenu: '/vipManager/vipList',
  380. id: 'xx5'
  381. }
  382. },
  383. {
  384. name: '网管课',
  385. path: 'newPractice',
  386. component: () => import('@/views/buildVip/index'),
  387. hidden: true,
  388. meta: {
  389. noCache: '1',
  390. title: '网管课申请',
  391. belongTopMenu: "/business",
  392. activeMenu: '/accompanyManager/accompany',
  393. id: 'xx5'
  394. }
  395. },
  396. {
  397. name: 'vip修改',
  398. path: 'vipReset',
  399. component: () => import('@/views/vipClass/vipReset'),
  400. hidden: true,
  401. meta: {
  402. noCache: '1',
  403. title: 'VIP/乐理课修改',
  404. belongTopMenu: "/business",
  405. activeMenu: '/vipManager/vipList',
  406. id: 'xx6'
  407. }
  408. },
  409. {
  410. name: 'vip详情',
  411. path: 'vipDetail',
  412. component: () => import('@/views/vipClass/vipDetail'),
  413. hidden: true,
  414. meta: {
  415. noCache: '1',
  416. title: 'vip详情',
  417. belongTopMenu: "/business",
  418. activeMenu: '/vipManager/vipList',
  419. id: 'xx7'
  420. }
  421. },
  422. {
  423. name: '网管课详情',
  424. path: 'accompanys',
  425. component: () => import('@/views/accompanyManager/accompanys'),
  426. hidden: true,
  427. meta: {
  428. noCache: '1',
  429. title: '网管课详情',
  430. belongTopMenu: "/business",
  431. activeMenu: '/accompanyManager/accompany',
  432. id: 'xx8'
  433. }
  434. },
  435. {
  436. name: '评价详情',
  437. path: 'evaluateDetail',
  438. component: () => import('@/views/evaluateManager/evaluateDetail'),
  439. hidden: true,
  440. meta: {
  441. noCache: '1',
  442. title: '评价详情',
  443. belongTopMenu: "/business",
  444. activeMenu: '/commentManager',
  445. id: 'xx9'
  446. }
  447. },
  448. {
  449. name: '课外训练详情',
  450. path: 'afterSchoolDetail',
  451. component: () => import('@/views/afterSchoolManager/afterSchoolDetail'),
  452. hidden: true,
  453. meta: {
  454. noCache: '1',
  455. title: 'VIP/乐理课详情',
  456. belongTopMenu: "/business",
  457. activeMenu: '/afterSchoolManager',
  458. id: 'xx10'
  459. }
  460. },
  461. {
  462. name: '学员详情',
  463. path: 'studentDetail',
  464. component: () => import('@/views/studentManager/index'),
  465. hidden: true,
  466. meta: {
  467. noCache: '1',
  468. title: '学员详情',
  469. belongTopMenu: "/business",
  470. activeMenu: '/studentManager/studentList',
  471. id: '4083'
  472. }
  473. },
  474. {
  475. name: '老师详情',
  476. path: 'teacherDetail',
  477. component: () => import('@/views/teacherManager/teacherDetail/index'),
  478. hidden: true,
  479. meta: {
  480. noCache: '1',
  481. title: '老师详情',
  482. belongTopMenu: "/business",
  483. activeMenu: '/teacherManager/teacherList',
  484. id: '4118'
  485. }
  486. },
  487. {
  488. name: '老师修改',
  489. path: 'teacherOperation',
  490. component: () => import('@/views/teacherManager/teacherOperation/index'),
  491. hidden: true,
  492. meta: {
  493. noCache: '1',
  494. title: '老师修改',
  495. belongTopMenu: "/business",
  496. activeMenu: '/teacherManager/teacherList',
  497. id: '4174'
  498. }
  499. },
  500. {
  501. name: '问答详情',
  502. path: 'answer',
  503. component: () => import('@/views/reaplceMusicPlayer/answerList'),
  504. hidden: true,
  505. meta: {
  506. noCache: '1',
  507. title: '问答详情',
  508. belongTopMenu: "/business",
  509. activeMenu: '/otherManager/reaplceMusicPlayer',
  510. id: '4293'
  511. }
  512. },
  513. {
  514. name: '活动详情',
  515. path: 'childrensdayDetail',
  516. component: () => import('@/views/childrensDay/detail'),
  517. hidden: true,
  518. meta: {
  519. noCache: '1',
  520. title: '活动详情',
  521. belongTopMenu: "/business",
  522. activeMenu: '/childrensDay'
  523. }
  524. },
  525. // /otherManager/reaplceMusicPlayer /reaplceMusicPlayer/answer
  526. ])
  527. }
  528. if (route.path == '/operateManager') {
  529. route.children = route.children.concat([{
  530. name: '服务指标(详情)',
  531. path: 'serverIndexDetail',
  532. component: () => import('@/views/operateManager/serverIndexDetail'),
  533. hidden: true,
  534. meta: {
  535. noCache: '1',
  536. title: '服务指标(详情)',
  537. belongTopMenu: "/operateManager",
  538. activeMenu: '/serverIndexManager/serverIndexList',
  539. id: '3513'
  540. }
  541. },
  542. {
  543. name: '新建活动方案',
  544. path: 'vipNewActive',
  545. component: () => import('@/views/categroyManager/vipNewActive'),
  546. hidden: true,
  547. meta: {
  548. noCache: '1',
  549. title: '新建活动方案',
  550. belongTopMenu: "/operateManager",
  551. activeMenu: '/vipActiveManager/vipActiveList',
  552. id: '3558'
  553. }
  554. },
  555. {
  556. name: '活动资格管理',
  557. path: 'activeSenior',
  558. component: () => import('@/views/categroyManager/activeSenior'),
  559. hidden: true,
  560. meta: {
  561. noCache: '1',
  562. title: '活动资格管理',
  563. belongTopMenu: "/operateManager",
  564. activeMenu: '/vipActiveManager/vipActiveList',
  565. id: '4610'
  566. }
  567. },
  568. // activeSenior
  569. {
  570. name: '添加分部活动',
  571. path: 'branchActiveOperationAdd',
  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: '3527'
  580. }
  581. },
  582. {
  583. name: '修改分部活动',
  584. path: 'branchActiveOperation',
  585. component: () => import('@/views/categroyManager/insideSetting/branchActiveOperation'),
  586. hidden: true,
  587. meta: {
  588. noCache: '1',
  589. title: '修改分部活动',
  590. belongTopMenu: "/operateManager",
  591. activeMenu: '/branchActiveManager/branchActive',
  592. id: '3528'
  593. }
  594. },
  595. {
  596. name: '添加问卷',
  597. path: 'questionOperations',
  598. component: () => import('@/views/setQuestions/operation'),
  599. hidden: true,
  600. meta: {
  601. noCache: '1',
  602. title: '添加问卷',
  603. belongTopMenu: "/operateManager",
  604. activeMenu: '/operateManager/setQuestions',
  605. id: '4286'
  606. }
  607. },
  608. {
  609. name: '2021memeberActionManager',
  610. path: '/2021memeberActionManager',
  611. component: () => import('@/views/2021memeberActionManager'),
  612. hidden: true,
  613. meta: {
  614. noCache: '1',
  615. title: '2021会员活动',
  616. belongTopMenu: "/operateManager",
  617. activeMenu: '/activeMarketing',
  618. id: '4550'
  619. }
  620. },
  621. {
  622. name: 'memberActiveDetail',
  623. path: 'memberActiveDetail',
  624. component: () => import('@/views/2021memeberActionManager/memberActiveDetail'),
  625. hidden: true,
  626. meta: {
  627. noCache: '1',
  628. title: '2021十一活动详情',
  629. belongTopMenu: "/operateManager",
  630. activeMenu: '/activeMarketing',
  631. id: '4551'
  632. }
  633. },
  634. {
  635. name: '2021double11List',
  636. path: '/2021double11List',
  637. component: () => import('@/views/activityScheduling/2021double11List'),
  638. hidden: true,
  639. meta: {
  640. noCache: '1',
  641. title: '2021双十一活动',
  642. belongTopMenu: "/operateManager",
  643. activeMenu: '/activeMarketing',
  644. id: '4594'
  645. }
  646. },
  647. {
  648. name: '2021doubleDetail',
  649. path: '2021doubleDetail',
  650. component: () => import('@/views/activityScheduling/2021doubleDetail'),
  651. hidden: true,
  652. meta: {
  653. noCache: '1',
  654. title: '2021双十一活动详情',
  655. belongTopMenu: "/operateManager",
  656. activeMenu: '/activeMarketing',
  657. id: '4595'
  658. }
  659. },
  660. {
  661. name: '新增优惠券',
  662. path: 'couponUpdate',
  663. component: () => import('@/views/couponManager/couponUpdate'),
  664. hidden: true,
  665. meta: {
  666. noCache: '1',
  667. title: '新增优惠券',
  668. belongTopMenu: "/operateManager",
  669. activeMenu: '/couponManager',
  670. id: '4553'
  671. }
  672. },
  673. {
  674. name: '发放优惠券',
  675. path: 'couponGrant',
  676. component: () => import('@/views/couponManager/couponGrant'),
  677. hidden: true,
  678. meta: {
  679. noCache: '1',
  680. title: '发放优惠券',
  681. belongTopMenu: "/operateManager",
  682. activeMenu: '/couponManager',
  683. id: 'xx19'
  684. }
  685. },
  686. {
  687. name: '答题详情',
  688. path: 'userAskList',
  689. component: () => import('@/views/setQuestions/userAskList'),
  690. hidden: true,
  691. meta: {
  692. noCache: '1',
  693. title: '答题详情',
  694. belongTopMenu: "/operateManager",
  695. activeMenu: '/operateManager/setQuestions',
  696. id: 'xx19'
  697. }
  698. },
  699. ])
  700. }
  701. if (route.path == '/financialManager') {
  702. route.children = route.children.concat([{
  703. name: '经营报表详情',
  704. path: 'businessStatementDetail',
  705. component: () => import('@/views/businessManager/orderManager/businessStatementDetail'),
  706. hidden: true,
  707. meta: {
  708. noCache: '1',
  709. title: '经营报表详情',
  710. belongTopMenu: "/financialManager",
  711. activeMenu: '/businessStatement',
  712. id: '4217'
  713. }
  714. }, ])
  715. }
  716. if (route.path == '/contentManager') {
  717. route.children = route.children.concat([{
  718. name: '帮助中心分类',
  719. path: 'helpCategory',
  720. component: () => import('@/views/helpCenter/helpCategory'),
  721. hidden: true,
  722. meta: {
  723. noCache: '1',
  724. title: '帮助中心分类',
  725. belongTopMenu: "/contentManager",
  726. activeMenu: '/contentManager/helpContent',
  727. id: '3596'
  728. }
  729. },
  730. {
  731. name: '添加&修改内容管理',
  732. path: 'contentOperation',
  733. component: () => import('@/views/contentManager/contentOperation'),
  734. hidden: true,
  735. meta: {
  736. noCache: '1',
  737. title: '添加&修改内容管理',
  738. belongTopMenu: "/contentManager",
  739. activeMenu: '/contentManager/contentManager',
  740. id: 'xx22'
  741. }
  742. },
  743. ])
  744. }
  745. if (route.path == '/shopManager') {
  746. route.children = route.children.concat([{
  747. name: '进货清单',
  748. path: 'purchaseLlist',
  749. component: () => import('@/views/businessManager/shopManager/purchase-llist'),
  750. hidden: true,
  751. meta: {
  752. noCache: '1',
  753. title: '进货清单',
  754. belongTopMenu: "/shopManager",
  755. activeMenu: '/shopList',
  756. id: '3618'
  757. }
  758. },
  759. {
  760. name: '添加修改商品',
  761. path: 'shopOperation',
  762. component: () => import('@/views/businessManager/shopManager/shopOperation'),
  763. hidden: true,
  764. meta: {
  765. noCache: '1',
  766. title: '添加修改商品',
  767. belongTopMenu: "/shopManager",
  768. activeMenu: '/shopList',
  769. id: '3617'
  770. }
  771. },
  772. ])
  773. }
  774. if (route.path == '/systemManager') {
  775. route.children = route.children.concat([{
  776. name: '创建&修改汇付账号',
  777. path: 'adapayOperation',
  778. component: () => import('@/views/adapayAccount/form'),
  779. hidden: true,
  780. meta: {
  781. noCache: '1',
  782. title: '创建&修改汇付账号',
  783. belongTopMenu: "/systemManager",
  784. activeMenu: '/sysBasics/adapayManager',
  785. id: '3748'
  786. }
  787. },
  788. {
  789. name: '添加&查看时间充值活动',
  790. path: 'entryOperation',
  791. component: () => import('@/views/app/entryOperation'),
  792. hidden: true,
  793. meta: {
  794. noCache: '1',
  795. title: '添加&查看时间充值活动',
  796. belongTopMenu: "/systemManager",
  797. activeMenu: '/sysBasics/entryActivities',
  798. id: '3773'
  799. }
  800. },
  801. {
  802. name: '添加&修改系统权限',
  803. path: 'adminOperation',
  804. component: () => import('@/views/categroyManager/insideSetting/adminOperation'),
  805. hidden: true,
  806. meta: {
  807. noCache: '1',
  808. title: '添加&修改系统权限',
  809. belongTopMenu: "/systemManager",
  810. activeMenu: '/parameter/adminManager',
  811. id: '3993'
  812. }
  813. }, {
  814. name: '扣费记录',
  815. path: 'chargingRecord',
  816. component: () => import('@/views/tenantSetting/chargingRecord.vue'),
  817. hidden: true,
  818. meta: {
  819. noCache: '1',
  820. title: '扣费记录',
  821. belongTopMenu: "/systemManager",
  822. activeMenu: '/productService',
  823. id: '4741'
  824. }
  825. }
  826. // /parameter/adminManager adminOperation
  827. ])
  828. }
  829. if (route.path == '/platformManager') {
  830. route.children = route.children.concat([{
  831. name: '添加&修改',
  832. path: 'serviceOperation',
  833. component: () => import('@/views/platformManager/serviceManager/form'),
  834. hidden: true,
  835. meta: {
  836. noCache: '1',
  837. title: '添加&修改',
  838. belongTopMenu: "/platformManager",
  839. activeMenu: '/serviceManager/serviceList',
  840. id: '4631'
  841. }
  842. }, {
  843. name: '添加&修改',
  844. path: 'organOperation',
  845. component: () => import('@/views/organManager/organOperation'),
  846. hidden: true,
  847. meta: {
  848. noCache: '1',
  849. title: '添加&修改',
  850. belongTopMenu: "/platformManager",
  851. activeMenu: '/organManager/organList',
  852. id: '4652'
  853. }
  854. }])
  855. }
  856. })
  857. return accessedRoutes
  858. }
  859. const actions = {
  860. generateRoutes({
  861. commit
  862. }) {
  863. return new Promise(resolve => {
  864. // 获取接口返回的权限菜单
  865. getSilder().then(async res => {
  866. if (res.code == 200) {
  867. let result = addTopMenu(res.data)
  868. if (res.data?.length < 1) {
  869. // 一条权限都没有
  870. //退出 跳到登录页 提示'该账号无任何权限'
  871. // console.log(store.dispatch)
  872. await store.dispatch("user/logout");
  873. localStorage.removeItem("firstMenuUrl");
  874. // await this.$store.dispatch("permission/removePermission")
  875. Message.error('该用户无访问权限')
  876. router.push(`/login`);
  877. // window.location.reload();
  878. }
  879. let newData = recursionRouter(result);
  880. newData = getFirstMenu(newData)
  881. recursionPermission(res.data)
  882. let accessedRoutes
  883. // 生成异步路由表
  884. accessedRoutes = generateAsyncRouter(asyncRoutes, newData)
  885. accessedRoutes = setDetailRoute(accessedRoutes)
  886. // console.log('生成出来的异步路由', accessedRoutes)
  887. // var result = accessedRoutes.concat({ path: '*', redirect: '/404', hidden: true })
  888. commit('SET_ROUTES', accessedRoutes)
  889. // commit('SET_PERMISSION', recursionPermission(res.data).flat(Infinity))
  890. window.localStorage.removeItem('permission')
  891. window.localStorage.setItem('permission', tempArr)
  892. this.dispatch('app/setDotStatus')
  893. this.dispatch('app/setServiceInfo') // 获取机构信息,用于续费弹窗和个人信息
  894. resolve(accessedRoutes)
  895. }
  896. })
  897. })
  898. },
  899. removePermission({
  900. commit
  901. }) {
  902. window.localStorage.removeItem('permission')
  903. commit('SET_PERMISSION', [])
  904. }
  905. }
  906. export default {
  907. namespaced: true,
  908. state,
  909. mutations,
  910. actions
  911. }