index.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Layout from '@/views/Layout.vue'
  4. import axios from 'axios'
  5. import { getEffectivePermissions, hasPermission, getRoleHomePage } from '@/utils/permissions'
  6. import { orgMy } from '@/api/org'
  7. Vue.use(VueRouter)
  8. const routes = [
  9. {
  10. path: '/login',
  11. name: 'Login',
  12. component: () => import('@/views/Login.vue')
  13. },
  14. {
  15. path: '/403',
  16. name: 'Forbidden',
  17. component: { template: '<div style="text-align:center;padding:100px"><h1>403</h1><p>权限不足</p><router-link to="/">返回首页</router-link></div>' },
  18. meta: { title: '权限不足' }
  19. },
  20. {
  21. path: '/',
  22. component: Layout,
  23. redirect: '/dashboard',
  24. children: [
  25. {
  26. path: 'dashboard',
  27. name: 'Dashboard',
  28. component: () => import('@/views/Dashboard.vue'),
  29. meta: { title: '首页', perm: 'dashboard' }
  30. },
  31. {
  32. path: 'teacher-dashboard',
  33. name: 'TeacherDashboard',
  34. component: () => import('@/views/TeacherDashboard.vue'),
  35. meta: { title: '规划师首页', requiresTeacher: true, perm: 'dashboard' }
  36. },
  37. {
  38. path: 'admin/dashboard',
  39. name: 'AdminDashboard',
  40. component: () => import('@/views/admin/Dashboard'),
  41. meta: { title: '数据大屏', roles: ['admin'] }
  42. },
  43. // 家庭管理
  44. {
  45. path: 'families',
  46. name: 'Families',
  47. component: () => import('@/views/Families.vue'),
  48. meta: { title: '家庭列表', perm: 'family:list' }
  49. },
  50. {
  51. path: 'children',
  52. name: 'Children',
  53. component: () => import('@/views/Children.vue'),
  54. meta: { title: '孩子管理', perm: 'family:children' }
  55. },
  56. {
  57. path: 'points',
  58. name: 'Points',
  59. component: () => import('@/views/Points.vue'),
  60. meta: { title: '积分管理', perm: 'family:points' }
  61. },
  62. {
  63. path: 'points-log',
  64. name: 'PointsLog',
  65. component: () => import('@/views/admin/PointsLog.vue'),
  66. meta: { title: '积分记录', perm: 'family:points' }
  67. },
  68. {
  69. path: 'membership-center',
  70. name: 'MembershipCenter',
  71. component: () => import('@/views/admin/MembershipCenter.vue'),
  72. meta: { title: '会员中心', perm: 'config:member' }
  73. },
  74. // 方案中心
  75. {
  76. path: 'health-plan-manage',
  77. name: 'HealthPlanManage',
  78. component: () => import('@/views/admin/HealthPlanManage.vue'),
  79. meta: { title: '健康方案管理', perm: 'plan:health' }
  80. },
  81. {
  82. path: 'assessment-plan-manage',
  83. name: 'AssessmentPlanManage',
  84. component: () => import('@/views/admin/AssessmentPlanManage.vue'),
  85. meta: { title: '测评方案管理', perm: 'plan:assessment' }
  86. },
  87. // 任务管理
  88. {
  89. path: 'tasks',
  90. name: 'Tasks',
  91. component: () => import('@/views/Tasks.vue'),
  92. meta: { title: '任务列表', perm: 'task:list' }
  93. },
  94. {
  95. path: 'task-templates',
  96. name: 'TaskTemplates',
  97. component: () => import('@/views/TaskTemplates.vue'),
  98. meta: { title: '任务模板', perm: 'task:templates' }
  99. },
  100. {
  101. path: 'orchestration',
  102. name: 'OrchestrationFlow',
  103. component: () => import('@/views/orchestration/OrchestrationFlow.vue'),
  104. meta: { title: '编排流管理', perm: 'task:templates' }
  105. },
  106. {
  107. path: 'orchestration/edit/:id?',
  108. name: 'FlowEditor',
  109. component: () => import('@/views/orchestration/FlowEditor.vue'),
  110. meta: { title: '编排画布', perm: 'task:templates' }
  111. },
  112. {
  113. path: 'orchestration/execution/:id',
  114. name: 'ExecutionDetail',
  115. component: () => import('@/views/orchestration/ExecutionDetail.vue'),
  116. meta: { title: '执行详情', perm: 'task:templates' }
  117. },
  118. {
  119. path: 'growth-task',
  120. name: 'GrowthTaskManagement',
  121. component: () => import('@/views/admin/GrowthTaskManagement'),
  122. meta: { title: '成长任务管理', perm: 'task:list' }
  123. },
  124. // 奖励管理
  125. {
  126. path: 'rewards',
  127. name: 'Rewards',
  128. component: () => import('@/views/Rewards.vue'),
  129. meta: { title: '奖励列表', perm: 'family:rewards' }
  130. },
  131. {
  132. path: 'wishes',
  133. name: 'Wishes',
  134. component: () => import('@/views/Wishes.vue'),
  135. meta: { title: '心愿管理', perm: 'family:wishes' }
  136. },
  137. // 成长规划师管理
  138. {
  139. path: 'guide-packages',
  140. name: 'GuidePackages',
  141. component: () => import('@/views/GuidePackages.vue'),
  142. meta: { title: '成长规划师任务模板', requiresTeacher: true, perm: 'biz:packages' }
  143. },
  144. {
  145. path: 'guide-family-task',
  146. name: 'GuideFamilyTask',
  147. component: () => import('@/views/GuideFamilyTask.vue'),
  148. meta: { title: '家庭任务管理', requiresTeacher: true, perm: 'service:families' }
  149. },
  150. {
  151. path: 'teacher-consult',
  152. name: 'TeacherConsult',
  153. component: () => import('@/views/TeacherConsult.vue'),
  154. meta: { title: '家长咨询', requiresTeacher: true, perm: 'assessment:consult' }
  155. },
  156. {
  157. path: 'teacher-families',
  158. name: 'TeacherFamilies',
  159. component: () => import('@/views/teacher/TeacherFamilies.vue'),
  160. meta: { title: '我的家庭', requiresTeacher: true, perm: 'service:families' }
  161. },
  162. {
  163. path: 'teacher-team',
  164. name: 'TeacherTeam',
  165. component: () => import('@/views/teacher/TeacherTeam.vue'),
  166. meta: { title: '我的团队', requiresTeacher: true, perm: 'service:team' }
  167. },
  168. {
  169. path: 'teacher-packages',
  170. name: 'TeacherPackages',
  171. component: () => import('@/views/teacher/TeacherPackages.vue'),
  172. meta: { title: '任务模板管理', requiresTeacher: true, perm: 'biz:packages' }
  173. },
  174. {
  175. path: 'teacher-orders',
  176. name: 'TeacherOrders',
  177. component: () => import('@/views/teacher/TeacherOrders.vue'),
  178. meta: { title: '订单与佣金', requiresTeacher: true, perm: 'biz:orders' }
  179. },
  180. // 系统管理
  181. {
  182. path: 'users',
  183. name: 'Users',
  184. component: () => import('@/views/Users.vue'),
  185. meta: { title: '用户管理', perm: 'system:users' }
  186. },
  187. {
  188. path: 'review-center',
  189. name: 'ReviewCenter',
  190. component: () => import('@/views/admin/ReviewCenter.vue'),
  191. meta: { title: '审核中心', perm: 'audit' }
  192. },
  193. {
  194. path: 'butler-assignments',
  195. name: 'ButlerAssignments',
  196. component: () => import('@/views/admin/ButlerAssignments.vue'),
  197. meta: { title: '管家分配管理', perm: 'audit' }
  198. },
  199. {
  200. path: 'operation-logs',
  201. name: 'OperationLogs',
  202. component: () => import('@/views/OperationLogs.vue'),
  203. meta: { title: '操作日志', perm: 'system:logs' }
  204. },
  205. {
  206. path: 'menu-manage',
  207. name: 'MenuManage',
  208. component: () => import('@/views/admin/MenuManage.vue'),
  209. meta: { title: '菜单管理', perm: 'system:menu' }
  210. },
  211. // 服务角色申请审核已合并进审核中心,旧路由重定向
  212. {
  213. path: 'service-role-applications',
  214. name: 'ServiceRoleApplications',
  215. redirect: '/review-center?tab=vendor'
  216. },
  217. {
  218. path: 'teacher-messages',
  219. name: 'TeacherMessages',
  220. component: () => import('@/views/teacher/TeacherMessages.vue'),
  221. meta: { title: '消息中心', requiresTeacher: true, perm: 'messages' }
  222. },
  223. {
  224. path: 'teacher-assessment',
  225. name: 'TeacherAssessment',
  226. component: () => import('@/views/teacher/TeacherAssessment.vue'),
  227. meta: { title: 'DAN测评管理', requiresTeacher: true, perm: 'assessment:dan' }
  228. },
  229. {
  230. path: 'teacher-proxy-report',
  231. name: 'TeacherProxyReport',
  232. component: () => import('@/views/teacher/ProxyReport.vue'),
  233. meta: { title: '代上传报告', requiresTeacher: true, perm: 'health:reports' }
  234. },
  235. {
  236. path: 'teacher-health-plan-review',
  237. name: 'TeacherHealthPlanReview',
  238. component: () => import('@/views/teacher/HealthPlanReview.vue'),
  239. meta: { title: '健康方案审核', requiresTeacher: true, perm: 'health:plan:review' }
  240. },
  241. {
  242. path: 'assessment-admin',
  243. name: 'AssessmentAdmin',
  244. component: () => import('@/views/admin/Assessment.vue'),
  245. meta: { title: '测评管理', perm: 'assessment:dan' }
  246. },
  247. {
  248. path: 'assessment-assign',
  249. name: 'AssessmentAssign',
  250. component: () => import('@/views/admin/AssessmentAssign.vue'),
  251. meta: { title: '待分配规划师', perm: 'assessment:dan' }
  252. },
  253. {
  254. path: 'assessment-orders',
  255. name: 'AssessmentOrders',
  256. component: () => import('@/views/admin/AssessmentOrders.vue'),
  257. meta: { title: '测评订单', perm: 'assessment:dan' }
  258. },
  259. {
  260. path: 'dan-execution',
  261. name: 'DanExecution',
  262. component: () => import('@/views/admin/DanExecution.vue'),
  263. meta: { title: 'DAN服务执行', perm: 'assessment:dan' }
  264. },
  265. {
  266. path: 'dan-settlement',
  267. name: 'DanSettlement',
  268. component: () => import('@/views/admin/DanSettlement.vue'),
  269. meta: { title: 'DAN结算管理', perm: 'assessment:dan' }
  270. },
  271. {
  272. path: 'product-manage',
  273. name: 'ProductManage',
  274. component: () => import('@/views/admin/ProductManage.vue'),
  275. meta: { title: '商品管理', perm: 'commerce:products,commerce:self' }
  276. },
  277. {
  278. path: 'special-price',
  279. name: 'SpecialPriceManage',
  280. component: () => import('@/views/admin/SpecialPriceManage.vue'),
  281. meta: { title: '限时特价', perm: 'commerce:products' }
  282. },
  283. {
  284. path: 'inventory',
  285. name: 'InventoryManage',
  286. component: () => import('@/views/admin/InventoryManage.vue'),
  287. meta: { title: '库存管理', perm: 'commerce:products' }
  288. },
  289. {
  290. path: 'inventory/inbound-create',
  291. name: 'InventoryInboundCreate',
  292. component: () => import('@/views/admin/InventoryInboundCreate.vue'),
  293. meta: { title: '创建入库单', perm: 'commerce:products' }
  294. },
  295. {
  296. path: 'product-edit',
  297. name: 'ProductEdit',
  298. component: () => import('@/views/admin/ProductEdit.vue'),
  299. meta: { title: '商品编辑', perm: 'commerce:products' }
  300. },
  301. {
  302. path: 'assessment-products',
  303. name: 'AssessmentProducts',
  304. component: () => import('@/views/admin/AssessmentProducts.vue'),
  305. meta: { title: '测评商品管理', perm: 'commerce:products' }
  306. },
  307. {
  308. path: 'assessment-plan-rules',
  309. name: 'AssessmentPlanRules',
  310. component: () => import('@/views/admin/AssessmentPlanRules.vue'),
  311. meta: { title: '方案生成规则', perm: 'plan:rules' }
  312. },
  313. {
  314. path: 'plan-management',
  315. name: 'PlanManagement',
  316. component: () => import('@/views/admin/PlanManagement.vue'),
  317. meta: { title: '方案管理', perm: 'plan:manage' }
  318. },
  319. {
  320. path: 'category-manage',
  321. name: 'CategoryManage',
  322. component: () => import('@/views/admin/CategoryManage.vue'),
  323. meta: { title: '商品分类', perm: 'commerce:category' }
  324. },
  325. {
  326. path: 'order-manage',
  327. name: 'OrderManage',
  328. component: () => import('@/views/admin/OrderManage.vue'),
  329. meta: { title: '订单管理', perm: 'commerce:orders' }
  330. },
  331. {
  332. path: 'pending-refund',
  333. name: 'PendingRefund',
  334. component: () => import('@/views/admin/PendingRefund.vue'),
  335. meta: { title: '待退款管理', perm: 'commerce:orders' }
  336. },
  337. {
  338. path: 'order-detail/:orderNo',
  339. name: 'OrderDetail',
  340. component: () => import('@/views/admin/OrderDetail.vue'),
  341. meta: { title: '订单详情', perm: 'commerce:orders' }
  342. },
  343. {
  344. path: 'sys-config',
  345. name: 'SysConfig',
  346. component: () => import('@/views/admin/SysConfig.vue'),
  347. meta: { title: '系统配置', perm: 'system:base' }
  348. },
  349. {
  350. path: 'guide-config',
  351. name: 'GuideConfig',
  352. component: () => import('@/views/admin/GuideConfig.vue'),
  353. meta: { title: '引导配置', perm: 'system:base' }
  354. },
  355. {
  356. path: 'guide-popup-config',
  357. name: 'GuidePopupConfig',
  358. component: () => import('@/views/admin/GuidePopupConfig.vue'),
  359. meta: { title: '引导弹窗配置', icon: 'el-icon-s-opportunity' }
  360. },
  361. {
  362. path: 'guide-popup-stats',
  363. name: 'GuidePopupStats',
  364. component: () => import('@/views/admin/GuidePopupStats.vue'),
  365. meta: { title: '引导弹窗数据', icon: 'el-icon-data-analysis' }
  366. },
  367. {
  368. path: 'menu-manage',
  369. name: 'MenuManage',
  370. component: () => import('@/views/admin/MenuManage.vue'),
  371. meta: { title: '菜单管理', perm: 'system:menu' }
  372. },
  373. {
  374. path: 'energy-sandbox',
  375. name: 'EnergySandbox',
  376. component: () => import('@/views/admin/EnergySandbox.vue'),
  377. meta: { title: '五维能量', perm: 'energy' }
  378. },
  379. {
  380. path: 'energy-rule',
  381. name: 'EnergyRuleManagement',
  382. component: () => import('@/views/admin/EnergyRuleManagement.vue'),
  383. meta: { title: '能量规则管理', perm: 'energy' }
  384. },
  385. {
  386. path: 'energy-behavior-config',
  387. name: 'EnergyBehaviorConfig',
  388. component: () => import('@/views/admin/EnergyBehaviorConfig.vue'),
  389. meta: { title: '能量行为配置', perm: 'energy' }
  390. },
  391. {
  392. path: 'challenge-score-config',
  393. name: 'ChallengeScoreConfig',
  394. component: () => import('@/views/admin/ChallengeScoreConfig.vue'),
  395. meta: { title: '挑战评分配置', perm: 'energy' }
  396. },
  397. // ========== 文章管理 ==========
  398. {
  399. path: 'article-categories',
  400. name: 'ArticleCategory',
  401. component: () => import('@/views/admin/ArticleCategory.vue'),
  402. meta: { title: '文章分类', perm: 'articles:categories' }
  403. },
  404. {
  405. path: 'article-manage',
  406. name: 'ArticleManage',
  407. component: () => import('@/views/admin/ArticleManage.vue'),
  408. meta: { title: '文章管理', perm: 'articles:manage' }
  409. },
  410. {
  411. path: 'article-edit',
  412. name: 'ArticleEdit',
  413. component: () => import('@/views/admin/ArticleEdit.vue'),
  414. meta: { title: '文章编辑', perm: 'articles:manage' }
  415. },
  416. {
  417. path: 'comment-review',
  418. name: 'CommentReview',
  419. component: () => import('@/views/admin/CommentReview.vue'),
  420. meta: { title: '评论审核', perm: 'articles:manage' }
  421. },
  422. {
  423. path: 'notice-manage',
  424. name: 'NoticeManage',
  425. component: () => import('@/views/admin/NoticeManage.vue'),
  426. meta: { title: '公告管理', perm: 'admin' }
  427. },
  428. {
  429. path: 'periodic-service-config',
  430. name: 'PeriodicServiceConfig',
  431. component: () => import('@/views/admin/PeriodicServiceConfig.vue'),
  432. meta: { title: '周期性服务配置', perm: 'admin' }
  433. },
  434. {
  435. path: 'knowledge-tags',
  436. name: 'KnowledgeTag',
  437. component: () => import('@/views/admin/KnowledgeTag.vue'),
  438. meta: { title: '知识标签', perm: 'articles:categories' }
  439. },
  440. {
  441. path: 'vector-knowledge',
  442. name: 'VectorKnowledgeBase',
  443. component: () => import('@/views/admin/VectorKnowledgeBase.vue'),
  444. meta: { title: '向量知识库', perm: 'knowledge:base' }
  445. },
  446. {
  447. path: 'virtual-goods-config',
  448. name: 'VirtualGoodsConfig',
  449. component: () => import('@/views/admin/VirtualGoodsConfig.vue'),
  450. meta: { title: '虚拟支付道具', perm: 'config:member' }
  451. },
  452. {
  453. path: 'gates',
  454. name: 'Gates',
  455. component: () => import('@/views/admin/gates.vue'),
  456. meta: { title: '关卡配置', perm: 'system:base' }
  457. },
  458. {
  459. path: 'system-prompt',
  460. name: 'SystemPromptManagement',
  461. component: () => import('@/views/admin/SystemPromptManagement.vue'),
  462. meta: { title: '系统提示词', perm: 'system:base' }
  463. },
  464. // ========== 佣金推荐系统 ==========
  465. {
  466. path: 'product-profit-rate',
  467. name: 'ProductProfitRate',
  468. component: () => import('@/views/admin/ProductProfitRate.vue'),
  469. meta: { title: '产品利润率', perm: 'commerce:profit-rate' }
  470. },
  471. {
  472. path: 'product-ppoint',
  473. name: 'ProductPpointManage',
  474. component: () => import('@/views/admin/ProductPpointManage.vue'),
  475. meta: { title: 'P点配置', perm: 'commerce:ppoint' }
  476. },
  477. {
  478. path: 'cf-value',
  479. name: 'CfValueManage',
  480. component: () => import('@/views/admin/CfValueManage.vue'),
  481. meta: { title: 'CF值管理', perm: 'finance:cf-value' }
  482. },
  483. {
  484. path: 'supply-system',
  485. name: 'SupplySystemList',
  486. component: () => import('@/views/admin/supply-system/List.vue'),
  487. meta: { title: '供应商体系', perm: 'system:supply' }
  488. },
  489. {
  490. path: 'supply-system/create',
  491. name: 'SupplySystemCreate',
  492. component: () => import('@/views/admin/supply-system/Form.vue'),
  493. meta: { title: '新建体系', perm: 'system:supply' }
  494. },
  495. {
  496. path: 'supply-system/:id',
  497. name: 'SupplySystemDetail',
  498. component: () => import('@/views/admin/supply-system/Detail.vue'),
  499. meta: { title: '体系详情', perm: 'system:supply' },
  500. props: true
  501. },
  502. {
  503. path: 'supplier-products',
  504. name: 'SupplierProducts',
  505. component: () => import('@/views/admin/SupplierProductManage.vue'),
  506. meta: { title: '商品管理', perm: 'commerce:product' }
  507. },
  508. {
  509. path: 'supply-system/:id/edit',
  510. name: 'SupplySystemEdit',
  511. component: () => import('@/views/admin/supply-system/Form.vue'),
  512. meta: { title: '编辑体系', perm: 'system:supply' },
  513. props: true
  514. },
  515. {
  516. path: 'supply-hierarchy/change-requests',
  517. name: 'SupplyHierarchyChangeRequests',
  518. component: () => import('@/views/admin/supply-hierarchy/ChangeRequest.vue'),
  519. meta: { title: '更换上级审核', perm: 'system:supply' }
  520. },
  521. // ========== 供应商管理 (supplier_admin) ==========
  522. {
  523. path: 'supply-manage',
  524. name: 'SupplyManage',
  525. component: () => import('@/views/admin/supply-manage/List.vue'),
  526. meta: { title: '供应商管理', perm: 'supply:manage' }
  527. },
  528. {
  529. path: 'supply-manage/create',
  530. name: 'SupplyManageCreate',
  531. component: () => import('@/views/admin/supply-manage/Form.vue'),
  532. meta: { title: '新增供应商', perm: 'supply:manage' }
  533. },
  534. {
  535. path: 'supply-manage/:id',
  536. name: 'SupplyManageDetail',
  537. component: () => import('@/views/admin/supply-manage/Detail.vue'),
  538. meta: { title: '供应商详情', perm: 'supply:manage' },
  539. props: true
  540. },
  541. {
  542. path: 'supply-manage/:id/edit',
  543. name: 'SupplyManageEdit',
  544. component: () => import('@/views/admin/supply-manage/Form.vue'),
  545. meta: { title: '编辑供应商', perm: 'supply:manage' },
  546. props: true
  547. },
  548. {
  549. path: 'zodiac-configs',
  550. name: 'ZodiacConfigs',
  551. component: () => import('@/views/admin/ZodiacConfigs.vue'),
  552. meta: { title: '星座配置', perm: 'config:dimension' }
  553. },
  554. {
  555. path: 'bazi-configs',
  556. name: 'BaziConfigs',
  557. component: () => import('@/views/admin/BaziConfigs.vue'),
  558. meta: { title: '八字配置', perm: 'config:dimension' }
  559. },
  560. {
  561. path: 'blood-type-configs',
  562. name: 'BloodTypeConfigs',
  563. component: () => import('@/views/admin/BloodTypeConfigs.vue'),
  564. meta: { title: '血型配置', perm: 'config:dimension' }
  565. },
  566. {
  567. path: 'innate-portrait-config',
  568. name: 'InnatePortraitConfig',
  569. component: () => import('@/views/admin/InnatePortraitConfig.vue'),
  570. meta: { title: '先天画像权重配置', perm: 'config:dimension' }
  571. },
  572. {
  573. path: 'numsoul-detail-config',
  574. name: 'NumSoulDetailConfig',
  575. component: () => import('@/views/admin/NumSoulDetailConfig.vue'),
  576. meta: { title: '数字能量配置', perm: 'config:dimension' }
  577. },
  578. // ========== 饮食管理 (admin) ==========
  579. {
  580. path: 'foods',
  581. name: 'Foods',
  582. component: () => import('@/views/admin/Foods.vue'),
  583. meta: { title: '食材管理', perm: 'diet:foods' }
  584. },
  585. {
  586. path: 'recipes',
  587. name: 'Recipes',
  588. component: () => import('@/views/admin/Recipes.vue'),
  589. meta: { title: '食谱管理', perm: 'diet:recipes' }
  590. },
  591. {
  592. path: 'my-families',
  593. name: 'MyFamilies',
  594. component: () => import('@/views/teacher/FamilyList.vue'),
  595. meta: { title: '我的家庭', perm: 'service:family' }
  596. },
  597. {
  598. path: 'growth-records',
  599. name: 'GrowthRecords',
  600. component: () => import('@/views/teacher/GrowthRecords.vue'),
  601. meta: { title: '成长记录', perm: 'growth:records' }
  602. },
  603. {
  604. path: 'growth-plans',
  605. name: 'GrowthPlans',
  606. component: () => import('@/views/teacher/GrowthPlans.vue'),
  607. meta: { title: '成长计划', perm: 'growth:plans' }
  608. },
  609. {
  610. path: 'health-indicators',
  611. name: 'HealthIndicators',
  612. component: () => import('@/views/nutritionist/HealthIndicators.vue'),
  613. meta: { title: '健康指标', perm: 'health:indicators' }
  614. },
  615. {
  616. path: 'health-checkins',
  617. name: 'HealthCheckinManage',
  618. component: () => import('@/views/admin/HealthCheckinManage.vue'),
  619. meta: { title: '健康打卡管理', perm: 'health:checkins' }
  620. },
  621. {
  622. path: 'emotion-alert',
  623. name: 'EmotionAlertManage',
  624. component: () => import('@/views/admin/EmotionAlertManage.vue'),
  625. meta: { title: '情绪告警管理', perm: 'health:checkins' }
  626. },
  627. {
  628. path: 'nutrition-mappings',
  629. name: 'NutritionMappings',
  630. component: () => import('@/views/nutritionist/NutritionMappings.vue'),
  631. meta: { title: '营养素映射管理', perm: 'health:mappings' }
  632. },
  633. {
  634. path: 'report-management',
  635. name: 'ReportManagement',
  636. component: () => import('@/views/admin/ReportManagement.vue'),
  637. meta: { title: '报告管理', perm: 'health:reports' }
  638. },
  639. {
  640. path: 'report-management/:id',
  641. name: 'HealthReportEdit',
  642. component: () => import('@/views/admin/HealthReportEdit.vue'),
  643. meta: { title: '报告详情/编辑', perm: 'health:reports' },
  644. props: true
  645. },
  646. {
  647. path: 'report-proxy-upload',
  648. name: 'ProxyReportUpload',
  649. component: () => import('@/views/admin/ProxyReportUpload.vue'),
  650. meta: { title: '代传报告', perm: 'health:reports' }
  651. },
  652. {
  653. path: 'report-parse-status',
  654. name: 'ReportParseStatus',
  655. component: () => import('@/views/admin/ReportParseStatus.vue'),
  656. meta: { title: '解析进度', perm: 'health:reports' }
  657. },
  658. {
  659. path: 'seasonal-foods',
  660. name: 'SeasonalFoods',
  661. component: () => import('@/views/admin/SeasonalFoods.vue'),
  662. meta: { title: '应季食材', perm: 'diet:foods' }
  663. },
  664. {
  665. path: 'activities',
  666. name: 'Activities',
  667. component: () => import('@/views/admin/Activities.vue'),
  668. meta: { title: '活动列表', perm: 'activity:list,activity:self' }
  669. },
  670. {
  671. path: 'activity-edit',
  672. name: 'ActivityEdit',
  673. component: () => import('@/views/admin/ActivityEdit.vue'),
  674. meta: { title: '活动编辑', perm: 'activity:list' }
  675. },
  676. {
  677. path: 'home-banner-manage',
  678. name: 'HomeBannerManage',
  679. component: () => import('@/views/admin/HomeBannerManage.vue'),
  680. meta: { title: '首页广告栏', perm: 'marketing:promotion' }
  681. },
  682. {
  683. path: 'survey-templates',
  684. name: 'SurveyTemplates',
  685. component: () => import('@/views/admin/SurveyTemplates.vue'),
  686. meta: { title: '调研模板管理', perm: 'admin:all' }
  687. },
  688. {
  689. path: 'problem-domain-manage',
  690. name: 'ProblemDomainManage',
  691. component: () => import('@/views/admin/ProblemDomainManage.vue'),
  692. meta: { title: '问题域管理', perm: 'admin:all' }
  693. },
  694. {
  695. path: 'notification-template-manage',
  696. name: 'NotificationTemplateManage',
  697. component: () => import('@/views/admin/NotificationTemplateManage.vue'),
  698. meta: { title: '通知模板管理', perm: 'admin:all' }
  699. },
  700. {
  701. // 旧版活动审核页已由审核中心统一承接
  702. path: 'activity-review',
  703. redirect: '/review-center?tab=activity'
  704. },
  705. {
  706. path: 'activity-registration-review',
  707. name: 'ActivityRegistrationReview',
  708. component: () => import('@/views/admin/ActivityRegistrationReview.vue'),
  709. meta: { title: '活动报名审核', perm: 'activity:review' }
  710. },
  711. {
  712. path: 'poster-template-manage',
  713. name: 'PosterTemplateManage',
  714. component: () => import('@/views/admin/PosterTemplateManage.vue'),
  715. meta: { title: '海报模板管理', perm: 'activity:poster_template' }
  716. },
  717. // ========== 维度配置 + 知识库管理 ==========
  718. {
  719. path: 'coupon',
  720. name: 'CouponManagement',
  721. component: () => import('@/views/admin/CouponManagement'),
  722. meta: { title: '优惠券管理', perm: 'marketing:coupon' }
  723. },
  724. {
  725. path: 'coupon-grant-log',
  726. name: 'CouponGrantLog',
  727. component: () => import('@/views/admin/CouponGrantLog.vue'),
  728. meta: { title: '发券记录', perm: 'marketing:coupon' }
  729. },
  730. {
  731. path: 'discount-rules',
  732. name: 'DiscountRuleManagement',
  733. component: () => import('@/views/admin/DiscountRuleManagement.vue'),
  734. meta: { title: '限时折扣管理', perm: 'marketing:discount' }
  735. },
  736. {
  737. path: 'recommendation-rules',
  738. name: 'RecommendationRules',
  739. component: () => import('@/views/admin/RecommendationRules.vue'),
  740. meta: { title: '商品推荐规则管理', perm: 'config:recommendation' }
  741. },
  742. {
  743. path: 'promotion',
  744. name: 'PromotionManagement',
  745. component: () => import('@/views/admin/PromotionManagement'),
  746. meta: { title: '推广管理', perm: 'marketing:promotion' }
  747. },
  748. {
  749. path: 'family-earnings',
  750. name: 'FamilyEarnings',
  751. component: () => import('@/views/admin/FamilyEarnings.vue'),
  752. meta: { title: '家庭收益管理', perm: 'marketing:promotion' }
  753. },
  754. {
  755. path: 'family-earnings-withdraw',
  756. name: 'FamilyEarningsWithdraw',
  757. component: () => import('@/views/admin/FamilyEarningsWithdraw.vue'),
  758. meta: { title: '家庭收益提现审核', perm: 'audit:withdraw' }
  759. },
  760. {
  761. path: 'dimension-config',
  762. name: 'DimensionConfig',
  763. component: () => import('@/views/admin/dimension'),
  764. meta: { title: '维度配置', perm: 'config:dimension' }
  765. },
  766. {
  767. path: 'knowledge-base',
  768. name: 'KnowledgeBase',
  769. component: () => import('@/views/admin/knowledge'),
  770. meta: { title: '知识库管理', perm: 'knowledge:base' }
  771. },
  772. {
  773. path: 'knowledge-base/unified',
  774. name: 'UnifiedKnowledgeBase',
  775. component: () => import('@/views/admin/unified-knowledge.vue'),
  776. meta: { title: '统一知识库管理', perm: 'knowledge:base' }
  777. },
  778. // ========== 健康维度配置 ==========
  779. {
  780. path: 'health-norm-config',
  781. name: 'HealthNormConfig',
  782. component: () => import('@/views/admin/dimension-config'),
  783. meta: { title: '健康常模配置', perm: 'config:health' }
  784. },
  785. {
  786. path: 'health-data-source',
  787. name: 'HealthDataSource',
  788. component: () => import('@/views/admin/data-source-config'),
  789. meta: { title: '健康数据源配置', perm: 'config:health' }
  790. },
  791. {
  792. path: 'health-energy-config',
  793. name: 'HealthEnergyConfig',
  794. component: () => import('@/views/admin/HealthEnergyConfig'),
  795. meta: { title: '五维能量配置', perm: 'config:health' }
  796. },
  797. {
  798. path: 'energy-config',
  799. name: 'EnergyConfig',
  800. component: () => import('@/views/admin/energy-config/WuxingConfig'),
  801. meta: { title: '五行能量配置', perm: 'config:health' }
  802. },
  803. {
  804. path: 'indicators',
  805. name: 'IndicatorManage',
  806. component: () => import('@/views/admin/indicators'),
  807. meta: { title: '指标管理', perm: 'config:health' }
  808. },
  809. {
  810. path: 'indicator-correlations',
  811. name: 'IndicatorCorrelations',
  812. component: () => import('@/views/admin/IndicatorCorrelations.vue'),
  813. meta: { title: '指标关联配置', perm: 'config:health' }
  814. },
  815. {
  816. path: 'indicator-mappings',
  817. name: 'IndicatorMappings',
  818. component: () => import('@/views/admin/IndicatorMappings.vue'),
  819. meta: { title: '指标映射管理', perm: 'config:health' }
  820. },
  821. // ========== 虚拟服务商团队管理 ==========
  822. {
  823. path: 'virtual-teams',
  824. name: 'VirtualTeamList',
  825. component: () => import('@/views/admin/VirtualTeamList'),
  826. meta: { title: '虚拟团队管理', perm: 'system:base' }
  827. },
  828. {
  829. path: 'virtual-team-detail/:systemId',
  830. name: 'VirtualTeamDetail',
  831. component: () => import('@/views/admin/VirtualTeamDetail'),
  832. meta: { title: '团队成员管理', perm: 'system:base' },
  833. props: true
  834. },
  835. // ========== 电商供应商管理(已合并至供应商体系,路由指向 /supply-system)==========
  836. {
  837. path: 'ecom-supplier',
  838. redirect: '/admin/supply-system',
  839. name: 'EcomSupplierManage',
  840. meta: { title: '电商供应商管理', perm: 'system:supply', hidden: true }
  841. },
  842. {
  843. path: 'badge-manage',
  844. name: 'BadgeManage',
  845. component: () => import('@/views/admin/BadgeManage'),
  846. meta: { title: '勋章管理', perm: 'config:member' }
  847. },
  848. // ========== 报告指纹解析系统 ==========
  849. {
  850. path: 'report-types',
  851. name: 'ReportTypeManagement',
  852. component: () => import('@/views/admin/ReportTypeManagement.vue'),
  853. meta: { title: '报告类型管理', perm: 'config:report-parser' }
  854. },
  855. {
  856. path: 'report-parser-import',
  857. name: 'ReportParserImport',
  858. component: () => import('@/views/admin/ReportParserImport.vue'),
  859. meta: { title: '解析器导入管理', perm: 'config:report-parser' }
  860. },
  861. {
  862. path: 'report-collector-trainer',
  863. name: 'ReportCollectorTrainer',
  864. component: () => import('@/views/admin/ReportCollectorTrainer.vue'),
  865. meta: { title: '报告采集训练', perm: 'config:report-parser' }
  866. },
  867. {
  868. path: 'report-template',
  869. name: 'ReportTemplateManage',
  870. component: () => import('@/views/admin/ReportTemplateManage.vue'),
  871. meta: { title: '报告模板管理', perm: 'config:report-parser' }
  872. },
  873. {
  874. path: 'report-unknown-clusters',
  875. name: 'ReportUnknownCluster',
  876. component: () => import('@/views/admin/ReportUnknownCluster.vue'),
  877. meta: { title: '未知报告审核', perm: 'config:report-parser' }
  878. },
  879. {
  880. path: 'report-auto-learn',
  881. name: 'ReportAutoLearn',
  882. component: () => import('@/views/admin/ReportAutoLearn.vue'),
  883. meta: { title: '报告自学习', perm: 'config:report-parser' }
  884. },
  885. // ========== LangGraph AI 服务管理 ==========
  886. {
  887. path: 'langgraph-admin',
  888. name: 'LangGraphAdmin',
  889. component: () => import('@/views/admin/LangGraphAdmin.vue'),
  890. meta: { title: 'LangGraph 管理', perm: 'config:report-parser' }
  891. },
  892. // ========== 营养产品管理 ==========
  893. {
  894. path: 'nutrition-products',
  895. name: 'NutritionProducts',
  896. component: () => import('@/views/admin/NutritionProducts.vue'),
  897. meta: { title: '营养产品管理', perm: 'health:*' }
  898. },
  899. {
  900. path: 'file-manage',
  901. name: 'FileManage',
  902. component: () => import('@/views/admin/FileManage'),
  903. meta: { title: '文件管理', perm: 'system:base' }
  904. },
  905. // ========== 机构管理 ==========
  906. {
  907. path: 'org',
  908. name: 'OrgList',
  909. component: () => import('@/views/admin/org/List.vue'),
  910. meta: { title: '组织管理', perm: 'org:*' }
  911. },
  912. {
  913. path: 'org/create',
  914. name: 'OrgCreate',
  915. component: () => import('@/views/admin/org/Form.vue'),
  916. meta: { title: '新建组织', perm: 'org:*' }
  917. },
  918. {
  919. path: 'org/edit/:id',
  920. name: 'OrgEdit',
  921. component: () => import('@/views/admin/org/Form.vue'),
  922. meta: { title: '编辑组织', perm: 'org:*' },
  923. props: true
  924. },
  925. {
  926. path: 'org/:id',
  927. name: 'OrgDetail',
  928. component: () => import('@/views/admin/org/Detail.vue'),
  929. meta: { title: '组织详情', perm: 'org:*' },
  930. props: true
  931. },
  932. {
  933. path: 'org/:id/dashboard',
  934. name: 'OrgDashboard',
  935. component: () => import('@/views/admin/org/Dashboard.vue'),
  936. meta: { title: '组织大屏', perm: 'org:*' }
  937. }
  938. ]
  939. }
  940. ]
  941. const router = new VueRouter({
  942. mode: 'history',
  943. base: process.env.BASE_URL,
  944. routes
  945. })
  946. // Token 验证缓存:避免 redirect 链中重复调用 /api/admin-auth/info
  947. let tokenValidationCache = { token: '', timestamp: 0 }
  948. const TOKEN_CACHE_TTL = 30000 // 30秒内不重复验证
  949. async function validateToken(token) {
  950. try {
  951. const baseURL = process.env.VUE_APP_BASE_API || ''
  952. const res = await axios.post(`${baseURL}/api/admin-auth/info`, {}, {
  953. headers: { Authorization: `Bearer ${token}` },
  954. validateStatus: () => true
  955. })
  956. return res.status === 200 && res.data?.code === 200
  957. } catch (e) {
  958. return false
  959. }
  960. }
  961. router.beforeEach(async (to, from, next) => {
  962. const token = localStorage.getItem('token')
  963. const role = localStorage.getItem('role')
  964. // 1. 登录页允许访问
  965. if (to.path === '/login') {
  966. // 如果已有token和role,直接跳转到对应角色首页
  967. if (token && role) {
  968. const rolesStr = localStorage.getItem('roles')
  969. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  970. const home = getRoleHomePage(roleList)
  971. if (home !== '/') {
  972. return next(home)
  973. }
  974. }
  975. return next()
  976. }
  977. // 2. 无Token强制跳转
  978. if (!token) {
  979. return next('/login')
  980. }
  981. // 3. Token有效性验证 (使用缓存避免 redirect 链重复调用)
  982. const now = Date.now()
  983. let isValid = false
  984. if (tokenValidationCache.token === token && (now - tokenValidationCache.timestamp) < TOKEN_CACHE_TTL) {
  985. isValid = true
  986. } else {
  987. isValid = await validateToken(token)
  988. if (isValid) {
  989. tokenValidationCache = { token, timestamp: now }
  990. }
  991. }
  992. if (!isValid) {
  993. tokenValidationCache = { token: '', timestamp: 0 }
  994. localStorage.clear()
  995. return next('/login')
  996. }
  997. // 3.5 入驻角色访问 /dashboard → 跳转各自工作台(B-6 入驻角色默认首页)
  998. if (to.path === '/dashboard') {
  999. const rolesStr = localStorage.getItem('roles')
  1000. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  1001. const home = getRoleHomePage(roleList)
  1002. if (home !== '/') {
  1003. return next(home)
  1004. }
  1005. }
  1006. // 3.6 组织管理员(org_admin 且不含平台角色)路由分流:规范第五节
  1007. const rolesStr2 = localStorage.getItem('roles')
  1008. if (rolesStr2) {
  1009. const roleList2 = JSON.parse(rolesStr2)
  1010. const isOrgAdminOnly = roleList2.indexOf('org_admin') >= 0
  1011. && roleList2.indexOf('admin') < 0 && roleList2.indexOf('operator') < 0 && roleList2.indexOf('finance') < 0
  1012. if (isOrgAdminOnly) {
  1013. // 访问首页/列表页 → 重定向到自身组织大屏
  1014. if (to.path === '/dashboard' || to.path === '/org') {
  1015. let cachedOrgId = localStorage.getItem('orgId')
  1016. if (cachedOrgId) {
  1017. return next('/org/' + cachedOrgId + '/dashboard')
  1018. }
  1019. try {
  1020. const orgRes = await orgMy()
  1021. if (orgRes && orgRes.data && orgRes.data.id) {
  1022. localStorage.setItem('orgId', orgRes.data.id)
  1023. return next('/org/' + orgRes.data.id + '/dashboard')
  1024. }
  1025. return next({ path: '/login', replace: true })
  1026. } catch (e2) {
  1027. return next({ path: '/login', replace: true })
  1028. }
  1029. }
  1030. // 仅允许 org 相关路由;其他管理端路由拦截
  1031. if (to.path !== '/403' && to.path !== '/login' && !to.path.startsWith('/org/')) {
  1032. return next({ path: '/403', replace: true })
  1033. }
  1034. }
  1035. }
  1036. // 4. 权限检查:如果路由有 perm 要求,检查用户权限
  1037. const requiredPerm = to.meta && to.meta.perm
  1038. if (requiredPerm) {
  1039. const rolesStr = localStorage.getItem('roles')
  1040. const roles = rolesStr ? JSON.parse(rolesStr) : [localStorage.getItem('role')]
  1041. const perms = getEffectivePermissions(roles)
  1042. if (!hasPermission(perms, requiredPerm)) {
  1043. console.warn('Access denied: insufficient permissions for', to.name)
  1044. return next({ path: '/403', replace: true })
  1045. }
  1046. }
  1047. return next()
  1048. })
  1049. // Suppress navigation guard redirect errors (teacher/admin route cross-access)
  1050. const originalPush = VueRouter.prototype.push
  1051. VueRouter.prototype.push = function push(location) {
  1052. return originalPush.call(this, location).catch(err => err)
  1053. }
  1054. export default router