修改拣货、复核发货模块,新增包材

This commit is contained in:
zm2000 2026-06-16 15:52:49 +08:00
parent ddc61a3ac8
commit 502a4df4cb
5 changed files with 496 additions and 27 deletions

View File

@ -2,9 +2,12 @@
<view class="nav-wrap">
<view class="status_bar"></view>
<view class="nav-title">
<view class="left" @click="back">
<u-icon v-if="showBack" name="arrow-left"></u-icon>
<u-icon v-else name="home" @click="toHome"></u-icon>
<view class="left">
<view class="left-back" @click="back">
<u-icon v-if="showBack" name="arrow-left"></u-icon>
<u-icon v-else name="home" @click="toHome"></u-icon>
</view>
<slot name="left"></slot>
</view>
<view class="title">{{title}}</view>
<view class="right">
@ -102,19 +105,28 @@
/* #endif */
flex-direction: row;
align-items: center;
justify-content: flex-start;
justify-content: space-between;
height:110rpx;
line-height:110rpx;
background: #FFF;
justify-content: space-between;
padding:0 20rpx;
position: relative;
.left {
width: 80rpx;
min-width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
justify-content: flex-start;
gap: 10rpx;
.left-back {
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
}
.u-icon {
font-size: 40rpx;
@ -122,8 +134,10 @@
}
.title {
flex: 1;
text-align: center;
position: absolute;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
font-size: 32rpx;
font-weight: bold;
color: #333;
@ -131,6 +145,9 @@
.right {
width: 80rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
}

View File

@ -359,6 +359,12 @@ export default {
method: "POST",
isSystemApi: true
}
},
bindExpressPackageMaterialByWaybill: {
path: "order.bindExpressPackageMaterialByWaybill",
auth: true,
method: "POST",
isSystemApi: true
}
},
print: {
@ -380,5 +386,15 @@ export default {
method: "POST",
isSystemApi: true
}
},
setting: {
packageMaterial: {
search: {
path: "setting.packageMaterial.search",
auth: true,
method: "POST",
isSystemApi: true
}
}
}
};

View File

