调整全部功能页菜单名称字号和字重,统一与首页常用功能菜单一致 放大左侧导航按钮字号和点击区域,提升分类选择时的可操作性 调整右侧字母索引按钮间距和热区,优化快速定位体验 细化页面内留白设计,修正搜索区、导航区与功能列表之间的间距问题 参考商品查询页搜索框风格,更新为圆角浅灰输入框,并保留独立搜索按钮 去掉扫描图标,仅保留搜索入口,保持页面更简洁、交互更聚焦 优化头部与内容区分隔逻辑,提升页面整体视觉一致性
2264 lines
61 KiB
Vue
2264 lines
61 KiB
Vue
<template>
|
||
<view class="pda-home">
|
||
<view class="status_bar">
|
||
</view>
|
||
<view class="compact-header">
|
||
<!-- 主体切换 -->
|
||
<view class="org-switcher">
|
||
<view class="org-block" @click="showStoreSelector">
|
||
<view class="org-info">
|
||
<text class="org-name">{{ userInfo.store_name || '选择主体' }}</text>
|
||
<text class="org-id">{{ userInfo.employees_name || '---' }}</text>
|
||
</view>
|
||
<u-icon class="org-arrow" name="arrow-down" size="14" color="#909399" v-if="userInfo.employees && userInfo.employees.length > 1"></u-icon>
|
||
</view>
|
||
<view class="news-wrapper" @click="openNoticePopup">
|
||
<view class="news-pill">
|
||
<view class="news-pill__icon">
|
||
<u-icon name="bell-fill" size="14" color="#2979ff"></u-icon>
|
||
</view>
|
||
<view class="news-pill__body">
|
||
<view class="news-marquee">
|
||
<view class="news-marquee__track" :class="{ 'is-paused': !pageVisible }" :style="{ animationDuration: marqueeDuration }">
|
||
<text class="news-marquee__text">{{ noticeText }}</text>
|
||
<text class="news-marquee__text">{{ noticeText }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 主内容区 -->
|
||
<view class="main-scroll">
|
||
<!-- 快捷入口区域 -->
|
||
<view class="quick-section">
|
||
<view class="section-title-bar">
|
||
<view class="title-left">
|
||
<view class="title-accent"></view>
|
||
<text class="section-title">常用功能</text>
|
||
<text class="drag-tip" v-if="quickActions.length > 0 && !quickActionRemoveMode">长按排序</text>
|
||
</view>
|
||
<view class="title-right">
|
||
<text v-if="quickActionRemoveMode" class="done-btn" @click="exitQuickActionRemoveMode">完成</text>
|
||
<text v-else-if="quickActions.length > 0" class="manage-btn" @click="enterQuickActionRemoveMode">管理</text>
|
||
<view class="edit-btn" @click="toEditPage">
|
||
<text class="edit-btn__text">全部功能</text>
|
||
<u-icon name="arrow-right" size="14" color="#2979ff" style="margin-left: 6rpx;"></u-icon>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 3行4列的快捷入口网格 -->
|
||
<view class="quick-grid-container">
|
||
<!-- 上一页按钮 -->
|
||
<view class="nav-arrow left-arrow" @click="prevPage" :class="{ disabled: currentPage === 1 }">
|
||
<u-icon name="arrow-left" size="20" color="#666"></u-icon>
|
||
</view>
|
||
|
||
<!-- 网格内容 -->
|
||
<view class="quick-grid-wrapper" @touchstart="handleWrapperTouchStart" @touchmove="handleWrapperTouchMove" @touchend="handleWrapperTouchEnd" @touchcancel="handleWrapperTouchEnd">
|
||
<!-- 首次加载骨架屏,避免出现一大片空白 -->
|
||
<view class="skeleton-grid" v-if="isLoading && !quickActions.length">
|
||
<view class="skeleton-item" v-for="n in pageSize" :key="`skeleton-${n}`">
|
||
<view class="skeleton-icon"></view>
|
||
<view class="skeleton-text"></view>
|
||
</view>
|
||
</view>
|
||
<!-- 空状态提示 -->
|
||
<view class="empty-state" v-else-if="!isLoading && quickActions.length === 0">
|
||
<u-icon name="grid" size="80" color="#ccc"></u-icon>
|
||
<text class="empty-text">暂无可用功能</text>
|
||
<text class="empty-hint">请联系仓库管理员检查授权</text>
|
||
<text class="empty-retry" @click.stop="retryLoad">重新加载</text>
|
||
</view>
|
||
<view v-else class="quick-page-shell">
|
||
<view class="grid-page" :id="`grid-page-${currentPage - 1}`">
|
||
<view
|
||
class="grid-item grid-slot"
|
||
v-for="slot in renderPageSlots"
|
||
:key="slot.key"
|
||
:class="[
|
||
`page-slot-${currentPage - 1}`,
|
||
{
|
||
'drag-placeholder': slot.action && isDraggingItem(slot.action),
|
||
'drag-disabled': dragState.active,
|
||
'empty-item': !slot.action
|
||
}
|
||
]">
|
||
<template v-if="slot.action">
|
||
<view
|
||
class="grid-item-touch-layer"
|
||
@longpress.stop.prevent="handleQuickActionLongPress($event, slot.action, currentPage - 1, slot.index)"
|
||
@click.stop.prevent="handleGridItemClick(slot.action)"
|
||
></view>
|
||
<view
|
||
v-if="quickActionRemoveMode"
|
||
class="remove-action-btn"
|
||
@click.stop="removeQuickAction(slot.action)"
|
||
>
|
||
<text class="remove-action-icon">{{ removeActionIconGlyph }}</text>
|
||
</view>
|
||
<view class="grid-item-content">
|
||
<view class="item-icon-box" :style="{ background: (slot.action.color || '#2979ff') + '15', color: slot.action.color || '#2979ff' }">
|
||
<image
|
||
v-if="slot.action.isImageIcon"
|
||
class="item-icon-image"
|
||
:src="slot.action.resolvedIconSource"
|
||
mode="aspectFit"
|
||
></image>
|
||
<text v-else class="item-icon-font" :style="{ color: slot.action.color || '#2979ff' }">{{ slot.action.resolvedIconGlyph || fallbackIconGlyph }}</text>
|
||
</view>
|
||
<text class="item-name">{{ slot.action.name || '未命名菜单' }}</text>
|
||
<u-badge v-if="Number(slot.action.badge || 0) > 0" :count="Number(slot.action.badge || 0)" size="mini"
|
||
type="error" :offset="[-3, 3]" class="item-badge"></u-badge>
|
||
</view>
|
||
</template>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view
|
||
v-show="dragState.active"
|
||
class="drag-preview"
|
||
:style="dragPreviewStyle"
|
||
>
|
||
<text v-if="quickActionRemoveMode" class="preview-remove-action-icon">{{ removeActionIconGlyph }}</text>
|
||
<view class="item-icon-box" :style="{ background: (dragPreviewSnapshot.color || '#2979ff') + '15', color: dragPreviewSnapshot.color || '#2979ff' }">
|
||
<image
|
||
v-if="dragPreviewSnapshot.isImageIcon"
|
||
class="item-icon-image"
|
||
:src="dragPreviewSnapshot.resolvedIconSource"
|
||
mode="aspectFit"
|
||
></image>
|
||
<text v-else class="item-icon-font" :style="{ color: dragPreviewSnapshot.color || '#2979ff' }">{{ dragPreviewSnapshot.resolvedIconGlyph || fallbackIconGlyph }}</text>
|
||
</view>
|
||
<text class="item-name" v-text="dragPreviewSnapshot.name || '未命名菜单'"></text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 下一页按钮 -->
|
||
<view class="nav-arrow right-arrow" @click="nextPage"
|
||
:class="{ disabled: currentPage === totalPages }">
|
||
<u-icon name="arrow-right" size="20" color="#666"></u-icon>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 分页指示器 -->
|
||
<view class="pagination-dots" v-if="totalPages > 1">
|
||
<view v-for="n in totalPages" :key="n" class="pagination-dot"
|
||
:class="{ active: n === currentPage }"></view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 加载状态 -->
|
||
<view class="loading-state" v-if="isLoading">
|
||
<text class="loading-text">加载中...</text>
|
||
</view>
|
||
|
||
</view>
|
||
|
||
<!-- 移除撤销提示 -->
|
||
<view v-if="undoAction && undoAction.item" class="undo-bar">
|
||
<text class="undo-bar__text">已移出「{{ undoAction.item.name }}」</text>
|
||
<text class="undo-bar__btn" @click.stop="undoRemoveAction">撤销</text>
|
||
</view>
|
||
|
||
<!-- 通知信息弹窗 -->
|
||
<u-popup :show="showNoticePopup" mode="bottom" round="20" :closeable="true" :safeAreaInsetBottom="true" @close="closeNoticePopup">
|
||
<view class="notice-popup">
|
||
<view class="notice-popup__header">
|
||
<text class="notice-popup__title">通知信息</text>
|
||
</view>
|
||
<scroll-view scroll-y class="notice-popup__body">
|
||
<view class="notice-popup__grid">
|
||
<view v-for="item in noticeStatItems" :key="item.label" class="notice-popup__item">
|
||
<text class="notice-popup__value">{{ item.value }}</text>
|
||
<text class="notice-popup__label">{{ item.label }}</text>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</u-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import uviewIcons from '@/uni_modules/uview-ui/components/u-icon/icons.js'
|
||
|
||
const VALID_UVIEW_ICON_NAMES = new Set(
|
||
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,
|
||
userInfo: {},
|
||
dashboardStats: null,
|
||
hasReviewShippingMenu: false,
|
||
hasOrderPickingMenu: false,
|
||
hasClaimShippingMenu: false,
|
||
unclaimedWaveCount: 0,
|
||
showNoticePopup: false,
|
||
quickActions: [],
|
||
pageSize: 12,
|
||
pageVisible: true,
|
||
undoAction: null,
|
||
FIXED_MENU_KEY: 'fixed_home_menus',
|
||
dragState: {
|
||
active: false,
|
||
item: null,
|
||
key: '',
|
||
originalIndex: -1,
|
||
pageIndex: -1,
|
||
hoverIndex: -1,
|
||
previewX: 0,
|
||
previewY: 0,
|
||
slotRects: [],
|
||
pageRect: null
|
||
},
|
||
dragPreviewSnapshot: null,
|
||
isSavingOrder: false,
|
||
quickActionRemoveMode: false,
|
||
suppressItemClick: false,
|
||
dragPageSwitching: false,
|
||
dragPageSnapshot: [],
|
||
wrapperGesture: {
|
||
startX: 0,
|
||
startY: 0,
|
||
deltaX: 0,
|
||
deltaY: 0,
|
||
startTime: 0
|
||
}
|
||
}
|
||
},
|
||
|
||
computed: {
|
||
normalizedQuickActions() {
|
||
return Array.isArray(this.quickActions)
|
||
? this.quickActions.filter(Boolean).map(item => this.normalizeAction(item))
|
||
: [];
|
||
},
|
||
|
||
displayQuickActions() {
|
||
if (!this.dragState.active || !this.dragState.key) {
|
||
return this.normalizedQuickActions;
|
||
}
|
||
|
||
const sourceActions = this.normalizedQuickActions;
|
||
const sourceIndex = sourceActions.findIndex(item => this.getMenuKey(item) === this.dragState.key);
|
||
const targetIndex = this.dragState.hoverIndex;
|
||
if (sourceIndex < 0 || targetIndex < 0) {
|
||
return sourceActions;
|
||
}
|
||
|
||
const projected = [...sourceActions];
|
||
const [dragItem] = projected.splice(sourceIndex, 1);
|
||
if (!dragItem) {
|
||
return sourceActions;
|
||
}
|
||
projected.splice(Math.min(targetIndex, projected.length), 0, dragItem);
|
||
return projected.filter(Boolean);
|
||
},
|
||
// 分页后的快捷入口
|
||
paginatedActions() {
|
||
const pages = [];
|
||
for (let i = 0; i < this.displayQuickActions.length; i += this.pageSize) {
|
||
pages.push(this.displayQuickActions.slice(i, i + this.pageSize));
|
||
}
|
||
return pages;
|
||
},
|
||
|
||
currentPageItems() {
|
||
return (this.paginatedActions[this.currentPage - 1] || []).filter(Boolean);
|
||
},
|
||
|
||
safeCurrentPageSlots() {
|
||
const items = this.currentPageItems
|
||
.map(item => this.normalizeAction(item))
|
||
.filter(Boolean)
|
||
.slice(0, this.pageSize);
|
||
|
||
return Array.from({ length: this.pageSize }, (_, index) => {
|
||
const action = items[index] || null;
|
||
return {
|
||
index,
|
||
action,
|
||
key: action ? this.getMenuKey(action) : `empty-slot-${this.currentPage}-${index}`
|
||
};
|
||
});
|
||
},
|
||
|
||
renderPageSlots() {
|
||
if (this.dragState.active && Array.isArray(this.dragPageSnapshot) && this.dragPageSnapshot.length) {
|
||
return this.dragPageSnapshot;
|
||
}
|
||
return this.safeCurrentPageSlots;
|
||
},
|
||
|
||
fallbackIconGlyph() {
|
||
return uviewIcons['uicon-grid'] || '\ue673';
|
||
},
|
||
|
||
removeActionIconGlyph() {
|
||
return uviewIcons['uicon-minus-circle-fill'] || '\ue652';
|
||
},
|
||
|
||
totalPages() {
|
||
return Math.ceil(this.displayQuickActions.length / this.pageSize) || 1;
|
||
},
|
||
|
||
dragPreviewStyle() {
|
||
return {
|
||
left: `${this.dragState.previewX}px`,
|
||
top: `${this.dragState.previewY}px`
|
||
};
|
||
},
|
||
|
||
// 公告与看板弹窗的唯一数据源,避免两处重复拼装同一套统计规则
|
||
noticeStats() {
|
||
const stats = this.dashboardStats || null;
|
||
const showUnclaimed = this.hasClaimShippingMenu && this.hasOrderPickingMenu;
|
||
if (!stats && !showUnclaimed) {
|
||
return [];
|
||
}
|
||
|
||
const f = this.formatStatNumber;
|
||
const items = [];
|
||
if (stats) {
|
||
items.push({ label: '今日订单', value: f(stats.todayOrders) });
|
||
}
|
||
if (showUnclaimed) {
|
||
items.push({ label: '未领料波次', value: f(this.unclaimedWaveCount) });
|
||
}
|
||
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.pageVisible = true;
|
||
if (this._skipNextShow) {
|
||
this._skipNextShow = false;
|
||
return;
|
||
}
|
||
// 返回首页时静默刷新,不闪烁加载态
|
||
this.loadUserInfo({ silent: true });
|
||
},
|
||
|
||
onHide() {
|
||
// 离开页面时暂停跑马灯动画,避免后台持续占用渲染
|
||
this.pageVisible = false;
|
||
},
|
||
|
||
onUnload() {
|
||
this.unbindGlobalDragListeners();
|
||
this.clearUndoTimer();
|
||
},
|
||
|
||
methods: {
|
||
async getLatestUserInfo() {
|
||
try {
|
||
const latestUser = await this.$store.dispatch('getUserInfo');
|
||
// 不再输出完整用户对象(可能含登录凭证),只保留用于排查的关键信息
|
||
console.log(
|
||
'[index] 用户信息已更新:',
|
||
latestUser?.store_name || '',
|
||
'菜单数:',
|
||
Array.isArray(latestUser?.menus) ? latestUser.menus.length : 0
|
||
);
|
||
if (latestUser && typeof latestUser === 'object') {
|
||
this.userInfo = latestUser;
|
||
return latestUser;
|
||
}
|
||
} catch (error) {
|
||
console.warn('拉取最新用户信息失败,回退本地用户缓存:', error);
|
||
}
|
||
|
||
const fallbackUser = this.$store.getters.user || this.userInfo || null;
|
||
if (fallbackUser && typeof fallbackUser === 'object') {
|
||
this.userInfo = fallbackUser;
|
||
return fallbackUser;
|
||
}
|
||
|
||
return null;
|
||
},
|
||
|
||
createDefaultDragPreviewSnapshot() {
|
||
return {
|
||
name: '未命名菜单',
|
||
color: '#2979ff',
|
||
isImageIcon: false,
|
||
resolvedIconName: 'grid',
|
||
resolvedIconSource: 'grid',
|
||
resolvedIconGlyph: this.fallbackIconGlyph || uviewIcons['uicon-grid'] || '\ue673'
|
||
};
|
||
},
|
||
|
||
createDragPreviewSnapshot(action) {
|
||
const normalized = this.normalizeAction(action);
|
||
if (!normalized) {
|
||
return this.createDefaultDragPreviewSnapshot();
|
||
}
|
||
|
||
const name = this.sanitizeText(normalized.name, '未命名菜单');
|
||
const color = this.sanitizeText(normalized.color, '#2979ff');
|
||
const rawSource = this.sanitizeText(normalized.resolvedIconSource, 'grid');
|
||
const isImageIcon = Boolean(normalized.isImageIcon) && rawSource.includes('/');
|
||
const resolvedIconName = isImageIcon
|
||
? 'grid'
|
||
: this.sanitizeText(normalized.resolvedIconName, 'grid');
|
||
const resolvedIconGlyph = this.sanitizeText(
|
||
normalized.resolvedIconGlyph,
|
||
uviewIcons[`uicon-${resolvedIconName}`] || this.fallbackIconGlyph || uviewIcons['uicon-grid'] || '\ue673'
|
||
);
|
||
|
||
return {
|
||
name,
|
||
color,
|
||
isImageIcon,
|
||
resolvedIconName,
|
||
resolvedIconSource: isImageIcon ? rawSource : resolvedIconName,
|
||
resolvedIconGlyph
|
||
};
|
||
},
|
||
|
||
sanitizeText(value, fallback = '') {
|
||
const text = String(value ?? '').trim();
|
||
if (!text || text === 'undefined' || text === 'null') {
|
||
return fallback;
|
||
}
|
||
return text;
|
||
},
|
||
|
||
normalizeAction(action) {
|
||
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');
|
||
const color = this.sanitizeText(action.color, '#2979ff');
|
||
const path = this.sanitizeText(action.path);
|
||
const component = this.sanitizeText(action.component);
|
||
const id = this.sanitizeText(action.id || action.menuId || component || path || name);
|
||
const isImageIcon = String(rawIcon).includes('/');
|
||
const resolvedIconName = isImageIcon
|
||
? rawIcon
|
||
: (() => {
|
||
const iconName = this.sanitizeText(rawIcon, 'grid').replace(/^uicon-/, '');
|
||
return VALID_UVIEW_ICON_NAMES.has(iconName) ? iconName : 'grid';
|
||
})();
|
||
const resolvedIconGlyph = isImageIcon
|
||
? (uviewIcons['uicon-grid'] || '\ue673')
|
||
: (uviewIcons[`uicon-${resolvedIconName}`] || uviewIcons['uicon-grid'] || '\ue673');
|
||
const normalized = {
|
||
...action,
|
||
id,
|
||
name,
|
||
icon: rawIcon,
|
||
color,
|
||
badge: Number(action.badge || 0),
|
||
path,
|
||
component,
|
||
resolvedIconName,
|
||
resolvedIconSource: resolvedIconName,
|
||
resolvedIconGlyph,
|
||
isImageIcon
|
||
};
|
||
|
||
// 非枚举标记:不会被 JSON 序列化,因此不会污染保存到本地的配置
|
||
Object.defineProperty(normalized, '__normalized', {
|
||
value: true,
|
||
enumerable: false
|
||
});
|
||
|
||
return normalized;
|
||
},
|
||
|
||
buildPageSlots(pageIndex, actions = this.displayQuickActions) {
|
||
const sourceActions = Array.isArray(actions)
|
||
? actions.map(item => this.normalizeAction(item)).filter(Boolean)
|
||
: [];
|
||
const start = Math.max(pageIndex, 0) * this.pageSize;
|
||
const items = sourceActions.slice(start, start + this.pageSize);
|
||
|
||
return Array.from({ length: this.pageSize }, (_, index) => {
|
||
const action = items[index] || null;
|
||
return {
|
||
index,
|
||
action,
|
||
key: action ? this.getMenuKey(action) : `drag-empty-slot-${pageIndex}-${index}`
|
||
};
|
||
});
|
||
},
|
||
|
||
refreshDragPageSnapshot(pageIndex = this.currentPage - 1) {
|
||
this.dragPageSnapshot = this.buildPageSlots(pageIndex);
|
||
},
|
||
|
||
ensureCurrentPageInRange() {
|
||
const maxPage = Math.max(this.totalPages, 1);
|
||
if (this.currentPage > maxPage) {
|
||
this.currentPage = maxPage;
|
||
}
|
||
if (this.currentPage < 1) {
|
||
this.currentPage = 1;
|
||
}
|
||
},
|
||
|
||
// silent: true 时不切换整页加载态,用于返回首页 / 切换主体后的静默刷新
|
||
async loadUserInfo({ silent = false } = {}) {
|
||
// 菜单加载会决定看板统计是否展示,必须先完成
|
||
await this.refreshQuickActions({ silent });
|
||
// 两个统计接口互不依赖,并行请求
|
||
await Promise.all([
|
||
this.loadDashboardStats(),
|
||
this.loadUnclaimedWaveCount()
|
||
]);
|
||
},
|
||
|
||
// 刷新快捷入口
|
||
async refreshQuickActions({ silent = false } = {}) {
|
||
if (!silent) {
|
||
this.isLoading = true;
|
||
}
|
||
|
||
try {
|
||
const latestUser = await this.getLatestUserInfo();
|
||
if (!latestUser) {
|
||
console.log('用户信息不可用,快捷入口置空');
|
||
this.hasReviewShippingMenu = false;
|
||
this.hasOrderPickingMenu = false;
|
||
this.quickActions = [];
|
||
this.ensureCurrentPageInRange();
|
||
return;
|
||
}
|
||
|
||
// 1. 获取用户当前可用的菜单
|
||
const userMenus = this.getUserMenus(latestUser);
|
||
const latestActions = this.processMenus(userMenus, null);
|
||
|
||
// 识别用户是否拥有复核发货 / 订单拣货功能菜单,用于展示看板统计
|
||
this.detectDashboardMenus(latestActions);
|
||
|
||
// 2. 从Vuex获取已固定的菜单
|
||
const savedFixedMenus = await this.$store.dispatch('setting/getValue', this.FIXED_MENU_KEY);
|
||
const hasSavedConfig = Array.isArray(savedFixedMenus);
|
||
|
||
// 3. 如果存在已保存的常用配置(包括空数组),优先按配置展示
|
||
if (hasSavedConfig) {
|
||
const validFixedMenus = this.validateAndFilterMenus(savedFixedMenus, latestActions);
|
||
console.log('按已保存常用菜单展示:', validFixedMenus);
|
||
this.quickActions = validFixedMenus.map(item => this.normalizeAction(item)).filter(Boolean);
|
||
this.ensureCurrentPageInRange();
|
||
return;
|
||
}
|
||
|
||
// 4. 如果没有有效的固定菜单,检查用户菜单
|
||
if (userMenus && userMenus.length > 0) {
|
||
console.log('从用户菜单生成快捷入口:', userMenus);
|
||
// 首次登录默认带出全部菜单,并将商品查询前置
|
||
const defaultQuickActions = this.prioritizeDefaultQuickActions(latestActions);
|
||
this.quickActions = defaultQuickActions.map(item => this.normalizeAction(item)).filter(Boolean);
|
||
await this.saveQuickActionsOrder();
|
||
} else {
|
||
// 5. 如果还是没有菜单,返回空数组
|
||
console.log('用户没有可用菜单');
|
||
this.quickActions = [];
|
||
}
|
||
this.ensureCurrentPageInRange();
|
||
|
||
} catch (error) {
|
||
console.error('刷新快捷入口失败:', error);
|
||
// 弱网 / 接口异常时保留已展示的菜单,避免把本地常用配置清空
|
||
this.ensureCurrentPageInRange();
|
||
if (!this.quickActions.length) {
|
||
uni.showToast({
|
||
title: '常用功能加载失败,请重试',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} finally {
|
||
this.isLoading = false;
|
||
}
|
||
},
|
||
|
||
// 根据用户菜单识别看板相关功能(复核发货 / 订单拣货 / 领取快递面单)
|
||
detectDashboardMenus(actions) {
|
||
const list = Array.isArray(actions) ? actions.filter(Boolean) : [];
|
||
let hasReviewShipping = false;
|
||
let hasOrderPicking = false;
|
||
let hasClaimShipping = false;
|
||
|
||
list.forEach((item) => {
|
||
const name = this.sanitizeText(item?.name);
|
||
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;
|
||
},
|
||
|
||
// 加载仓库/货主看板统计
|
||
async loadDashboardStats() {
|
||
if (!this.hasReviewShippingMenu && !this.hasOrderPickingMenu) {
|
||
this.dashboardStats = null;
|
||
return;
|
||
}
|
||
|
||
try {
|
||
const response = await this.$http('dashboard.storeStats', {}, '', false);
|
||
if (response && response.flag === 'success' && response.data) {
|
||
this.dashboardStats = response.data;
|
||
} else {
|
||
this.dashboardStats = null;
|
||
}
|
||
} catch (error) {
|
||
console.warn('[index] 看板统计加载失败:', error);
|
||
this.dashboardStats = null;
|
||
}
|
||
},
|
||
|
||
// 加载「未领料波次」数量(order.wave.confirmPrintUnclaimedWaveCount)
|
||
// 仅同时拥有「领取快递面单」与「订单拣货」菜单时展示
|
||
async loadUnclaimedWaveCount() {
|
||
if (!this.hasClaimShippingMenu || !this.hasOrderPickingMenu) {
|
||
this.unclaimedWaveCount = 0;
|
||
return;
|
||
}
|
||
|
||
try {
|
||
const res = await this.$http(
|
||
'order.wave.confirmPrintUnclaimedWaveCount',
|
||
{},
|
||
'',
|
||
false
|
||
);
|
||
const data = (res && res.data && typeof res.data === 'object' && !Array.isArray(res.data))
|
||
? res.data
|
||
: {};
|
||
const payload = { ...(res || {}), ...data };
|
||
const count = Number(payload.count);
|
||
this.unclaimedWaveCount = Number.isFinite(count) ? count : 0;
|
||
} catch (error) {
|
||
console.warn('[index] 未领料波次数量加载失败:', error);
|
||
this.unclaimedWaveCount = 0;
|
||
}
|
||
},
|
||
|
||
formatStatNumber(value) {
|
||
const num = Number(value);
|
||
return Number.isFinite(num) ? num : '--';
|
||
},
|
||
|
||
prioritizeDefaultQuickActions(actions) {
|
||
const source = Array.isArray(actions) ? actions.filter(Boolean) : [];
|
||
if (!source.length) {
|
||
return [];
|
||
}
|
||
|
||
// 用户权限菜单超过12个时,按固定优先级取前12个
|
||
if (source.length > 12) {
|
||
const defaultMenuNames = [
|
||
'收货作业',
|
||
'商品查询',
|
||
'订单拣货',
|
||
'散单波次策略',
|
||
'团购波次策略',
|
||
'散单拣货详情',
|
||
'团购拣货详情',
|
||
'订单复核',
|
||
'随机入库',
|
||
'移库作业'
|
||
];
|
||
|
||
const selectedKeys = new Set();
|
||
const prioritized = [];
|
||
|
||
defaultMenuNames.forEach((targetName) => {
|
||
const matched = source.find((item) => {
|
||
const menuName = this.sanitizeText(item?.name || item?.meta?.title);
|
||
const key = this.getMenuKey(item);
|
||
return key && !selectedKeys.has(key) && menuName === targetName;
|
||
});
|
||
|
||
if (matched) {
|
||
const key = this.getMenuKey(matched);
|
||
selectedKeys.add(key);
|
||
prioritized.push(matched);
|
||
}
|
||
});
|
||
|
||
const remaining = source.filter((item) => {
|
||
const key = this.getMenuKey(item);
|
||
return key && !selectedKeys.has(key);
|
||
});
|
||
|
||
return [...prioritized, ...remaining].slice(0, 12);
|
||
}
|
||
|
||
// 低于12个时,商品查询置顶,其余全部显示
|
||
const selectedKeys = new Set();
|
||
const prioritized = [];
|
||
|
||
const goodsQuery = source.find((item) => {
|
||
const menuName = this.sanitizeText(item?.name || item?.meta?.title);
|
||
const key = this.getMenuKey(item);
|
||
return key && menuName === '商品查询';
|
||
});
|
||
|
||
if (goodsQuery) {
|
||
const key = this.getMenuKey(goodsQuery);
|
||
selectedKeys.add(key);
|
||
prioritized.push(goodsQuery);
|
||
}
|
||
|
||
const remaining = source.filter((item) => {
|
||
const key = this.getMenuKey(item);
|
||
return key && !selectedKeys.has(key);
|
||
});
|
||
|
||
return [...prioritized, ...remaining];
|
||
},
|
||
|
||
// 辅助方法:验证和过滤菜单权限
|
||
validateAndFilterMenus(fixedMenus, latestActions) {
|
||
if (!Array.isArray(fixedMenus) || !Array.isArray(latestActions)) return [];
|
||
|
||
const actionMap = new Map();
|
||
latestActions.forEach(action => {
|
||
actionMap.set(this.getMenuKey(action), action);
|
||
});
|
||
|
||
return fixedMenus
|
||
.map(fixedMenu => {
|
||
const matched = actionMap.get(this.getMenuKey(fixedMenu));
|
||
if (!matched) return null;
|
||
return this.normalizeAction({
|
||
...matched,
|
||
...fixedMenu,
|
||
name: matched.name,
|
||
path: matched.path,
|
||
component: matched.component,
|
||
icon: matched.icon || fixedMenu.icon,
|
||
id: matched.id || fixedMenu.id
|
||
});
|
||
})
|
||
.filter(Boolean);
|
||
},
|
||
|
||
getMenuKey(menu) {
|
||
return this.sanitizeText(
|
||
menu?.component ||
|
||
menu?.path ||
|
||
menu?.id ||
|
||
menu?.menuId ||
|
||
menu?.name ||
|
||
'',
|
||
''
|
||
);
|
||
},
|
||
getTouchPoint(event) {
|
||
const fallbackPoint = event?.detail?.x || event?.detail?.y
|
||
? {
|
||
pageX: event.detail.x,
|
||
pageY: event.detail.y
|
||
}
|
||
: null;
|
||
const touch = event?.touches?.[0] || event?.changedTouches?.[0] || fallbackPoint;
|
||
|
||
return {
|
||
x: Number(touch?.pageX || touch?.clientX || 0),
|
||
y: Number(touch?.pageY || touch?.clientY || 0)
|
||
};
|
||
},
|
||
bindGlobalDragListeners() {
|
||
if (typeof window === 'undefined' || this._globalDragListenersBound) {
|
||
return;
|
||
}
|
||
|
||
this._globalTouchMoveHandler = (event) => {
|
||
if (!this.dragState.active) {
|
||
return;
|
||
}
|
||
if (typeof event.preventDefault === 'function') {
|
||
event.preventDefault();
|
||
}
|
||
this.onDragMove(event);
|
||
};
|
||
this._globalTouchEndHandler = (event) => {
|
||
if (!this.dragState.active) {
|
||
return;
|
||
}
|
||
this.endDrag(event);
|
||
};
|
||
|
||
window.addEventListener('touchmove', this._globalTouchMoveHandler, { passive: false });
|
||
window.addEventListener('touchend', this._globalTouchEndHandler, { passive: false });
|
||
window.addEventListener('touchcancel', this._globalTouchEndHandler, { passive: false });
|
||
this._globalDragListenersBound = true;
|
||
},
|
||
unbindGlobalDragListeners() {
|
||
if (typeof window === 'undefined' || !this._globalDragListenersBound) {
|
||
return;
|
||
}
|
||
|
||
window.removeEventListener('touchmove', this._globalTouchMoveHandler);
|
||
window.removeEventListener('touchend', this._globalTouchEndHandler);
|
||
window.removeEventListener('touchcancel', this._globalTouchEndHandler);
|
||
this._globalTouchMoveHandler = null;
|
||
this._globalTouchEndHandler = null;
|
||
this._globalDragListenersBound = false;
|
||
},
|
||
enterQuickActionRemoveMode() {
|
||
if (this.dragState.active) {
|
||
return;
|
||
}
|
||
this.quickActionRemoveMode = true;
|
||
},
|
||
exitQuickActionRemoveMode() {
|
||
this.quickActionRemoveMode = false;
|
||
},
|
||
handleQuickActionLongPress(event, item, pageIndex, index) {
|
||
if (!item || this.dragState.active) {
|
||
return;
|
||
}
|
||
// 长按只负责排序;移除必须在标题栏「管理」里显式开启,避免误删
|
||
this.onGridItemLongPress(event, item, pageIndex, index);
|
||
},
|
||
onGridItemLongPress(event, item, pageIndex, index) {
|
||
if (this.dragState.active) {
|
||
return;
|
||
}
|
||
|
||
const point = this.getTouchPoint(event);
|
||
this.startDragWithPoint(item, pageIndex, index, point);
|
||
},
|
||
async removeQuickAction(item) {
|
||
const targetKey = this.getMenuKey(item);
|
||
if (!targetKey) {
|
||
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;
|
||
}
|
||
|
||
this.quickActions = nextActions;
|
||
this.ensureCurrentPageInRange();
|
||
if (!this.quickActions.length) {
|
||
this.quickActionRemoveMode = false;
|
||
}
|
||
this.showUndoBar(this.normalizeAction(item), removeIndex);
|
||
await this.saveQuickActionsOrder();
|
||
const tools = this.$tools;
|
||
if (tools && typeof tools.speakText === 'function') {
|
||
try {
|
||
const task = tools.speakText('已移出常用功能');
|
||
if (task && typeof task.catch === 'function') {
|
||
task.catch(error => {
|
||
console.warn('[HomeIndex] 语音播报失败:', error);
|
||
});
|
||
}
|
||
} catch (error) {
|
||
console.warn('[HomeIndex] 语音播报异常:', error);
|
||
}
|
||
}
|
||
},
|
||
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;
|
||
}
|
||
|
||
const point = this.getTouchPoint(event);
|
||
this.wrapperGesture = {
|
||
startX: point.x,
|
||
startY: point.y,
|
||
deltaX: 0,
|
||
deltaY: 0,
|
||
startTime: Date.now()
|
||
};
|
||
},
|
||
handleWrapperTouchMove(event) {
|
||
if (!this.dragState.active) {
|
||
const point = this.getTouchPoint(event);
|
||
this.wrapperGesture.deltaX = point.x - this.wrapperGesture.startX;
|
||
this.wrapperGesture.deltaY = point.y - this.wrapperGesture.startY;
|
||
return;
|
||
}
|
||
|
||
// 拖动中同一次 touchmove 也会命中全局监听,这里跳过避免重复计算
|
||
if (this._globalDragListenersBound) {
|
||
return;
|
||
}
|
||
|
||
if (typeof event?.preventDefault === 'function') {
|
||
event.preventDefault();
|
||
}
|
||
if (typeof event?.stopPropagation === 'function') {
|
||
event.stopPropagation();
|
||
}
|
||
this.onDragMove(event);
|
||
},
|
||
handleWrapperTouchEnd() {
|
||
if (this.dragState.active) {
|
||
this.endDrag();
|
||
return;
|
||
}
|
||
|
||
const { deltaX, deltaY, startTime } = this.wrapperGesture;
|
||
const duration = startTime ? (Date.now() - startTime) : 0;
|
||
if (duration > 0 && duration < 320 && Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY) + 12) {
|
||
if (deltaX < 0 && this.currentPage < this.totalPages) {
|
||
this.currentPage += 1;
|
||
} else if (deltaX > 0 && this.currentPage > 1) {
|
||
this.currentPage -= 1;
|
||
}
|
||
}
|
||
|
||
this.wrapperGesture = {
|
||
startX: 0,
|
||
startY: 0,
|
||
deltaX: 0,
|
||
deltaY: 0,
|
||
startTime: 0
|
||
};
|
||
},
|
||
isDraggingItem(item) {
|
||
return this.dragState.active && this.getMenuKey(item) === this.dragState.key;
|
||
},
|
||
async captureCurrentPageSlots(pageIndex) {
|
||
return new Promise((resolve) => {
|
||
const query = uni.createSelectorQuery().in(this);
|
||
query.select(`#grid-page-${pageIndex}`).boundingClientRect();
|
||
query.selectAll(`.page-slot-${pageIndex}`).boundingClientRect();
|
||
query.exec((res) => {
|
||
resolve({
|
||
pageRect: res?.[0] || null,
|
||
slotRects: res?.[1] || []
|
||
});
|
||
});
|
||
});
|
||
},
|
||
async startDragWithPoint(item, pageIndex, index, startPoint) {
|
||
if (!item || this.dragState.active || this.quickActions.length <= 1) {
|
||
return;
|
||
}
|
||
|
||
const point = startPoint || { x: 0, y: 0 };
|
||
this.suppressItemClick = true;
|
||
const safeItem = this.normalizeAction(item);
|
||
const originalIndex = this.quickActions.findIndex(action => this.getMenuKey(action) === this.getMenuKey(safeItem));
|
||
this.dragPreviewSnapshot = this.createDragPreviewSnapshot(safeItem);
|
||
this.dragState = {
|
||
active: true,
|
||
item: safeItem,
|
||
key: this.getMenuKey(safeItem),
|
||
originalIndex,
|
||
pageIndex,
|
||
hoverIndex: originalIndex >= 0 ? originalIndex : (pageIndex * this.pageSize + index),
|
||
previewX: (point.x || 0) - 60,
|
||
previewY: (point.y || 0) - 60,
|
||
slotRects: [],
|
||
pageRect: null
|
||
};
|
||
this.refreshDragPageSnapshot(pageIndex);
|
||
this.bindGlobalDragListeners();
|
||
|
||
const { pageRect, slotRects } = await this.captureCurrentPageSlots(pageIndex);
|
||
if (!this.dragState.active) {
|
||
return;
|
||
}
|
||
|
||
if (pageRect && slotRects && slotRects.length) {
|
||
const slotRect = slotRects[index] || slotRects[0];
|
||
const dragStartPoint = (point.x || point.y)
|
||
? point
|
||
: {
|
||
x: (slotRect?.left || 0) + ((slotRect?.width || 0) / 2),
|
||
y: (slotRect?.top || 0) + ((slotRect?.height || 0) / 2)
|
||
};
|
||
|
||
this.dragState = {
|
||
...this.dragState,
|
||
previewX: dragStartPoint.x - ((slotRect?.width || 120) / 2),
|
||
previewY: dragStartPoint.y - ((slotRect?.height || 120) / 2),
|
||
slotRects,
|
||
pageRect
|
||
};
|
||
}
|
||
},
|
||
getPageAbsoluteIndex(pageIndex, slotIndex) {
|
||
const pageStart = pageIndex * this.pageSize;
|
||
return Math.min(pageStart + Math.max(slotIndex, 0), this.quickActions.length - 1);
|
||
},
|
||
async switchDragPage(targetPageIndex, point) {
|
||
if (!this.dragState.active || this.dragPageSwitching) {
|
||
return false;
|
||
}
|
||
|
||
if (targetPageIndex < 0 || targetPageIndex >= this.totalPages || targetPageIndex === this.dragState.pageIndex) {
|
||
return false;
|
||
}
|
||
|
||
this.dragPageSwitching = true;
|
||
|
||
const fallbackIndex = targetPageIndex < this.dragState.pageIndex
|
||
? Math.min(((targetPageIndex + 1) * this.pageSize) - 1, this.quickActions.length - 1)
|
||
: Math.min(targetPageIndex * this.pageSize, this.quickActions.length - 1);
|
||
|
||
let nextHoverIndex = fallbackIndex;
|
||
const preciseSlotIndex = this.findClosestSlotIndex(point);
|
||
if (preciseSlotIndex >= 0) {
|
||
nextHoverIndex = this.getPageAbsoluteIndex(targetPageIndex, preciseSlotIndex);
|
||
}
|
||
|
||
this.dragState = {
|
||
...this.dragState,
|
||
pageIndex: targetPageIndex,
|
||
hoverIndex: nextHoverIndex
|
||
};
|
||
this.currentPage = targetPageIndex + 1;
|
||
this.refreshDragPageSnapshot(targetPageIndex);
|
||
|
||
await this.$nextTick();
|
||
await new Promise(resolve => setTimeout(resolve, 16));
|
||
const { pageRect, slotRects } = await this.captureCurrentPageSlots(targetPageIndex);
|
||
if (pageRect && slotRects && slotRects.length) {
|
||
this.dragState = {
|
||
...this.dragState,
|
||
pageRect,
|
||
slotRects
|
||
};
|
||
|
||
const refreshedSlotIndex = this.findClosestSlotIndex(point);
|
||
if (refreshedSlotIndex >= 0) {
|
||
this.dragState.hoverIndex = this.getPageAbsoluteIndex(targetPageIndex, refreshedSlotIndex);
|
||
this.refreshDragPageSnapshot(targetPageIndex);
|
||
}
|
||
}
|
||
this.dragPageSwitching = false;
|
||
|
||
return true;
|
||
},
|
||
async maybeSwitchDragPage(point) {
|
||
if (this.dragPageSwitching) {
|
||
return true;
|
||
}
|
||
|
||
const pageRect = this.dragState.pageRect;
|
||
if (!pageRect) {
|
||
return false;
|
||
}
|
||
|
||
const edgeThreshold = 50;
|
||
if (point.x <= pageRect.left + edgeThreshold && this.dragState.pageIndex > 0) {
|
||
return this.switchDragPage(this.dragState.pageIndex - 1, point);
|
||
}
|
||
|
||
if (point.x >= pageRect.right - edgeThreshold && this.dragState.pageIndex < this.totalPages - 1) {
|
||
return this.switchDragPage(this.dragState.pageIndex + 1, point);
|
||
}
|
||
|
||
return false;
|
||
},
|
||
findClosestSlotIndex(point) {
|
||
const { slotRects } = this.dragState;
|
||
if (!Array.isArray(slotRects) || !slotRects.length) {
|
||
return -1;
|
||
}
|
||
|
||
let closestIndex = -1;
|
||
let minDistance = Infinity;
|
||
|
||
slotRects.forEach((rect, index) => {
|
||
if (!rect) {
|
||
return;
|
||
}
|
||
|
||
const inside = point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom;
|
||
if (inside) {
|
||
closestIndex = index;
|
||
minDistance = 0;
|
||
return;
|
||
}
|
||
|
||
if (minDistance === 0) {
|
||
return;
|
||
}
|
||
|
||
const centerX = rect.left + rect.width / 2;
|
||
const centerY = rect.top + rect.height / 2;
|
||
const distance = Math.pow(point.x - centerX, 2) + Math.pow(point.y - centerY, 2);
|
||
if (distance < minDistance) {
|
||
minDistance = distance;
|
||
closestIndex = index;
|
||
}
|
||
});
|
||
|
||
return closestIndex;
|
||
},
|
||
reorderQuickActions(dragKey, targetIndex) {
|
||
const fromIndex = this.quickActions.findIndex(item => this.getMenuKey(item) === dragKey);
|
||
if (fromIndex < 0) {
|
||
return;
|
||
}
|
||
|
||
const maxIndex = Math.max(this.quickActions.length - 1, 0);
|
||
const safeTargetIndex = Math.min(Math.max(targetIndex, 0), maxIndex);
|
||
if (fromIndex === safeTargetIndex) {
|
||
return;
|
||
}
|
||
|
||
const nextActions = [...this.quickActions];
|
||
const [movedItem] = nextActions.splice(fromIndex, 1);
|
||
if (!movedItem) {
|
||
return;
|
||
}
|
||
nextActions.splice(safeTargetIndex, 0, movedItem);
|
||
this.quickActions = nextActions.filter(Boolean);
|
||
this.ensureCurrentPageInRange();
|
||
},
|
||
async onDragMove(event) {
|
||
if (!this.dragState.active) {
|
||
return;
|
||
}
|
||
|
||
if (typeof event?.preventDefault === 'function') {
|
||
event.preventDefault();
|
||
}
|
||
|
||
const point = this.getTouchPoint(event);
|
||
this.dragState.previewX = point.x - 60;
|
||
this.dragState.previewY = point.y - 60;
|
||
|
||
const switched = await this.maybeSwitchDragPage(point);
|
||
if (switched) {
|
||
return;
|
||
}
|
||
|
||
const slotIndex = this.findClosestSlotIndex(point);
|
||
if (slotIndex < 0) {
|
||
return;
|
||
}
|
||
|
||
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;
|
||
try {
|
||
const normalizedActions = this.quickActions.map(item => this.normalizeAction(item)).filter(Boolean);
|
||
this.quickActions = normalizedActions;
|
||
await this.$store.dispatch('setting/setValue', {
|
||
key: this.FIXED_MENU_KEY,
|
||
value: normalizedActions
|
||
});
|
||
} catch (error) {
|
||
console.error('保存常用功能排序失败:', error);
|
||
uni.showToast({
|
||
title: '排序保存失败',
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
this.isSavingOrder = false;
|
||
if (this._pendingSaveOrder) {
|
||
this._pendingSaveOrder = false;
|
||
this.saveQuickActionsOrder();
|
||
}
|
||
}
|
||
},
|
||
async endDrag() {
|
||
if (!this.dragState.active) {
|
||
this.unbindGlobalDragListeners();
|
||
return;
|
||
}
|
||
|
||
const finalHoverIndex = this.dragState.hoverIndex >= 0
|
||
? this.dragState.hoverIndex
|
||
: this.dragState.originalIndex;
|
||
if (finalHoverIndex >= 0 && finalHoverIndex !== this.dragState.originalIndex) {
|
||
this.reorderQuickActions(this.dragState.key, finalHoverIndex);
|
||
}
|
||
if (finalHoverIndex >= 0) {
|
||
this.currentPage = Math.floor(finalHoverIndex / this.pageSize) + 1;
|
||
}
|
||
this.ensureCurrentPageInRange();
|
||
|
||
this.dragState = {
|
||
active: false,
|
||
item: null,
|
||
key: '',
|
||
originalIndex: -1,
|
||
pageIndex: -1,
|
||
hoverIndex: -1,
|
||
previewX: 0,
|
||
previewY: 0,
|
||
slotRects: [],
|
||
pageRect: null
|
||
};
|
||
this.dragPreviewSnapshot = this.createDefaultDragPreviewSnapshot();
|
||
this.dragPageSnapshot = [];
|
||
this.dragPageSwitching = false;
|
||
this.unbindGlobalDragListeners();
|
||
this.suppressItemClick = false;
|
||
await this.saveQuickActionsOrder();
|
||
},
|
||
handleGridItemClick(item) {
|
||
if (this.dragState.active || this.suppressItemClick || this.quickActionRemoveMode) {
|
||
return;
|
||
}
|
||
this.toPath(item);
|
||
},
|
||
|
||
// 获取用户菜单
|
||
getUserMenus(userData = null) {
|
||
const user = userData || this.userInfo || this.$store.getters.user;
|
||
if (!user) return [];
|
||
|
||
// 从用户信息中获取菜单
|
||
return user.menus || user.permissions || [];
|
||
},
|
||
|
||
// 处理菜单数据:展平一级子菜单 → 过滤有效项 → 可选数量限制 → 统一格式
|
||
processMenus(menus, limit = null) {
|
||
if (!Array.isArray(menus)) {
|
||
return [];
|
||
}
|
||
|
||
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) {
|
||
return;
|
||
}
|
||
|
||
// 提取店铺名称列表
|
||
const storeList = this.userInfo.employees.map(emp => emp.store_name);
|
||
|
||
uni.showActionSheet({
|
||
itemList: storeList,
|
||
success: (res) => {
|
||
const selectedIndex = res.tapIndex;
|
||
if (selectedIndex >= 0 && selectedIndex < this.userInfo.employees.length) {
|
||
const selectedEmployee = this.userInfo.employees[selectedIndex];
|
||
this.handleStoreSwitch(selectedEmployee);
|
||
}
|
||
},
|
||
fail: (err) => {
|
||
console.log('用户取消选择', err);
|
||
}
|
||
});
|
||
},
|
||
|
||
async handleStoreSwitch(selectedEmployee) {
|
||
uni.showLoading({
|
||
title: '切换中...',
|
||
mask: true
|
||
});
|
||
try {
|
||
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();
|
||
}
|
||
},
|
||
|
||
// 按 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: '功能暂未开放',
|
||
icon: 'none',
|
||
duration: 1500
|
||
});
|
||
return;
|
||
}
|
||
|
||
this.$tools.routerTo(targetPath);
|
||
},
|
||
|
||
openNoticePopup() {
|
||
if (!this.noticeStatItems.length) {
|
||
return;
|
||
}
|
||
this.showNoticePopup = true;
|
||
},
|
||
|
||
closeNoticePopup() {
|
||
this.showNoticePopup = false;
|
||
},
|
||
|
||
toEditPage() {
|
||
uni.navigateTo({
|
||
url: '/pages/home/edit-quick-actions'
|
||
});
|
||
},
|
||
|
||
retryLoad() {
|
||
if (this.isLoading) {
|
||
return;
|
||
}
|
||
this.loadUserInfo();
|
||
},
|
||
|
||
prevPage() {
|
||
if (this.dragState.active) {
|
||
return;
|
||
}
|
||
if (this.currentPage > 1) {
|
||
this.currentPage--;
|
||
}
|
||
},
|
||
|
||
nextPage() {
|
||
if (this.dragState.active) {
|
||
return;
|
||
}
|
||
if (this.currentPage < this.totalPages) {
|
||
this.currentPage++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
// 本地静态字体(原为 https://at.alicdn.com/font_2225171_8kdcwk4po24.ttf)
|
||
@font-face {
|
||
font-family: 'uicon-iconfont';
|
||
src: url('~@/static/fonts/uicon-iconfont.ttf') format('truetype');
|
||
}
|
||
|
||
.pda-home {
|
||
display: flex;
|
||
flex-direction: column;
|
||
background: #f8f9fa;
|
||
}
|
||
|
||
// 紧凑型头部
|
||
.compact-header {
|
||
padding: 12rpx 24rpx 16rpx;
|
||
background: #ffffff;
|
||
border-bottom: 1rpx solid #f0f2f5;
|
||
|
||
.org-switcher {
|
||
display: flex;
|
||
align-items: center;
|
||
|
||
.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 {
|
||
flex-shrink: 0;
|
||
margin-left: 6rpx;
|
||
}
|
||
|
||
.org-info {
|
||
flex: 1;
|
||
min-width: 0;
|
||
|
||
.org-name {
|
||
font-size: 32rpx;
|
||
font-weight: 600;
|
||
color: #1f2329;
|
||
display: block;
|
||
line-height: 1.3;
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.org-id {
|
||
font-size: 24rpx;
|
||
color: #9aa0a6;
|
||
display: block;
|
||
line-height: 1.3;
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
}
|
||
}
|
||
|
||
.news-wrapper {
|
||
flex: 1;
|
||
min-width: 0;
|
||
margin-left: 16rpx;
|
||
overflow: hidden;
|
||
|
||
.news-pill {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 56rpx;
|
||
padding: 0 20rpx;
|
||
background: #f2f7ff;
|
||
border: 0;
|
||
border-radius: 28rpx;
|
||
box-sizing: border-box;
|
||
overflow: hidden;
|
||
|
||
&__icon {
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
margin-right: 10rpx;
|
||
}
|
||
|
||
&__body {
|
||
flex: 1;
|
||
min-width: 0;
|
||
overflow: hidden;
|
||
|
||
.news-marquee {
|
||
width: 100%;
|
||
height: 56rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
overflow: hidden;
|
||
|
||
&__track {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
white-space: nowrap;
|
||
will-change: transform;
|
||
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: 26rpx;
|
||
color: #2979ff;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
// 顶部公告无缝滚动
|
||
@keyframes news-marquee-scroll {
|
||
from {
|
||
transform: translateX(0);
|
||
}
|
||
to {
|
||
transform: translateX(-50%);
|
||
}
|
||
}
|
||
|
||
// 骨架屏呼吸
|
||
@keyframes skeleton-pulse {
|
||
0%, 100% {
|
||
opacity: 1;
|
||
}
|
||
50% {
|
||
opacity: 0.45;
|
||
}
|
||
}
|
||
|
||
// 主内容区:父级高度由内容撑开,保留纵向滚动能力,避免小屏裁切
|
||
.main-scroll {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow-y: auto;
|
||
-webkit-overflow-scrolling: touch;
|
||
}
|
||
|
||
// 快捷入口区域
|
||
.quick-section {
|
||
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: 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: #1f2329;
|
||
}
|
||
|
||
.drag-tip {
|
||
margin-left: 12rpx;
|
||
font-size: 24rpx;
|
||
color: #a8adb5;
|
||
}
|
||
}
|
||
|
||
.title-right {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-shrink: 0;
|
||
|
||
.done-btn,
|
||
.manage-btn {
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
color: #2979ff;
|
||
padding: 10rpx 16rpx;
|
||
border-radius: 10rpx;
|
||
|
||
&:active {
|
||
background: #f0f7ff;
|
||
}
|
||
}
|
||
|
||
.edit-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-left: 16rpx;
|
||
padding: 10rpx 20rpx;
|
||
border-radius: 28rpx;
|
||
background: #f2f7ff;
|
||
line-height: 1;
|
||
|
||
&:active {
|
||
background: #e6f0ff;
|
||
}
|
||
|
||
.edit-btn__text {
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
color: #2979ff;
|
||
line-height: 1;
|
||
}
|
||
|
||
.u-icon {
|
||
margin-left: 6rpx;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 网格容器
|
||
.quick-grid-container {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 4rpx;
|
||
|
||
.nav-arrow {
|
||
flex: 0 0 48rpx;
|
||
width: 48rpx;
|
||
height: 96rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 24rpx;
|
||
background: #f5f7fa;
|
||
|
||
&:active:not(.disabled) {
|
||
background: #e9edf3;
|
||
}
|
||
|
||
&.disabled {
|
||
opacity: 0.3;
|
||
}
|
||
}
|
||
|
||
.quick-grid-wrapper {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
position: relative;
|
||
|
||
.quick-page-shell {
|
||
width: 100%;
|
||
min-height: 0;
|
||
}
|
||
|
||
.grid-page {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, 1fr);
|
||
grid-template-rows: repeat(4, auto);
|
||
gap: 10rpx;
|
||
padding: 0 10rpx;
|
||
|
||
.grid-item {
|
||
min-height: 170rpx;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
border-radius: 16rpx;
|
||
transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
|
||
|
||
.grid-item-touch-layer {
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 3;
|
||
background: transparent;
|
||
}
|
||
|
||
.remove-action-btn {
|
||
position: absolute;
|
||
top: 8rpx;
|
||
right: 8rpx;
|
||
z-index: 4;
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.remove-action-icon {
|
||
font-family: 'uicon-iconfont' !important;
|
||
font-size: 44rpx;
|
||
line-height: 1;
|
||
font-style: normal;
|
||
font-weight: normal;
|
||
color: #ff4d4f;
|
||
display: block;
|
||
}
|
||
}
|
||
|
||
.grid-item-content {
|
||
position: relative;
|
||
z-index: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 100%;
|
||
height: 100%;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.item-icon-box {
|
||
width: 100rpx;
|
||
height: 100rpx;
|
||
border-radius: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 12rpx;
|
||
|
||
.item-icon-image {
|
||
width: 52rpx;
|
||
height: 52rpx;
|
||
}
|
||
|
||
.item-icon-font {
|
||
font-family: 'uicon-iconfont' !important;
|
||
font-size: 58rpx;
|
||
line-height: 1;
|
||
font-style: normal;
|
||
font-weight: normal;
|
||
display: block;
|
||
}
|
||
|
||
.drag-icon-placeholder {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
display: grid;
|
||
grid-template-columns: repeat(2, 1fr);
|
||
grid-template-rows: repeat(2, 1fr);
|
||
gap: 6rpx;
|
||
|
||
&__dot {
|
||
width: 100%;
|
||
height: 100%;
|
||
background: currentColor;
|
||
border-radius: 8rpx;
|
||
display: block;
|
||
opacity: 0.72;
|
||
}
|
||
}
|
||
}
|
||
|
||
.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: 4rpx;
|
||
right: 4rpx;
|
||
}
|
||
|
||
&:active {
|
||
background: #f8f9fa;
|
||
}
|
||
|
||
&.drag-placeholder {
|
||
opacity: 0.2;
|
||
transform: scale(0.92);
|
||
}
|
||
|
||
&.drag-disabled {
|
||
transition: none;
|
||
}
|
||
|
||
&.empty-item {
|
||
opacity: 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
.drag-preview {
|
||
position: fixed;
|
||
z-index: 999;
|
||
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);
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
pointer-events: none;
|
||
transform: scale(1.05);
|
||
|
||
.preview-remove-action-icon {
|
||
position: absolute;
|
||
top: 8rpx;
|
||
right: 8rpx;
|
||
font-family: 'uicon-iconfont' !important;
|
||
font-size: 44rpx;
|
||
line-height: 1;
|
||
font-style: normal;
|
||
font-weight: normal;
|
||
color: #ff4d4f;
|
||
display: block;
|
||
}
|
||
|
||
.item-icon-box {
|
||
width: 100rpx;
|
||
height: 100rpx;
|
||
border-radius: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 12rpx;
|
||
|
||
.item-icon-image {
|
||
width: 52rpx;
|
||
height: 52rpx;
|
||
}
|
||
|
||
.item-icon-font {
|
||
font-family: 'uicon-iconfont' !important;
|
||
font-size: 58rpx;
|
||
line-height: 1;
|
||
font-style: normal;
|
||
font-weight: normal;
|
||
display: block;
|
||
}
|
||
}
|
||
|
||
.item-name {
|
||
max-width: 100%;
|
||
font-size: 34rpx;
|
||
font-weight: bold;
|
||
color: #333;
|
||
text-align: center;
|
||
line-height: 1.4;
|
||
padding: 0 4rpx;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 分页指示器
|
||
.pagination-dots {
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
margin-top: 16rpx;
|
||
|
||
.pagination-dot {
|
||
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: 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;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
|
||
.loading-text {
|
||
margin-top: 20rpx;
|
||
color: #909399;
|
||
font-size: 24rpx;
|
||
}
|
||
}
|
||
|
||
// 空状态提示
|
||
.empty-state {
|
||
padding: 80rpx 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
.empty-text {
|
||
display: block;
|
||
font-size: 32rpx;
|
||
color: #999;
|
||
margin-top: 30rpx;
|
||
margin-bottom: 15rpx;
|
||
}
|
||
|
||
.empty-hint {
|
||
display: block;
|
||
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;
|
||
}
|
||
}
|
||
|
||
// 看板统计弹窗
|
||
.notice-popup {
|
||
padding: 32rpx 30rpx 40rpx;
|
||
|
||
&__header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 30rpx;
|
||
padding-bottom: 24rpx;
|
||
border-bottom: 1rpx solid #f0f0f0;
|
||
}
|
||
|
||
&__title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #333;
|
||
}
|
||
|
||
&__body {
|
||
max-height: 60vh;
|
||
}
|
||
|
||
&__grid {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin: -12rpx;
|
||
}
|
||
|
||
&__item {
|
||
width: calc(33.333% - 24rpx);
|
||
margin: 12rpx;
|
||
background: #f6f8fb;
|
||
border-radius: 16rpx;
|
||
padding: 32rpx 12rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
|
||
}
|
||
|
||
&__value {
|
||
font-size: 44rpx;
|
||
font-weight: 600;
|
||
color: #2979ff;
|
||
margin-bottom: 10rpx;
|
||
}
|
||
|
||
&__label {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
}
|
||
}
|
||
</style> |