feat(home): 首页看板统计与通知栏改造

- 新增 dashboard.storeStats 看板接口(core/request/apis.js)
- 首页顶部欢迎语改为按用户菜单动态展示看板统计
  - 有「复核发货」菜单:今日订单、已复核
  - 有「订单拣货」菜单:今日订单、未拣货
  - 两者都有:今日订单、未拣货、已复核
- 点击通知区域弹出「看板统计」弹窗,展示项与通知栏一致(均按菜单控制)
- 修复通知栏与仓库主体布局,仓库名不再被压缩,并调大两者间距
This commit is contained in:
zm2000 2026-09-28 20:09:43 +08:00
parent 428f06ebd3
commit c443f7ccae
4 changed files with 380 additions and 86 deletions

View File

@ -109,6 +109,15 @@ export default {
isSystemApi: true
}
},
/** 看板 ↓ **/
dashboard: {
storeStats: {
path: "dashboard.storeStats",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 仓库 ↓ **/
warehouse: {
getSpaceInfo: {

View File

@ -10,8 +10,8 @@
<text class="org-id">{{ userInfo.employees_name || '---' }}</text>
</view>
<u-icon @click="showStoreSelector" name="arrow-down" size="16" color="#666" v-if="userInfo.employees && userInfo.employees.length > 1"></u-icon>
<view class="news-wrapper" @click="toNewsPage">
<u-notice-bar :text="newsList[0]" mode="horizontal" bg-color="transparent" color="#666"
<view class="news-wrapper" @click="openNoticePopup">
<u-notice-bar :text="noticeText" mode="horizontal" bg-color="transparent" color="#666"
:font-size="12" :padding="0" :radius="0" :volume-icon="false" :more-icon="false" :speed="60"
:height="30" :autoplay="true"></u-notice-bar>
</view>
@ -136,6 +136,23 @@
</view>
</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>
@ -153,11 +170,10 @@
currentPage: 1,
scrollTop: 0,
userInfo: {},
newsList: [
'欢迎使用PDA仓库管理系统',
'请及时处理待办任务',
'祝您工作愉快'
],
dashboardStats: null,
hasReviewShippingMenu: false,
hasOrderPickingMenu: false,
showNoticePopup: false,
unreadCount: 0,
quickActions: [],
pageSize: 12,
@ -271,6 +287,41 @@
left: `${this.dragState.previewX}px`,
top: `${this.dragState.previewY}px`
};
},
noticeText() {
const stats = this.dashboardStats || null;
if (!stats || (!this.hasReviewShippingMenu && !this.hasOrderPickingMenu)) {
return '欢迎使用PDA仓库管理系统';
}
const parts = [];
parts.push(`今日订单 ${this.formatStatNumber(stats.todayOrders)}`);
if (this.hasOrderPickingMenu) {
parts.push(`未拣货 ${this.formatStatNumber(stats.unpickedOrders)}`);
}
if (this.hasReviewShippingMenu) {
parts.push(`已复核 ${this.formatStatNumber(stats.recheckedOrders)}`);
}
return parts.join(',');
},
noticeStatItems() {
const stats = this.dashboardStats || null;
if (!stats || (!this.hasReviewShippingMenu && !this.hasOrderPickingMenu)) {
return [];
}
const f = this.formatStatNumber;
const items = [];
items.push({ label: '今日订单', value: f(stats.todayOrders) });
if (this.hasOrderPickingMenu) {
items.push({ label: '未拣货', value: f(stats.unpickedOrders) });
}
if (this.hasReviewShippingMenu) {
items.push({ label: '已复核', value: f(stats.recheckedOrders) });
}
return items;
}
},
@ -461,6 +512,7 @@
async loadUserInfo() {
await this.refreshQuickActions();
await this.loadDashboardStats();
},
// 刷新快捷入口
@ -471,6 +523,8 @@
const latestUser = await this.getLatestUserInfo();
if (!latestUser) {
console.log('用户信息不可用,快捷入口置空');
this.hasReviewShippingMenu = false;
this.hasOrderPickingMenu = false;
this.quickActions = [];
this.ensureCurrentPageInRange();
return;
@ -480,6 +534,9 @@
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);
@ -516,6 +573,52 @@
}
},
// 根据用户菜单识别看板相关功能(复核发货 / 订单拣货)
detectDashboardMenus(actions) {
const list = Array.isArray(actions) ? actions.filter(Boolean) : [];
this.hasReviewShippingMenu = list.some(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('拣货'));
});
},
// 加载仓库/货主看板统计
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;
}
},
formatStatNumber(value) {
const num = Number(value);
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) {
@ -1261,6 +1364,14 @@
});
},
openNoticePopup() {
this.showNoticePopup = true;
},
closeNoticePopup() {
this.showNoticePopup = false;
},
toEditPage() {
uni.navigateTo({
url: '/pages/home/edit-quick-actions'
@ -1316,7 +1427,10 @@
}
.org-info {
flex: 1;
flex: 0 0 auto;
max-width: 40%;
min-width: 0;
margin-right: 40rpx;
.org-name {
font-size: 28rpx;
@ -1324,12 +1438,29 @@
color: #333;
display: block;
line-height: 1.4;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.org-id {
font-size: 22rpx;
color: #909399;
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.news-wrapper {
flex: 1;
min-width: 0;
overflow: hidden;
::v-deep .u-notice-bar {
height: 30rpx !important;
line-height: 30rpx !important;
}
}
}
@ -1339,17 +1470,6 @@
align-items: center;
justify-content: space-between;
.news-wrapper {
flex: 1;
margin-right: 20rpx;
overflow: hidden;
::v-deep .u-notice-bar {
height: 30rpx !important;
line-height: 30rpx !important;
}
}
.message-bell {
position: relative;
width: 60rpx;
@ -1757,4 +1877,55 @@
color: #ccc;
}
}
// 看板统计弹窗
.notice-popup {
padding: 32rpx 30rpx 40rpx;
&__header {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30rpx;
}
&__title {
font-size: 32rpx;
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: #f5f6f8;
border-radius: 12rpx;
padding: 24rpx 12rpx;
display: flex;
flex-direction: column;
align-items: center;
}
&__value {
font-size: 34rpx;
font-weight: 600;
color: #2979ff;
margin-bottom: 8rpx;
}
&__label {
font-size: 22rpx;
color: #909399;
}
}
</style>

View File

@ -8,7 +8,7 @@
<view class="search-input-wrap">
<u-search
v-model="keyword"
placeholder="请输入/扫描商品条码、名称或操作人"
:placeholder="searchPlaceholder"
:bg-color="'#f5f5f5'"
shape="round"
:show-action="false"
@ -25,18 +25,33 @@
</view>
</view>
</view>
</view>
<!-- 移库类型筛选 -->
<view class="type-filter">
<view
v-for="opt in transferTypeOptions"
:key="opt.value"
class="type-filter__item"
:class="{ 'type-filter__item--active': transferType === opt.value }"
@click="handleTypeChange(opt.value)"
>
<text class="type-filter__item-text">{{ opt.label }}</text>
<view class="filter-row">
<view class="filter-group">
<view
v-for="opt in searchDimensionOptions"
:key="opt.value"
class="filter-group__item"
:class="{ 'filter-group__item--active': searchDimension === opt.value }"
@click="handleDimensionChange(opt.value)"
>
<text class="filter-group__item-text">{{ opt.label }}</text>
</view>
</view>
<view class="filter-divider"></view>
<view class="filter-group">
<view
v-for="opt in transferTypeOptions"
:key="opt.value"
class="filter-group__item"
:class="{
'filter-group__item--active': transferType === opt.value,
'filter-group__item--warning': transferType === opt.value && opt.value === 'TRANSFER_OUT'
}"
@click="handleTypeChange(opt.value)"
>
<text class="filter-group__item-text">{{ opt.label }}</text>
</view>
</view>
</view>
</view>
@ -49,33 +64,33 @@
</view>
<view v-else class="record-list">
<view v-for="(item, index) in recordList" :key="item.id || index" class="record-card">
<view class="record-card__row">
<text class="record-card__label">商品编码</text>
<text class="record-card__value">{{ item.barcode || '--' }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">商品名称</text>
<text class="record-card__value">{{ item.name || '--' }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">操作时间</text>
<text class="record-card__value">{{ item.timeText || '--' }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">操作人</text>
<text class="record-card__value">{{ item.operator || '--' }}</text>
<text class="record-card__label">商品编码</text>
<text class="record-card__value">{{ item.barcode || '--' }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">数量</text>
<text class="record-card__value record-card__value--strong">{{ item.quantityText }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">移出库位</text>
<text class="record-card__value">{{ item.fromSpace || '--' }}</text>
<text class="record-card__label">{{ item.transactionType === 'TRANSFER_OUT' ? '移出库位' : '移入库位' }}</text>
<text class="record-card__value">{{ item.transactionType === 'TRANSFER_OUT' ? (item.fromSpace || '--') : (item.toSpace || '--') }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">批次号</text>
<text class="record-card__value">{{ item.batchNo || '--' }}</text>
</view>
<view class="record-card__row">
<text class="record-card__label">操作人</text>
<text class="record-card__value">{{ item.operator || '--' }}</text>
</view>
<view class="record-card__row record-card__row--last">
<text class="record-card__label">移入库位</text>
<text class="record-card__value">{{ item.toSpace || '--' }}</text>
<text class="record-card__label">操作时间</text>
<text class="record-card__value">{{ item.timeText || '--' }}</text>
</view>
</view>
</view>
@ -106,6 +121,11 @@ export default {
data() {
return {
keyword: '',
searchDimension: 'PRODUCT',
searchDimensionOptions: [
{ label: '商品', value: 'PRODUCT' },
{ label: '操作人', value: 'OPERATOR' }
],
transferType: 'TRANSFER_IN',
transferTypeOptions: [
{ label: '移入', value: 'TRANSFER_IN' },
@ -118,6 +138,11 @@ export default {
loading: false
}
},
computed: {
searchPlaceholder() {
return this.searchDimension === 'OPERATOR' ? '请输入操作人名称' : '请输入/扫描商品条码或名称';
}
},
onLoad(options = {}) {
// 支持通过 ?keyword=xxx 预填关键字并自动查询
const preset = String(options.keyword || '').trim();
@ -133,11 +158,16 @@ export default {
onShow() {
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
this.safeDispatchBroadcast('resume');
this.scheduleBroadcastSelfHeal();
},
onHide() {
this.safeDispatchBroadcast('pause');
},
onUnload() {
if (this._broadcastHealTimer) {
clearTimeout(this._broadcastHealTimer);
this._broadcastHealTimer = null;
}
this.safeDispatchBroadcast('stop');
},
methods: {
@ -152,6 +182,16 @@ export default {
console.warn(`[inventoryTransfer] broadcast/${action} 调用异常:`, error);
}
},
scheduleBroadcastSelfHeal() {
if (this._broadcastHealTimer) {
clearTimeout(this._broadcastHealTimer);
}
this._broadcastHealTimer = setTimeout(() => {
// 兼容跳转时序竞态:旧页 onHide 的 pause(=stop) 可能晚于本页 onShow 执行,导致广播被误停
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
this.safeDispatchBroadcast('start');
}, 1200);
},
normalizeScanResult(scanResult) {
if (!scanResult) return '';
if (typeof scanResult === 'string') return scanResult.trim();
@ -196,6 +236,11 @@ export default {
this.transferType = value;
this.loadRecordList(1);
},
handleDimensionChange(value) {
if (this.searchDimension === value) return;
this.searchDimension = value;
this.loadRecordList(1);
},
handlePageChange(page) {
const targetPage = Math.max(1, Number(page || 1));
if (targetPage === this.currentPage) return;
@ -203,25 +248,46 @@ export default {
this.loadRecordList(targetPage);
},
buildRecordParams(page = this.currentPage) {
const targetPage = Math.max(1, Number(page || 1));
const pageSize = Math.max(1, Number(this.pageSize || 20));
const params = {
group_by_batch: true,
pagination: {
page: Math.max(1, Number(page || 1)),
pageSize: Math.max(1, Number(this.pageSize || 20))
page: targetPage,
pageSize
},
sort: {
sortField: 'created_at',
sortOrder: 'DESC'
}
};
const where = {};
const keyword = String(this.keyword || '').trim();
if (keyword) {
params.keyword = keyword;
if (this.searchDimension === 'OPERATOR') {
where.operator_name = {
operator: 'like',
value: keyword,
type: 'text'
};
} else {
where.keyword = {
operator: 'contains',
value: [keyword],
type: 'text'
};
}
}
if (this.transferType) {
params.where = {
transaction_type: {
operator: 'eq',
value: this.transferType,
type: 'select'
}
where.transaction_type = {
operator: 'eq',
value: this.transferType,
type: 'select'
};
}
if (Object.keys(where).length) {
params.where = where;
}
return params;
},
extractRecordPayload(response) {
@ -314,6 +380,9 @@ export default {
'operator_name', 'operatorName', 'operator', 'operate_user', 'operateUser',
'create_user', 'createUser', 'user_name', 'userName', 'scanner_name'
]);
const batchNo = this.firstValue(merged, [
'batch_no', 'batchNo', 'batch_number', 'batchNumber'
]);
const transactionType = String(source.transaction_type || source.transactionType || '').trim();
// 单库位流水:库位可能是 space_code/space_name 或仅 space_id
const spaceId = this.firstValue(source, ['space_id', 'spaceId']);
@ -352,6 +421,7 @@ export default {
barcode,
name,
operator,
batchNo,
fromSpace,
toSpace,
spaceId,
@ -514,7 +584,7 @@ export default {
flex-shrink: 0;
&__text {
font-size: 30rpx;
font-size: 34rpx;
font-weight: 500;
color: #2979ff;
line-height: 1;
@ -525,43 +595,67 @@ export default {
}
}
/* 移库类型筛选 */
.type-filter {
background: #ffffff;
border-bottom: 1rpx solid #f2f2f2;
padding: 8rpx 16rpx 20rpx;
box-sizing: border-box;
/* 筛选条件行(商品/操作人 | 移入/移出) */
.filter-row {
margin-top: 16rpx;
display: flex;
flex-wrap: wrap;
gap: 16rpx;
flex-shrink: 0;
align-items: center;
}
.type-filter__item {
height: 60rpx;
padding: 0 32rpx;
.filter-group {
flex: 1;
display: flex;
}
.filter-group__item {
flex: 1;
height: 56rpx;
padding: 0 12rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f5f7fa;
border: 1rpx solid #ebeef5;
border-radius: 30rpx;
border-radius: 28rpx;
}
.type-filter__item--active {
.filter-group__item + .filter-group__item {
margin-left: 16rpx;
}
.filter-group__item--active {
background: #ecf3ff;
border-color: #2979ff;
}
.type-filter__item-text {
font-size: 28rpx;
.filter-group__item-text {
font-size: 30rpx;
color: #303133;
white-space: nowrap;
}
.type-filter__item--active .type-filter__item-text {
.filter-group__item--active .filter-group__item-text {
color: #2979ff;
}
/* 移出(橙色警示) */
.filter-group__item--warning {
background: #fff7e6;
border-color: #ff9800;
}
.filter-group__item--warning .filter-group__item-text {
color: #ff9800;
}
.filter-divider {
width: 1rpx;
height: 36rpx;
margin: 0 16rpx;
background: #dcdfe6;
flex-shrink: 0;
}
/* 列表区 */
.detail-scroll {
flex: 1;
@ -581,13 +675,13 @@ export default {
.empty-text {
margin-top: 24rpx;
font-size: 32rpx;
font-size: 36rpx;
color: #909399;
}
.empty-hint {
margin-top: 12rpx;
font-size: 26rpx;
font-size: 30rpx;
color: #c0c4cc;
}
@ -600,18 +694,18 @@ export default {
.record-card {
background: #ffffff;
border: 2rpx solid #ebeef5;
border-radius: 16rpx;
padding: 8rpx 24rpx;
margin-bottom: 16rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
border: 2rpx solid #ebedf2;
border-radius: 20rpx;
padding: 4rpx 28rpx;
margin-bottom: 20rpx;
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
}
.record-card__row {
display: flex;
align-items: flex-start;
padding: 18rpx 0;
border-bottom: 1rpx solid #f5f5f5;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f2f5;
}
.record-card__row--last {
@ -621,15 +715,15 @@ export default {
.record-card__label {
flex-shrink: 0;
width: 160rpx;
font-size: 28rpx;
color: #909399;
font-size: 36rpx;
color: #8a9099;
line-height: 1.5;
}
.record-card__value {
flex: 1;
min-width: 0;
font-size: 30rpx;
font-size: 40rpx;
color: #303133;
line-height: 1.5;
word-break: break-all;
@ -651,5 +745,10 @@ export default {
border-top: 1rpx solid #f0f0f0;
padding: 0 24rpx env(safe-area-inset-bottom);
flex-shrink: 0;
::v-deep .total-info {
font-size: 32rpx;
color: #606266;
}
}
</style>

View File

@ -100,7 +100,7 @@
<text class="image-index-text">1/{{ getImageCount(item) }}</text>
</view>
</view>
<view class="item-info">
<view class="item-info" @click.stop="goTransferRecord(item)">
<view class="item-row">
<text class="label">货主:</text>
<text class="value">{{ getStoreOwnerText(item) }}</text>
@ -2150,6 +2150,21 @@
urls
});
},
goTransferRecord(item) {
if (!item || typeof item !== 'object') {
return;
}
// 预填条码/编码优先,其次名称,跳转到移库记录页并自动查询
const keyword = String(
item.item_code || item.goods_code || item.barcode || item.bar_code
|| item.item_name || item.product_name || item.name || ''
).trim();
const query = keyword ? `?keyword=${encodeURIComponent(keyword)}` : '';
uni.navigateTo({
url: `/pages/warehouse/inventoryTransfer${query}`
});
},
async goProductDetail(item) {
if (!item || typeof item !== 'object') {
return;