From ee6e52ff407f3ecd51eb9718224a4fa438b97ba1 Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Tue, 3 Nov 2026 18:00:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E4=BC=98=E5=8C=96=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=8A=9F=E8=83=BD=E9=A1=B5=E5=B8=83=E5=B1=80=E4=B8=8E?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整全部功能页菜单名称字号和字重,统一与首页常用功能菜单一致 放大左侧导航按钮字号和点击区域,提升分类选择时的可操作性 调整右侧字母索引按钮间距和热区,优化快速定位体验 细化页面内留白设计,修正搜索区、导航区与功能列表之间的间距问题 参考商品查询页搜索框风格,更新为圆角浅灰输入框,并保留独立搜索按钮 去掉扫描图标,仅保留搜索入口,保持页面更简洁、交互更聚焦 优化头部与内容区分隔逻辑,提升页面整体视觉一致性 --- src/pages/home/edit-quick-actions.vue | 130 ++-- src/pages/index/index.vue | 971 +++++++++++++++----------- 2 files changed, 669 insertions(+), 432 deletions(-) diff --git a/src/pages/home/edit-quick-actions.vue b/src/pages/home/edit-quick-actions.vue index 967684a..09d9ab5 100644 --- a/src/pages/home/edit-quick-actions.vue +++ b/src/pages/home/edit-quick-actions.vue @@ -12,15 +12,22 @@ - + - - + bg-color="#f5f5f5" + shape="round" + :show-action="false" + @search="handleSearchAction" + @clear="handleSearchAction" + > + + + 搜索 + + @@ -306,6 +313,12 @@ this.activeParent = '全部'; this.activeNav = '全部'; }, + handleSearchAction() { + // 列表已随关键字实时过滤,这里只收起键盘 + if (typeof uni !== 'undefined' && uni.hideKeyboard) { + uni.hideKeyboard(); + } + }, onClickParent(group) { this.activeParent = group.key; this.activeNav = group.initial || '全部'; @@ -423,7 +436,6 @@ position: relative; padding: 20rpx; background: #fff; - border-bottom: 1rpx solid #f0f0f0; display: flex; align-items: center; justify-content: center; @@ -472,22 +484,23 @@ display: flex; min-height: 0; position: relative; + padding-top: 20rpx; } .left-nav { - width: 160rpx; + width: 180rpx; background: #fff; border-right: 1rpx solid #f0f0f0; padding: 12rpx 8rpx; .nav-item { position: relative; - min-height: 60rpx; + min-height: 68rpx; display: flex; align-items: center; justify-content: center; margin-bottom: 10rpx; - font-size: 30rpx; + font-size: 34rpx; color: #666; background: #f4f5f7; border-radius: 10rpx; @@ -515,7 +528,7 @@ } .parent-nav-item { - font-size: 28rpx; + font-size: 34rpx; line-height: 1.4; word-break: break-all; } @@ -537,25 +550,30 @@ align-items: center; background: transparent; border-radius: 16rpx; - padding: 4rpx 3rpx; + padding: 6rpx 4rpx; .initial-item { position: relative; - min-width: 32rpx; - height: 32rpx; - line-height: 32rpx; + min-width: 36rpx; + height: 36rpx; + line-height: 36rpx; text-align: center; - font-size: 20rpx; + font-size: 22rpx; color: #666; - border-radius: 6rpx; + border-radius: 8rpx; + margin-bottom: 6rpx; + + &:last-child { + margin-bottom: 0; + } &::before { content: ''; position: absolute; - left: -8rpx; - right: -8rpx; - top: -6rpx; - bottom: -6rpx; + left: -6rpx; + right: -6rpx; + top: -2rpx; + bottom: -2rpx; } &.active { @@ -565,31 +583,58 @@ } } - .search-bar { - padding: 16rpx 20rpx; + .search-panel { + padding: 20rpx; background: #fff; - border-bottom: 1rpx solid #f0f0f0; + border-bottom: 1rpx solid #f2f2f2; + flex-shrink: 0; + position: relative; + z-index: 1; + } - .search-input-wrap { - height: 72rpx; - background: #f4f5f7; - border-radius: 10rpx; - padding: 0 20rpx; - display: flex; - align-items: center; + .search-input-wrap { + position: relative; + + ::v-deep .u-search { + width: 100%; } - .search-input { - flex: 1; - height: 72rpx; - padding-left: 12rpx; - font-size: 30rpx; - color: #333; + ::v-deep .u-search__content { + padding-right: 110rpx; } - .search-placeholder { + ::v-deep .u-search__content__close { + margin-right: 12rpx; + } + } + + .search-actions { + position: absolute; + right: 24rpx; + top: 50%; + transform: translateY(-50%); + height: 68rpx; + display: flex; + align-items: center; + } + + .search-btn { + height: 68rpx; + padding: 0 8rpx; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + + &__text { font-size: 30rpx; - color: #999; + font-weight: 500; + color: #2979ff; + line-height: 1; + } + + &:active { + opacity: 0.88; } } @@ -603,6 +648,10 @@ color: #666; padding: 18rpx 4rpx 10rpx; } + + &:first-child .group-title { + padding-top: 0; + } } } @@ -646,7 +695,8 @@ } .item-name { - font-size: 28rpx; + font-size: 34rpx; + font-weight: normal; color: #333; text-align: left; padding: 0; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 95283d3..6d6197e 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -5,11 +5,13 @@ - - {{ userInfo.store_name || '选择主体' }} - {{ userInfo.employees_name || '---' }} + + + {{ userInfo.store_name || '选择主体' }} + {{ userInfo.employees_name || '---' }} + + - @@ -17,7 +19,7 @@ - + {{ noticeText }} {{ noticeText }} @@ -27,11 +29,6 @@ - - - - - @@ -40,15 +37,17 @@ + 常用功能 - 长按可排序/移除 - 完成 + 长按排序 - - 全部功能 - | - {{ currentPage }}/{{ totalPages }} + 完成 + 管理 + + 全部功能 + + @@ -61,11 +60,19 @@ + + + + + + + - + 暂无可用功能 请联系仓库管理员检查授权 + 重新加载 @@ -120,7 +127,13 @@ > {{ removeActionIconGlyph }} - + + {{ dragPreviewSnapshot.resolvedIconGlyph || fallbackIconGlyph }} @@ -134,7 +147,7 @@ - + @@ -147,6 +160,12 @@ + + + 已移出「{{ undoAction.item.name }}」 + 撤销 + + @@ -173,12 +192,61 @@ Object.keys(uviewIcons || {}).map(key => String(key).replace(/^uicon-/, '')) ) + // 常用功能配色:按菜单 key 取模,保证同一菜单每次刷新颜色一致 + const MENU_COLOR_POOL = [ + '#FF6B6B', '#4ECDC4', '#FFD166', '#06D6A0', '#118AB2', + '#EF476F', '#26547C', '#7209B7', '#3A86FF', '#FB5607', + '#8338EC', '#2EC4B6' + ] + + // 看板统计相关的菜单识别(后台菜单名可能调整,保留关键字兜底) + const isReviewShippingMenuName = name => name === '散单复核发货' || + name === '订单复核' || + (name.includes('复核') && name.includes('发货')) + + const isScatterReviewShippingMenuName = name => name === '散单复核发货' || + name === '订单复核' || + (name.includes('散单') && name.includes('复核') && name.includes('发货')) + + const isOrderPickingMenuName = name => name === '订单拣货' || + (name.includes('订单') && name.includes('拣货')) + + const isClaimShippingMenuName = name => name === '领取快递面单' || + (name.includes('领取') && name.includes('面单')) + + /** + * 常用功能菜单 → 页面路由。 + * 顺序敏感:按数组顺序命中即返回(与原 if/else 链保持一致)。 + * names 精确匹配、all 需同时包含、any 命中任一、test 自定义判断; + * paths 按 component/path 命中;block 只提示不跳转。 + */ + const MENU_ROUTE_RULES = [ + { + block: '该功能只支持在商品查询页面使用!', + paths: ['/pages/work/storage/relocation', '/pages/work/product/itemMaint'], + names: ['移库作业', '商品信息维护'] + }, + { path: '/pages/work/storage/random-storage', names: ['随机入库'], all: ['随机', '入库'] }, + { path: '/pages/warehouse/locationInquiry', names: ['库位查询'], all: ['库位', '查询'] }, + { path: '/pages/warehouse/inventoryTransfer', names: ['移库记录'], all: ['移库', '记录'] }, + { path: '/pages/warehouse/inventoryCount', names: ['库存盘点'], all: ['库存', '盘点'], any: ['盘点'] }, + { path: '/pages/work/product/query', names: ['商品查询'], all: ['商品', '查询'] }, + { path: '/pages/work/order/picking', test: isOrderPickingMenuName }, + { path: '/pages/work/order/scatter-wave-strategy', names: ['散单波次策略'], all: ['散单', '波次'] }, + { path: '/pages/work/order/gBWaveStrategy', names: ['团购波次策略'], all: ['团购', '波次'] }, + { path: '/pages/work/order/order-review', test: isScatterReviewShippingMenuName }, + { path: '/pages/work/order/scatter-picking-detail', names: ['散单拣货详情'], all: ['散单', '拣货', '详情'] }, + { path: '/pages/work/order/groupon-picking-detail', names: ['团购拣货详情'], all: ['团购', '拣货', '详情'] }, + { path: '/pages/packing/labelReprint', names: ['面单补打'], all: ['面单', '补打'] }, + { path: '/pages/work/order/interceptionLog', names: ['拦截登记'] }, + { path: '/pages/work/order/pickingRecord', names: ['拣货记录'], all: ['拣货', '记录'] } + ] + export default { data() { return { isLoading: true, currentPage: 1, - scrollTop: 0, userInfo: {}, dashboardStats: null, hasReviewShippingMenu: false, @@ -186,11 +254,11 @@ hasClaimShippingMenu: false, unclaimedWaveCount: 0, showNoticePopup: false, - unreadCount: 0, quickActions: [], pageSize: 12, + pageVisible: true, + undoAction: null, FIXED_MENU_KEY: 'fixed_home_menus', - dragTouchStart: null, dragState: { active: false, item: null, @@ -301,38 +369,8 @@ }; }, - noticeText() { - const stats = this.dashboardStats || null; - const showUnclaimed = this.hasClaimShippingMenu && this.hasOrderPickingMenu; - if (!stats && !showUnclaimed) { - return '欢迎使用PDA仓库管理系统'; - } - - const parts = []; - if (stats) { - parts.push(`今日订单 ${this.formatStatNumber(stats.todayOrders)}`); - } - if (showUnclaimed) { - parts.push(`未领料波次 ${this.formatStatNumber(this.unclaimedWaveCount)}`); - } - if (stats) { - if (showUnclaimed) { - parts.push(`未拣货 ${this.formatStatNumber(stats.unpickedOrders)}`); - } - if (this.hasReviewShippingMenu) { - parts.push(`已复核 ${this.formatStatNumber(stats.recheckedOrders)}`); - } - } - return parts.length ? parts.join(',') : '欢迎使用PDA仓库管理系统'; - }, - - // 滚动时长:按文字长度估算,保证滚动速度稳定 - marqueeDuration() { - const len = String(this.noticeText || '').length; - return `${Math.max(8, len * 0.4)}s`; - }, - - noticeStatItems() { + // 公告与看板弹窗的唯一数据源,避免两处重复拼装同一套统计规则 + noticeStats() { const stats = this.dashboardStats || null; const showUnclaimed = this.hasClaimShippingMenu && this.hasOrderPickingMenu; if (!stats && !showUnclaimed) { @@ -347,37 +385,72 @@ if (showUnclaimed) { items.push({ label: '未领料波次', value: f(this.unclaimedWaveCount) }); } - if (stats) { - if (showUnclaimed) { - items.push({ label: '未拣货', value: f(stats.unpickedOrders) }); - } - if (this.hasReviewShippingMenu) { - items.push({ label: '已复核', value: f(stats.recheckedOrders) }); - } + if (stats && showUnclaimed) { + items.push({ label: '未拣货', value: f(stats.unpickedOrders) }); + } + if (stats && this.hasReviewShippingMenu) { + items.push({ label: '已复核', value: f(stats.recheckedOrders) }); } return items; + }, + + noticeText() { + const items = this.noticeStats; + if (!items.length) { + return '欢迎使用PDA仓库管理系统'; + } + return items.map(item => `${item.label} ${item.value}`).join(','); + }, + + // 滚动时长:按文字长度估算,保证滚动速度稳定 + marqueeDuration() { + const len = String(this.noticeText || '').length; + return `${Math.max(8, len * 0.4)}s`; + }, + + noticeStatItems() { + return this.noticeStats; } }, async onLoad() { this.dragPreviewSnapshot = this.createDefaultDragPreviewSnapshot(); + // onLoad 之后紧接的首次 onShow 会立刻触发,跳过它避免首屏重复请求 + this._skipNextShow = true; await this.loadUserInfo(); }, onShow() { - this.loadUserInfo(); + this.pageVisible = true; + if (this._skipNextShow) { + this._skipNextShow = false; + return; + } + // 返回首页时静默刷新,不闪烁加载态 + this.loadUserInfo({ silent: true }); + }, + + onHide() { + // 离开页面时暂停跑马灯动画,避免后台持续占用渲染 + this.pageVisible = false; }, onUnload() { this.unbindGlobalDragListeners(); - this.clearPendingLongPress(); + this.clearUndoTimer(); }, methods: { async getLatestUserInfo() { try { const latestUser = await this.$store.dispatch('getUserInfo'); - console.log('[index] user.info 返回数据:', JSON.parse(JSON.stringify(latestUser))); + // 不再输出完整用户对象(可能含登录凭证),只保留用于排查的关键信息 + console.log( + '[index] 用户信息已更新:', + latestUser?.store_name || '', + '菜单数:', + Array.isArray(latestUser?.menus) ? latestUser.menus.length : 0 + ); if (latestUser && typeof latestUser === 'object') { this.userInfo = latestUser; return latestUser; @@ -446,6 +519,10 @@ if (!action || typeof action !== 'object' || Array.isArray(action)) { return null; } + // 已归一化的对象直接复用,避免渲染链路里反复做字符串处理 + if (action.__normalized === true) { + return action; + } const name = this.sanitizeText(action.name || action.meta?.title, '未命名菜单'); const rawIcon = this.sanitizeText(action.icon || action.meta?.icon, 'grid'); @@ -478,41 +555,15 @@ isImageIcon }; + // 非枚举标记:不会被 JSON 序列化,因此不会污染保存到本地的配置 + Object.defineProperty(normalized, '__normalized', { + value: true, + enumerable: false + }); + return normalized; }, - getActionName(action) { - return this.normalizeAction(action)?.name || '未命名菜单'; - }, - - getActionIcon(action) { - return this.normalizeAction(action)?.resolvedIconName || 'grid'; - }, - - getActionIconSource(action) { - return this.normalizeAction(action)?.resolvedIconSource || 'grid'; - }, - - isActionImageIcon(action) { - return Boolean(this.normalizeAction(action)?.isImageIcon); - }, - - getActionIconGlyph(action) { - return this.normalizeAction(action)?.resolvedIconGlyph || uviewIcons['uicon-grid'] || '\ue673'; - }, - - getRenderIcon(action, forceStable = false) { - return this.getActionIcon(action); - }, - - getActionColor(action) { - return this.normalizeAction(action)?.color || '#2979ff'; - }, - - getActionBadge(action) { - return Number(this.normalizeAction(action)?.badge || 0); - }, - buildPageSlots(pageIndex, actions = this.displayQuickActions) { const sourceActions = Array.isArray(actions) ? actions.map(item => this.normalizeAction(item)).filter(Boolean) @@ -544,15 +595,22 @@ } }, - async loadUserInfo() { - await this.refreshQuickActions(); - await this.loadDashboardStats(); - await this.loadUnclaimedWaveCount(); + // silent: true 时不切换整页加载态,用于返回首页 / 切换主体后的静默刷新 + async loadUserInfo({ silent = false } = {}) { + // 菜单加载会决定看板统计是否展示,必须先完成 + await this.refreshQuickActions({ silent }); + // 两个统计接口互不依赖,并行请求 + await Promise.all([ + this.loadDashboardStats(), + this.loadUnclaimedWaveCount() + ]); }, // 刷新快捷入口 - async refreshQuickActions() { - this.isLoading = true; + async refreshQuickActions({ silent = false } = {}) { + if (!silent) { + this.isLoading = true; + } try { const latestUser = await this.getLatestUserInfo(); @@ -601,8 +659,15 @@ } catch (error) { console.error('刷新快捷入口失败:', error); - this.quickActions = []; + // 弱网 / 接口异常时保留已展示的菜单,避免把本地常用配置清空 this.ensureCurrentPageInRange(); + if (!this.quickActions.length) { + uni.showToast({ + title: '常用功能加载失败,请重试', + icon: 'none', + duration: 2000 + }); + } } finally { this.isLoading = false; } @@ -611,20 +676,29 @@ // 根据用户菜单识别看板相关功能(复核发货 / 订单拣货 / 领取快递面单) detectDashboardMenus(actions) { const list = Array.isArray(actions) ? actions.filter(Boolean) : []; - this.hasReviewShippingMenu = list.some(item => { + let hasReviewShipping = false; + let hasOrderPicking = false; + let hasClaimShipping = false; + + list.forEach((item) => { const name = this.sanitizeText(item?.name); - return name === '散单复核发货' || - name === '订单复核' || - (name.includes('复核') && name.includes('发货')); - }); - this.hasOrderPickingMenu = list.some(item => { - const name = this.sanitizeText(item?.name); - return name === '订单拣货' || (name.includes('订单') && name.includes('拣货')); - }); - this.hasClaimShippingMenu = list.some(item => { - const name = this.sanitizeText(item?.name); - return name === '领取快递面单' || (name.includes('领取') && name.includes('面单')); + if (!name) { + return; + } + if (!hasReviewShipping && isReviewShippingMenuName(name)) { + hasReviewShipping = true; + } + if (!hasOrderPicking && isOrderPickingMenuName(name)) { + hasOrderPicking = true; + } + if (!hasClaimShipping && isClaimShippingMenuName(name)) { + hasClaimShipping = true; + } }); + + this.hasReviewShippingMenu = hasReviewShipping; + this.hasOrderPickingMenu = hasOrderPicking; + this.hasClaimShippingMenu = hasClaimShipping; }, // 加载仓库/货主看板统计 @@ -679,12 +753,6 @@ return Number.isFinite(num) ? num : '--'; }, - formatPercent(value) { - const num = Number(value); - if (!Number.isFinite(num)) return '--'; - return `${num}%`; - }, - prioritizeDefaultQuickActions(actions) { const source = Array.isArray(actions) ? actions.filter(Boolean) : []; if (!source.length) { @@ -806,9 +874,6 @@ y: Number(touch?.pageY || touch?.clientY || 0) }; }, - clearPendingLongPress() { - return; - }, bindGlobalDragListeners() { if (typeof window === 'undefined' || this._globalDragListenersBound) { return; @@ -847,13 +912,7 @@ this._globalTouchEndHandler = null; this._globalDragListenersBound = false; }, - onGridItemTouchMove(event) { - return; - }, - onGridItemTouchEnd() { - return; - }, - enterQuickActionRemoveMode() { + enterQuickActionRemoveMode() { if (this.dragState.active) { return; } @@ -866,7 +925,7 @@ if (!item || this.dragState.active) { return; } - this.enterQuickActionRemoveMode(); + // 长按只负责排序;移除必须在标题栏「管理」里显式开启,避免误删 this.onGridItemLongPress(event, item, pageIndex, index); }, onGridItemLongPress(event, item, pageIndex, index) { @@ -883,6 +942,7 @@ return; } + const removeIndex = this.quickActions.findIndex(action => this.getMenuKey(action) === targetKey); const nextActions = this.quickActions.filter(action => this.getMenuKey(action) !== targetKey); if (nextActions.length === this.quickActions.length) { return; @@ -893,11 +953,8 @@ if (!this.quickActions.length) { this.quickActionRemoveMode = false; } + this.showUndoBar(this.normalizeAction(item), removeIndex); await this.saveQuickActionsOrder(); - uni.showToast({ - title: '已移出常用功能', - icon: 'success' - }); const tools = this.$tools; if (tools && typeof tools.speakText === 'function') { try { @@ -912,6 +969,47 @@ } } }, + showUndoBar(item, index) { + if (!item) { + return; + } + this.clearUndoTimer(); + this.undoAction = { + item, + index: Math.max(index, 0) + }; + this._undoTimer = setTimeout(() => { + this.undoAction = null; + this._undoTimer = null; + }, 3000); + }, + clearUndoTimer() { + if (this._undoTimer) { + clearTimeout(this._undoTimer); + this._undoTimer = null; + } + }, + async undoRemoveAction() { + const undo = this.undoAction; + if (!undo || !undo.item) { + return; + } + + this.clearUndoTimer(); + this.undoAction = null; + + const undoKey = this.getMenuKey(undo.item); + if (!undoKey || this.quickActions.some(action => this.getMenuKey(action) === undoKey)) { + return; + } + + const nextActions = [...this.quickActions]; + const insertIndex = Math.min(Math.max(undo.index, 0), nextActions.length); + nextActions.splice(insertIndex, 0, undo.item); + this.quickActions = nextActions; + this.ensureCurrentPageInRange(); + await this.saveQuickActionsOrder(); + }, handleWrapperTouchStart(event) { if (this.dragState.active) { return; @@ -934,6 +1032,11 @@ return; } + // 拖动中同一次 touchmove 也会命中全局监听,这里跳过避免重复计算 + if (this._globalDragListenersBound) { + return; + } + if (typeof event?.preventDefault === 'function') { event.preventDefault(); } @@ -988,7 +1091,6 @@ } const point = startPoint || { x: 0, y: 0 }; - this.clearPendingLongPress(); this.suppressItemClick = true; const safeItem = this.normalizeAction(item); const originalIndex = this.quickActions.findIndex(action => this.getMenuKey(action) === this.getMenuKey(safeItem)); @@ -1187,11 +1289,17 @@ const pageStart = this.dragState.pageIndex * this.pageSize; const targetIndex = Math.min(pageStart + slotIndex, this.quickActions.length - 1); + // 只在目标格子变化时才重建页面快照,避免每个 touchmove 都重算 + if (this.dragState.hoverIndex === targetIndex) { + return; + } this.dragState.hoverIndex = targetIndex; this.refreshDragPageSnapshot(this.dragState.pageIndex); }, async saveQuickActionsOrder() { if (this.isSavingOrder) { + // 保存中又发生变更:标记待保存,本轮结束后补存最新顺序 + this._pendingSaveOrder = true; return; } this.isSavingOrder = true; @@ -1210,10 +1318,13 @@ }); } finally { this.isSavingOrder = false; + if (this._pendingSaveOrder) { + this._pendingSaveOrder = false; + this.saveQuickActionsOrder(); + } } }, async endDrag() { - this.clearPendingLongPress(); if (!this.dragState.active) { this.unbindGlobalDragListeners(); return; @@ -1244,7 +1355,6 @@ }; this.dragPreviewSnapshot = this.createDefaultDragPreviewSnapshot(); this.dragPageSnapshot = []; - this.dragTouchStart = null; this.dragPageSwitching = false; this.unbindGlobalDragListeners(); this.suppressItemClick = false; @@ -1266,49 +1376,52 @@ return user.menus || user.permissions || []; }, - // 处理菜单数据 - processMenus(menus, limit = 24) { - // 1. 展平所有子菜单(使用 flatMap 替代 map + filter) - const allChildren = menus.flatMap(item => - item.children || [] // 确保 children 存在,否则返回空数组 - ); - - // 2. 过滤有效菜单并限制数量 - let validMenus = allChildren.filter(menu => - menu && - menu.component && - menu.component !== 'Layout' && - menu.meta && - menu.meta.title - ); + // 处理菜单数据:展平一级子菜单 → 过滤有效项 → 可选数量限制 → 统一格式 + processMenus(menus, limit = null) { + if (!Array.isArray(menus)) { + return []; + } - if (typeof limit === 'number' && limit > 0) { - validMenus = validMenus.slice(0, limit); // 默认最多显示24个 - } - - // 3. 生成随机颜色的函数 - const generateRandomColor = () => { - const colorPool = [ - '#FF6B6B', '#4ECDC4', '#FFD166', '#06D6A0', '#118AB2', - '#EF476F', '#26547C', '#FFD166', '#06D6A0', '#118AB2', - '#7209B7', '#3A86FF', '#FB5607', '#8338EC', '#3A86FF' - ]; - return colorPool[Math.floor(Math.random() * colorPool.length)]; - }; - - // 4. 转换为目标格式 - return validMenus.map(menu => { - return { - id: menu.id || menu.menuId || menu.component || menu.path || menu.meta?.title || '', - name: menu.meta?.title || '未命名菜单', - path: menu.path || '', - component: menu.component || '', - permissions: menu.permissions || [], - icon: menu.meta?.icon || '', - color: generateRandomColor(), // 随机颜色 - isFixed: true // 标记为已固定 - }; - }); + const allChildren = []; + menus.forEach((item) => { + if (item && Array.isArray(item.children)) { + allChildren.push(...item.children); + } + }); + + let validMenus = allChildren.filter(menu => + menu && + menu.component && + menu.component !== 'Layout' && + menu.meta && + menu.meta.title + ); + + // limit 为 null/0 时不限制数量 + if (typeof limit === 'number' && limit > 0) { + validMenus = validMenus.slice(0, limit); + } + + return validMenus.map(menu => ({ + id: menu.id || menu.menuId || menu.component || menu.path || menu.meta?.title || '', + name: menu.meta?.title || '未命名菜单', + path: menu.path || '', + component: menu.component || '', + permissions: menu.permissions || [], + icon: menu.meta?.icon || '', + color: this.pickMenuColor(menu.component || menu.path || menu.id || menu.meta?.title || ''), + isFixed: true + })); + }, + + // 同一菜单始终得到同一颜色,避免每次刷新配色乱跳 + pickMenuColor(key) { + const text = String(key || ''); + let hash = 0; + for (let i = 0; i < text.length; i += 1) { + hash = ((hash * 31) + text.charCodeAt(i)) % 100000007; + } + return MENU_COLOR_POOL[hash % MENU_COLOR_POOL.length]; }, showStoreSelector() { if (!this.userInfo.employees || this.userInfo.employees.length <= 1) { @@ -1334,92 +1447,74 @@ }, async handleStoreSwitch(selectedEmployee) { + uni.showLoading({ + title: '切换中...', + mask: true + }); try { - // 显示加载中 - uni.showLoading({ - title: '切换中...', - mask: true - }); - const result = await this.$store.dispatch('changeEmployee', selectedEmployee.id); - this.loadUserInfo(); - + await this.$store.dispatch('changeEmployee', selectedEmployee.id); + await this.loadUserInfo({ silent: true }); } catch (error) { + console.error('切换主体失败:', error); + uni.showToast({ + title: '切换失败,请重试', + icon: 'none' + }); + } finally { uni.hideLoading(); } }, - toPath(item) { - const menuName = String(item?.name || '').trim(); - const isGoodsQuery = menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询')); - const isSpaceQuery = menuName === '库位查询' || (menuName.includes('库位') && menuName.includes('查询')); - const isOrderPicking = menuName === '订单拣货' || (menuName.includes('订单') && menuName.includes('拣货')); - const isScatterWaveStrategy = menuName === '散单波次策略' || (menuName.includes('散单') && menuName.includes('波次')); - const isGrouponWaveStrategy = menuName === '团购波次策略' || (menuName.includes('团购') && menuName.includes('波次')); - const isScatterPickingDetail = menuName === '散单拣货详情' || (menuName.includes('散单') && menuName.includes('拣货') && menuName.includes('详情')); - const isScatterReviewShipping = menuName === '散单复核发货' || menuName === '订单复核' || (menuName.includes('散单') && menuName.includes('复核') && menuName.includes('发货')); - const isGrouponPickingDetail = menuName === '团购拣货详情' || (menuName.includes('团购') && menuName.includes('拣货') && menuName.includes('详情')); - const isLabelReprint = menuName === '面单补打' || (menuName.includes('面单') && menuName.includes('补打')); - const isBlockRegistration = menuName === '拦截登记'; - const isPickingRecord = menuName === '拣货记录' || (menuName.includes('拣货') && menuName.includes('记录')); - const isTransferRecord = menuName === '移库记录' || (menuName.includes('移库') && menuName.includes('记录')); - const isInventoryCount = menuName === '库存盘点' || (menuName.includes('库存') && menuName.includes('盘点')) || menuName.includes('盘点'); - const rawPath = item?.component || item?.path || ''; - const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : ''; - const isRandomStorage = menuName === '随机入库' || (menuName.includes('随机') && menuName.includes('入库')); - const isRelocation = menuName === '移库作业' || normalizedPath === '/pages/work/storage/relocation'; - const isItemMaint = menuName === '商品信息维护' || normalizedPath === '/pages/work/product/itemMaint'; - if (isRelocation) { - uni.showToast({ - title: '该功能只支持在商品查询页面使用!', - icon: 'none', - duration: 2500 - }); - return; - } - if (isItemMaint) { - uni.showToast({ - title: '该功能只支持在商品查询页面使用!', - icon: 'none', - duration: 2500 - }); - return; - } - if (isRandomStorage) { - this.$tools.routerTo('/pages/work/storage/random-storage'); - return; - } - if (isSpaceQuery) { - this.$tools.routerTo('/pages/warehouse/locationInquiry'); - return; - } - if (isTransferRecord) { - this.$tools.routerTo('/pages/warehouse/inventoryTransfer'); - return; - } - if (isInventoryCount) { - this.$tools.routerTo('/pages/warehouse/inventoryCount'); - return; - } - const targetPath = isGoodsQuery - ? '/pages/work/product/query' - : (isOrderPicking - ? '/pages/work/order/picking' - : (isScatterWaveStrategy - ? '/pages/work/order/scatter-wave-strategy' - : (isGrouponWaveStrategy - ? '/pages/work/order/gBWaveStrategy' - : (isScatterReviewShipping - ? '/pages/work/order/order-review' - : (isScatterPickingDetail - ? '/pages/work/order/scatter-picking-detail' - : (isGrouponPickingDetail - ? '/pages/work/order/groupon-picking-detail' - : (isLabelReprint - ? '/pages/packing/labelReprint' - : (isBlockRegistration - ? '/pages/work/order/interceptionLog' - : (isPickingRecord ? '/pages/work/order/pickingRecord' : normalizedPath))))))))); + // 按 component/path + 菜单名解析目标路由,规则表见 MENU_ROUTE_RULES + resolveMenuRoute(item) { + const name = String(item?.name || '').trim(); + const normalizedPath = this.normalizeMenuPath(item); + for (let i = 0; i < MENU_ROUTE_RULES.length; i += 1) { + const rule = MENU_ROUTE_RULES[i]; + if (Array.isArray(rule.paths) && normalizedPath && rule.paths.includes(normalizedPath)) { + return rule; + } + if (this.matchesMenuRule(name, rule)) { + return rule; + } + } + return null; + }, + + matchesMenuRule(name, rule) { + if (typeof rule.test === 'function') { + return Boolean(rule.test(name)); + } + if (Array.isArray(rule.names) && rule.names.includes(name)) { + return true; + } + if (Array.isArray(rule.all) && rule.all.every(key => name.includes(key))) { + return true; + } + if (Array.isArray(rule.any) && rule.any.some(key => name.includes(key))) { + return true; + } + return false; + }, + + normalizeMenuPath(item) { + const rawPath = item?.component || item?.path || ''; + return rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : ''; + }, + + toPath(item) { + const rule = this.resolveMenuRoute(item); + if (rule && rule.block) { + uni.showToast({ + title: rule.block, + icon: 'none', + duration: 2500 + }); + return; + } + + const targetPath = (rule && rule.path) ? rule.path : this.normalizeMenuPath(item); if (!targetPath) { uni.showToast({ title: '功能暂未开放', @@ -1432,18 +1527,6 @@ this.$tools.routerTo(targetPath); }, - toMessagePage() { - uni.navigateTo({ - url: '/pages/message/index' - }); - }, - - toNewsPage() { - uni.switchTab({ - url: '/pages/oa/index' - }); - }, - openNoticePopup() { if (!this.noticeStatItems.length) { return; @@ -1461,6 +1544,13 @@ }); }, + retryLoad() { + if (this.isLoading) { + return; + } + this.loadUserInfo(); + }, + prevPage() { if (this.dragState.active) { return; @@ -1497,44 +1587,52 @@ // 紧凑型头部 .compact-header { - padding:0 20rpx; - background: white; - border-bottom: 1rpx solid #f0f0f0; + padding: 12rpx 24rpx 16rpx; + background: #ffffff; + border-bottom: 1rpx solid #f0f2f5; .org-switcher { display: flex; align-items: center; - margin-bottom: 6px; - .org-icon { - margin-right: 15rpx; + .org-block { + display: flex; + align-items: center; + flex: 0 1 auto; + max-width: 46%; + min-width: 0; + padding: 4rpx 0; + + &:active { + opacity: 0.7; + } } .org-arrow { - margin-right: 24rpx; + flex-shrink: 0; + margin-left: 6rpx; } .org-info { - flex: 0 0 auto; - max-width: 40%; + flex: 1; min-width: 0; - margin-right: 70rpx; .org-name { - font-size: 28rpx; + font-size: 32rpx; font-weight: 600; - color: #333; + color: #1f2329; display: block; - line-height: 1.4; + line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .org-id { - font-size: 22rpx; - color: #909399; + font-size: 24rpx; + color: #9aa0a6; display: block; + line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; @@ -1544,16 +1642,17 @@ .news-wrapper { flex: 1; min-width: 0; + margin-left: 16rpx; overflow: hidden; .news-pill { display: flex; align-items: center; - height: 52rpx; - padding: 0 18rpx; - background: transparent; - border: 1rpx solid #e3edff; - border-radius: 8rpx; + height: 56rpx; + padding: 0 20rpx; + background: #f2f7ff; + border: 0; + border-radius: 28rpx; box-sizing: border-box; overflow: hidden; @@ -1571,7 +1670,7 @@ .news-marquee { width: 100%; - height: 52rpx; + height: 56rpx; display: flex; align-items: center; overflow: hidden; @@ -1584,11 +1683,15 @@ animation: news-marquee-scroll 12s linear infinite; } + &__track.is-paused { + animation-play-state: paused; + } + &__text { display: inline-block; white-space: nowrap; padding-right: 60rpx; - font-size: 24rpx; + font-size: 26rpx; color: #2979ff; } } @@ -1597,25 +1700,6 @@ } } - .header-actions { - display: flex; - align-items: center; - justify-content: space-between; - - .message-bell { - position: relative; - width: 60rpx; - height: 60rpx; - display: flex; - align-items: center; - justify-content: center; - border-radius: 50%; - - &:active { - background: #f0f0f0; - } - } - } } // 顶部公告无缝滚动 @@ -1628,81 +1712,107 @@ } } - // 主滚动区域 + // 骨架屏呼吸 + @keyframes skeleton-pulse { + 0%, 100% { + opacity: 1; + } + 50% { + opacity: 0.45; + } + } + + // 主内容区:父级高度由内容撑开,保留纵向滚动能力,避免小屏裁切 .main-scroll { flex: 1; - overflow: hidden; + min-height: 0; + overflow-y: auto; + -webkit-overflow-scrolling: touch; } // 快捷入口区域 .quick-section { - padding: 20rpx 20rpx 30rpx; - background: white; - margin: 20rpx; - border-radius: 16rpx; - box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); + padding: 20rpx 20rpx 12rpx; + background: #ffffff; + margin: 16rpx 20rpx 20rpx; + border-radius: 20rpx; + box-shadow: 0 6rpx 24rpx rgba(15, 23, 42, 0.05); .section-title-bar { display: flex; justify-content: space-between; align-items: center; - margin-bottom: 25rpx; - padding-bottom: 15rpx; - border-bottom: 1rpx solid #f0f0f0; + margin-bottom: 14rpx; + padding-bottom: 12rpx; + border-bottom: 1rpx solid #f2f4f7; .title-left { display: flex; align-items: center; + min-width: 0; + + .title-accent { + width: 6rpx; + height: 28rpx; + border-radius: 3rpx; + background: #2979ff; + margin-right: 12rpx; + } .section-title { font-size: 32rpx; font-weight: 600; - color: #333; - margin-left: 10rpx; + color: #1f2329; } .drag-tip { - margin-left: 16rpx; - font-size: 22rpx; - color: #909399; - } - - .done-btn { - font-size: 24rpx; - color: #2979ff; - padding: 6rpx 12rpx; - border-radius: 6rpx; margin-left: 12rpx; - - &:active { - background: #f0f7ff; - } + font-size: 24rpx; + color: #a8adb5; } } .title-right { display: flex; align-items: center; + flex-shrink: 0; - .edit-btn { - font-size: 34rpx; + .done-btn, + .manage-btn { + font-size: 30rpx; + font-weight: 500; color: #2979ff; - padding: 6rpx 12rpx; - border-radius: 6rpx; + padding: 10rpx 16rpx; + border-radius: 10rpx; &:active { background: #f0f7ff; } } - .divider { - color: #e0e0e0; - margin: 0 15rpx; - } + .edit-btn { + display: flex; + align-items: center; + margin-left: 16rpx; + padding: 10rpx 20rpx; + border-radius: 28rpx; + background: #f2f7ff; + line-height: 1; - .page-indicator { - font-size: 24rpx; - color: #909399; + &:active { + background: #e6f0ff; + } + + .edit-btn__text { + font-size: 30rpx; + font-weight: 500; + color: #2979ff; + line-height: 1; + } + + .u-icon { + margin-left: 6rpx; + } } } } @@ -1712,19 +1822,20 @@ .quick-grid-container { display: flex; align-items: center; - margin-bottom: 20rpx; + margin-bottom: 4rpx; .nav-arrow { - width: 20rpx; - height: 60rpx; + flex: 0 0 48rpx; + width: 48rpx; + height: 96rpx; display: flex; align-items: center; justify-content: center; - border-radius: 50%; - background: #f8f9fa; + border-radius: 24rpx; + background: #f5f7fa; &:active:not(.disabled) { - background: #e9ecef; + background: #e9edf3; } &.disabled { @@ -1741,33 +1852,25 @@ .quick-page-shell { width: 100%; - min-height: 540rpx; - } - - .quick-swiper { - width: 100%; - height: 540rpx; // 3行 × 180rpx - - &.drag-source-hidden { - opacity: 0.01; - } + min-height: 0; } .grid-page { display: grid; - grid-template-columns: repeat(4, 1fr); - grid-template-rows: repeat(3, 1fr); + grid-template-columns: repeat(3, 1fr); + grid-template-rows: repeat(4, auto); gap: 10rpx; padding: 0 10rpx; .grid-item { - height: 170rpx; + min-height: 170rpx; + box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; - border-radius: 12rpx; + border-radius: 16rpx; transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease; .grid-item-touch-layer { @@ -1857,18 +1960,25 @@ } .item-name { + max-width: 100%; font-size: 34rpx; font-weight: bold; color: #333; text-align: center; line-height: 1.4; padding: 0 6rpx; + word-break: break-all; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + line-clamp: 2; + overflow: hidden; } .item-badge { position: absolute; - top: 10rpx; - right: 10rpx; + top: 4rpx; + right: 4rpx; } &:active { @@ -1893,8 +2003,8 @@ .drag-preview { position: fixed; z-index: 999; - width: 120rpx; - height: 170rpx; + width: 140rpx; + height: 172rpx; border-radius: 12rpx; background: rgba(255, 255, 255, 0.96); box-shadow: 0 12rpx 32rpx rgba(0, 0, 0, 0.16); @@ -1943,22 +2053,18 @@ } .item-name { + max-width: 100%; font-size: 34rpx; font-weight: bold; color: #333; text-align: center; line-height: 1.4; - padding: 0 6rpx; + padding: 0 4rpx; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } } - - .drag-grid-layer { - position: absolute; - left: 0; - top: 0; - right: 0; - z-index: 5; - } } } @@ -1966,23 +2072,60 @@ .pagination-dots { display: flex; justify-content: center; - margin-top: 20rpx; + align-items: center; + margin-top: 16rpx; .pagination-dot { - width: 10rpx; - height: 10rpx; - border-radius: 50%; - background: #e0e0e0; - margin: 0 6rpx; + width: 8rpx; + height: 8rpx; + border-radius: 4rpx; + background: #dfe3e8; + margin: 0 5rpx; + transition: width 0.2s ease, background 0.2s ease; &.active { background: #2979ff; - width: 30rpx; - border-radius: 5rpx; + width: 24rpx; } } } + // 首次加载骨架屏 + .skeleton-grid { + width: 100%; + display: grid; + grid-template-columns: repeat(3, 1fr); + grid-template-rows: repeat(4, auto); + gap: 10rpx; + padding: 0 10rpx; + box-sizing: border-box; + + .skeleton-item { + min-height: 190rpx; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } + + .skeleton-icon { + width: 100rpx; + height: 100rpx; + border-radius: 20rpx; + margin-bottom: 12rpx; + background: #eef1f5; + animation: skeleton-pulse 1.2s ease-in-out infinite; + } + + .skeleton-text { + width: 108rpx; + height: 28rpx; + border-radius: 14rpx; + background: #eef1f5; + animation: skeleton-pulse 1.2s ease-in-out infinite; + } + } + // 加载状态 .loading-state { padding: 100rpx 0; @@ -2015,9 +2158,53 @@ .empty-hint { display: block; - font-size: 26rpx; + font-size: 28rpx; color: #ccc; } + + .empty-retry { + display: block; + margin-top: 24rpx; + padding: 14rpx 36rpx; + font-size: 28rpx; + color: #2979ff; + border: 1rpx solid #2979ff; + border-radius: 8rpx; + } + } + + // 移除撤销条 + .undo-bar { + position: fixed; + left: 40rpx; + right: 40rpx; + bottom: 140rpx; + z-index: 1200; + display: flex; + align-items: center; + justify-content: space-between; + padding: 20rpx 28rpx; + background: rgba(51, 51, 51, 0.92); + border-radius: 12rpx; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18); + + &__text { + flex: 1; + min-width: 0; + font-size: 28rpx; + color: #ffffff; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + &__btn { + flex-shrink: 0; + margin-left: 24rpx; + font-size: 30rpx; + font-weight: 600; + color: #4d9bff; + } } // 看板统计弹窗