@ -102,6 +102,7 @@
<text class="record-value" :class="getReviewStatusText(item) === '已复核' ? 'record-value--reviewed' : 'record-value--unreviewed'">{{ getReviewStatusText(item) }}</text>
<text v-if="item.waveIndex" class="record-value record-value--wave-index" :class="{ 'record-value--wave-index-reviewed': getReviewStatusText(item) === '已复核' }">[{{ item.waveIndex }}]</text>
<text class="record-value record-value--id" :class="{ 'record-value--id-reviewed': getReviewStatusText(item) === '已复核' }">{{ listType === 'single' ? (item.waybillNo || '--') : (item.waveNo || '--') }}</text>
<text v-if="item.boxNo" class="record-value record-value--box-no">{{ item.boxNo }}号篮</text>
<view class="record-print-col">
<text v-if="getPrintStatusText(item) === '已打印'" class="record-value record-value--printed">已打印</text>
<text v-else class="record-value" :class="isPrintDisabled(item) ? 'record-value--print-disabled' : 'record-value--unprinted'" @click.stop="!isPrintDisabled(item) && handlePrintOrder(item)">未打印</text>
@ -1007,6 +1008,7 @@
waveNo: String(wave?.wave_no || wave?.waveNo || '').trim(),
waveIndex: String(wave?.wave_index || wave?.waveIndex || '').trim(),
waveId: wave?.wave_id ?? wave?.waveId ?? wave?.id ?? '',
boxNo: String(wave?.box_no ?? wave?.boxNo ?? '').trim(),
cartNo: String(wave?.cart_code || wave?.cartCode || wave?.cart_no || wave?.cartNo || '').trim(),
pickerName: String(wave?.picker_name || wave?.pickerName || '').trim(),
status: String(wave?.status || 'pending'),
@ -1100,6 +1102,7 @@
waybillNo: String(item?.waybill_no || item?.waybillCode || item?.waybill_code || '').trim(),
waveNo: String(item?.wave_no || item?.waveNo || '').trim(),
waveIndex: String(item?.wave_index || item?.waveIndex || '').trim(),
boxNo: String(item?.box_no || item?.boxNo || '').trim(),
pickerName: String(item?.picker_name || item?.pickerName || '').trim(),
cartNo: String(item?.cart_code || item?.cartCode || item?.cart_no || item?.cartNo || '').trim(),
status: String(item?.status || 'pending'),
@ -1145,6 +1148,7 @@
waveNo: item?.waveNo || '--',
waybillNo: item?.waybillNo || '',
waveIndex: item?.waveIndex || '',
boxNo: item?.boxNo || '',
pickerName: item?.pickerName || '--',
cartNo: item?.cartNo || '--',
unreviewedCount: item?.recheckStatus === 'fin' ? 0 : 1,
@ -1178,11 +1182,14 @@
const subList = Array.isArray(wave?.list) ? wave.list : [];
const waveUnreviewed = Number(wave?.unreviewedCount ?? 0);
const rawWaveId = wave?.waveId ?? wave?.id ?? '';
// 从子订单中取第一个有 boxNo 的值
const firstChildBoxNo = subList.reduce((found, child) => found || (child?.boxNo || ''), '');
return {
id: String(rawWaveId || wave?.waveNo || `wave-${Date.now()}-${wi}`),
waveId: rawWaveId,
waveNo: wave?.waveNo || '--',
waveIndex: String(wave?.wave_index || wave?.waveIndex || '').trim(),
boxNo: wave?.boxNo || firstChildBoxNo || '',
waybillNo: groupWaybillNo,
pickerName: wave?.pickerName || '--',
cartNo: wave?.cartNo || '--',
@ -1296,6 +1303,17 @@
}
try {
const response = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword));
// 检测接口返回的错误信息
if (response?.flag === 'failure') {
const errorMsg = String(response?.message || response?.msg || '').trim();
if (!silent) {
uni.showToast({
title: errorMsg || '订单查询失败',
icon: 'none'
});
}
return;
}
const payload = this.extractScanOrderPayload(response);
const result = this.normalizeScanOrderResult(payload);
this.handleScanOrderSuccess(result, silent);
@ -1448,7 +1466,10 @@
`waveIndex=${encodeURIComponent(waveIndex)}`,
`interceptStatus=${encodeURIComponent(interceptStatus)}`,
`orderIds=${encodeURIComponent(JSON.stringify(orderIds))}`,
`cacheKey=${encodeURIComponent(cacheKey)}`
`cacheKey=${encodeURIComponent(cacheKey)}`,
`printStationId=${encodeURIComponent(String(this.printStationId || ''))}`,
`printStationName=${encodeURIComponent(String(this.printStationName || ''))}`,
`boxNo=${encodeURIComponent(String(item.boxNo || ''))}`
];
this._navigatedToDetail = true;
this.$tools.routerTo(`/pages/work/order/scatter-pick-goods-detail?${params.join('&')}`);
@ -2141,6 +2162,7 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 29rpx;
}
.record-value--wave-index {
@ -2158,6 +2180,21 @@
align-items: center;
}
.record-value--box-no {
flex-shrink: 0;
font-size: 28rpx;
color: #e6a23c;
background: #fdf6ec;
border: 1rpx solid #f5dab1;
border-radius: 6rpx;
padding: 0 8rpx;
margin-right: 8rpx;
line-height: 34rpx;
height: 34rpx;
display: inline-flex;
align-items: center;
}
/* 已复核行:运单/波次号颜色与复核状态一致 */
.record-main--row .record-value--id.record-value--id-reviewed {
color: #909399;

View File

@ -2,11 +2,13 @@
<view class="order-picking-page">
<view class="normar_container">
<page-nav :title="title" @click.native="handleTitleClick">
<template #left>
<view class="nav-action-btn nav-action-btn--bind" @click="openBindCartPopup">
<text class="nav-action-btn__text">拣货车</text>
</view>
</template>
<template #right>
<view class="nav-right" :class="{ 'nav-right--disabled': !hasActiveTask }">
<view class="nav-action-btn nav-action-btn--bind" @click="openBindCartPopup">
<text class="nav-action-btn__text">拣货车</text>
</view>
<u-icon name="more-dot-fill" size="22" @click="openActionSheet"></u-icon>
</view>
</template>
@ -1773,7 +1775,7 @@
}
.nav-right {
padding-right: 12rpx;
padding-right: 24rpx;
display: flex;
align-items: center;
justify-content: flex-end;
@ -1800,6 +1802,7 @@
border-radius: 8rpx;
height: 60rpx;
padding: 0 22rpx;
margin-left: 20rpx;
}
.nav-action-btn--bind .nav-action-btn__text {

View File

@ -2,6 +2,9 @@
<view class="scatter-pick-goods-detail-page">
<view class="normar_container">
<page-nav :title="title">
<template #left>
<view class="nav-packaging-btn" @click="handlePackaging">包材</view>
</template>
<template #right>
<view v-if="isIntercepted" class="nav-right-complete nav-right-complete--intercept" @click="handleIntercept">确认拦截</view>
<view v-else class="nav-right-complete" :class="{ 'nav-right-complete--disabled': !canConfirmRecheck }" @click="canConfirmRecheck && handleComplete()">确认复核</view>
@ -60,7 +63,7 @@
<view class="goods-row goods-row--qty" :class="{ 'goods-row--scanned-complete': isScannedComplete }">
<view class="qty-item"><view class="label">已扫:</view><text class="value">{{ currentGoods.scannedQty || 0 }}</text></view>
<view class="qty-divider"></view>
<view class="qty-item"><view class="label">蓝号:</view><text class="value">{{ detailInfo.waveIndex || '--' }}</text></view>
<view class="qty-item"><view class="label">蓝号:</view><text class="value">{{ detailInfo.waveIndex || (detailInfo.boxNo ? '' : '--') }}<text v-if="detailInfo.boxNo" class="box-no-suffix">{{ detailInfo.boxNo }}号篮</text></text></view>
</view>
<view class="goods-row goods-row--qty">
<view class="qty-item"><view class="label">总数:</view><text class="value">{{ currentGoods.planQty || 0 }}</text></view>
@ -137,6 +140,62 @@
</view>
</view>
</u-popup>
<u-popup :show="showPackagingPopup" mode="center" :closeable="true" border-radius="20" :z-index="10090" :customStyle="{ transform: 'translateY(-80rpx)' }" @close="handlePackagingClose">
<view class="packaging-popup">
<view class="packaging-popup-title">绑定包材</view>
<view class="packaging-popup-body">
<view class="packaging-row">
<text class="packaging-label">运单号 <text class="packaging-required">*</text></text>
<input
class="packaging-input"
v-model="packagingWaybillNo"
placeholder="请输入运单号"
placeholder-style="color:#c0c4cc;font-size:32rpx"
/>
</view>
<view class="packaging-row">
<text class="packaging-label">输入编码/名称搜索 <text class="packaging-required">*</text></text>
<view class="packaging-search-wrap">
<input
class="packaging-input"
:value="packagingSearchKeyword"
placeholder="输入编码/名称搜索"
placeholder-style="color:#c0c4cc;font-size:32rpx"
@input="handlePackagingSearchInput"
@focus="handlePackagingSearchFocus"
@blur="handlePackagingSearchBlur"
@confirm="handlePackagingSearchConfirm"
/>
<view v-if="showPackagingDropdown && packagingFilteredList.length > 0" class="packaging-dropdown">
<scroll-view scroll-y class="packaging-dropdown-scroll">
<view
v-for="item in packagingFilteredList"
:key="item.id || item.code"
class="packaging-option"
:class="{ 'packaging-option--active': packagingSelectedCode === (item.code || '') }"
@mousedown.stop="handlePackagingSelect(item)"
>
<text class="packaging-option-code">{{ item.code || '--' }}</text>
<text class="packaging-option-name">{{ item.name || '--' }}</text>
</view>
</scroll-view>
</view>
<view v-if="showPackagingDropdown && packagingSearchKeyword && packagingFilteredList.length === 0" class="packaging-dropdown">
<view class="packaging-option packaging-option--empty">未匹配到包材</view>
</view>
</view>
</view>
<view class="packaging-tip">
<text class="packaging-tip__text">仅需运单号与包材编码,系统自动反查订单运单记录并绑定包材,无需订单 ID。</text>
</view>
</view>
<view class="packaging-popup-footer">
<view class="packaging-footer-btn packaging-footer-btn--cancel" @click="handlePackagingClose">取消</view>
<view class="packaging-footer-btn packaging-footer-btn--save" @click="handlePackagingSubmit">保存</view>
</view>
</view>
</u-popup>
</view>
</template>
@ -154,6 +213,14 @@
weighWeight: 0,
weighInputFocused: false,
_weighAfterReview: false,
showPackagingPopup: false,
packagingWaybillNo: '',
packagingSearchKeyword: '',
packagingSelectedCode: '',
packagingSelectedName: '',
showPackagingDropdown: false,
packagingMaterialList: [],
packagingListLoading: false,
detailInfo: {
recordId: '',
orderId: 0,
@ -169,7 +236,10 @@
storeRemark: '',
waveIndex: '',
orderIds: [],
interceptStatus: ''
interceptStatus: '',
printStationId: '',
printStationName: '',
boxNo: ''
},
goodsList: []
};
@ -225,6 +295,18 @@
const status = String(this.detailInfo?.interceptStatus || '').trim().toLowerCase();
return !!status && status !== 'none' && status !== '';
},
packagingFilteredList() {
const list = Array.isArray(this.packagingMaterialList) ? this.packagingMaterialList : [];
const keyword = String(this.packagingSearchKeyword || '').trim().toLowerCase();
if (!keyword) {
return list;
}
return list.filter(item => {
const code = String(item.code || '').toLowerCase();
const name = String(item.name || '').toLowerCase();
return code.includes(keyword) || name.includes(keyword);
});
},
isCurrentBarcodeMatched() {
const currentId = String(this.currentGoods?.id || '');
if (!currentId) {
@ -293,7 +375,10 @@
storeRemark: safeDecode(options?.storeRemark),
waveIndex: String(options?.waveIndex || '').trim(),
orderIds: Array.isArray(parsedOrderIds) ? parsedOrderIds : [],
interceptStatus: String(options?.interceptStatus || '').trim()
interceptStatus: String(options?.interceptStatus || '').trim(),
printStationId: String(options?.printStationId || '').trim(),
printStationName: String(options?.printStationName || '').trim(),
boxNo: String(options?.boxNo || '').trim()
};
if (this.isRecheckFinished) {
uni.showToast({
@ -451,6 +536,12 @@
return;
}
// 包材弹窗打开时,扫描编码自动匹配包材
if (this.showPackagingPopup) {
this.handlePackagingScanMatch(scanCode);
return;
}
const matchIndex = this.goodsList.findIndex(item => {
const candidates = this.extractBarcodeCandidates(item);
return candidates.includes(scanCode);
@ -795,6 +886,13 @@
orderIdsParam = [orderId];
}
// 使用当前已绑定的打印台
const printStationId = String(this.detailInfo?.printStationId || '').trim();
if (!printStationId) {
uni.showToast({ title: '请先在订单复核页绑定打印台', icon: 'none' });
return;
}
uni.showLoading({ title: '处理打印中...' });
try {
// 1. 获取打印数据
@ -807,19 +905,11 @@
throw new Error('未获取到可打印数据');
}
// 2. 获取打印台列表,使用第一个可用打印台
const stationResponse = await this.$http('print.getList', { page: 1, pageSize: 20, where: {} });
const stationList = this.normalizePrintStations(this.extractPrintRecordList(stationResponse));
if (!stationList.length) {
throw new Error('无可用的打印台');
}
const printStation = stationList[0];
// 3. 发送打印
// 2. 发送打印,使用已绑定的打印台
const requestCode = this.buildPrintRequestCode();
const sendParams = {
type: 'express',
printStationId: printStation.id,
printStationId,
requestCode,
data: { waveGroups }
};
@ -837,6 +927,144 @@
uni.showToast({ title: message, icon: 'none' });
}
},
async handlePackaging() {
this.packagingWaybillNo = this.detailInfo?.waybillNo || '';
this.packagingSearchKeyword = '';
this.packagingSelectedCode = '';
this.packagingSelectedName = '';
this.packagingMaterialList = [];
this.showPackagingDropdown = false;
this.showPackagingPopup = true;
// 打开弹窗后加载包材列表
await this.loadPackagingMaterialList();
},
async loadPackagingMaterialList() {
this.packagingListLoading = true;
try {
const response = await this.$http('setting.packageMaterial.search', {});
const rawList = this.extractPackagingList(response);
// 将 API 返回的 material_code / material_name 归一化为 code / name
this.packagingMaterialList = Array.isArray(rawList)
? rawList.map(item => ({
code: item.material_code || item.code || '',
name: item.material_name || item.name || ''
}))
: [];
} catch (e) {
this.packagingMaterialList = [];
} finally {
this.packagingListLoading = false;
}
},
extractPackagingList(response) {
const candidates = [
response?.data?.data,
response?.data?.list,
response?.data?.data?.list,
response?.data?.data?.rows,
response?.data?.rows,
response?.data,
response?.list,
response?.rows
];
for (let i = 0; i < candidates.length; i += 1) {
if (Array.isArray(candidates[i])) {
return candidates[i];
}
}
return [];
},
async handlePackagingSearchInput(event) {
const value = event?.detail?.value ?? event?.target?.value ?? event ?? '';
this.packagingSearchKeyword = value;
this.showPackagingDropdown = true;
// 输入变化时客户端过滤,仅首次加载
if (this.packagingMaterialList.length === 0) {
await this.loadPackagingMaterialList();
}
},
handlePackagingSearchFocus() {
this.showPackagingDropdown = true;
},
handlePackagingSearchBlur() {
setTimeout(() => {
this.showPackagingDropdown = false;
}, 200);
},
handlePackagingSearchConfirm() {
const keyword = String(this.packagingSearchKeyword || '').trim().toLowerCase();
if (!keyword || !this.packagingFilteredList.length) {
return;
}
const matched = this.packagingFilteredList.find(item => {
const code = String(item.code || '').toLowerCase();
return code === keyword;
});
if (matched) {
this.handlePackagingSelect(matched);
} else {
this.handlePackagingSelect(this.packagingFilteredList[0]);
}
this.showPackagingDropdown = false;
},
handlePackagingSelect(item) {
this.packagingSelectedCode = item.code || '';
this.packagingSelectedName = item.name || '';
this.packagingSearchKeyword = `${item.code || ''} ${item.name || ''}`;
this.showPackagingDropdown = false;
},
async handlePackagingScanMatch(scanCode) {
// 确保包材列表已加载
if (this.packagingMaterialList.length === 0) {
await this.loadPackagingMaterialList();
}
const matched = this.packagingMaterialList.find(item => {
const code = String(item.code || '').toLowerCase();
return code === scanCode.toLowerCase();
});
if (matched) {
this.handlePackagingSelect(matched);
uni.showToast({ title: `已匹配包材:${matched.name}`, icon: 'success' });
} else {
// 未精确匹配时,将扫描码填入搜索框
this.packagingSearchKeyword = scanCode;
this.showPackagingDropdown = true;
uni.showToast({ title: '未匹配到包材,请手动选择', icon: 'none' });
}
},
handlePackagingClose() {
this.showPackagingPopup = false;
},
async handlePackagingSubmit() {
const waybillNo = String(this.packagingWaybillNo || '').trim();
const code = String(this.packagingSelectedCode || '').trim();
if (!waybillNo) {
uni.showToast({ title: '请输入运单号', icon: 'none' });
return;
}
if (!code) {
uni.showToast({ title: '请搜索并选择包材', icon: 'none' });
return;
}
uni.showLoading({ title: '提交中...' });
try {
const response = await this.$http('order.bindExpressPackageMaterialByWaybill', {
waybill_code: waybillNo,
package_material_code: code
});
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
if (!success) {
throw new Error(response?.message || response?.msg || '绑定包材失败');
}
uni.hideLoading();
uni.showToast({ title: '绑定包材成功', icon: 'success' });
this.showPackagingPopup = false;
} catch (error) {
uni.hideLoading();
const message = String(error?.message || error?.msg || error?.errMsg || '绑定包材失败');
uni.showToast({ title: message, icon: 'none' });
}
},
handleWeighClose() {
this.showWeighPopup = false;
if (this._weighAfterReview) {
@ -1085,6 +1313,16 @@
background: #07c160;
}
.nav-packaging-btn {
font-size: 36rpx;
line-height: 44rpx;
color: #ffffff;
padding: 14rpx 24rpx;
border-radius: 8rpx;
background: #2979ff;
white-space: nowrap;
}
.nav-right-complete--disabled {
background: #c0c4cc;
pointer-events: none;
@ -1303,6 +1541,12 @@
flex-shrink: 0;
}
.box-no-suffix {
color: #303133;
font-weight: 500;
margin-left: 8rpx;
}
.label {
width: 110rpx;
min-width: 110rpx;
@ -1754,4 +1998,156 @@
background: #2979ff;
color: #ffffff;
}
.packaging-popup {
width: 640rpx;
padding: 32rpx 40rpx 40rpx;
box-sizing: border-box;
}
.packaging-popup-title {
font-size: 44rpx;
font-weight: 500;
color: #303133;
text-align: left;
line-height: 1;
padding-top: 8rpx;
margin-bottom: 28rpx;
}
.packaging-popup-body {
margin: 20rpx 0 40rpx;
}
.packaging-row {
display: flex;
flex-direction: column;
margin-bottom: 24rpx;
}
.packaging-label {
font-size: 32rpx;
color: #606266;
margin-bottom: 12rpx;
}
.packaging-required {
color: #f56c6c;
}
.packaging-input {
height: 80rpx;
font-size: 32rpx;
color: #303133;
background: #f5f7fa;
border: 2rpx solid #dcdfe6;
border-radius: 10rpx;
padding: 0 20rpx;
box-sizing: border-box;
}
.packaging-tip {
background: #fef9e7;
border: 1rpx solid #f9e7b3;
border-radius: 8rpx;
padding: 16rpx 20rpx;
margin-top: 8rpx;
}
.packaging-tip__text {
font-size: 26rpx;
color: #b37400;
line-height: 1.5;
}
.packaging-popup-footer {
display: flex;
gap: 28rpx;
}
.packaging-footer-btn {
flex: 1;
height: 90rpx;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
font-weight: 500;
}
.packaging-footer-btn:active {
opacity: 0.7;
}
.packaging-footer-btn--cancel {
background: #f4f4f5;
color: #909399;
}
.packaging-footer-btn--save {
background: #2979ff;
color: #ffffff;
}
.packaging-search-wrap {
position: relative;
width: 100%;
}
.packaging-dropdown {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: #ffffff;
border: 2rpx solid #dcdfe6;
border-top: none;
border-radius: 0 0 10rpx 10rpx;
z-index: 100;
max-height: 320rpx;
overflow: hidden;
}
.packaging-dropdown-scroll {
max-height: 320rpx;
}
.packaging-option {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16rpx 20rpx;
border-bottom: 1rpx solid #f2f2f2;
}
.packaging-option:last-child {
border-bottom: none;
}
.packaging-option:active {
background: #f0f7ff;
}
.packaging-option--active {
background: #eef4ff;
}
.packaging-option--empty {
justify-content: center;
color: #909399;
font-size: 28rpx;
}
.packaging-option-code {
font-size: 34rpx;
color: #303133;
font-weight: 500;
}
.packaging-option-name {
font-size: 30rpx;
color: #909399;
margin-left: 12rpx;
}
</style>