新增随机入库模块,修改散单复核模块

This commit is contained in:
zm2000 2026-06-23 18:43:08 +08:00
parent 2aef552697
commit df7ba01211
4 changed files with 574 additions and 65 deletions

View File

@ -4,7 +4,7 @@
<view class="nav-title">
<view class="left">
<view class="left-back" @click="back">
<u-icon v-if="showBack" name="arrow-left"></u-icon>
<u-icon v-if="effectiveShowBack" name="arrow-left"></u-icon>
<u-icon v-else name="home" @click="toHome"></u-icon>
</view>
<slot name="left"></slot>
@ -21,20 +21,30 @@
export default {
props: {
title: String,
showBack: {
type: Boolean,
default: undefined
}
},
data() {
return {
showBack: true, // 默认显示返回按钮
internalShowBack: true, // 默认显示返回按钮
pagesLength: 0
}
},
computed: {
effectiveShowBack() {
// 如果父组件显式传了 showBack,优先使用;否则用自动检测值
return this.showBack !== undefined ? this.showBack : this.internalShowBack;
}
},
methods: {
checkPagesLength() {
// 获取当前页面栈
const pages = getCurrentPages();
this.pagesLength = pages.length;
this.showBack = pages.length > 1;
console.log('当前页面栈长度:', pages.length, '显示返回按钮:', this.showBack);
this.internalShowBack = pages.length > 1;
console.log('当前页面栈长度:', pages.length, '显示返回按钮:', this.internalShowBack);
},
back() {
console.log("返回");
@ -43,7 +53,7 @@
return;
}
if (this.showBack) {
if (this.effectiveShowBack) {
// 有上一页,正常返回
uni.navigateBack({
delta: 1,

View File

@ -182,6 +182,18 @@ export default {
auth: true,
method: "POST",
isSystemApi: true
},
addItem: {
path: "storage.directInbound.addItem",
auth: true,
method: "POST",
isSystemApi: true
},
commit: {
path: "storage.directInbound.commit",
auth: true,
method: "POST",
isSystemApi: true
}
}
},

View File

@ -189,6 +189,7 @@
<text class="settings-label">打印模式</text>
<view class="settings-options">
<text
v-if="listType !== 'single'"
class="settings-option"
:class="{ 'settings-option--active': printMode === 'printFirst' }"
@click="printMode = 'printFirst'; saveSettings(); showSettingsPopup = false"
@ -465,6 +466,10 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
const g = kg > 0 ? Math.round(kg * 1000) : 0;
console.log('[refWeightG] itemsWeight:', this.detailInfo?.itemsWeight, 'kg:', kg, 'g:', g);
return g;
},
effectivePrintMode() {
// 散单模式只走先复核后打印
return this.listType === 'single' ? 'reviewFirst' : this.printMode;
}
},
onLoad(options) {
@ -1816,7 +1821,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
this.listExpanded = false;
// 先打印后复核:进入详情时自动触发未打印订单的打印
if (this.printMode === 'printFirst' && this.printStationId) {
if (this.effectivePrintMode === 'printFirst' && this.printStationId) {
const isGroup = this.listType === 'group';
const isAlreadyPrinted = isGroup
? (item.unprintedCount || 0) === 0 && (item.orderCount || 0) > 0
@ -1866,7 +1871,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
listType: this.detailInfo.listType
});
// 先复核后打印:复核完成后发送未打印订单的打印
if (this.printMode === 'reviewFirst' && this.printStationId) {
if (this.effectivePrintMode === 'reviewFirst' && this.printStationId) {
const isGroup = this.detailInfo?.listType === 'group';
const isAlreadyPrinted = isGroup
? (this.detailInfo?.unprintedCount || 0) === 0 && (this.detailInfo?.orderCount || 0) > 0

View File

@ -1,8 +1,11 @@
<template>
<view class="random-storage-page">
<view class="normar_container">
<page-nav title="随机入库">
<page-nav title="随机入库" :showBack="true" @back="handleBack">
<template #left>
<view class="nav-back-btn" @click="handleBack">
<u-icon name="arrow-left" size="22" color="#333"></u-icon>
</view>
<view v-if="hasInboundOrder" class="nav-cancel-btn" @click="handleCancelInbound">
<text class="nav-cancel-btn__text">取消入库</text>
</view>
@ -41,14 +44,13 @@
<!-- 已加载入库单 -->
<view v-else class="content-split">
<view class="summary-bar">
<text class="summary-label">已入总数/所有总数:</text>
<text class="summary-value">{{ summaryReceived }}</text>
<text class="summary-split">/</text>
<text class="summary-total">{{ summaryTotal }}</text>
</view>
<scroll-view class="content-top" scroll-y>
<view class="summary-bar">
<text class="summary-label">已入总数/所有总数:</text>
<text class="summary-value">{{ summaryReceived }}</text>
<text class="summary-split">/</text>
<text class="summary-total">{{ summaryTotal }}</text>
</view>
<!-- 商品详情区(占上部分80%) -->
<view class="product-detail-area">
<view class="product-detail">
@ -95,42 +97,123 @@
<!-- 订单信息区(占上部分20%) -->
<view class="order-info-area">
<view class="order-info-row">
<view class="order-info-item">
<text class="order-info-label">入库编号:</text>
<text class="order-info-value">{{ inboundOrderNo || '--' }}</text>
<!-- 左列:蓝色背景,两行连续 -->
<view class="order-info-col order-info-col--left">
<view class="order-info-col__item order-info-col__item--blue">
<text class="order-info-label">入库编号</text>
</view>
<view class="order-info-col__item order-info-col__item--blue">
<text class="order-info-label">货主</text>
</view>
</view>
<view class="order-info-item">
<text class="order-info-label">上架:</text>
<text class="order-info-value">{{ (selectedStock && selectedStock.shelf_status) || '--' }}</text>
<!-- 中列:白色背景 -->
<view class="order-info-col order-info-col--middle">
<view class="order-info-col__item order-info-col__item--white">
<text class="order-info-value order-info-value--center">{{ inboundOrderNo || '--' }}</text>
</view>
<view class="order-info-col__item order-info-col__item--white">
<text class="order-info-value order-info-value--center">{{ (selectedStock && selectedStock.owner) || '--' }}</text>
</view>
</view>
</view>
<view class="order-info-row">
<view class="order-info-item">
<text class="order-info-label">货主:</text>
<text class="order-info-value">{{ (selectedStock && selectedStock.owner) || '--' }}</text>
</view>
<view class="order-info-item">
<text class="order-info-label">维护信息:</text>
<text class="order-info-value">{{ (selectedStock && selectedStock.maintain_info) || '--' }}</text>
<!-- 右列:上蓝下绿 -->
<view class="order-info-col order-info-col--right">
<view class="order-info-col__item order-info-col__item--blue">
<view class="shelf-btn" @click="handleShelf">
<text class="shelf-btn__text">{{ (selectedStock && selectedStock.shelf_status) || '上架' }}</text>
</view>
</view>
<view class="order-info-col__item order-info-col__item--green">
<view class="shelf-btn shelf-btn--green" @click="handleMaintain">
<text class="shelf-btn__text">{{ (selectedStock && selectedStock.maintain_info) || '维护信息' }}</text>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="content-bottom">
<view class="submit-btn-wrap">
<u-button
type="primary"
:loading="submitting"
:disabled="submitting"
:customStyle="{ width: '100%', height: '88rpx', fontSize: '34rpx', borderRadius: '12rpx' }"
@click="handleSubmit"
>确认入库</u-button>
</view>
<scroll-view class="item-list-scroll" scroll-y>
<view
v-for="(item, idx) in inboundItems"
:key="item.id"
class="item-chip"
:class="{ 'item-chip--active': idx === currentItemIndex }"
@click="selectInboundItem(idx)"
>
<text class="item-chip__no">{{ idx + 1 }}</text>
<text class="item-chip__total">{{ item.planQty || 0 }}</text>
</view>
</scroll-view>
</view>
</view>
</view>
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
<!-- 上架抽屉 -->
<view v-if="showShelfDrawer" class="shelf-overlay" @click="handleShelfCancel">
<view class="shelf-drawer" @click.stop>
<!-- 头部 -->
<view class="shelf-drawer__header">
<text class="shelf-drawer__title">上架</text>
<text class="shelf-drawer__product-name">{{ selectedStock ? selectedStock.item_name : '--' }}</text>
</view>
<!-- 内容区 -->
<view class="shelf-drawer__body">
<view class="shelf-form-row">
<text class="shelf-form-label">可上架数</text>
<text class="shelf-form-value">{{ shelfFormData.availableQty }}</text>
</view>
<view class="shelf-form-row">
<text class="shelf-form-label">库位</text>
<input
class="shelf-form-input"
v-model="shelfFormData.spaceCode"
placeholder="请输入/扫描库位"
placeholder-style="color: #c0c4cc; font-size: 30rpx;"
@click="setActiveScanField('space')"
/>
</view>
<view class="shelf-form-row">
<text class="shelf-form-label">数量</text>
<input
class="shelf-form-input"
v-model="shelfFormData.quantity"
type="number"
placeholder="请输入数量"
placeholder-style="color: #c0c4cc; font-size: 30rpx;"
/>
</view>
<view class="shelf-form-row">
<text class="shelf-form-label">生产日期</text>
<view class="shelf-form-date" @click="showDatePicker = true">
<text class="shelf-form-date__text" :class="{ 'shelf-form-date__text--placeholder': !shelfFormData.productionDate }">{{ shelfFormData.productionDate || '请选择日期' }}</text>
<u-icon name="arrow-down" size="28rpx" color="#909399"></u-icon>
</view>
</view>
</view>
<!-- 底部按钮 -->
<view class="shelf-drawer__footer">
<view class="shelf-btn-submit" @click="handleShelfSubmit">
<text class="shelf-btn-submit__text">上架</text>
</view>
<view class="shelf-btn-cancel" @click="handleShelfCancel">
<text class="shelf-btn-cancel__text">取消</text>
</view>
</view>
</view>
</view>
<!-- 日期选择器 -->
<u-datetime-picker
:show="showDatePicker"
v-model="datePickerValue"
mode="date"
:min-date="minDate"
:max-date="maxDate"
@confirm="handleDateConfirm"
@cancel="showDatePicker = false"
></u-datetime-picker>
</view>
</template>
@ -150,6 +233,17 @@ import voice from '@/core/utils/voice';
summaryData: null,
currentItemIndex: 0,
activeScanField: 'productKeyword',
showShelfDrawer: false,
showDatePicker: false,
datePickerValue: Number(new Date()),
minDate: new Date(2000, 0, 1).getTime(),
maxDate: new Date(2099, 11, 31).getTime(),
shelfFormData: {
availableQty: 0,
spaceCode: '',
quantity: '',
productionDate: ''
},
selectedStock: null,
formData: {
productKeyword: '',
@ -207,6 +301,82 @@ import voice from '@/core/utils/voice';
console.warn(`[RandomStorage] broadcast/${action} 调用异常:`, error);
}
},
handleBack() {
uni.navigateBack({ delta: 1 });
},
handleShelf() {
const qty = this.selectedStock ? (this.selectedStock.remaining_qty || this.selectedStock.plan_qty || 0) : 0;
this.shelfFormData = {
availableQty: qty,
spaceCode: '',
quantity: String(qty || ''),
productionDate: ''
};
this.showShelfDrawer = true;
},
handleShelfCancel() {
this.showShelfDrawer = false;
this.showDatePicker = false;
},
handleDateConfirm(e) {
const date = new Date(e.value);
const y = date.getFullYear();
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
this.shelfFormData.productionDate = `${y}-${m}-${d}`;
this.showDatePicker = false;
},
async handleShelfSubmit() {
if (!this.shelfFormData.spaceCode) {
uni.showToast({ title: '请输入库位', icon: 'none' });
return;
}
const qty = Number(this.shelfFormData.quantity);
if (!qty || qty <= 0) {
uni.showToast({ title: '请输入有效数量', icon: 'none' });
return;
}
const currentItem = this.inboundItems[this.currentItemIndex];
if (!currentItem) {
uni.showToast({ title: '未选中商品', icon: 'none' });
return;
}
const stockId = currentItem.stockId;
if (!stockId) {
uni.showToast({ title: '商品ID无效', icon: 'none' });
return;
}
const spaceId = Number(this.shelfFormData.spaceCode);
const params = {
entry_order_code: this.inboundOrderNo,
stock_id: stockId,
quantity: qty,
inbound_type: 'pda'
};
if (Number.isFinite(spaceId)) {
params.space_id = spaceId;
}
uni.showLoading({ title: '上架中...' });
try {
const res = await this.$http('storage.directInbound.addItem', params);
uni.hideLoading();
if (res?.flag === 'failure') {
uni.showToast({ title: res?.message || '上架失败', icon: 'none' });
return;
}
uni.showToast({ title: '上架成功', icon: 'success' });
this.speakVoice('上架成功');
this.showShelfDrawer = false;
} catch (error) {
uni.hideLoading();
const msg = String(error?.message || error?.msg || '上架失败');
uni.showToast({ title: msg, icon: 'none' });
}
},
handleMaintain() {
// TODO: 跳转到维护信息页面
uni.showToast({ title: '维护信息功能开发中', icon: 'none' });
},
normalizeKeyword(value) {
return String(value || '').replace(/\s+/g, '');
},
@ -236,7 +406,11 @@ import voice from '@/core/utils/voice';
this.formData.productKeyword = scanText;
this.handleProductSearch();
} else if (this.activeScanField === 'space') {
this.formData.spaceKeyword = scanText;
if (this.showShelfDrawer) {
this.shelfFormData.spaceCode = scanText;
} else {
this.formData.spaceKeyword = scanText;
}
}
},
handleSearchInboundOrder() {
@ -318,6 +492,7 @@ import voice from '@/core/utils/voice';
const remainingQty = Number(item.remaining_quantity ?? item.remainingQty ?? (Math.max(0, planQty - receivedQty)));
return {
id: String(item.id || item.stock_id || `item-${index + 1}`),
stockId: Number(item.stock_id ?? 0),
lineNo: index + 1,
skuCode: String(item.item_code || item.skuCode || ''),
skuName: String(item.warehouse_item_name || item.item_name || item.skuName || '--'),
@ -371,8 +546,12 @@ import voice from '@/core/utils/voice';
if (!res.confirm) return;
uni.showLoading({ title: '提交中...' });
try {
await this.$http('storage.directInbound.complete', { entry_order_code: this.inboundOrderNo });
const result = await this.$http('storage.directInbound.commit', { entry_order_code: this.inboundOrderNo });
uni.hideLoading();
if (result?.flag === 'failure') {
uni.showToast({ title: result?.message || '提交失败', icon: 'none' });
return;
}
uni.showToast({ title: '入库完成', icon: 'success' });
this.speakVoice('入库完成');
this.handleClearOrder();
@ -521,7 +700,8 @@ import voice from '@/core/utils/voice';
} finally {
this.submitting = false;
}
}
},
}
};
</script>
@ -558,22 +738,30 @@ import voice from '@/core/utils/voice';
}
.content-top {
flex: 7;
flex: 6;
padding: 0 0 0;
box-sizing: border-box;
}
.content-bottom {
flex: 3;
background: #ffffff;
background: #1a1a1a;
display: flex;
align-items: center;
justify-content: center;
padding: 0 24rpx 20rpx;
align-items: stretch;
justify-content: flex-start;
padding: 0 24rpx 12rpx;
box-sizing: border-box;
}
/* ===== 导航按钮 ===== */
.nav-back-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.nav-cancel-btn {
padding: 8rpx 18rpx;
display: flex;
@ -680,7 +868,7 @@ import voice from '@/core/utils/voice';
/* ===== 商品详情区 ===== */
.product-detail-area {
height: 80%;
height: 75%;
background: #ffffff;
padding: 20rpx 24rpx;
box-sizing: border-box;
@ -728,12 +916,12 @@ import voice from '@/core/utils/voice';
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
justify-content: flex-start;
gap: 14rpx;
}
.product-name {
font-size: 34rpx;
font-size: 38rpx;
font-weight: 600;
color: #303133;
margin-bottom: 4rpx;
@ -746,13 +934,13 @@ import voice from '@/core/utils/voice';
}
.product-info-label {
font-size: 26rpx;
color: #909399;
font-size: 30rpx;
color: #303133;
flex-shrink: 0;
}
.product-info-value {
font-size: 26rpx;
font-size: 30rpx;
color: #303133;
flex: 1;
}
@ -764,26 +952,64 @@ import voice from '@/core/utils/voice';
.product-info-value-qty {
color: #f56c6c;
font-weight: 600;
font-size: 28rpx;
font-size: 32rpx;
}
/* ===== 订单信息区 ===== */
.order-info-area {
height: 20%;
height: auto;
background: #ffffff;
border-top: 1rpx solid #f2f3f5;
padding: 16rpx 24rpx;
padding: 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
gap: 12rpx;
}
.order-info-row {
display: flex;
align-items: stretch;
gap: 0;
}
.order-info-col {
display: flex;
flex-direction: column;
border-radius: 8rpx;
overflow: hidden;
}
.order-info-col--left {
flex: 1;
}
.order-info-col--middle {
flex: 2;
}
.order-info-col--right {
flex: 1;
}
.order-info-col__item {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
justify-content: center;
padding: 12rpx 8rpx;
}
.order-info-col__item--blue {
background: #b1cfff;
}
.order-info-col__item--white {
background: #ffffff;
}
.order-info-col__item--green {
background: #d4edda;
}
.order-info-item {
@ -794,21 +1020,277 @@ import voice from '@/core/utils/voice';
}
.order-info-label {
font-size: 26rpx;
color: #909399;
font-size: 30rpx;
color: #303133;
flex-shrink: 0;
}
.order-info-value {
font-size: 26rpx;
font-size: 30rpx;
color: #303133;
flex: 1;
}
.order-info-value--center {
text-align: center;
}
.order-info-item--center .order-info-value {
text-align: center;
}
.order-info-item--right {
flex: none;
justify-content: flex-end;
}
.shelf-btn {
display: inline-flex;
align-items: center;
padding: 4rpx 0;
}
.shelf-btn:active {
opacity: 0.5;
}
.shelf-btn__text {
font-size: 30rpx;
color: #2979ff;
line-height: 1.4;
}
.order-info-col__item--green .shelf-btn__text {
color: #07c160;
}
.shelf-btn--green .shelf-btn__text {
color: #07c160;
}
.submit-btn-wrap {
width: 100%;
}
/* ===== 上架抽屉 ===== */
.shelf-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 999;
display: flex;
align-items: flex-end;
justify-content: center;
}
.shelf-drawer {
width: 100%;
background: #ffffff;
border-radius: 24rpx 24rpx 0 0;
display: flex;
flex-direction: column;
height: 80vh;
overflow: hidden;
animation: slideUp 0.3s ease;
}
@keyframes slideUp {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
.shelf-drawer__header {
display: flex;
align-items: center;
padding: 30rpx 32rpx 20rpx;
border-bottom: 1rpx solid #f2f3f5;
gap: 12rpx;
}
.shelf-drawer__title {
font-size: 36rpx;
font-weight: 600;
color: #303133;
flex-shrink: 0;
}
.shelf-drawer__product-name {
font-size: 34rpx;
color: #303133;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.shelf-drawer__body {
padding: 24rpx 32rpx;
display: flex;
flex-direction: column;
gap: 28rpx;
overflow-y: auto;
flex: 1;
}
.shelf-form-row {
display: flex;
align-items: center;
min-height: 72rpx;
}
.shelf-form-label {
font-size: 32rpx;
color: #303133;
width: 160rpx;
flex-shrink: 0;
}
.shelf-form-value {
font-size: 32rpx;
color: #f56c6c;
font-weight: 600;
}
.shelf-form-input {
flex: 1;
height: 72rpx;
background: #f5f7fa;
border-radius: 8rpx;
padding: 0 20rpx;
font-size: 30rpx;
color: #303133;
box-sizing: border-box;
}
.shelf-form-date {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
height: 72rpx;
background: #f5f7fa;
border-radius: 8rpx;
padding: 0 20rpx;
box-sizing: border-box;
}
.shelf-form-date:active {
opacity: 0.7;
}
.shelf-form-date__text {
font-size: 30rpx;
color: #303133;
}
.shelf-form-date__text--placeholder {
color: #c0c4cc;
}
.shelf-drawer__footer {
display: flex;
padding: 20rpx 32rpx;
gap: 20rpx;
border-top: 1rpx solid #f2f3f5;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
}
.shelf-btn-cancel {
flex: 1;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
border: 2rpx solid #dcdfe6;
border-radius: 12rpx;
background: #ffffff;
}
.shelf-btn-cancel:active {
opacity: 0.7;
}
.shelf-btn-cancel__text {
font-size: 34rpx;
color: #606266;
}
.shelf-btn-submit {
flex: 1;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 12rpx;
background: #2979ff;
}
.shelf-btn-submit:active {
opacity: 0.8;
}
.shelf-btn-submit__text {
font-size: 34rpx;
color: #ffffff;
font-weight: 600;
}
.item-list-scroll {
width: 100%;
white-space: nowrap;
}
.item-chip {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-width: 120rpx;
height: 80rpx;
padding: 4rpx 16rpx;
margin-right: 12rpx;
margin-top: 12rpx;
background: #f0f7ff;
border: 2rpx solid #2979ff;
border-radius: 10rpx;
}
.item-chip:active {
opacity: 0.7;
}
.item-chip--active {
background: #2979ff;
}
.item-chip--active .item-chip__no {
color: #fff;
}
.item-chip--active .item-chip__total {
color: rgba(255,255,255,0.85);
}
.item-chip__no {
font-size: 32rpx;
color: #2979ff;
font-weight: 600;
line-height: 1.4;
}
.item-chip__total {
font-size: 30rpx;
color: #606266;
margin-top: 2rpx;
}
.summary-bar {
display: flex;
align-items: center;
@ -820,26 +1302,26 @@ import voice from '@/core/utils/voice';
}
.summary-label {
font-size: 30rpx;
font-size: 34rpx;
color: #f56c6c;
}
.summary-value {
color: #f56c6c;
font-weight: 600;
font-size: 32rpx;
font-size: 36rpx;
margin-left: 6rpx;
}
.summary-split {
color: #f56c6c;
font-size: 30rpx;
font-size: 34rpx;
margin: 0 6rpx;
}
.summary-total {
color: #f56c6c;
font-weight: 600;
font-size: 32rpx;
font-size: 36rpx;
}
</style>