| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052 |
- <template>
- <el-container class="layout-container">
- <!-- Mobile overlay -->
- <div v-if="isMobile && sidebarVisible" class="sidebar-overlay" @click="sidebarVisible = false"></div>
- <el-aside :class="['el-aside', { 'sidebar-mobile': isMobile, 'sidebar-open': isMobile && sidebarVisible, 'sidebar-closed': isMobile && !sidebarVisible }]" :width="isMobile ? '200px' : '200px'">
- <div class="logo">浠艾福</div>
- <el-scrollbar wrap-class="sidebar-scrollbar-wrap">
- <div v-if="menuLoadFailed && effectiveMenuItems.length === 0" class="menu-load-failed">
- <i class="el-icon-warning-outline"></i>
- <p class="menu-load-failed-title">菜单加载失败</p>
- <p class="menu-load-failed-sub">请刷新页面重试</p>
- </div>
- <el-menu
- :default-active="activeMenu"
- class="sidebar-menu"
- background-color="transparent"
- text-color="#64748B"
- active-text-color="#1677FF"
- @select="handleMenuSelect"
- >
- <template v-for="item in effectiveMenuItems">
- <el-submenu v-if="item.children && item.children.length > 0 && hasPerm(item.perm)" :key="item.title || item.path" :index="item.title || item.path">
- <template slot="title">
- <i :class="item.icon"></i>
- <span>{{ item.title || item.label }}</span>
- </template>
- <template v-for="child in item.children">
- <!-- 子项有 children = 三级菜单 -->
- <el-submenu v-if="child.children && child.children.length > 0 && hasPerm(child.perm)" :key="child.title" :index="child.title">
- <template slot="title">
- <i :class="child.icon"></i>
- <span>{{ child.title || child.label }}</span>
- </template>
- <el-menu-item
- v-for="grandson in child.children"
- :key="grandson.path || grandson.id"
- :index="grandson.path"
- >
- <i :class="grandson.icon"></i>
- <span slot="title">{{ grandson.label }}</span>
- </el-menu-item>
- </el-submenu>
- <!-- 普通二级菜单项 -->
- <el-menu-item v-else-if="hasPerm(child.perm)" :key="child.path || child.id" :index="getMenuIndex(child)">
- <i :class="child.icon"></i>
- <span slot="title">{{ child.label }}</span>
- </el-menu-item>
- </template>
- </el-submenu>
- <el-menu-item v-else-if="hasPerm(item.perm)" :key="item.path || item.id" :index="getMenuIndex(item)">
- <i :class="item.icon"></i>
- <span slot="title">{{ item.label }}</span>
- </el-menu-item>
- </template>
- </el-menu>
- </el-scrollbar>
- </el-aside>
- <el-container>
- <el-header>
- <div class="header-left">
- <el-button v-if="isMobile" type="text" class="hamburger-btn" @click="toggleSidebar">
- <i :class="sidebarVisible ? 'el-icon-s-unfold' : 'el-icon-s-fold'"></i>
- </el-button>
- </div>
- <div class="header-right">
- <el-badge :value="unreadMessageCount" :hidden="unreadMessageCount === 0" class="msg-badge">
- <el-button type="text" class="msg-btn" @click="handleMessageClick" icon="el-icon-bell"></el-button>
- </el-badge>
- <el-button v-if="hasPerm('service:*')" type="text" class="invite-code-btn" @click="showInviteCode" icon="el-icon-share">
- 邀请码
- </el-button>
- <el-dropdown trigger="click" @command="handleProfileCommand">
- <span class="el-dropdown-link username">
- {{ displayUserLabel }}<i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="profile" icon="el-icon-user">个人信息</el-dropdown-item>
- <el-dropdown-item command="password" icon="el-icon-key">修改密码</el-dropdown-item>
- <el-dropdown-item command="logout" icon="el-icon-switch-button" divided>退出登录</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <!-- 邀请码 dialog -->
- <el-dialog title="我的邀请码" :visible.sync="inviteCodeVisible" width="500px" :close-on-click-modal="false">
- <div v-loading="inviteCodeLoading">
- <div v-if="inviteCodeData" class="invite-code-content">
- <div class="invite-code-section">
- <div class="invite-code-label">团队邀请码</div>
- <div class="invite-code-value">
- <span class="code-text">{{ inviteCodeData.code || '无' }}</span>
- <el-button size="mini" type="primary" @click="copyCode(inviteCodeData.code)" plain>复制</el-button>
- </div>
- <div class="invite-code-desc">
- 家庭用户通过此码加入您的团队
- </div>
- </div>
- </div>
- <div v-else-if="!inviteCodeLoading" class="no-invite-code">
- <i class="el-icon-warning-outline"></i>
- <p>暂无邀请码,请先生成</p>
- <el-button type="primary" @click="generateInviteCode">生成邀请码</el-button>
- </div>
- </div>
- </el-dialog>
- </el-header>
- <!-- 个人信息 dialog -->
- <el-dialog title="个人信息" :visible.sync="profileDialogVisible" width="400px">
- <el-form :model="profileForm" label-width="80px">
- <el-form-item label="用户名">
- <el-input v-model="profileForm.username" disabled></el-input>
- </el-form-item>
- <el-form-item label="真实姓名">
- <el-input v-model="profileForm.realName" disabled></el-input>
- </el-form-item>
- <el-form-item label="昵称">
- <el-input v-model="profileForm.nickname"></el-input>
- </el-form-item>
- <el-form-item label="手机号">
- <el-input v-model="profileForm.phone"></el-input>
- </el-form-item>
- <el-form-item label="邮箱">
- <el-input v-model="profileForm.email"></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer">
- <el-button @click="profileDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="confirmUpdateInfo" :loading="submitting">保存</el-button>
- </span>
- </el-dialog>
- <!-- 修改密码 dialog -->
- <el-dialog title="修改密码" :visible.sync="passwordDialogVisible" width="400px">
- <el-form :model="passwordForm" :rules="passwordRules" ref="passwordForm" label-width="100px">
- <el-form-item label="原密码" prop="oldPassword">
- <el-input v-model="passwordForm.oldPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="新密码" prop="newPassword">
- <el-input v-model="passwordForm.newPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="确认密码" prop="confirmPassword">
- <el-input v-model="passwordForm.confirmPassword" type="password" show-password></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer">
- <el-button @click="passwordDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="confirmChangePassword" :loading="submitting">确定</el-button>
- </span>
- </el-dialog>
- <el-main>
- <div class="main-wrapper">
- <!-- 白名单缓存列表页组件:进入编辑/详情返回时保留筛选条件、页码、勾选等状态(见 ListStateMixin) -->
- <keep-alive :include="cachedPages">
- <router-view />
- </keep-alive>
- </div>
- </el-main>
- </el-container>
- </el-container>
- </template>
- <script>
- import { getAdminInfo, changePassword } from '@/api/auth'
- import { updateAdminInfo } from '@/api/admin'
- import { getMyInviteCode } from '@/api/guide'
- import { getUnreadMessageCount } from '@/api/teacherMessage'
- import { getEffectivePermissions, hasPermission, getRoleLabel } from '@/utils/permissions'
- import { getUserMenus } from '@/api/menu'
- export default {
- data() {
- return {
- menuItems: [
- // ===== 1. 首页 (ALL) =====
- { path: '/dashboard', label: '首页', icon: 'el-icon-s-home', perm: 'dashboard' },
- // ===== 2. 家庭运营 (family:*) =====
- { title: '家庭运营', icon: 'el-icon-s-custom', perm: 'family:*',
- children: [
- { path: '/families', label: '家庭列表', icon: 'el-icon-s-custom', perm: 'family:list,family:read,family:bound' },
- { path: '/children', label: '孩子管理', icon: 'el-icon-user-solid', perm: 'family:children,family:read,family:bound' },
- { path: '/points', label: '积分管理', icon: 'el-icon-s-finance', perm: 'family:points' },
- { path: '/points-log', label: '积分记录', icon: 'el-icon-document', perm: 'family:points,family:bound' },
- { path: '/wishes', label: '心愿管理', icon: 'el-icon-star-off', perm: 'family:wishes' },
- { path: '/rewards', label: '奖励管理', icon: 'el-icon-s-goods', perm: 'reward:list' },
- ]},
- // ===== 3. 方案中心 (plan:*) =====
- { title: '方案中心', icon: 'el-icon-notebook-2', perm: 'plan:*',
- children: [
- { path: '/health-plan-manage', label: '健康方案管理', icon: 'el-icon-first-aid-kit', perm: 'plan:health' },
- { path: '/assessment-plan-manage', label: '测评方案管理', icon: 'el-icon-edit', perm: 'plan:assessment' },
- ]},
- // ===== 4. 任务中心 (task:*) =====
- { title: '任务中心', icon: 'el-icon-s-order', perm: 'task:*,task:read',
- children: [
- { path: '/tasks', label: '任务列表', icon: 'el-icon-s-order', perm: 'task:list' },
- { path: '/task-templates', label: '任务模板', icon: 'el-icon-document', perm: 'task:templates' },
- { path: '/growth-task', label: '成长任务管理', icon: 'el-icon-s-management', perm: 'task:growth' },
- ]},
- // ===== 5. 审核中心(归集:服务角色申请/活动审核/退款/提现) =====
- { title: '审核中心', icon: 'el-icon-s-check', perm: 'audit',
- children: [
- { path: '/review-center', label: '审核中心总览', icon: 'el-icon-s-check', perm: 'audit' },
- { path: '/activity-review', label: '活动审核', icon: 'el-icon-document-checked', perm: 'audit:activity' },
- { path: '/pending-refund', label: '待退款管理', icon: 'el-icon-warning', perm: 'audit:refund' },
- { path: '/family-earnings-withdraw', label: '收益提现审核', icon: 'el-icon-document-checked', perm: 'audit:withdraw' },
- ]},
- // ===== 5. 商城营销 (commerce:*) =====
- { title: '商城营销', icon: 'el-icon-s-goods', perm: 'commerce:*',
- children: [
- { path: '/product-manage', label: '商品管理', icon: 'el-icon-s-goods', perm: 'commerce:products,commerce:self' },
- { path: '/inventory', label: '库存管理', icon: 'el-icon-document', perm: 'inventory:self' },
- { path: '/order-manage', label: '订单管理', icon: 'el-icon-s-order', perm: 'commerce:orders,order:self' },
- { path: '/ecom-supplier', label: '供应商管理', icon: 'el-icon-s-shop', perm: 'commerce:supplier' },
- { path: '/product-profit-rate', label: '产品利润率', icon: 'el-icon-data-line', perm: 'finance:profit-rate' },
- { path: '/coupon', label: '优惠券管理', icon: 'el-icon-ticket', perm: 'commerce:coupon' },
- { path: '/coupon-grant-log', label: '发券记录', icon: 'el-icon-document', perm: 'commerce:coupon' },
- { path: '/discount-rules', label: '限时折扣管理', icon: 'el-icon-timer', perm: 'commerce:discount' },
- { path: '/promotion', label: '推广管理', icon: 'el-icon-s-marketing', perm: 'commerce:promotion' },
- { path: '/home-banner-manage', label: '首页广告栏', icon: 'el-icon-picture', perm: 'marketing:promotion' },
- { path: '/family-earnings', label: '家庭收益', icon: 'el-icon-s-money', perm: 'finance:family-earnings' },
- ]},
- // ===== 6. 知识中心 (articles:*) =====
- { title: '知识中心', icon: 'el-icon-document', perm: 'articles:*,knowledge:read',
- children: [
- { path: '/article-categories', label: '知识分类', icon: 'el-icon-folder', perm: 'articles:categories' },
- { path: '/article-manage', label: '知识管理', icon: 'el-icon-document', perm: 'articles:manage' },
- { path: '/comment-review', label: '评论审核', icon: 'el-icon-chat-dot-round', perm: 'articles:manage' },
- { path: '/knowledge-tags', label: '知识标签', icon: 'el-icon-price-tag', perm: 'articles:categories' },
- { path: '/knowledge-base', label: '知识库', icon: 'el-icon-reading', perm: 'knowledge:base' },
- { path: '/knowledge-base/unified', label: '统一知识库', icon: 'el-icon-notebook-2', perm: 'knowledge:base' },
- { path: '/vector-knowledge', label: '向量知识库', icon: 'el-icon-data-line', perm: 'knowledge:base' },
- ]},
- // ===== 6.5 活动管理(activity:*,活动审核已移入审核中心) =====
- { title: '活动管理', icon: 'el-icon-date', perm: 'activity:*', children: [
- { path: '/activities', label: '活动列表', icon: 'el-icon-date', perm: 'activity:list,activity:self' },
- { path: '/activity-registration-review', label: '活动报名审核', icon: 'el-icon-document-checked', perm: 'activity:registration' },
- { path: '/poster-template-manage', label: '海报模板管理', icon: 'el-icon-picture', perm: 'activity:poster_template' },
- ]},
- // ===== 7. 健康饮食 (health:*,报告管理/代传报告挂载,顺序对齐方案最终菜单树) =====
- { title: '健康饮食', icon: 'el-icon-first-aid-kit', perm: 'health:*',
- children: [
- { path: '/report-management', label: '报告管理', icon: 'el-icon-document', perm: 'health:reports' },
- { path: '/report-proxy-upload', label: '代传报告', icon: 'el-icon-upload', perm: 'health:reports' },
- { path: '/report-parse-status', label: '解析进度', icon: 'el-icon-data-line', perm: 'health:reports' },
- { path: '/health-indicators', label: '健康指标', icon: 'el-icon-data-line', perm: 'health:indicators' },
- { path: '/health-checkins', label: '健康打卡', icon: 'el-icon-s-order', perm: 'health:checkins' },
- { path: '/emotion-alert', label: '情绪告警', icon: 'el-icon-warning', perm: 'health:checkins' },
- { path: '/nutrition-mappings', label: '营养素映射', icon: 'el-icon-connection', perm: 'health:mappings' },
- { path: '/foods', label: '食材管理', icon: 'el-icon-apple', perm: 'diet:foods' },
- { path: '/recipes', label: '食谱管理', icon: 'el-icon-dish', perm: 'diet:recipes' },
- { path: '/seasonal-foods', label: '应季食材', icon: 'el-icon-apple', perm: 'diet:foods' },
- { path: '/nutrition-products', label: '营养产品', icon: 'el-icon-first-aid-kit', perm: 'health:products' },
- { path: '/energy-sandbox', label: '五维能量', icon: 'el-icon-data-line', perm: 'health:energy' },
- ]},
- // ===== 8. 报告解析系统 (config:report-parser,LangGraph 管理归入) =====
- { title: '报告解析系统', icon: 'el-icon-cpu', perm: 'config:report-parser',
- children: [
- { path: '/report-types', label: '报告类型管理', icon: 'el-icon-collection', perm: 'config:report-parser' },
- { path: '/report-parser-import', label: '解析器导入', icon: 'el-icon-upload2', perm: 'config:report-parser' },
- { path: '/report-unknown-clusters', label: '未知报告审核', icon: 'el-icon-question', perm: 'config:report-parser' },
- { path: '/report-auto-learn', label: '报告自学习', icon: 'el-icon-magic-stick', perm: 'config:report-parser' },
- { path: '/report-collector-trainer', label: '报告采集训练', icon: 'el-icon-film', perm: 'config:report-parser' },
- { path: '/report-template', label: '报告模板管理', icon: 'el-icon-setting', perm: 'config:report-parser' },
- { path: '/langgraph-admin', label: 'LangGraph 管理', icon: 'el-icon-cpu', perm: 'config:report-parser' },
- ]},
- { title: '家庭服务', icon: 'el-icon-s-custom', perm: 'service:*',
- children: [
- { path: '/my-families', label: '我的家庭', icon: 'el-icon-s-custom', perm: 'service:family' },
- { path: '/teacher-team', label: '我的团队', icon: 'el-icon-s-custom', perm: 'service:team' },
- ]},
- { title: '业务管理', icon: 'el-icon-s-marketing', perm: 'biz:*',
- children: [
- { path: '/teacher-packages', label: '任务模板管理', icon: 'el-icon-s-goods', perm: 'biz:packages' },
- { path: '/teacher-orders', label: '订单佣金', icon: 'el-icon-s-order', perm: 'biz:orders' },
- ]},
- // ===== 测评咨询(测评管理/订单/待分配规划师已从系统配置移入) =====
- { title: '测评咨询', icon: 'el-icon-edit', perm: 'assessment:*,assessment:read',
- children: [
- { path: '/assessment-admin', label: '测评管理', icon: 'el-icon-edit', perm: 'assessment:manage' },
- { path: '/assessment-orders', label: '测评订单', icon: 'el-icon-s-order', perm: 'assessment:orders' },
- { path: '/assessment-assign', label: '待分配规划师', icon: 'el-icon-user', perm: 'assessment:assign' },
- { path: '/teacher-assessment', label: 'DAN测评', icon: 'el-icon-edit', perm: 'assessment:dan' },
- { path: '/teacher-consult', label: '家长咨询', icon: 'el-icon-chat-dot-round', perm: 'assessment:consult' },
- { path: '/growth-records', label: '成长记录', icon: 'el-icon-document', perm: 'growth:records' },
- { path: '/growth-plans', label: '成长计划', icon: 'el-icon-document', perm: 'growth:plans' },
- ]},
- // ===== 9. 系统配置 (system:*,权限拆分 system:base/config:member/config:dimension/config:health) =====
- { title: '系统配置', icon: 'el-icon-s-tools', perm: 'system:*',
- children: [
- // --- 基础管理 ---
- { title: '基础管理', icon: 'el-icon-s-tools', perm: 'system:base',
- children: [
- { path: '/sys-config', label: '系统配置', icon: 'el-icon-s-tools', perm: 'system:base' },
- { path: '/guide-config', label: '引导配置', icon: 'el-icon-setting', perm: 'system:base' },
- { path: '/users', label: '用户管理', icon: 'el-icon-user', perm: 'system:users' },
- { path: '/menu-manage', label: '菜单管理', icon: 'el-icon-menu', perm: 'system:menu' },
- { path: '/operation-logs', label: '操作日志', icon: 'el-icon-s-order', perm: 'system:logs' },
- { path: '/membership-center', label: '会员中心', icon: 'el-icon-s-custom', perm: 'config:member' },
- { path: '/badge-manage', label: '勋章管理', icon: 'el-icon-medal', perm: 'config:member' },
- { path: '/virtual-goods-config', label: '虚拟支付道具', icon: 'el-icon-goods', perm: 'config:member' },
- { path: '/gates', label: '关卡配置', icon: 'el-icon-key', perm: 'system:base' },
- { path: '/system-prompt', label: '系统提示词', icon: 'el-icon-chat-line-square', perm: 'system:base' },
- { path: '/file-manage', label: '文件管理', icon: 'el-icon-files', perm: 'system:base' },
- ]},
- // --- 配置中心 ---
- { title: '配置中心', icon: 'el-icon-setting', perm: 'config:dimension',
- children: [
- { path: '/dimension-config', label: '维度配置', icon: 'el-icon-data-line', perm: 'config:dimension' },
- ]},
- // --- 供应商体系 ---
- { title: '供应商体系', icon: 'el-icon-s-management', perm: 'system:supply',
- children: [
- { path: '/supply-system', label: '供应商体系', icon: 'el-icon-s-management', perm: 'system:supply' },
- ]},
- // --- 供应商管理 ---
- { title: '供应商管理', icon: 'el-icon-s-shop', perm: 'supply:manage',
- children: [
- { path: '/supply-manage', label: '供应商管理', icon: 'el-icon-s-shop', perm: 'supply:manage' },
- { path: '/supplier-products', label: '商品管理', icon: 'el-icon-s-goods', perm: 'supply:manage' },
- ]},
- // --- 健康配置(能量规则/行为/周期性服务已从健康饮食移入;术语统一:五维能量配置) ---
- { title: '健康配置', icon: 'el-icon-first-aid-kit', perm: 'config:health',
- children: [
- { path: '/health-norm-config', label: '健康常模', icon: 'el-icon-data-line', perm: 'config:health' },
- { path: '/health-data-source', label: '健康数据源', icon: 'el-icon-data-line', perm: 'config:health' },
- { path: '/health-energy-config', label: '五维能量配置', icon: 'el-icon-data-line', perm: 'config:health' },
- { path: '/energy-rule', label: '能量规则管理', icon: 'el-icon-setting', perm: 'config:health' },
- { path: '/energy-behavior-config', label: '能量行为配置', icon: 'el-icon-edit-outline', perm: 'config:health' },
- { path: '/periodic-service-config', label: '周期性服务配置', icon: 'el-icon-refresh', perm: 'config:health' },
- { path: '/indicator-correlations', label: '指标关联配置', icon: 'el-icon-connection', perm: 'config:health' },
- { path: '/indicator-mappings', label: '指标映射管理', icon: 'el-icon-sort', perm: 'config:health' },
- ]},
- // --- 人生维度 ---
- { title: '人生维度', icon: 'el-icon-s-custom', perm: 'config:dimension',
- children: [
- { path: '/zodiac-configs', label: '星座配置', icon: 'el-icon-s-management', perm: 'config:dimension' },
- { path: '/bazi-configs', label: '八字配置', icon: 'el-icon-s-management', perm: 'config:dimension' },
- { path: '/blood-type-configs', label: '血型配置', icon: 'el-icon-s-management', perm: 'config:dimension' },
- { path: '/innate-portrait-config', label: '先天画像权重配置', icon: 'el-icon-s-management', perm: 'config:dimension' },
- { path: '/numsoul-detail-config', label: '数字能量配置', icon: 'el-icon-s-management', perm: 'config:dimension' },
- ]},
- // --- 虚拟团队 ---
- { title: '虚拟团队', icon: 'el-icon-s-custom', perm: 'system:base',
- children: [
- { path: '/virtual-teams', label: '虚拟团队', icon: 'el-icon-s-custom', perm: 'system:base' },
- ]},
- ]},
- ],
- // 需要保持列表状态的页面组件 name(进入编辑/详情返回时保留筛选、页码、勾选)。
- // 接入方式:把组件 name 加进数组,并在该页面混入 ListStateMixin(见 src/mixins/ListStateMixin.js)
- cachedPages: ['Activities', 'ActivityReview', 'ArticleAudit', 'ArticleManage', 'AssessmentAssign', 'AssessmentOrders', 'AssessmentProducts', 'ButlerAssignments', 'ButlerAudit', 'CfValueManage', 'Children', 'CommentReview', 'CouponGrantLog', 'CouponManagement', 'DanExecution', 'DanSettlement', 'DataSourceConfig', 'DiscountRuleManagement', 'EcomSupplierManage', 'EmotionAlertManage', 'EnergyRuleManagement', 'Families', 'FamilyEarningsWithdraw', 'FileManage', 'Foods', 'GatesManage', 'GrowthTaskManagement', 'GuideAudit', 'GuideFamilyTask', 'HealthPlanManage', 'HealthReports', 'HomeBannerManage', 'IndicatorCorrelations', 'IndicatorMappings', 'InventoryManage', 'KnowledgeManage', 'MembershipCenter', 'NutritionistAudit', 'NutritionProducts', 'OperationLogs', 'OrchestrationFlow', 'OrderManage', 'PackageAudit', 'PendingRefund', 'PendingRefundAudit', 'Points', 'PointsLog', 'ProductManage', 'ProductPpointManage', 'ProductProfitRate', 'ProfileManagement', 'PromotionManagement', 'ProxyReport', 'ProxyReportUpload', 'PurchaseManagement', 'RecommendationRules', 'ReportManagement', 'ReportParseStatus', 'Rewards', 'SubscriptionManagement', 'SupplierProductManage', 'SupplyManageList', 'SupplySystemList', 'SysConfig', 'SystemPromptManagement', 'Tasks', 'TaskTemplates', 'TeacherConsult', 'TeacherOrders', 'Users', 'VectorKnowledgeBase', 'VendorAudit', 'VirtualTeamList', 'Wishes', 'WithdrawAudit'],
- menuLoadFailed: false,
- profileDialogVisible: false,
- passwordDialogVisible: false,
- submitting: false,
- profileForm: {
- nickname: '',
- phone: '',
- email: '',
- username: '',
- realName: ''
- },
- passwordForm: {
- oldPassword: '',
- newPassword: '',
- confirmPassword: ''
- },
- inviteCodeVisible: false,
- inviteCodeLoading: false,
- inviteCodeData: null,
- unreadMessageCount: 0,
- isMobile: window.innerWidth <= 768,
- sidebarVisible: window.innerWidth > 768,
- passwordRules: {
- oldPassword: [
- { required: true, message: '请输入原密码', trigger: 'blur' }
- ],
- newPassword: [
- { required: true, message: '请输入新密码', trigger: 'blur' },
- { min: 6, message: '密码长度不能少于6位', trigger: 'blur' }
- ],
- confirmPassword: [
- { required: true, message: '请确认新密码', trigger: 'blur' },
- {
- validator: (rule, value, callback) => {
- if (value !== this.passwordForm.newPassword) {
- callback(new Error('两次输入密码不一致'))
- } else {
- callback()
- }
- },
- trigger: 'blur'
- }
- ]
- }
- }
- },
- computed: {
- activeMenu() {
- return this.$route.path
- },
- // 菜单去重(B-7:按 title/path 去重,修复侧边栏菜单重复渲染 bug)
- effectiveMenuItems() {
- return this.dedupeMenuItems(this.menuItems)
- },
- currentRole() {
- return localStorage.getItem('role') || 'admin'
- },
- vendorType() {
- return localStorage.getItem('vendorType') || ''
- },
- effectivePerms() {
- // 菜单按当前登录身份隔离(登录时选择的身份),多角色账号不再默认并集展示
- return getEffectivePermissions([this.currentRole])
- },
- displayRoles() {
- const rolesStr = localStorage.getItem('roles')
- const roles = rolesStr ? JSON.parse(rolesStr) : [this.currentRole]
- return roles.map(function(r) { return getRoleLabel(r) }).join(' / ')
- },
- displayUserLabel() {
- const adminName = localStorage.getItem('adminName')
- if (adminName) {
- return adminName + ' (' + this.displayRoles + ')'
- }
- return this.displayRoles
- }
- },
- watch: {
- '$route'() {
- if (this.isMobile) {
- this.sidebarVisible = false
- }
- }
- },
- mounted() {
- // 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
- window.onbeforeunload = null
- // 响应式监听
- this.handleResize = this.handleResize.bind(this)
- window.addEventListener('resize', this.handleResize)
- // 有消息权限(老师/营养师角色)才加载未读数,管理员不调用
- if (hasPermission(this.effectivePerms, 'messages') && this.currentRole !== 'admin') {
- this.fetchUnreadCount()
- }
- // 从后端加载菜单(/api/admin/menu/tree),失败则使用硬编码菜单
- this.fetchMenu()
- },
- beforeDestroy() {
- window.removeEventListener('resize', this.handleResize)
- },
- methods: {
- /**
- * 菜单去重:同层级内按 (title || path) + path 组合键去重,递归处理 children
- * 防止后端动态菜单与硬编码/全量菜单数据重叠时侧边栏重复渲染
- */
- dedupeMenuItems(items) {
- if (!items || items.length === 0) return items
- const seen = {}
- const result = []
- for (let i = 0; i < items.length; i++) {
- const it = items[i]
- const key = (it.title || '') + '|' + (it.path || '') + '|' + (it.label || '')
- if (seen[key]) continue
- seen[key] = true
- if (it.children && it.children.length > 0) {
- const copy = Object.assign({}, it)
- copy.children = this.dedupeMenuItems(it.children)
- result.push(copy)
- } else {
- result.push(it)
- }
- }
- return result
- },
- hasPerm(required) {
- return hasPermission(this.effectivePerms, required)
- },
- getMenuIndex(item) {
- return item.path === '/dashboard' && this.currentRole === 'teacher'
- ? '/teacher-dashboard'
- : item.path
- },
- handleMenuSelect(index) {
- if (index && index.startsWith('/')) {
- this.$router.push(index)
- }
- if (this.isMobile) {
- this.sidebarVisible = false
- }
- },
- toggleSidebar() {
- this.sidebarVisible = !this.sidebarVisible
- },
- handleResize() {
- const mobile = window.innerWidth <= 768
- if (mobile !== this.isMobile) {
- this.isMobile = mobile
- if (!mobile) {
- this.sidebarVisible = true
- } else {
- this.sidebarVisible = false
- }
- }
- },
- async fetchMenu() {
- try {
- var res = await getUserMenus()
- if (res.code === 200 && res.data && res.data.length > 0) {
- this.menuItems = this.buildMenuItems(res.data)
- this.menuLoadFailed = false
- } else {
- this.menuLoadFailed = true
- }
- } catch (e) {
- this.menuLoadFailed = true
- console.error('菜单加载失败', e)
- }
- },
- buildMenuItems(nodes) {
- var result = []
- for (var i = 0; i < nodes.length; i++) {
- var n = nodes[i]
- var item = {}
- if (n.path) {
- item.path = n.path
- item.label = n.label || n.title || ''
- item.icon = n.icon || ''
- item.perm = n.perm || ''
- } else {
- item.title = n.title || ''
- item.label = n.label || ''
- item.icon = n.icon || ''
- item.perm = n.perm || ''
- }
- if (n.children && n.children.length > 0) {
- item.children = this.buildMenuItems(n.children)
- }
- result.push(item)
- }
- return result
- },
- handleProfileCommand(command) {
- if (command === 'profile') {
- this.loadAdminInfo()
- this.profileDialogVisible = true
- } else if (command === 'password') {
- this.passwordForm = { oldPassword: '', newPassword: '', confirmPassword: '' }
- this.passwordDialogVisible = true
- } else if (command === 'logout') {
- this.handleLogout()
- }
- },
- async loadAdminInfo() {
- try {
- const res = await getAdminInfo()
- this.profileForm = {
- nickname: res.data.nickname || '',
- phone: res.data.phone || '',
- email: res.data.email || '',
- username: res.data.username || '',
- realName: res.data.realName || ''
- }
- } catch (e) {
- this.$message.error('加载个人信息失败')
- }
- },
- async confirmUpdateInfo() {
- this.submitting = true
- try {
- await updateAdminInfo({
- nickname: this.profileForm.nickname,
- phone: this.profileForm.phone,
- email: this.profileForm.email
- })
- if (this.profileForm.nickname) {
- localStorage.setItem('adminName', this.profileForm.nickname)
- }
- this.$message.success('保存成功')
- this.profileDialogVisible = false
- } catch (e) {
- this.$message.error(e.message || '保存失败')
- } finally {
- this.submitting = false
- }
- },
- async confirmChangePassword() {
- this.$refs.passwordForm.validate(async (valid) => {
- if (!valid) return
- this.submitting = true
- try {
- await changePassword({
- oldPassword: this.passwordForm.oldPassword,
- newPassword: this.passwordForm.newPassword
- })
- this.$message.success('密码修改成功')
- this.passwordDialogVisible = false
- } catch (e) {
- this.$message.error(e.message || '密码修改失败')
- } finally {
- this.submitting = false
- }
- })
- },
- async showInviteCode() {
- this.inviteCodeVisible = true
- this.inviteCodeLoading = true
- this.inviteCodeData = null
- try {
- const res = await getMyInviteCode()
- if (res.data) {
- this.inviteCodeData = res.data
- }
- } catch (e) {
- this.$message.error('获取邀请码失败')
- } finally {
- this.inviteCodeLoading = false
- }
- },
- async generateInviteCode() {
- this.inviteCodeLoading = true
- try {
- const res = await getMyInviteCode()
- if (res.data) {
- this.inviteCodeData = res.data
- this.$message.success('邀请码已生成')
- }
- } catch (e) {
- this.$message.error('生成邀请码失败')
- } finally {
- this.inviteCodeLoading = false
- }
- },
- copyCode(code) {
- if (!code) return
- const input = document.createElement('input')
- input.value = code
- document.body.appendChild(input)
- input.select()
- document.execCommand('copy')
- document.body.removeChild(input)
- this.$message.success('已复制邀请码')
- },
- async fetchUnreadCount() {
- try {
- const res = await getUnreadMessageCount()
- if (res.data !== undefined) {
- this.unreadMessageCount = res.data || 0
- }
- } catch (e) {
- // silent: not critical
- }
- },
- handleMessageClick() {
- this.$router.push('/teacher-messages')
- },
- handleLogout() {
- // 不使用 modal 遮罩(全局 .v-modal { display:none } 会与 $confirm 的遮罩冲突)
- this.$confirm('确定要退出登录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- modal: false,
- customClass: 'cfc-logout-confirm'
- }).then(() => {
- localStorage.removeItem('token')
- localStorage.removeItem('role')
- localStorage.removeItem('roles')
- localStorage.removeItem('adminId')
- localStorage.removeItem('adminName')
- this.$router.push('/login')
- })
- }
- }
- }
- </script>
- <style>
- /* 全局防御:防止 Element UI 弹窗或组件残留 DOM 产生遮罩覆盖 */
- .v-modal {
- display: none !important;
- }
- .layout-container {
- height: 100vh;
- }
- .el-aside {
- background-color: #001529;
- overflow: visible;
- display: flex;
- flex-direction: column;
- }
- .logo {
- height: 60px;
- line-height: 60px;
- text-align: center;
- color: #fff;
- font-size: 20px;
- font-weight: bold;
- background-color: #001529;
- flex-shrink: 0;
- }
- /* 侧边栏滚动条样式 */
- .sidebar-scrollbar-wrap {
- height: calc(100vh - 60px) !important;
- overflow-x: hidden !important;
- overflow-y: auto !important;
- }
- .sidebar-scrollbar-wrap .el-scrollbar__view {
- height: 100%;
- }
- .sidebar-scrollbar-wrap::-webkit-scrollbar {
- width: 6px;
- }
- .sidebar-scrollbar-wrap::-webkit-scrollbar-track {
- background: #001529;
- }
- .sidebar-scrollbar-wrap::-webkit-scrollbar-thumb {
- background: #4a5568;
- border-radius: 3px;
- }
- .sidebar-scrollbar-wrap::-webkit-scrollbar-thumb:hover {
- background: #5a6578;
- }
- .el-header {
- background-color: #fff;
- box-shadow: 0 1px 4px rgba(0,21,41,.08);
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 20px;
- }
- .header-right {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .username {
- color: #606266;
- }
- .invite-code-btn {
- color: #1677FF;
- font-size: 13px;
- }
- .invite-code-btn:hover {
- color: #4F46E5;
- }
- .msg-badge {
- margin-right: 4px;
- }
- .msg-badge .el-badge__content.is-fixed {
- top: 10px;
- right: 6px;
- }
- .msg-btn {
- font-size: 18px;
- color: #606266;
- padding: 4px;
- }
- .msg-btn:hover {
- color: #1677FF;
- }
- .invite-code-content {
- padding: 8px 0;
- }
- .invite-code-section {
- background: #F8FAFC;
- border: 1px solid #E2E8F0;
- border-radius: 8px;
- padding: 20px;
- text-align: center;
- }
- .invite-code-label {
- font-size: 14px;
- color: #64748B;
- margin-bottom: 12px;
- }
- .invite-code-value {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 12px;
- margin-bottom: 8px;
- }
- .code-text {
- font-size: 28px;
- font-weight: 700;
- letter-spacing: 6px;
- color: #1E293B;
- font-family: monospace;
- }
- .no-invite-code {
- text-align: center;
- padding: 24px;
- color: #94A3B8;
- }
- .no-invite-code i {
- font-size: 48px;
- margin-bottom: 12px;
- }
- .no-invite-code p {
- margin-bottom: 16px;
- }
- .el-main {
- background-color: #f0f2f5;
- padding: 24px;
- position: relative;
- z-index: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- overflow-y: auto;
- }
- .main-wrapper {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- }
- /* ========== 全局 .admin-page 样式 ========== */
- /* 所有后台维护页面根元素使用此 class,使页面内容充满可视区 */
- .admin-page {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- }
- /* 当 admin-page 的直接子元素是 el-card 时让卡片自动填充 */
- .admin-page > .el-card {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- }
- .admin-page > .el-card .el-card__body {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- padding: 20px;
- }
- /* 当 admin-page > div > el-card(如 ArticleManage 的嵌套 div) */
- .admin-page > div:only-child {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- }
- .admin-page > div:only-child > .el-card {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- }
- .admin-page > div:only-child > .el-card .el-card__body {
- flex: 1;
- display: flex;
- flex-direction: column;
- min-height: 0;
- padding: 20px;
- }
- /* ========== 响应式:侧边栏折叠 ========== */
- @media (max-width: 768px) {
- .sidebar-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.4);
- z-index: 1001;
- }
- .sidebar-mobile {
- position: fixed !important;
- top: 0;
- left: 0;
- height: 100vh !important;
- z-index: 1002;
- transition: transform 0.25s ease;
- transform: translateX(-100%);
- }
- .sidebar-mobile.sidebar-open {
- transform: translateX(0);
- }
- .sidebar-mobile.sidebar-closed {
- transform: translateX(-100%);
- }
- .header-left {
- display: flex;
- align-items: center;
- }
- .hamburger-btn {
- font-size: 20px;
- color: #606266;
- padding: 8px;
- }
- .hamburger-btn:hover {
- color: #1677FF;
- }
- .el-header {
- padding: 0 10px !important;
- }
- .el-main {
- padding: 12px !important;
- }
- .admin-page > .el-card .el-card__body {
- padding: 12px !important;
- }
- .admin-page > div:only-child > .el-card .el-card__body {
- padding: 12px !important;
- }
- .username {
- font-size: 13px;
- }
- /* el-table 小屏字号 */
- .el-table {
- font-size: 12px;
- }
- .el-table .cell {
- padding-left: 4px !important;
- padding-right: 4px !important;
- }
- /* 表格横向滚动优化 */
- .el-table {
- min-width: 600px !important;
- table-layout: auto !important;
- }
- .el-table__body-wrapper {
- overflow-x: auto !important;
- -webkit-overflow-scrolling: touch;
- }
- /* 搜索表单:form-item 换行 */
- .el-form-item--inline {
- display: block !important;
- margin-bottom: 12px !important;
- }
- .el-form-item--inline .el-form-item__content {
- display: flex !important;
- width: 100% !important;
- margin-left: 0 !important;
- }
- .el-form-item--inline .el-form-item__label {
- display: block !important;
- text-align: left !important;
- margin-bottom: 4px !important;
- }
- /* 搜索表单中 el-input/el-select 宽度 100% */
- .el-form-item--inline .el-input,
- .el-form-item--inline .el-select,
- .el-form-item--inline .el-date-editor {
- width: 100% !important;
- }
- /* 文章编辑等复杂表单 */
- .el-form--inline .el-form-item {
- display: block !important;
- }
- .el-form--inline .el-form-item__content {
- display: block !important;
- width: 100% !important;
- margin-left: 0 !important;
- }
- .el-form--inline .el-form-item__label {
- text-align: left !important;
- display: block !important;
- }
- /* 通用:卡片内容紧凑 */
- .stat-card {
- margin-bottom: 12px !important;
- }
- }
- /* 桌面端隐藏 header-left(无汉堡按钮) */
- @media (min-width: 769px) {
- .header-left {
- display: none;
- }
- }
- .menu-load-failed {
- padding: 24px 16px;
- text-align: center;
- color: #94a3b8;
- }
- .menu-load-failed .el-icon-warning-outline {
- font-size: 28px;
- color: #f59e0b;
- }
- .menu-load-failed-title {
- margin: 8px 0 0;
- font-size: 13px;
- font-weight: 600;
- color: #64748b;
- }
- .menu-load-failed-sub {
- margin: 4px 0 0;
- font-size: 12px;
- color: #94a3b8;
- }
- </style>
|