index.js 41 KB

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