index.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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: 'admin/family-coupon',
  768. name: 'FamilyCouponManage',
  769. component: () => import('@/views/admin/FamilyCouponManage.vue'),
  770. meta: { title: '家庭优惠券', perm: 'marketing:coupon' }
  771. },
  772. {
  773. path: 'discount-rules',
  774. name: 'DiscountRuleManagement',
  775. component: () => import('@/views/admin/DiscountRuleManagement.vue'),
  776. meta: { title: '限时折扣管理', perm: 'marketing:discount' }
  777. },
  778. {
  779. path: 'recommendation-rules',
  780. name: 'RecommendationRules',
  781. component: () => import('@/views/admin/RecommendationRules.vue'),
  782. meta: { title: '商品推荐规则管理', perm: 'config:recommendation' }
  783. },
  784. {
  785. path: 'promotion',
  786. name: 'PromotionManagement',
  787. component: () => import('@/views/admin/PromotionManagement'),
  788. meta: { title: '推广管理', perm: 'marketing:promotion' }
  789. },
  790. {
  791. path: 'family-earnings',
  792. name: 'FamilyEarnings',
  793. component: () => import('@/views/admin/FamilyEarnings.vue'),
  794. meta: { title: '家庭收益管理', perm: 'marketing:promotion' }
  795. },
  796. {
  797. path: 'family-earnings-withdraw',
  798. name: 'FamilyEarningsWithdraw',
  799. component: () => import('@/views/admin/FamilyEarningsWithdraw.vue'),
  800. meta: { title: '家庭收益提现审核', perm: 'audit:withdraw' }
  801. },
  802. {
  803. path: 'dimension-config',
  804. name: 'DimensionConfig',
  805. component: () => import('@/views/admin/dimension'),
  806. meta: { title: '维度配置', perm: 'config:dimension' }
  807. },
  808. {
  809. path: 'config-center',
  810. name: 'ConfigCenter',
  811. component: () => import('@/views/admin/ConfigCenter.vue'),
  812. meta: { title: '配置中心', perm: 'config:dimension' }
  813. },
  814. {
  815. path: 'knowledge-base',
  816. name: 'KnowledgeBase',
  817. component: () => import('@/views/admin/knowledge'),
  818. meta: { title: '知识库管理', perm: 'knowledge:base' }
  819. },
  820. {
  821. path: 'knowledge-base/unified',
  822. name: 'UnifiedKnowledgeBase',
  823. component: () => import('@/views/admin/unified-knowledge.vue'),
  824. meta: { title: '统一知识库管理', perm: 'knowledge:base' }
  825. },
  826. // ========== 健康维度配置 ==========
  827. {
  828. path: 'health-norm-config',
  829. name: 'HealthNormConfig',
  830. component: () => import('@/views/admin/dimension-config'),
  831. meta: { title: '健康常模配置', perm: 'config:health' }
  832. },
  833. {
  834. path: 'health-data-source',
  835. name: 'HealthDataSource',
  836. component: () => import('@/views/admin/data-source-config'),
  837. meta: { title: '健康数据源配置', perm: 'config:health' }
  838. },
  839. {
  840. path: 'health-energy-config',
  841. name: 'HealthEnergyConfig',
  842. component: () => import('@/views/admin/HealthEnergyConfig'),
  843. meta: { title: '五维能量配置', perm: 'config:health' }
  844. },
  845. {
  846. path: 'energy-config',
  847. name: 'EnergyConfig',
  848. component: () => import('@/views/admin/energy-config/WuxingConfig'),
  849. meta: { title: '五行能量配置', perm: 'config:health' }
  850. },
  851. {
  852. path: 'indicators',
  853. name: 'IndicatorManage',
  854. component: () => import('@/views/admin/indicators'),
  855. meta: { title: '指标管理', perm: 'config:health' }
  856. },
  857. {
  858. path: 'indicator-correlations',
  859. name: 'IndicatorCorrelations',
  860. component: () => import('@/views/admin/IndicatorCorrelations.vue'),
  861. meta: { title: '指标关联配置', perm: 'config:health' }
  862. },
  863. {
  864. path: 'indicator-mappings',
  865. name: 'IndicatorMappings',
  866. component: () => import('@/views/admin/IndicatorMappings.vue'),
  867. meta: { title: '指标映射管理', perm: 'config:health' }
  868. },
  869. // ========== 虚拟服务商团队管理 ==========
  870. {
  871. path: 'virtual-teams',
  872. name: 'VirtualTeamList',
  873. component: () => import('@/views/admin/VirtualTeamList'),
  874. meta: { title: '虚拟团队管理', perm: 'system:base' }
  875. },
  876. {
  877. path: 'virtual-team-detail/:systemId',
  878. name: 'VirtualTeamDetail',
  879. component: () => import('@/views/admin/VirtualTeamDetail'),
  880. meta: { title: '团队成员管理', perm: 'system:base' },
  881. props: true
  882. },
  883. // ========== 电商供应商管理(已合并至供应商体系,路由指向 /supply-system)==========
  884. {
  885. path: 'ecom-supplier',
  886. redirect: '/admin/supply-system',
  887. name: 'EcomSupplierManage',
  888. meta: { title: '电商供应商管理', perm: 'system:supply', hidden: true }
  889. },
  890. {
  891. path: 'badge-manage',
  892. name: 'BadgeManage',
  893. component: () => import('@/views/admin/BadgeManage'),
  894. meta: { title: '勋章管理', perm: 'config:member' }
  895. },
  896. // ========== 报告指纹解析系统 ==========
  897. // 兼容旧链接:/admin/report-parser(报告解析系统)→ 报告类型管理
  898. {
  899. path: 'report-parser',
  900. redirect: '/report-types'
  901. },
  902. {
  903. path: 'report-types',
  904. name: 'ReportTypeManagement',
  905. component: () => import('@/views/admin/ReportTypeManagement.vue'),
  906. meta: { title: '报告类型管理', perm: 'config:report-parser' }
  907. },
  908. {
  909. path: 'report-parser-import',
  910. name: 'ReportParserImport',
  911. component: () => import('@/views/admin/ReportParserImport.vue'),
  912. meta: { title: '解析器导入管理', perm: 'config:report-parser' }
  913. },
  914. {
  915. path: 'report-collector-trainer',
  916. name: 'ReportCollectorTrainer',
  917. component: () => import('@/views/admin/ReportCollectorTrainer.vue'),
  918. meta: { title: '报告采集训练', perm: 'config:report-parser' }
  919. },
  920. {
  921. path: 'report-template',
  922. name: 'ReportTemplateManage',
  923. component: () => import('@/views/admin/ReportTemplateManage.vue'),
  924. meta: { title: '报告模板管理', perm: 'config:report-parser' }
  925. },
  926. {
  927. path: 'report-unknown-clusters',
  928. name: 'ReportUnknownCluster',
  929. component: () => import('@/views/admin/ReportUnknownCluster.vue'),
  930. meta: { title: '未知报告审核', perm: 'config:report-parser' }
  931. },
  932. {
  933. path: 'report-auto-learn',
  934. name: 'ReportAutoLearn',
  935. component: () => import('@/views/admin/ReportAutoLearn.vue'),
  936. meta: { title: '报告自学习', perm: 'config:report-parser' }
  937. },
  938. // ========== LangGraph AI 服务管理 ==========
  939. {
  940. path: 'langgraph-admin',
  941. name: 'LangGraphAdmin',
  942. component: () => import('@/views/admin/LangGraphAdmin.vue'),
  943. meta: { title: 'LangGraph 管理', perm: 'config:report-parser' }
  944. },
  945. // ========== 营养产品管理 ==========
  946. {
  947. path: 'nutrition-products',
  948. name: 'NutritionProducts',
  949. component: () => import('@/views/admin/NutritionProducts.vue'),
  950. meta: { title: '营养产品管理', perm: 'health:*' }
  951. },
  952. {
  953. path: 'file-manage',
  954. name: 'FileManage',
  955. component: () => import('@/views/admin/FileManage'),
  956. meta: { title: '文件管理', perm: 'system:base' }
  957. },
  958. {
  959. path: 'admin/asset-library',
  960. name: 'AssetLibrary',
  961. component: () => import('@/views/admin/AssetLibrary.vue'),
  962. meta: { title: '素材库', perm: 'system:base' }
  963. },
  964. // ========== 机构管理 ==========
  965. {
  966. path: 'org',
  967. name: 'OrgList',
  968. component: () => import('@/views/admin/org/List.vue'),
  969. meta: { title: '组织管理', perm: 'org:*' }
  970. },
  971. {
  972. path: 'org/create',
  973. name: 'OrgCreate',
  974. component: () => import('@/views/admin/org/Form.vue'),
  975. meta: { title: '新建组织', perm: 'org:*' }
  976. },
  977. {
  978. path: 'org/edit/:id',
  979. name: 'OrgEdit',
  980. component: () => import('@/views/admin/org/Form.vue'),
  981. meta: { title: '编辑组织', perm: 'org:*' },
  982. props: true
  983. },
  984. {
  985. path: 'org/:id',
  986. name: 'OrgDetail',
  987. component: () => import('@/views/admin/org/Detail.vue'),
  988. meta: { title: '组织详情', perm: 'org:*' },
  989. props: true
  990. },
  991. {
  992. path: 'org/:id/dashboard',
  993. name: 'OrgDashboard',
  994. component: () => import('@/views/admin/org/Dashboard.vue'),
  995. meta: { title: '组织大屏', perm: 'org:*' }
  996. },
  997. // ========== 规划师培训认证管理(W3 认证闸门) ==========
  998. {
  999. path: 'planner-cert-categories',
  1000. name: 'PlannerCertCategories',
  1001. component: () => import('@/views/admin/planner-cert/Categories.vue'),
  1002. meta: { title: '学习种类管理', perm: 'planner:cert' }
  1003. },
  1004. {
  1005. path: 'planner-cert-courses',
  1006. name: 'PlannerCertCourses',
  1007. component: () => import('@/views/admin/planner-cert/Courses.vue'),
  1008. meta: { title: '线上课程管理', perm: 'planner:cert' }
  1009. },
  1010. {
  1011. path: 'planner-cert-offline',
  1012. name: 'PlannerCertOffline',
  1013. component: () => import('@/views/admin/planner-cert/OfflineMap.vue'),
  1014. meta: { title: '线下课程映射', perm: 'planner:cert' }
  1015. },
  1016. {
  1017. path: 'planner-cert-exams',
  1018. name: 'PlannerCertExams',
  1019. component: () => import('@/views/admin/planner-cert/Exams.vue'),
  1020. meta: { title: '考核题库管理', perm: 'planner:cert' }
  1021. },
  1022. {
  1023. path: 'planner-cert-board',
  1024. name: 'PlannerCertBoard',
  1025. component: () => import('@/views/admin/planner-cert/CertBoard.vue'),
  1026. meta: { title: '规划师认证看板', perm: 'planner:cert' }
  1027. }
  1028. ]
  1029. }
  1030. ]
  1031. const router = new VueRouter({
  1032. mode: 'history',
  1033. base: process.env.BASE_URL,
  1034. routes
  1035. })
  1036. // Token 验证缓存:避免 redirect 链中重复调用 /api/admin-auth/info
  1037. let tokenValidationCache = { token: '', timestamp: 0 }
  1038. const TOKEN_CACHE_TTL = 30000 // 30秒内不重复验证
  1039. async function validateToken(token) {
  1040. try {
  1041. const baseURL = process.env.VUE_APP_BASE_API || ''
  1042. const res = await axios.post(`${baseURL}/api/admin-auth/info`, {}, {
  1043. headers: { Authorization: `Bearer ${token}` },
  1044. validateStatus: () => true
  1045. })
  1046. return res.status === 200 && res.data?.code === 200
  1047. } catch (e) {
  1048. return false
  1049. }
  1050. }
  1051. router.beforeEach(async (to, from, next) => {
  1052. const token = localStorage.getItem('token')
  1053. const role = localStorage.getItem('role')
  1054. // 1. 登录页允许访问
  1055. if (to.path === '/login') {
  1056. // 如果已有token和role,直接跳转到对应角色首页
  1057. if (token && role) {
  1058. const rolesStr = localStorage.getItem('roles')
  1059. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  1060. const home = getRoleHomePage(roleList)
  1061. if (home !== '/') {
  1062. return next(home)
  1063. }
  1064. }
  1065. return next()
  1066. }
  1067. // 2. 无Token强制跳转
  1068. if (!token) {
  1069. return next('/login')
  1070. }
  1071. // 3. Token有效性验证 (使用缓存避免 redirect 链重复调用)
  1072. const now = Date.now()
  1073. let isValid = false
  1074. if (tokenValidationCache.token === token && (now - tokenValidationCache.timestamp) < TOKEN_CACHE_TTL) {
  1075. isValid = true
  1076. } else {
  1077. isValid = await validateToken(token)
  1078. if (isValid) {
  1079. tokenValidationCache = { token, timestamp: now }
  1080. }
  1081. }
  1082. if (!isValid) {
  1083. tokenValidationCache = { token: '', timestamp: 0 }
  1084. localStorage.clear()
  1085. return next('/login')
  1086. }
  1087. // 3.5 入驻角色访问 /dashboard → 跳转各自工作台(B-6 入驻角色默认首页)
  1088. if (to.path === '/dashboard') {
  1089. const rolesStr = localStorage.getItem('roles')
  1090. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  1091. const home = getRoleHomePage(roleList)
  1092. if (home !== '/') {
  1093. return next(home)
  1094. }
  1095. }
  1096. // 3.6 组织管理员(org_admin 且不含平台角色)路由分流:规范第五节
  1097. const rolesStr2 = localStorage.getItem('roles')
  1098. if (rolesStr2) {
  1099. const roleList2 = JSON.parse(rolesStr2)
  1100. const isOrgAdminOnly = roleList2.indexOf('org_admin') >= 0
  1101. && roleList2.indexOf('admin') < 0 && roleList2.indexOf('operator') < 0 && roleList2.indexOf('finance') < 0
  1102. if (isOrgAdminOnly) {
  1103. // 访问首页/列表页 → 重定向到自身组织大屏
  1104. if (to.path === '/dashboard' || to.path === '/org') {
  1105. let cachedOrgId = localStorage.getItem('orgId')
  1106. if (cachedOrgId) {
  1107. return next('/org/' + cachedOrgId + '/dashboard')
  1108. }
  1109. try {
  1110. const orgRes = await orgMy()
  1111. if (orgRes && orgRes.data && orgRes.data.id) {
  1112. localStorage.setItem('orgId', orgRes.data.id)
  1113. return next('/org/' + orgRes.data.id + '/dashboard')
  1114. }
  1115. return next({ path: '/login', replace: true })
  1116. } catch (e2) {
  1117. return next({ path: '/login', replace: true })
  1118. }
  1119. }
  1120. // 仅允许 org 相关路由;其他管理端路由拦截
  1121. if (to.path !== '/403' && to.path !== '/login' && !to.path.startsWith('/org/')) {
  1122. return next({ path: '/403', replace: true })
  1123. }
  1124. }
  1125. }
  1126. // 4. 权限检查:如果路由有 perm 要求,检查用户权限
  1127. const requiredPerm = to.meta && to.meta.perm
  1128. if (requiredPerm) {
  1129. const rolesStr = localStorage.getItem('roles')
  1130. const roles = rolesStr ? JSON.parse(rolesStr) : [localStorage.getItem('role')]
  1131. const perms = getEffectivePermissions(roles)
  1132. if (!hasPermission(perms, requiredPerm)) {
  1133. console.warn('Access denied: insufficient permissions for', to.name)
  1134. return next({ path: '/403', replace: true })
  1135. }
  1136. }
  1137. return next()
  1138. })
  1139. // Suppress navigation guard redirect errors (teacher/admin route cross-access)
  1140. const originalPush = VueRouter.prototype.push
  1141. VueRouter.prototype.push = function push(location) {
  1142. return originalPush.call(this, location).catch(err => err)
  1143. }
  1144. export default router