936 lines
25 KiB
Vue
936 lines
25 KiB
Vue
<template>
|
||
<view class="picking-detail-page">
|
||
<view class="normar_container">
|
||
<page-nav :title="title"></page-nav>
|
||
|
||
<view class="summary-card">
|
||
<view class="summary-row"><text class="label">波次:</text><text class="value">{{ orderInfo.waveNo || '--' }}</text></view>
|
||
<view class="summary-row"><text class="label">订单总数:</text><text class="value">{{ orderInfo.needQty || 0 }}</text></view>
|
||
</view>
|
||
|
||
<view class="section-title-row">
|
||
<view class="section-title">拣货明细</view>
|
||
<view class="scan-entry" @click="handleScanBarcode">
|
||
<u-icon name="scan" size="26" color="#2979ff"></u-icon>
|
||
<text class="scan-entry__text">扫码拣货</text>
|
||
</view>
|
||
</view>
|
||
<view class="detail-list">
|
||
<view v-if="currentDetailList.length === 0" class="detail-empty">暂无拣货明细</view>
|
||
<view class="detail-item" v-for="line in currentDetailList" :key="line.lineId" @longpress.stop="handleLineLongPress(line, currentDetailIndex)">
|
||
<view class="detail-head">
|
||
<text class="sku-name">{{ line.skuName }}</text>
|
||
<view class="detail-head-right">
|
||
<text v-if="line.noBarcodeVerified" class="verify-tag">无条码核对</text>
|
||
<text v-if="line.locationErrorReported" class="error-tag">库位报错</text>
|
||
<text v-if="line.pickedQty >= line.needQty" class="picked-tag">已拣</text>
|
||
</view>
|
||
</view>
|
||
<view class="detail-main">
|
||
<u-image :src="line.imageUrl || ''" width="120rpx" height="120rpx" mode="aspectFill"></u-image>
|
||
<view class="detail-main-info">
|
||
<view class="detail-row"><text class="label">商品名称:</text><text class="value">{{ line.skuName || '--' }}</text></view>
|
||
<view class="detail-row"><text class="label">库位:</text><text class="value">{{ line.space || '--' }}</text></view>
|
||
<view class="detail-row"><text class="label">商品条码:</text><text class="value">{{ line.barcode || '--' }}</text></view>
|
||
<view class="detail-row"><text class="label">数量:</text><text class="value">{{ line.needQty }}</text></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="switch-row" v-if="detailList.length > 0">
|
||
<u-button size="mini" @click="showPrevDetail" :disabled="!hasPrevDetail">上一个</u-button>
|
||
<text class="switch-index">{{ currentDetailIndex + 1 }}/{{ detailList.length }}</text>
|
||
<u-button size="mini" type="primary" :customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }" @click="showNextDetail" :disabled="!hasNextDetail">下一个</u-button>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="action-bar">
|
||
<u-button
|
||
v-if="orderInfo.status === 'pending'"
|
||
type="primary"
|
||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }"
|
||
@click="startPicking"
|
||
>开始拣货</u-button>
|
||
<u-button
|
||
v-else-if="orderInfo.status === 'picking'"
|
||
type="success"
|
||
:loading="completing"
|
||
@click="completePicking"
|
||
>完成拣货</u-button>
|
||
<u-button v-else type="info" :disabled="true">已完成</u-button>
|
||
</view>
|
||
|
||
<u-popup :show="locationErrorPopupVisible" mode="bottom" :closeable="true" border-radius="20" @close="closeLocationErrorPopup">
|
||
<view class="location-error-popup">
|
||
<view class="popup-title">库位报错(拍照上传)</view>
|
||
<view class="popup-line">商品:{{ currentActionLine && currentActionLine.skuName ? currentActionLine.skuName : '--' }}</view>
|
||
<view class="popup-line">库位:{{ currentActionLine && currentActionLine.space ? currentActionLine.space : '--' }}</view>
|
||
<view class="popup-label">异常说明</view>
|
||
<u-textarea v-model="locationErrorRemark" placeholder="请输入异常说明(选填)" height="120" border="surround"></u-textarea>
|
||
|
||
<view class="popup-label">异常图片</view>
|
||
<view class="photo-list">
|
||
<view v-for="(img, imgIndex) in locationErrorImages" :key="img + '-' + imgIndex" class="photo-item">
|
||
<u-image :src="img" mode="aspectFill" width="120rpx" height="120rpx" @click="previewLocationErrorImage(imgIndex)"></u-image>
|
||
<view class="photo-remove" @click="removeLocationErrorImage(imgIndex)">×</view>
|
||
</view>
|
||
<view v-if="locationErrorImages.length < 3" class="photo-add" @click="chooseLocationErrorImage">
|
||
<u-icon name="camera" size="26" color="#2979ff"></u-icon>
|
||
<text class="photo-add-text">拍照</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="popup-actions">
|
||
<u-button @click="closeLocationErrorPopup">取消</u-button>
|
||
<u-button type="error" :loading="locationErrorSubmitting" @click="submitLocationError">提交报错</u-button>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
title: '拣货详情',
|
||
loading: false,
|
||
completing: false,
|
||
orderInfo: {
|
||
id: '',
|
||
orderId: 0,
|
||
orderItemId: 0,
|
||
orderNo: '',
|
||
customerName: '',
|
||
waveNo: '',
|
||
status: 'pending',
|
||
needQty: 0,
|
||
pickedQty: 0
|
||
},
|
||
detailList: [],
|
||
currentDetailIndex: 0,
|
||
locationErrorPopupVisible: false,
|
||
currentActionLineIndex: -1,
|
||
locationErrorRemark: '',
|
||
locationErrorImages: [],
|
||
locationErrorSubmitting: false
|
||
}
|
||
},
|
||
computed: {
|
||
statusText() {
|
||
const map = {
|
||
pending: '待拣货',
|
||
picking: '拣货中',
|
||
done: '已完成'
|
||
};
|
||
return map[this.orderInfo.status] || '未知状态';
|
||
},
|
||
currentActionLine() {
|
||
if (this.currentActionLineIndex < 0) {
|
||
return null;
|
||
}
|
||
return this.detailList[this.currentActionLineIndex] || null;
|
||
},
|
||
currentDetailList() {
|
||
const line = this.detailList[this.currentDetailIndex];
|
||
return line ? [line] : [];
|
||
},
|
||
hasPrevDetail() {
|
||
return this.currentDetailIndex > 0;
|
||
},
|
||
hasNextDetail() {
|
||
return this.currentDetailIndex < this.detailList.length - 1;
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
this.safeDispatchBroadcast('setCallbacks', {
|
||
onResult: this.handleBroadcastResult
|
||
});
|
||
this.safeDispatchBroadcast('start');
|
||
|
||
this.orderInfo = {
|
||
id: options?.id || '',
|
||
orderId: Number(options?.orderId || 0),
|
||
orderItemId: Number(options?.orderItemId || 0),
|
||
orderNo: options?.orderNo || '--',
|
||
customerName: options?.customerName || '--',
|
||
waveNo: options?.waveNo || '--',
|
||
status: options?.status || 'pending',
|
||
needQty: Number(options?.needQty || 0),
|
||
pickedQty: Number(options?.pickedQty || 0)
|
||
};
|
||
this.loadOrderDetail();
|
||
},
|
||
onShow() {
|
||
this.safeDispatchBroadcast('setCallbacks', {
|
||
onResult: this.handleBroadcastResult
|
||
});
|
||
this.safeDispatchBroadcast('resume');
|
||
},
|
||
onHide() {
|
||
this.safeDispatchBroadcast('pause');
|
||
},
|
||
onUnload() {
|
||
this.safeDispatchBroadcast('stop');
|
||
},
|
||
methods: {
|
||
getApiErrorMessage(error, fallback = '请求失败') {
|
||
const message = error?.message || error?.msg || error?.errMsg || error?.data?.message;
|
||
return String(message || fallback);
|
||
},
|
||
buildItemsQueryParams() {
|
||
return {
|
||
order_id: Number(this.orderInfo.orderId || 0),
|
||
order_item_id: Number(this.orderInfo.orderItemId || 0),
|
||
full_display: true
|
||
};
|
||
},
|
||
buildCompletePickingParams() {
|
||
return {
|
||
order_id: Number(this.orderInfo.orderId || 0),
|
||
order_item_id: Number(this.orderInfo.orderItemId || 0),
|
||
details: this.detailList.map(line => ({
|
||
id: line.lineId,
|
||
picked_qty: Number(line.pickedQty || 0),
|
||
need_qty: Number(line.needQty || 0)
|
||
}))
|
||
};
|
||
},
|
||
extractDetailPayload(response) {
|
||
const candidates = [
|
||
response?.data?.data,
|
||
response?.data,
|
||
response?.result,
|
||
response
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const current = candidates[i];
|
||
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
extractDetailList(payload, response) {
|
||
const candidates = [
|
||
Array.isArray(payload) ? payload : null,
|
||
payload?.list,
|
||
payload?.details,
|
||
payload?.rows,
|
||
payload?.items,
|
||
payload?.data?.list,
|
||
payload?.data?.details,
|
||
payload?.summary?.list,
|
||
payload?.summary?.details,
|
||
response?.data?.list,
|
||
response?.data?.rows,
|
||
response?.data?.items,
|
||
response?.data?.data?.list,
|
||
response?.data?.data?.rows,
|
||
response?.data?.data?.items,
|
||
response?.list,
|
||
response?.rows,
|
||
response?.items
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
if (Array.isArray(candidates[i])) {
|
||
return candidates[i];
|
||
}
|
||
}
|
||
return [];
|
||
},
|
||
extractItemsResponse(response) {
|
||
const payload = this.extractDetailPayload(response);
|
||
const list = this.extractDetailList(payload, response);
|
||
return {
|
||
payload,
|
||
list
|
||
};
|
||
},
|
||
syncOrderInfoFromPayload(payload) {
|
||
if (!payload || typeof payload !== 'object') {
|
||
return;
|
||
}
|
||
this.orderInfo.orderNo = payload.order_no || payload.orderNo || this.orderInfo.orderNo;
|
||
this.orderInfo.customerName = payload.customer_name || payload.customerName || this.orderInfo.customerName;
|
||
this.orderInfo.waveNo = payload.wave_no || payload.waveNo || this.orderInfo.waveNo;
|
||
const nextStatus = payload.picking_status || payload.status;
|
||
if (nextStatus) {
|
||
this.orderInfo.status = this.normalizeStatus(nextStatus);
|
||
}
|
||
},
|
||
async loadOrderDetail() {
|
||
const params = this.buildItemsQueryParams();
|
||
if (!params.order_id || !params.order_item_id) {
|
||
uni.showToast({
|
||
title: '缺少订单参数',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
this.loading = true;
|
||
try {
|
||
const response = await this.$http('pick.items', params);
|
||
const parsed = this.extractItemsResponse(response);
|
||
this.syncOrderInfoFromPayload(parsed.payload);
|
||
const list = parsed.list;
|
||
this.detailList = list.map((item, index) => this.normalizeDetailItem(item, index));
|
||
this.currentDetailIndex = 0;
|
||
this.recalculateOrderProgress();
|
||
} catch (error) {
|
||
this.detailList = [];
|
||
this.currentDetailIndex = 0;
|
||
this.recalculateOrderProgress();
|
||
uni.showToast({
|
||
title: this.getApiErrorMessage(error, '明细加载失败'),
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
normalizeStatus(value) {
|
||
const text = String(value || '').toLowerCase();
|
||
if (!text) {
|
||
return 'pending';
|
||
}
|
||
if (['fin', 'finished', 'done', 'completed', 'complete', 'success'].includes(text)) {
|
||
return 'done';
|
||
}
|
||
if (['picking', 'pick', 'doing', 'processing', 'progress', 'part'].includes(text)) {
|
||
return 'picking';
|
||
}
|
||
return 'pending';
|
||
},
|
||
normalizeDetailItem(item, index) {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const needQty = Number(source.need_qty || source.needQty || source.plan_qty || source.planQty || source.qty || source.total_qty || 0);
|
||
const pickedQty = Number(source.picked_qty || source.pickedQty || source.done_qty || source.doneQty || source.finish_qty || source.finishQty || source.scanned_qty || source.scannedQty || 0);
|
||
const basketNo = source.basket_no || source.basketNo || source.basket_code || source.bucket_no || '';
|
||
const space = source.space_name || source.spaceName || source.space || source.location || source.location_code || source.bin_code || source.slot || '--';
|
||
const skuCode = source.sku_code || source.skuCode || source.sku || source.product_code || source.goods_code || '--';
|
||
const skuName = source.sku_name || source.skuName || source.name || source.product_name || source.goods_name || '--';
|
||
const imageUrl = source.image || source.image_url || source.product_image || source.goods_image || source.pic || source.cover || '';
|
||
return {
|
||
lineId: source.line_id || source.lineId || source.detail_id || source.detailId || source.id || source.order_item_id || `${this.orderInfo.orderNo || 'detail'}-${index + 1}`,
|
||
skuName,
|
||
skuCode,
|
||
imageUrl,
|
||
barcode: source.barcode || source.code || source.ean || '',
|
||
basketNo,
|
||
space,
|
||
needQty,
|
||
pickedQty,
|
||
noBarcodeVerified: Boolean(source.no_barcode_verified || source.noBarcodeVerified),
|
||
locationErrorReported: Boolean(source.location_error_reported || source.locationErrorReported)
|
||
};
|
||
},
|
||
getBasketNoText(line) {
|
||
if (!line || typeof line !== 'object') {
|
||
return '--';
|
||
}
|
||
const basketNo = String(line.basketNo || '').trim();
|
||
if (basketNo) {
|
||
return basketNo;
|
||
}
|
||
const space = String(line.space || '').trim();
|
||
if (!space) {
|
||
return '--';
|
||
}
|
||
const segments = space.split('-').filter(Boolean);
|
||
return segments[segments.length - 1] || space;
|
||
},
|
||
speakPickResult(line) {
|
||
if (!line || typeof line !== 'object') {
|
||
return;
|
||
}
|
||
const basketNo = this.getBasketNoText(line);
|
||
const qty = Number(line.needQty || 0);
|
||
const speakText = `篮号${basketNo},数量${qty}`;
|
||
try {
|
||
const task = this.$tools && typeof this.$tools.speakText === 'function'
|
||
? this.$tools.speakText(speakText, { force: true })
|
||
: null;
|
||
if (task && typeof task.catch === 'function') {
|
||
task.catch(() => {});
|
||
}
|
||
} catch (error) {}
|
||
},
|
||
handleLineLongPress(line, index) {
|
||
if (!line || typeof line !== 'object') {
|
||
return;
|
||
}
|
||
uni.showActionSheet({
|
||
itemList: ['无条码核对', '库位报错(拍照上传)'],
|
||
success: (res) => {
|
||
if (res.tapIndex === 0) {
|
||
this.handleNoBarcodeVerify(index);
|
||
return;
|
||
}
|
||
if (res.tapIndex === 1) {
|
||
this.openLocationErrorPopup(index);
|
||
}
|
||
},
|
||
fail: () => {}
|
||
});
|
||
},
|
||
handleNoBarcodeVerify(index) {
|
||
const line = this.detailList[index];
|
||
if (!line) {
|
||
return;
|
||
}
|
||
|
||
if (Number(line.pickedQty || 0) >= Number(line.needQty || 0)) {
|
||
uni.showToast({
|
||
title: '该商品已拣完成',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
const updatedLine = {
|
||
...line,
|
||
pickedQty: Number(line.needQty || 0),
|
||
noBarcodeVerified: true,
|
||
noBarcodeVerifiedAt: Date.now()
|
||
};
|
||
this.$set(this.detailList, index, updatedLine);
|
||
this.recalculateOrderProgress();
|
||
this.emitOrderUpdate();
|
||
this.speakPickResult(updatedLine);
|
||
uni.showToast({
|
||
title: '已完成无条码核对',
|
||
icon: 'success'
|
||
});
|
||
},
|
||
openLocationErrorPopup(index) {
|
||
this.currentActionLineIndex = index;
|
||
this.locationErrorRemark = '';
|
||
this.locationErrorImages = [];
|
||
this.locationErrorPopupVisible = true;
|
||
},
|
||
closeLocationErrorPopup() {
|
||
this.locationErrorPopupVisible = false;
|
||
this.currentActionLineIndex = -1;
|
||
this.locationErrorSubmitting = false;
|
||
},
|
||
chooseLocationErrorImage() {
|
||
if (this.locationErrorImages.length >= 3) {
|
||
return;
|
||
}
|
||
uni.chooseImage({
|
||
count: 1,
|
||
sourceType: ['camera'],
|
||
sizeType: ['compressed'],
|
||
success: (res) => {
|
||
const filePath = res?.tempFilePaths?.[0] || res?.tempFiles?.[0]?.path;
|
||
if (!filePath) {
|
||
uni.showToast({
|
||
title: '拍照失败,请重试',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
this.locationErrorImages = [...this.locationErrorImages, filePath].slice(0, 3);
|
||
},
|
||
fail: () => {}
|
||
});
|
||
},
|
||
removeLocationErrorImage(index) {
|
||
this.locationErrorImages.splice(index, 1);
|
||
},
|
||
previewLocationErrorImage(index) {
|
||
if (!this.locationErrorImages.length) {
|
||
return;
|
||
}
|
||
uni.previewImage({
|
||
urls: this.locationErrorImages,
|
||
current: this.locationErrorImages[index] || this.locationErrorImages[0]
|
||
});
|
||
},
|
||
submitLocationError() {
|
||
const line = this.currentActionLine;
|
||
if (!line) {
|
||
this.closeLocationErrorPopup();
|
||
return;
|
||
}
|
||
|
||
if (!this.locationErrorImages.length) {
|
||
uni.showToast({
|
||
title: '请先拍照上传',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
this.locationErrorSubmitting = true;
|
||
const updatedLine = {
|
||
...line,
|
||
locationErrorReported: true,
|
||
locationErrorRemark: String(this.locationErrorRemark || '').trim(),
|
||
locationErrorImages: [...this.locationErrorImages],
|
||
locationErrorReportedAt: Date.now()
|
||
};
|
||
this.$set(this.detailList, this.currentActionLineIndex, updatedLine);
|
||
this.emitOrderUpdate();
|
||
this.locationErrorSubmitting = false;
|
||
this.locationErrorPopupVisible = false;
|
||
this.currentActionLineIndex = -1;
|
||
uni.showToast({
|
||
title: '库位报错已提交',
|
||
icon: 'success'
|
||
});
|
||
},
|
||
safeDispatchBroadcast(action, payload) {
|
||
try {
|
||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||
if (task && typeof task.catch === 'function') {
|
||
task.catch(error => {
|
||
console.warn(`[OrderDetail] broadcast/${action} 调用失败:`, error);
|
||
});
|
||
}
|
||
} catch (error) {
|
||
console.warn(`[OrderDetail] broadcast/${action} 调用异常:`, error);
|
||
}
|
||
},
|
||
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 firstResult = scanResult.result.find(item => item);
|
||
if (typeof firstResult === 'string') {
|
||
return this.normalizeKeyword(firstResult);
|
||
}
|
||
if (firstResult && typeof firstResult.data === 'string') {
|
||
return this.normalizeKeyword(firstResult.data);
|
||
}
|
||
}
|
||
|
||
if (typeof scanResult.data === 'string') {
|
||
return this.normalizeKeyword(scanResult.data);
|
||
}
|
||
|
||
return '';
|
||
},
|
||
handleBroadcastResult(result) {
|
||
const scanResult = this.normalizeScanResult(result);
|
||
if (!scanResult) {
|
||
return;
|
||
}
|
||
this.markPickedByBarcode(scanResult);
|
||
},
|
||
handleScanBarcode() {
|
||
this.safeDispatchBroadcast('resume');
|
||
uni.showToast({
|
||
title: '请使用扫描枪扫码',
|
||
icon: 'none'
|
||
});
|
||
},
|
||
markPickedByBarcode(barcode) {
|
||
const normalizedBarcode = String(barcode || '').trim();
|
||
if (!normalizedBarcode) {
|
||
return;
|
||
}
|
||
|
||
const index = this.detailList.findIndex(line => String(line.barcode || '').trim() === normalizedBarcode);
|
||
if (index < 0) {
|
||
uni.showToast({
|
||
title: '无扫描记录',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
const targetLine = this.detailList[index];
|
||
if (Number(targetLine.pickedQty || 0) >= Number(targetLine.needQty || 0)) {
|
||
uni.showToast({
|
||
title: '该商品已拣完成',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
const updatedLine = {
|
||
...targetLine,
|
||
pickedQty: Number(targetLine.needQty || 0)
|
||
};
|
||
this.$set(this.detailList, index, updatedLine);
|
||
this.currentDetailIndex = index;
|
||
|
||
this.recalculateOrderProgress();
|
||
this.emitOrderUpdate();
|
||
this.speakPickResult(updatedLine);
|
||
uni.showToast({
|
||
title: `已拣:${updatedLine.skuName}`,
|
||
icon: 'success'
|
||
});
|
||
},
|
||
recalculateOrderProgress() {
|
||
const totalPicked = this.detailList.reduce((sum, line) => {
|
||
return sum + Number(line.pickedQty || 0);
|
||
}, 0);
|
||
const totalNeed = this.detailList.reduce((sum, line) => {
|
||
return sum + Number(line.needQty || 0);
|
||
}, 0);
|
||
|
||
this.orderInfo.needQty = totalNeed;
|
||
this.orderInfo.pickedQty = Math.max(0, Math.min(totalPicked, totalNeed));
|
||
|
||
if (this.orderInfo.pickedQty >= totalNeed && totalNeed > 0) {
|
||
this.orderInfo.status = 'done';
|
||
return;
|
||
}
|
||
if (this.orderInfo.pickedQty > 0) {
|
||
this.orderInfo.status = 'picking';
|
||
return;
|
||
}
|
||
this.orderInfo.status = 'pending';
|
||
},
|
||
emitOrderUpdate() {
|
||
uni.$emit('order:picking:updated', {
|
||
id: this.orderInfo.id,
|
||
orderNo: this.orderInfo.orderNo,
|
||
status: this.orderInfo.status,
|
||
pickedQty: this.orderInfo.pickedQty,
|
||
needQty: this.orderInfo.needQty
|
||
});
|
||
},
|
||
startPicking() {
|
||
if (this.orderInfo.status !== 'pending') {
|
||
return;
|
||
}
|
||
this.orderInfo.status = 'picking';
|
||
this.emitOrderUpdate();
|
||
uni.showToast({
|
||
title: '已开始拣货',
|
||
icon: 'success'
|
||
});
|
||
},
|
||
completePicking() {
|
||
if (this.orderInfo.status !== 'picking') {
|
||
return;
|
||
}
|
||
this.submitCompletePicking();
|
||
},
|
||
showPrevDetail() {
|
||
if (!this.hasPrevDetail) {
|
||
return;
|
||
}
|
||
this.currentDetailIndex -= 1;
|
||
},
|
||
showNextDetail() {
|
||
if (!this.hasNextDetail) {
|
||
return;
|
||
}
|
||
this.currentDetailIndex += 1;
|
||
},
|
||
async submitCompletePicking() {
|
||
if (this.completing) {
|
||
return;
|
||
}
|
||
this.completing = true;
|
||
try {
|
||
const params = this.buildCompletePickingParams();
|
||
await this.$http('pick.complete', params);
|
||
this.orderInfo.status = 'done';
|
||
this.detailList = this.detailList.map(line => ({
|
||
...line,
|
||
pickedQty: Number(line.needQty || 0)
|
||
}));
|
||
this.recalculateOrderProgress();
|
||
this.emitOrderUpdate();
|
||
uni.showToast({
|
||
title: '拣货完成',
|
||
icon: 'success'
|
||
});
|
||
setTimeout(() => {
|
||
uni.navigateBack({
|
||
delta: 1
|
||
});
|
||
}, 300);
|
||
} catch (error) {
|
||
uni.showToast({
|
||
title: this.getApiErrorMessage(error, '完成拣货失败'),
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
this.completing = false;
|
||
}
|
||
},
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.picking-detail-page {
|
||
min-height: 100vh;
|
||
background: #f8f9fa;
|
||
}
|
||
|
||
.summary-card {
|
||
margin: 20rpx 24rpx 0;
|
||
padding: 20rpx;
|
||
background: #fff;
|
||
border-radius: 14rpx;
|
||
}
|
||
|
||
.summary-head {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.order-no {
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
|
||
.summary-row,
|
||
.detail-row {
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: 24rpx;
|
||
line-height: 38rpx;
|
||
}
|
||
|
||
.label {
|
||
width: 120rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.value {
|
||
flex: 1;
|
||
color: #303133;
|
||
}
|
||
|
||
.section-title-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 24rpx 24rpx 12rpx;
|
||
}
|
||
|
||
.section-title {
|
||
font-size: 26rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
|
||
.scan-entry {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
height: 46rpx;
|
||
padding: 0 14rpx;
|
||
background: #edf4ff;
|
||
border-radius: 23rpx;
|
||
}
|
||
|
||
.scan-entry__text {
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
color: #2979ff;
|
||
margin-left: 6rpx;
|
||
}
|
||
|
||
.detail-list {
|
||
padding: 0 24rpx 160rpx;
|
||
}
|
||
|
||
.detail-empty {
|
||
background: #fff;
|
||
border-radius: 14rpx;
|
||
padding: 30rpx 20rpx;
|
||
text-align: center;
|
||
font-size: 24rpx;
|
||
color: #909399;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.detail-item {
|
||
background: #fff;
|
||
border-radius: 14rpx;
|
||
padding: 18rpx 20rpx;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.detail-main {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.detail-main-info {
|
||
flex: 1;
|
||
margin-left: 14rpx;
|
||
}
|
||
|
||
.detail-head {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
.detail-head-right {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.verify-tag {
|
||
font-size: 20rpx;
|
||
color: #2979ff;
|
||
background: #edf4ff;
|
||
padding: 4rpx 10rpx;
|
||
border-radius: 12rpx;
|
||
margin-right: 8rpx;
|
||
}
|
||
|
||
.error-tag {
|
||
font-size: 20rpx;
|
||
color: #fa3534;
|
||
background: #fff2f0;
|
||
padding: 4rpx 10rpx;
|
||
border-radius: 12rpx;
|
||
margin-right: 8rpx;
|
||
}
|
||
|
||
.picked-tag {
|
||
font-size: 20rpx;
|
||
color: #19be6b;
|
||
background: #eafaf0;
|
||
padding: 4rpx 10rpx;
|
||
border-radius: 12rpx;
|
||
margin-right: 8rpx;
|
||
}
|
||
|
||
.sku-name {
|
||
font-size: 26rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
|
||
.space {
|
||
font-size: 22rpx;
|
||
color: #606266;
|
||
background: #f6f7fb;
|
||
padding: 4rpx 10rpx;
|
||
border-radius: 12rpx;
|
||
}
|
||
|
||
.switch-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 8rpx 0 14rpx;
|
||
}
|
||
|
||
.switch-index {
|
||
font-size: 24rpx;
|
||
color: #606266;
|
||
}
|
||
|
||
.action-bar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
||
background: #fff;
|
||
border-top: 1rpx solid #f0f0f0;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.location-error-popup {
|
||
padding: 26rpx 24rpx calc(20rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
.popup-title {
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
|
||
.popup-line {
|
||
font-size: 24rpx;
|
||
line-height: 38rpx;
|
||
color: #606266;
|
||
}
|
||
|
||
.popup-label {
|
||
font-size: 24rpx;
|
||
color: #303133;
|
||
font-weight: 600;
|
||
margin: 16rpx 0 10rpx;
|
||
}
|
||
|
||
.photo-list {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.photo-item {
|
||
position: relative;
|
||
width: 120rpx;
|
||
height: 120rpx;
|
||
margin-right: 12rpx;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.photo-remove {
|
||
position: absolute;
|
||
right: -10rpx;
|
||
top: -10rpx;
|
||
width: 34rpx;
|
||
height: 34rpx;
|
||
border-radius: 17rpx;
|
||
background: rgba(0, 0, 0, 0.6);
|
||
color: #fff;
|
||
font-size: 26rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.photo-add {
|
||
width: 120rpx;
|
||
height: 120rpx;
|
||
border: 1rpx dashed #bdd4ff;
|
||
border-radius: 10rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.photo-add-text {
|
||
font-size: 22rpx;
|
||
color: #2979ff;
|
||
margin-top: 4rpx;
|
||
}
|
||
|
||
.popup-actions {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
column-gap: 12rpx;
|
||
margin-top: 8rpx;
|
||
}
|
||
</style> |