WMS_PDA/src/pages/work/storage/random-storage.vue
zm2000 7c90d2f498 feat(receiving): 收货管理模块界面优化,统一字号与状态色
- 收货详情/收货单信息(info-container)
  * 表单标签、输入框、单选、文本域、状态标签字号统一为 36rpx
  * 状态色统一:收货中-橙、已完成-绿、已取消-红
  * 备注框由 u-input 改为 u-textarea 长文本
  * 打印按钮字号 36rpx,并增加与收货单号框的间隔
  * 物流单号相机按钮调大
  * 货主选择框样式对齐新建页,单选选项增加间隔
- 新建收货任务(receivingCreate)
  * 表单字号统一 36rpx
  * 货主选择改为底部弹窗,来货照片与装卸信息优化
- 收货列表(receiving)
  * 新增状态/货主/日期筛选弹窗与创建收货任务入口
  * 状态标签按状态着色
  * 界面字号统一
- 收货明细/清单(detail-container、receivingList)
  * 空状态提示字号 34rpx
  * 明细状态色统一,标题字号调整
- random-storage
  * 样式微调:增加底部间距与分隔线
2026-11-17 18:11:53 +08:00

553 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="random-storage-list-page">
<view class="normar_container">
<page-nav title="随机入库" :showBack="true" @back="handleBack"></page-nav>
<view class="search-filter">
<view class="search-row">
<SearchBar
v-model="searchKeyword"
placeholder="扫描/输入入库单号、采购单号、供应商..."
:show-search="true"
:input-font-size="'34rpx'"
:search-text-font-size="'34rpx'"
@search="handleSearch"
@clear="handleClearSearch"
@scan="handleScan"
></SearchBar>
</view>
</view>
<scroll-view class="list-content" scroll-y>
<view v-if="!loading && entryList.length === 0" class="empty-state">
<u-icon name="list-dot" size="100" color="#ccc"></u-icon>
<text class="empty-text">暂无待入库单</text>
<text class="empty-hint">可通过上方搜索框或扫码查找入库单</text>
</view>
<view class="entry-items">
<view
v-for="item in entryList"
:key="item.id || item.entry_order_code"
class="entry-card"
@click="openShelfPage(item)"
>
<view class="entry-card__header">
<text class="entry-card__code">{{ item.entry_order_code || '--' }}</text>
<u-tag :text="getStatusText(item.order_status)" :type="getStatusType(item.order_status)" size="mini"></u-tag>
</view>
<view class="entry-card__meta">
<text class="entry-card__meta-text">类型:{{ item.order_type || '--' }}</text>
<text class="entry-card__meta-text">行数:{{ item.total_order_lines || 0 }}</text>
</view>
<view class="entry-card__body">
<view class="entry-card__row">
<text class="entry-card__label">采购单号</text>
<text class="entry-card__value">{{ item.purchase_order_code || '--' }}</text>
</view>
<view class="entry-card__row">
<text class="entry-card__label">供应商</text>
<text class="entry-card__value">{{ item.supplier_name || '--' }}</text>
</view>
<view class="entry-card__row">
<text class="entry-card__label">货主</text>
<text class="entry-card__value">{{ item.store_name || '--' }}</text>
</view>
<view class="entry-card__row">
<text class="entry-card__label">仓库</text>
<text class="entry-card__value">{{ item.warehouse_name || '--' }}</text>
</view>
</view>
<view class="entry-card__footer">
<view class="entry-card__badges">
<u-tag
:text="item.hasReceiving ? '已绑定收货单' : '未绑定收货单'"
:type="item.hasReceiving ? 'success' : 'info'"
:plain="true"
size="mini"
></u-tag>
<u-tag
v-for="(receivingNo, receivingIndex) in getReceivingNumbers(item)"
:key="`${item.id || item.entry_order_code}-receiving-${receivingIndex}`"
:text="`收货单 ${receivingNo}`"
type="warning"
:plain="true"
size="mini"
></u-tag>
</view>
<text class="entry-card__time">创建:{{ formatDateTime(item.created_at) }}</text>
</view>
</view>
</view>
<view class="safe-area-bottom"></view>
</scroll-view>
<pagination
:pageNum.sync="currentPage"
:pageSize="pageSize"
:total="totalItems"
:showTotal="true"
:prevText="'上一页'"
:nextText="'下一页'"
:showFirstLast="true"
:firstText="'首页'"
:lastText="'末页'"
@change="handlePageChange"
/>
</view>
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
</view>
</template>
<script>
import voice from '@/core/utils/voice';
export default {
data() {
return {
loading: false,
searchKeyword: '',
entryList: [],
pageSize: 20,
currentPage: 1,
totalPages: 0,
totalItems: 0,
refreshMarker: 0
};
},
onLoad() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('start');
this.consumeRefreshFlag();
this.loadEntryList();
},
onShow() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
this.consumeRefreshFlag();
},
onHide() {
this.safeDispatchBroadcast('pause');
},
onUnload() {
this.safeDispatchBroadcast('stop');
},
methods: {
speakVoice(text) {
voice.speak(text, { minInterval: 800 });
},
safeDispatchBroadcast(action, payload) {
try {
const task = this.$store.dispatch(`broadcast/${action}`, payload);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn(`[RandomStorageList] broadcast/${action} 调用失败:`, error);
});
}
} catch (error) {
console.warn(`[RandomStorageList] broadcast/${action} 调用异常:`, error);
}
},
consumeRefreshFlag() {
const marker = Number(uni.getStorageSync('random_storage_need_refresh') || 0);
if (marker && marker !== this.refreshMarker) {
this.refreshMarker = marker;
uni.removeStorageSync('random_storage_need_refresh');
this.loadEntryList();
}
},
handleBack() {
uni.navigateBack({ delta: 1 });
},
normalizeKeyword(value) {
return String(value || '').replace(/\s+/g, '');
},
normalizeScanResult(scanResult) {
if (!scanResult) return '';
if (typeof scanResult === 'string') return this.normalizeKeyword(scanResult);
if (typeof scanResult.result === 'string') return this.normalizeKeyword(scanResult.result);
if (Array.isArray(scanResult.result)) {
const first = scanResult.result.find(item => item);
if (typeof first === 'string') return this.normalizeKeyword(first);
if (first && typeof first.data === 'string') return this.normalizeKeyword(first.data);
}
if (typeof scanResult.data === 'string') return this.normalizeKeyword(scanResult.data);
return '';
},
handleBroadcastResult(result) {
const scanText = this.normalizeScanResult(result);
if (!scanText) return;
this.searchKeyword = scanText;
this.handleSearch();
},
handleSearch() {
this.currentPage = 1;
this.loadEntryList();
},
handleClearSearch() {
this.searchKeyword = '';
this.currentPage = 1;
this.loadEntryList();
},
handleScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
success: (res) => {
const scanText = this.normalizeScanResult(res);
if (!scanText) {
uni.showToast({ title: '未识别到有效条码', icon: 'none' });
return;
}
this.searchKeyword = scanText;
this.handleSearch();
},
fail: (error) => {
const errMsg = String(error?.errMsg || '').toLowerCase();
if (errMsg.includes('cancel')) return;
uni.showToast({ title: '扫码失败,请重试', icon: 'none' });
}
});
},
buildWhere() {
const where = {
order_status: {
field: 'order_status',
operator: 'eq',
type: 'string',
value: 'PENDING'
}
};
const keyword = this.normalizeKeyword(this.searchKeyword);
if (keyword) {
where.quickWhere = {
value: keyword
};
}
return where;
},
async loadEntryList() {
if (this.loading) return;
this.loading = true;
try {
const res = await this.$http('storage.entry.list', {
pagination: {
page: this.currentPage,
pageSize: this.pageSize
},
where: this.buildWhere()
});
const isSuccess = String(res?.code || '') === '200' || String(res?.flag || '').toLowerCase() === 'success';
if (!isSuccess) {
this.entryList = [];
this.totalPages = 0;
this.totalItems = 0;
uni.showToast({ title: res?.message || '查询入库单失败', icon: 'none' });
return;
}
const data = res?.data?.data || res?.data || {};
const list = Array.isArray(data.list) ? data.list : [];
const pagination = data.pagination || {};
const summary = data.summary || {};
this.entryList = list;
this.totalItems = Number(pagination.total || summary.total || list.length || 0);
this.totalPages = Number(pagination.totalPages || Math.ceil(this.totalItems / this.pageSize) || 0);
this.currentPage = Number(pagination.page || this.currentPage || 1);
// 待入库列表为空且带关键词时,去掉 order_status 条件再查一次,仅用于判断是否已入库,不参与列表展示
if (list.length === 0 && this.normalizeKeyword(this.searchKeyword)) {
this.checkAlreadyInbound(this.searchKeyword);
}
} catch (error) {
const msg = String(error?.message || error?.msg || '查询入库单失败');
uni.showToast({ title: msg, icon: 'none' });
} finally {
this.loading = false;
}
},
async checkAlreadyInbound(keyword) {
const normalizedKeyword = this.normalizeKeyword(keyword);
if (!normalizedKeyword) return;
try {
// 不带 order_status 条件,仅按关键词查询,用于判断该单是否已不在待入库列表(如已入库)
const res = await this.$http('storage.entry.list', {
pagination: {
page: 1,
pageSize: this.pageSize
},
where: {
quickWhere: {
value: normalizedKeyword
}
}
});
const isSuccess = String(res?.code || '') === '200' || String(res?.flag || '').toLowerCase() === 'success';
if (!isSuccess) return;
const data = res?.data?.data || res?.data || {};
const list = Array.isArray(data.list) ? data.list : [];
// 关键词与返回列表的入库单号对比,命中则提示已入库(二次查询结果不用于展示)
const matched = list.some(item =>
this.normalizeKeyword(item?.entry_order_code) === normalizedKeyword
);
if (matched) {
uni.showToast({ title: '已入库', icon: 'none' });
this.speakVoice('已入库');
}
} catch (error) {
// 二次查询仅用于提示,异常时静默忽略,不影响主流程
console.warn('[RandomStorageList] checkAlreadyInbound 查询异常:', error);
}
},
handlePageChange(pageNum) {
const nextPage = Number(pageNum?.pageNum || pageNum?.page || pageNum);
this.currentPage = Number.isFinite(nextPage) && nextPage > 0 ? nextPage : 1;
this.loadEntryList();
},
getReceivingNumbers(item) {
const bindings = Array.isArray(item?.receivingBindings) ? item.receivingBindings : [];
return bindings
.map(binding => binding?.receiving?.receiving_number || binding?.receiving_id)
.filter(Boolean)
.slice(0, 2);
},
openShelfPage(item) {
const entryOrderCode = String(item?.entry_order_code || '').trim();
if (!entryOrderCode) {
uni.showToast({ title: '缺少入库单号', icon: 'none' });
return;
}
uni.navigateTo({
url: `/pages/work/storage/random-storage-shelf?entryOrderCode=${encodeURIComponent(entryOrderCode)}`
});
},
getStatusText(status) {
switch (String(status || '').toUpperCase()) {
case 'CREATING':
return '创建中';
case 'CREATED':
return '待审核';
case 'PENDING':
return '已审核';
case 'COMPLETED':
return '已完成';
case 'CANCELLED':
return '已取消';
default:
return status || '--';
}
},
getStatusType(status) {
switch (String(status || '').toUpperCase()) {
case 'CREATED':
return 'warning';
case 'PENDING':
return 'primary';
case 'COMPLETED':
return 'success';
case 'CANCELLED':
return 'error';
default:
return 'info';
}
},
formatDateTime(value) {
if (!value) return '--';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return String(value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}`;
}
}
};
</script>
<style lang="scss" scoped>
.random-storage-list-page {
height: 100vh;
background: #f8f9fa;
}
.normar_container {
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.search-filter {
background: #ffffff;
padding: 20rpx 24rpx 12rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.search-row {
display: flex;
align-items: center;
gap: 10rpx;
}
.list-content {
flex: 1;
height: 0;
min-height: 0;
padding: 20rpx 24rpx 0;
box-sizing: border-box;
}
.empty-state {
min-height: 50vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 14rpx;
color: #909399;
}
.empty-text {
font-size: 34rpx;
font-weight: 600;
color: #303133;
}
.empty-hint {
font-size: 26rpx;
color: #909399;
text-align: center;
}
.entry-items {
display: flex;
flex-direction: column;
padding-bottom: 24rpx;
}
.entry-items .entry-card + .entry-card {
margin-top: 20rpx;
}
.entry-card {
background: #ffffff;
border-radius: 18rpx;
padding: 22rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.entry-card:active {
opacity: 0.92;
}
.entry-card__header {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 15rpx;
border-bottom: 1rpx solid #f0f0f0;
::v-deep .u-tag__text {
font-size: 36rpx;
line-height: 36rpx;
}
}
.entry-card__code {
font-size: 38rpx;
font-weight: bold;
color: #303133;
flex: 1;
min-width: 0;
word-break: break-all;
}
.entry-card__body {
margin-top: 18rpx;
display: flex;
flex-direction: column;
}
.entry-card__body .entry-card__row + .entry-card__row {
margin-top: 12rpx;
}
.entry-card__meta {
margin-top: 10rpx;
display: flex;
align-items: center;
}
.entry-card__meta-text {
font-size: 34rpx;
color: #909399;
}
.entry-card__meta-text + .entry-card__meta-text {
margin-left: 20rpx;
}
.entry-card__row {
display: flex;
align-items: flex-start;
font-size: 36rpx;
line-height: 1.5;
}
.entry-card__label {
width: 160rpx;
flex-shrink: 0;
white-space: nowrap;
color: #909399;
margin-right: 12rpx;
}
.entry-card__value {
flex: 1;
min-width: 0;
color: #303133;
word-break: break-all;
}
.entry-card__footer {
margin-top: 18rpx;
display: flex;
flex-direction: column;
}
.entry-card__badges {
display: flex;
flex-wrap: wrap;
margin-bottom: -10rpx;
::v-deep .u-tag__text {
font-size: 34rpx;
line-height: 34rpx;
}
::v-deep .u-transition {
margin-right: 10rpx;
margin-bottom: 10rpx;
}
}
.entry-card__time {
margin-top: 12rpx;
font-size: 34rpx;
color: #909399;
}
.safe-area-bottom {
height: calc(20rpx + env(safe-area-inset-bottom));
}
</style>