3669 lines
114 KiB
Vue
3669 lines
114 KiB
Vue
<template>
|
||
<view class="scatter-picking-detail-page">
|
||
<view class="normar_container">
|
||
<page-nav :title="showDetailView ? '订单复核详情' : title">
|
||
<template #right>
|
||
<view class="nav-settings-btn" @click="showSettingsPopup = true">
|
||
<text class="nav-settings-btn__text">设置</text>
|
||
</view>
|
||
</template>
|
||
</page-nav>
|
||
|
||
<view class="search-filter">
|
||
<view class="search-row">
|
||
<u-search
|
||
v-model="keyword"
|
||
:placeholder="isDetailReadOnly ? '已复核,仅可查看' : (showDetailView ? '扫描/输入条码' : (printStationId || printMode === 'noPrint' ? '搜索快递单号/波次号' : '扫描/输入打印台编号'))"
|
||
:bg-color="isDetailReadOnly ? '#f0f0f0' : '#f5f5f5'"
|
||
shape="round"
|
||
:show-action="false"
|
||
:clearabled="true"
|
||
:disabled="isDetailReadOnly"
|
||
@search="handleSearch"
|
||
@clear="clearSearch"
|
||
></u-search>
|
||
<view class="search-scan-btn" :class="{ 'search-scan-btn--disabled': isDetailReadOnly }" @click="!isDetailReadOnly && handleCameraScan()">
|
||
<u-icon name="scan" size="34rpx" :color="isDetailReadOnly ? '#c0c4cc' : '#2979ff'"></u-icon>
|
||
</view>
|
||
<view class="unbound-print-btn" @click="handleOpenPrintSettings">
|
||
<text class="unbound-print-btn__text" :class="{ 'unbound-print-btn__text--bound': !!printStationId }">{{ printStationId ? printStationName : '未绑定' }}</text>
|
||
</view>
|
||
<view class="scan-qty-btn" @click="showScanQtyPopup = true">
|
||
<text class="scan-qty-btn__text">数量 {{ scanQuantity }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 复核明细区域:占满剩余空间 -->
|
||
<view class="detail-area" :class="{ 'detail-area--empty': !showDetailView }">
|
||
<ReviewDetail
|
||
v-if="showDetailView"
|
||
ref="reviewDetail"
|
||
:goodsList="detailGoodsList"
|
||
:detailInfo="detailInfo"
|
||
:scanQty="scanQuantity"
|
||
:autoShip="autoShip"
|
||
:scannedPackageMaterial="scannedPackageMaterial"
|
||
@updateScannedQty="handleUpdateScannedQty"
|
||
@allScanned="handleDetailAllScanned"
|
||
@resetScanQty="handleResetScanQty"
|
||
@confirmRecheck="handleConfirmRecheck"
|
||
@autoConfirmAndNext="handleAutoConfirmAndNext"
|
||
@reprint="handleReprint"
|
||
@goodsItemClick="handleGoodsItemClick"
|
||
/>
|
||
<view v-else class="detail-empty">
|
||
<u-icon :name="isDprefixedWave ? 'scan' : 'list'" size="86" color="#c0c4cc"></u-icon>
|
||
<text class="empty-text">{{ isDprefixedWave ? '请扫描商品条码进行复核' : '请搜索或扫码选择订单进行复核' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 底部统计 -->
|
||
<view v-if="orderList.length > 0" class="bottom-stats-bar">
|
||
<view class="bottom-stats-info">
|
||
<text class="bottom-stats-value bottom-stats-value--warn">{{ totalUnreviewedCount }}</text><text class="bottom-stats-split">/</text><text class="bottom-stats-value">{{ totalOrders }}</text>
|
||
</view>
|
||
<view class="bottom-stats-actions">
|
||
<view class="bottom-stats-btn bottom-stats-btn--list" @click="showListDrawer = true">
|
||
<text class="bottom-stats-btn__text">订单列表</text>
|
||
</view>
|
||
<view class="bottom-stats-divider-vertical"></view>
|
||
<view class="bottom-stats-btn" @click="handleClearAll">
|
||
<text class="bottom-stats-btn__text">清空</text>
|
||
</view>
|
||
<view class="bottom-stats-divider-vertical"></view>
|
||
<view class="bottom-stats-btn" @click="handleRefreshTask">
|
||
<text class="bottom-stats-btn__text">刷新</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
|
||
<!-- 订单列表抽屉 -->
|
||
<u-popup :show="showListDrawer" mode="bottom" border-radius="20" :z-index="10080" @close="showListDrawer = false">
|
||
<view class="list-drawer">
|
||
<view class="list-drawer-header">
|
||
<text class="list-drawer-title">订单列表</text>
|
||
<text class="list-drawer-close" @click="showListDrawer = false">关闭</text>
|
||
</view>
|
||
<OrderList
|
||
:goodsInfoList="goodsInfoList"
|
||
:orderList="orderList"
|
||
:displayList="displayOrderList"
|
||
:listType="listType"
|
||
:printMode="printMode"
|
||
:activeOrderId="showDetailView ? (detailInfo.orderId || detailInfo.recordId || '') : ''"
|
||
@orderClick="handleDrawerOrderClick"
|
||
@printClick="handlePrintOrder"
|
||
/>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<!-- 设置数量弹窗 -->
|
||
<u-popup :show="showScanQtyPopup" mode="center" :closeable="true" border-radius="16" :z-index="10080" @close="showScanQtyPopup = false">
|
||
<view class="scan-qty-popup">
|
||
<view class="scan-qty-popup-title">设置扫描数量</view>
|
||
<view class="scan-qty-popup-body">
|
||
<input
|
||
class="scan-qty-input"
|
||
type="number"
|
||
value=""
|
||
placeholder="输入数量"
|
||
placeholder-style="color:#c0c4cc;font-size:36rpx"
|
||
:focus="true"
|
||
@input="handleScanQtyInput"
|
||
@confirm="handleScanQtyConfirm"
|
||
/>
|
||
<text class="scan-qty-unit">件</text>
|
||
</view>
|
||
<view class="scan-qty-popup-footer">
|
||
<view class="scan-qty-footer-btn scan-qty-footer-btn--cancel" @click="showScanQtyPopup = false">取消</view>
|
||
<view class="scan-qty-footer-btn scan-qty-footer-btn--save" @click="handleScanQtySave">确定</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<!-- 称重弹窗 -->
|
||
<u-popup :show="showWeighPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10080" @close="showWeighPopup = false">
|
||
<view class="weigh-popup">
|
||
<view class="weigh-popup-title weigh-popup-title--sm">称重</view>
|
||
<view class="weigh-popup-body">
|
||
<view class="weigh-section-label">重量信息</view>
|
||
<view class="weigh-ref-row">
|
||
<text class="weigh-ref-label">参考重量:<text class="weigh-ref-value">{{ refWeightG }}g</text></text>
|
||
</view>
|
||
<view class="weigh-row">
|
||
<text class="weigh-label">称重 <text class="weigh-required">*</text></text>
|
||
<view class="weigh-control">
|
||
<view class="weigh-btn weigh-btn--minus" @click="weighWeight = Math.max(0, weighWeight - 1)">-</view>
|
||
<input
|
||
class="weigh-input"
|
||
type="number"
|
||
:value="weighWeight > 0 ? String(weighWeight) : ''"
|
||
:focus="true"
|
||
placeholder="请输入重量(g)"
|
||
placeholder-style="color:#c0c4cc;font-size:36rpx"
|
||
@input="handleWeighInput"
|
||
/>
|
||
<view class="weigh-btn weigh-btn--plus" @click="weighWeight += 1">+</view>
|
||
<text class="weigh-unit">g</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="weigh-popup-footer">
|
||
<view class="weigh-footer-btn weigh-footer-btn--cancel" @click="handleWeighCancel">取消</view>
|
||
<view class="weigh-footer-btn weigh-footer-btn--save" @click="handleWeighSave">确定</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<!-- 包材绑定弹窗 -->
|
||
<u-popup :show="showPackageBindingPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10080" @close="showPackageBindingPopup = false">
|
||
<view class="package-popup">
|
||
<view class="package-popup-title">包材绑定</view>
|
||
<view class="package-popup-body">
|
||
<view v-if="suggestedPkg" class="package-ref-row">
|
||
<text class="package-ref-label">推荐包材:<text class="package-ref-value">{{ suggestedPkg.name }}({{ suggestedPkg.code }})</text><text class="package-ref-spec"> {{ suggestedPkg.spec }}</text></text>
|
||
</view>
|
||
<view v-if="scannedPackageMaterial" class="package-ref-row">
|
||
<text class="package-ref-label">已扫包材:<text class="package-ref-value">{{ scannedPackageMaterial.material_name || '' }}({{ scannedPackageMaterial.material_code || '' }})</text><text class="package-ref-spec"> {{ scannedPackageMaterial.spec || '' }}</text></text>
|
||
</view>
|
||
<view class="package-input-row">
|
||
<input
|
||
class="package-input"
|
||
v-model="packageInputCode"
|
||
:focus="packageBindingActivated"
|
||
placeholder="扫描/输入包材条码"
|
||
placeholder-style="color:#c0c4cc;font-size:32rpx"
|
||
@confirm="handlePackageBindingInputConfirm"
|
||
@keyup="handlePackageBindingKeyUp"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="package-popup-footer">
|
||
<view class="package-footer-btn package-footer-btn--skip" @click="handlePackageBindingSkip">取消</view>
|
||
<view class="package-footer-btn package-footer-btn--confirm" @click="handlePackageBindingConfirm">确定</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<!-- 设置弹窗 -->
|
||
<u-popup :show="showSettingsPopup" mode="center" :closeable="true" border-radius="16" :z-index="10080" @close="showSettingsPopup = false">
|
||
<view class="settings-popup">
|
||
<view class="settings-popup-title">复核设置</view>
|
||
<view class="settings-row">
|
||
<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"
|
||
>先打印后复核</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': printMode === 'reviewFirst' }"
|
||
@click="printMode = 'reviewFirst'; saveSettings(); showSettingsPopup = false"
|
||
>先复核后打印</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': printMode === 'noPrint' }"
|
||
@click="printMode = 'noPrint'; saveSettings(); showSettingsPopup = false"
|
||
>不打印</text>
|
||
</view>
|
||
</view>
|
||
<view class="settings-row">
|
||
<text class="settings-label">称重模式</text>
|
||
<view class="settings-options">
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': weighAfterReview }"
|
||
@click="weighAfterReview = true; saveSettings(); showSettingsPopup = false"
|
||
>需要称重</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': !weighAfterReview }"
|
||
@click="weighAfterReview = false; saveSettings(); showSettingsPopup = false"
|
||
>不需要称重</text>
|
||
</view>
|
||
</view>
|
||
<view v-if="listType !== 'single'" class="settings-row">
|
||
<text class="settings-label">绑定包材</text>
|
||
<view class="settings-options">
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': enablePackageBinding }"
|
||
@click="enablePackageBinding = true; saveSettings(); showSettingsPopup = false"
|
||
>开启</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': !enablePackageBinding }"
|
||
@click="enablePackageBinding = false; saveSettings(); showSettingsPopup = false"
|
||
>关闭</text>
|
||
</view>
|
||
</view>
|
||
<view v-if="listType !== 'single'" class="settings-row">
|
||
<text class="settings-label">包材软键盘</text>
|
||
<view class="settings-options">
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': packageBindingActivated }"
|
||
@click="packageBindingActivated = true; saveSettings(); showSettingsPopup = false"
|
||
>激活</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': !packageBindingActivated }"
|
||
@click="packageBindingActivated = false; saveSettings(); showSettingsPopup = false"
|
||
>不激活</text>
|
||
</view>
|
||
</view>
|
||
<view class="settings-row">
|
||
<text class="settings-label">发货模式</text>
|
||
<view class="settings-options">
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': autoShip }"
|
||
@click="autoShip = true; saveSettings(); showSettingsPopup = false"
|
||
>自动发货</text>
|
||
<text
|
||
class="settings-option"
|
||
:class="{ 'settings-option--active': !autoShip }"
|
||
@click="autoShip = false; saveSettings(); showSettingsPopup = false"
|
||
>手动发货</text>
|
||
</view>
|
||
</view>
|
||
<view class="settings-popup-footer">
|
||
<view class="settings-footer-btn" @click="showSettingsPopup = false">关闭</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<u-popup v-if="showPrintPopup" :show="showPrintPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="showPrintPopup = false">
|
||
<view class="print-popup">
|
||
<scroll-view scroll-y class="print-popup-scroll">
|
||
<view class="print-popup-title">打印设置</view>
|
||
<view class="print-row print-row--station">
|
||
<text class="print-label">打印台</text>
|
||
<view class="print-station-input-wrap">
|
||
<u-input
|
||
v-model="printStationInputKeyword"
|
||
placeholder="请输入或扫描打印台编号"
|
||
:clearable="true"
|
||
:customStyle="{ fontSize: '28rpx', height: '80rpx', lineHeight: '80rpx', padding: '0 20rpx', background: '#fafafa', borderRadius: '10rpx' }"
|
||
@input="handlePrintStationInput"
|
||
@focus="handlePrintStationInputFocus"
|
||
@blur="handlePrintStationInputBlur"
|
||
@confirm="handlePrintStationInputConfirm"
|
||
></u-input>
|
||
<view v-if="showPrintStationDropdown && printStationFilteredList.length > 0" class="print-station-dropdown">
|
||
<scroll-view scroll-y class="print-station-dropdown-scroll">
|
||
<view
|
||
v-for="station in printStationFilteredList"
|
||
:key="station.id"
|
||
class="print-station-option print-station-option--row"
|
||
:class="{ 'print-station-option--active': station.id === printStationId }"
|
||
@mousedown.stop="handlePrintStationSelect(station)"
|
||
>
|
||
<text class="station-option-name">{{ station.name }}</text>
|
||
<text v-if="station.customBarcode" class="station-option-code">{{ station.customBarcode }}</text>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
<view v-if="showPrintStationDropdown && printStationInputKeyword && printStationFilteredList.length === 0" class="print-station-dropdown">
|
||
<view class="print-station-option print-station-option--empty">未匹配到打印台</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<u-popup :show="showStationListPopup" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="showStationListPopup = false; selectedStationId = ''">
|
||
<view class="print-popup">
|
||
<view class="print-popup-title">打印台列表</view>
|
||
<scroll-view class="station-list-scroll" scroll-y>
|
||
<view v-if="printStationList.length === 0" class="station-list-empty">暂无打印台数据</view>
|
||
<view
|
||
v-for="station in printStationList"
|
||
:key="station.id"
|
||
class="station-list-item"
|
||
:class="{ 'station-list-item--selected': selectedStationId === station.id }"
|
||
@click="handleStationListItemClick(station)"
|
||
>
|
||
<view class="station-list-item__left">
|
||
<text class="station-list-item__name" :class="{ 'station-list-item__name--active': selectedStationId === station.id }">{{ station.name }}</text>
|
||
</view>
|
||
<view v-if="selectedStationId === station.id" class="station-list-item__check">
|
||
<u-icon name="checkmark" size="36rpx" color="#2979ff"></u-icon>
|
||
</view>
|
||
</view>
|
||
<view class="safe-bottom-in-popup"></view>
|
||
</scroll-view>
|
||
<view v-if="stationListTotal > 0" class="station-list-pagination">
|
||
<pagination
|
||
:pageNum.sync="stationListPage"
|
||
:pageSize="stationListPageSize"
|
||
:total="stationListTotal"
|
||
:showTotal="true"
|
||
:prevText="'上一页'"
|
||
:nextText="'下一页'"
|
||
:showFirstLast="true"
|
||
:firstText="'首页'"
|
||
:lastText="'末页'"
|
||
@change="handleStationListPageChange"
|
||
/>
|
||
</view>
|
||
<view class="station-list-confirm">
|
||
<u-button
|
||
type="primary"
|
||
:disabled="!selectedStationId"
|
||
:customStyle="{ backgroundColor: selectedStationId ? '#2979ff' : '#a0c4ff', borderColor: selectedStationId ? '#2979ff' : '#a0c4ff', fontSize: '30rpx', height: '80rpx', lineHeight: '80rpx', borderRadius: '12rpx', marginTop: '20rpx' }"
|
||
@click="handleStationListConfirm"
|
||
>
|
||
确定
|
||
</u-button>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import voice from '@/core/utils/voice';
|
||
import OrderList from './order-review-comps/OrderList.vue';
|
||
import ReviewDetail from './order-review-comps/ReviewDetail.vue';
|
||
export default {
|
||
components: {
|
||
OrderList,
|
||
ReviewDetail
|
||
},
|
||
data() {
|
||
return {
|
||
title: '订单复核',
|
||
grabCount: 0,
|
||
keyword: '',
|
||
scanQuantity: 1,
|
||
showScanQtyPopup: false,
|
||
showUnboundPrintStationOnly: false,
|
||
currentUserId: '',
|
||
currentOrderIndex: -1,
|
||
pageSize: 20,
|
||
currentPage: 1,
|
||
paginationTotal: 0,
|
||
showStationListPopup: false,
|
||
showPrintPopup: false,
|
||
showPrintStationDropdown: false,
|
||
printStationInputKeyword: '',
|
||
printStationName: '--',
|
||
printStationId: '',
|
||
printMode: 'printFirst',
|
||
showPrintModeDropdown: false,
|
||
showSettingsPopup: false,
|
||
showWeighPopup: false,
|
||
weighWeight: 0,
|
||
weighAfterReview: false,
|
||
weighCancelled: false,
|
||
packageInputCode: '',
|
||
scannedPackageCode: '',
|
||
scannedPackageId: '',
|
||
scannedPackageMaterial: null,
|
||
suggestedPkg: null,
|
||
enablePackageBinding: true,
|
||
packageBindingActivated: false,
|
||
showPackageBindingPopup: false,
|
||
autoShip: true,
|
||
printStationList: [],
|
||
selectedStationId: '',
|
||
stationListPage: 1,
|
||
stationListPageSize: 20,
|
||
stationListTotal: 0,
|
||
printMessage: '',
|
||
pendingPrintCount: 0,
|
||
printRequestCode: '',
|
||
printWaveGroups: [],
|
||
printWavePlatformPrintData: null,
|
||
printTargetList: [],
|
||
goodsInfoList: [],
|
||
orderList: [],
|
||
listType: '',
|
||
totalOrders: 0,
|
||
taskId: '',
|
||
scanPickerName: '',
|
||
reviewedOrderIds: [],
|
||
_debugClickCount: 0,
|
||
_debugClickTimer: null,
|
||
_debugMode: false,
|
||
_debugLogs: [],
|
||
_autoSelectFirst: false,
|
||
packageBindingCancelled: false,
|
||
skipPackagePopupOnAllScanned: false,
|
||
showDetailView: false,
|
||
showListDrawer: false,
|
||
detailGoodsList: [],
|
||
detailInfo: {
|
||
recordId: '',
|
||
orderId: 0,
|
||
waveId: '',
|
||
waveNo: '--',
|
||
waybillNo: '',
|
||
matchType: '',
|
||
recheckStatus: '',
|
||
pickerName: '--',
|
||
cartNo: '--',
|
||
status: 'pending',
|
||
unreviewedCount: 0,
|
||
storeRemark: '',
|
||
waveIndex: '',
|
||
orderIds: [],
|
||
interceptStatus: '',
|
||
printStationId: '',
|
||
printStationName: '',
|
||
boxNo: ''
|
||
}
|
||
};
|
||
},
|
||
computed: {
|
||
isAllGoodsScanned() {
|
||
return this.detailGoodsList.length > 0 && this.detailGoodsList.every(item => Number(item.scannedQty) >= Number(item.planQty));
|
||
},
|
||
printStationFilteredList() {
|
||
const list = Array.isArray(this.printStationList) ? this.printStationList : [];
|
||
const keyword = this.normalizeKeyword(this.printStationInputKeyword);
|
||
if (!keyword) {
|
||
return list;
|
||
}
|
||
return list.filter(station => {
|
||
const name = String(station.name || '').toLowerCase();
|
||
const id = String(station.id || '').toLowerCase();
|
||
const barcode = String(station.customBarcode || '').toLowerCase();
|
||
const kw = keyword.toLowerCase();
|
||
return name.includes(kw) || id.includes(kw) || barcode.includes(kw);
|
||
});
|
||
},
|
||
displayOrderList() {
|
||
const list = Array.isArray(this.orderList) ? this.orderList : [];
|
||
if (!this.showUnboundPrintStationOnly) {
|
||
return list;
|
||
}
|
||
return list.filter(item => !item?.hasBoundPrintStation);
|
||
},
|
||
totalUnreviewedCount() {
|
||
const list = Array.isArray(this.orderList) ? this.orderList : [];
|
||
if (!list.length) return 0;
|
||
const reviewedIds = this.reviewedOrderIds;
|
||
if (this.listType === 'single') {
|
||
return list.filter(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId > 0 && reviewedIds.includes(itemId)) return false;
|
||
return !item.isReviewed;
|
||
}).length;
|
||
}
|
||
if (this.listType === 'group') {
|
||
return list.filter(item => (item.unreviewedCount || 0) > 0).length;
|
||
}
|
||
// listType 为空时兜底
|
||
return list.filter(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId > 0 && reviewedIds.includes(itemId)) return false;
|
||
return !item.isReviewed;
|
||
}).length;
|
||
},
|
||
isDetailReadOnly() {
|
||
return this.showDetailView && String(this.detailInfo?.recheckStatus || '').toLowerCase() === 'fin';
|
||
},
|
||
refWeightG() {
|
||
const kg = Number(this.detailInfo?.itemsWeight || 0);
|
||
const g = kg > 0 ? Math.round(kg * 1000) : 0;
|
||
console.log('[refWeightG] itemsWeight:', this.detailInfo?.itemsWeight, 'kg:', kg, 'g:', g);
|
||
return g;
|
||
},
|
||
effectivePrintMode() {
|
||
// 散单模式只走先复核后打印或不打印
|
||
if (this.listType === 'single' && this.printMode !== 'noPrint') {
|
||
return 'reviewFirst';
|
||
}
|
||
return this.printMode;
|
||
},
|
||
isDprefixedWave() {
|
||
// D前缀波次:单品单件订单,无需逐件扫描
|
||
if (this.listType !== 'single') return false;
|
||
const list = Array.isArray(this.orderList) ? this.orderList : [];
|
||
if (!list.length) return false;
|
||
return list.some(item => String(item.waveNo || '').startsWith('D'));
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
this.safeDispatchBroadcast('setCallbacks', {
|
||
onResult: this.handleBroadcastResult
|
||
});
|
||
this.safeDispatchBroadcast('start');
|
||
|
||
this.currentUserId = String(this.$store?.getters?.user?.id || this.$store?.getters?.user?.user_id || '');
|
||
const hasGrabCountParam = options && Object.prototype.hasOwnProperty.call(options, 'grabCount');
|
||
const parsedGrabCount = Number(options?.grabCount || 0);
|
||
this.grabCount = hasGrabCountParam
|
||
? Math.max(0, parsedGrabCount)
|
||
: 5;
|
||
this.loadSettings();
|
||
this.initializeOrderList();
|
||
this.loadPrintStations(1, false);
|
||
|
||
// 监听拦截完成事件
|
||
uni.$on('orderInterceptCompleted', this.handleInterceptCompleted);
|
||
},
|
||
onShow() {
|
||
this.safeDispatchBroadcast('setCallbacks', {
|
||
onResult: this.handleBroadcastResult
|
||
});
|
||
this.safeDispatchBroadcast('resume');
|
||
},
|
||
onHide() {
|
||
this.safeDispatchBroadcast('pause');
|
||
},
|
||
onUnload() {
|
||
this.safeDispatchBroadcast('stop');
|
||
uni.$off('orderInterceptCompleted', this.handleInterceptCompleted);
|
||
if (this._debugMode) {
|
||
this.flushDebugLogs();
|
||
}
|
||
if (this._debugClickTimer) {
|
||
clearTimeout(this._debugClickTimer);
|
||
this._debugClickTimer = null;
|
||
}
|
||
},
|
||
methods: {
|
||
buildBatchListParams(page = this.currentPage) {
|
||
const where = {
|
||
source: 0,
|
||
wave_type: 2
|
||
};
|
||
return {
|
||
pagination: {
|
||
page: Math.max(1, Number(page || 1)),
|
||
pageSize: Math.max(1, Number(this.pageSize || 20))
|
||
},
|
||
where
|
||
};
|
||
},
|
||
extractPagination(payload, response) {
|
||
return payload?.pagination || payload?.page || response?.data?.pagination || response?.pagination || null;
|
||
},
|
||
extractBatchListPayload(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 {};
|
||
},
|
||
extractBatchList(payload, response) {
|
||
const candidates = [
|
||
payload?.list,
|
||
payload?.rows,
|
||
payload?.items,
|
||
payload?.data?.list,
|
||
response?.data?.list,
|
||
response?.data?.data?.list,
|
||
response?.list
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
if (Array.isArray(candidates[i])) {
|
||
return candidates[i];
|
||
}
|
||
}
|
||
return [];
|
||
},
|
||
initializeOrderList() {
|
||
this.orderList = [];
|
||
this.paginationTotal = 0;
|
||
this.currentPage = 1;
|
||
this.pageSize = 20;
|
||
},
|
||
normalizeGoodsInfoList(items) {
|
||
if (!Array.isArray(items)) {
|
||
return [];
|
||
}
|
||
return items
|
||
.map((item, index) => {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const basketNo = String(
|
||
source.basket_no
|
||
|| source.basketNo
|
||
|| source.basket_code
|
||
|| source.basketCode
|
||
|| source.line_no
|
||
|| source.lineNo
|
||
|| '--'
|
||
).trim() || '--';
|
||
const planQty = Number(source.plan_qty ?? source.planQty ?? source.qty ?? source.quantity ?? 0);
|
||
const scannedQty = Number(source.scanned_qty ?? source.scannedQty ?? source.finish_qty ?? source.finishQty ?? source.done_qty ?? source.doneQty ?? source.picked_qty ?? source.pickedQty ?? 0);
|
||
const imageUrl = String(source.image || source.image_url || source.product_image || source.goods_image || source.pic || source.cover || '').trim();
|
||
const skuName = String(source.sku_name || source.skuName || source.name || source.product_name || source.goods_name || '--').trim() || '--';
|
||
return {
|
||
id: String(source.id ?? source.item_id ?? source.itemId ?? `${basketNo}-${index + 1}`),
|
||
basketNo,
|
||
planQty: Number.isFinite(planQty) ? planQty : 0,
|
||
scannedQty: Number.isFinite(scannedQty) ? scannedQty : 0,
|
||
imageUrl,
|
||
skuName
|
||
};
|
||
})
|
||
.filter(item => !!item.basketNo || !!item.skuName);
|
||
},
|
||
normalizeBatchWaveList(list) {
|
||
if (!Array.isArray(list)) {
|
||
return [];
|
||
}
|
||
return list
|
||
.map((item, index) => {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const waveNo = String(source.wave_no || source.waveNo || '').trim();
|
||
const waveId = source.wave_id ?? source.waveId ?? source.id ?? '';
|
||
const printStationId = source.print_station_id ?? source.printStationId ?? source.station_id ?? source.stationId ?? '';
|
||
const normalizedPrintStationId = String(printStationId || '').trim();
|
||
const rowId = source.id ?? waveId ?? waveNo ?? `batch-${this.currentPage}-${index + 1}`;
|
||
const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--';
|
||
const cartNo = String(source.cart_code || source.cartCode || source.cart_no || source.cartNo || '--').trim() || '--';
|
||
const unreviewedCount = Number(source.unreviewed_count ?? source.unreviewedCount ?? source.pending_count ?? source.pendingCount ?? 0);
|
||
const unprintedCount = Number(source.unprinted_count ?? source.unprintedCount ?? 0);
|
||
const orderCount = Number(source.order_count ?? source.orderCount ?? 0);
|
||
const interceptStatus = String(source.intercept_status || source.interceptStatus || '').trim();
|
||
const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim();
|
||
return {
|
||
id: String(rowId || `batch-${this.currentPage}-${index + 1}`),
|
||
waveId: typeof waveId === 'number' ? waveId : String(waveId || '').trim(),
|
||
waveNo,
|
||
pickerName,
|
||
cartNo,
|
||
unreviewedCount: Number.isFinite(unreviewedCount) ? unreviewedCount : 0,
|
||
unprintedCount: Number.isFinite(unprintedCount) ? unprintedCount : 0,
|
||
orderCount: Number.isFinite(orderCount) ? orderCount : 0,
|
||
interceptStatus,
|
||
status: String(source.status || 'pending'),
|
||
waybillCode: String(source.waybill_no || source.waybillCode || source.waybill_code || ''),
|
||
printStationId: normalizedPrintStationId,
|
||
hasBoundPrintStation: !!normalizedPrintStationId && normalizedPrintStationId !== '0',
|
||
isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId
|
||
};
|
||
})
|
||
.filter(item => !!item.waveNo);
|
||
},
|
||
resolvePaginationTotal(payload, response, pagination, list) {
|
||
const candidates = [
|
||
pagination?.total,
|
||
payload?.total,
|
||
payload?.count,
|
||
payload?.totalCount,
|
||
response?.data?.total,
|
||
response?.total,
|
||
Array.isArray(list) ? list.length : 0
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const value = Number(candidates[i]);
|
||
if (Number.isFinite(value) && value >= 0) {
|
||
return value;
|
||
}
|
||
}
|
||
return 0;
|
||
},
|
||
resolveWarehouseId() {
|
||
const user = this.$store?.getters?.user || {};
|
||
const userInfo = this.$store?.getters?.userInfo || {};
|
||
const candidates = [
|
||
user?.warehouse_id,
|
||
user?.warehouseId,
|
||
user?.store_id,
|
||
user?.storeId,
|
||
userInfo?.warehouse_id,
|
||
userInfo?.warehouseId,
|
||
userInfo?.store_id,
|
||
userInfo?.storeId,
|
||
uni.getStorageSync('warehouse_id'),
|
||
uni.getStorageSync('warehouseId'),
|
||
uni.getStorageSync('store_id'),
|
||
uni.getStorageSync('storeId')
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const value = Number(candidates[i]);
|
||
if (Number.isFinite(value) && value > 0) {
|
||
return value;
|
||
}
|
||
}
|
||
return 0;
|
||
},
|
||
normalizeWaveIds(list) {
|
||
const sourceList = Array.isArray(list) ? list : [];
|
||
const normalized = sourceList
|
||
.map(item => item?.waveId ?? '')
|
||
.map(value => (typeof value === 'number' ? value : String(value || '').trim()))
|
||
.filter(value => value !== '' && value !== '--');
|
||
return Array.from(new Set(normalized));
|
||
},
|
||
buildWavePlatformPrintParams() {
|
||
const warehouseId = this.resolveWarehouseId();
|
||
const waveIds = this.normalizeWaveIds(this.printTargetList);
|
||
return {
|
||
warehouse_id: warehouseId,
|
||
wave_ids: waveIds
|
||
};
|
||
},
|
||
extractWavePlatformPrintPayload(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') {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
normalizeWaveGroups(payload) {
|
||
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : [];
|
||
return groups
|
||
.map(group => (group && typeof group === 'object' ? group : null))
|
||
.filter(group => !!group);
|
||
},
|
||
buildPrintRequestCode() {
|
||
const timePart = Date.now().toString(36);
|
||
const randomPart = Math.random().toString(36).slice(2, 10);
|
||
return `PRINT_${timePart}_${randomPart}`;
|
||
},
|
||
async requestWavePlatformPrintData() {
|
||
const params = this.buildWavePlatformPrintParams();
|
||
if (!params.warehouse_id) {
|
||
throw new Error('缺少仓库ID');
|
||
}
|
||
if (!params.wave_ids.length) {
|
||
throw new Error('缺少波次ID');
|
||
}
|
||
const response = await this.$http('order.print.getWavePlatformPrintData', params);
|
||
const payload = this.extractWavePlatformPrintPayload(response);
|
||
const waveGroups = this.normalizeWaveGroups(payload);
|
||
if (!waveGroups.length) {
|
||
throw new Error('未获取到可打印的waveGroups');
|
||
}
|
||
this.printWavePlatformPrintData = payload;
|
||
this.printWaveGroups = waveGroups;
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
return payload;
|
||
},
|
||
buildPrintRecordWhere() {
|
||
return {};
|
||
},
|
||
buildPrintRecordParams(page = 1) {
|
||
return {
|
||
page: Math.max(1, Number(page || 1)),
|
||
pageSize: 20,
|
||
where: this.buildPrintRecordWhere()
|
||
};
|
||
},
|
||
extractPrintRecordList(response) {
|
||
const list = response?.data?.list || response?.data?.data?.list;
|
||
return Array.isArray(list) ? list : [];
|
||
},
|
||
extractPrintRecordTotal(response) {
|
||
const candidates = [
|
||
response?.data?.total,
|
||
response?.data?.pagination?.total,
|
||
response?.data?.data?.total,
|
||
response?.data?.count,
|
||
response?.total,
|
||
response?.count
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const value = Number(candidates[i]);
|
||
if (Number.isFinite(value) && value >= 0) {
|
||
return value;
|
||
}
|
||
}
|
||
return 0;
|
||
},
|
||
normalizePrintStations(list) {
|
||
return list
|
||
.map(item => {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const id = String(source.id ?? source.print_station_id ?? source.printStationId ?? '').trim();
|
||
const name = String(source.name || source.station_name || source.print_station_name || '').trim();
|
||
const customBarcode = String(source.custom_barcode || '').trim();
|
||
return {
|
||
id,
|
||
name,
|
||
customBarcode
|
||
};
|
||
})
|
||
.filter(item => !!item.id && !!item.name);
|
||
},
|
||
loadSettings() {
|
||
try {
|
||
const stored = uni.getStorageSync('review_settings');
|
||
if (stored) {
|
||
if (stored.printMode === 'printFirst' || stored.printMode === 'reviewFirst' || stored.printMode === 'noPrint') {
|
||
this.printMode = stored.printMode;
|
||
}
|
||
if (typeof stored.weighAfterReview === 'boolean') {
|
||
this.weighAfterReview = stored.weighAfterReview;
|
||
}
|
||
if (typeof stored.autoShip === 'boolean') {
|
||
this.autoShip = stored.autoShip;
|
||
}
|
||
const qty = Number(stored.scanQuantity);
|
||
if (Number.isFinite(qty) && qty > 0) {
|
||
this.scanQuantity = qty;
|
||
}
|
||
if (typeof stored.enablePackageBinding === 'boolean') {
|
||
this.enablePackageBinding = stored.enablePackageBinding;
|
||
}
|
||
if (typeof stored.packageBindingActivated === 'boolean') {
|
||
this.packageBindingActivated = stored.packageBindingActivated;
|
||
}
|
||
}
|
||
} catch (e) {
|
||
// 忽略
|
||
}
|
||
},
|
||
saveSettings() {
|
||
try {
|
||
uni.setStorageSync('review_settings', {
|
||
printMode: this.printMode,
|
||
weighAfterReview: this.weighAfterReview,
|
||
autoShip: this.autoShip,
|
||
scanQuantity: this.scanQuantity,
|
||
enablePackageBinding: this.enablePackageBinding,
|
||
packageBindingActivated: this.packageBindingActivated
|
||
});
|
||
} catch (e) {
|
||
console.warn('[OrderReview] 保存设置失败:', e);
|
||
}
|
||
},
|
||
speakVoice(text) {
|
||
voice.speak(text, { minInterval: 800 });
|
||
},
|
||
loadScanQuantity() {
|
||
try {
|
||
const stored = uni.getStorageSync('review_scan_quantity');
|
||
const num = Number(stored);
|
||
if (Number.isFinite(num) && num > 0) {
|
||
this.scanQuantity = num;
|
||
}
|
||
} catch (e) {
|
||
// 忽略
|
||
}
|
||
},
|
||
saveScanQuantity(val) {
|
||
this.scanQuantity = val;
|
||
this.saveSettings();
|
||
},
|
||
handleScanQtyInput(e) {
|
||
const val = e?.detail?.value ?? e?.target?.value ?? '';
|
||
const num = parseInt(val, 10);
|
||
if (Number.isFinite(num) && num > 0) {
|
||
this.scanQuantity = num;
|
||
}
|
||
},
|
||
handleScanQtyConfirm(e) {
|
||
const val = e?.detail?.value ?? e?.target?.value ?? '';
|
||
const num = parseInt(val, 10);
|
||
if (Number.isFinite(num) && num > 0) {
|
||
this.scanQuantity = num;
|
||
this.saveScanQuantity(num);
|
||
this.showScanQtyPopup = false;
|
||
} else {
|
||
uni.showToast({ title: '请输入有效数量', icon: 'none' });
|
||
}
|
||
},
|
||
handleScanQtySave() {
|
||
if (this.scanQuantity > 0) {
|
||
this.saveScanQuantity(this.scanQuantity);
|
||
this.showScanQtyPopup = false;
|
||
} else {
|
||
uni.showToast({ title: '请输入有效数量', icon: 'none' });
|
||
}
|
||
},
|
||
async loadPrintStations(page = 1, autoAssign = true) {
|
||
const response = await this.$http('print.getList', this.buildPrintRecordParams(page));
|
||
const list = this.extractPrintRecordList(response);
|
||
const total = this.extractPrintRecordTotal(response);
|
||
const stations = this.normalizePrintStations(list);
|
||
this.printStationList = stations;
|
||
this.stationListTotal = total;
|
||
this.stationListPage = Math.max(1, Number(page || 1));
|
||
if (autoAssign && stations.length && !this.printStationId) {
|
||
this.printStationId = stations[0]?.id || '';
|
||
this.printStationName = stations[0]?.name || '--';
|
||
}
|
||
},
|
||
togglePrintStationDropdown() {
|
||
if (!this.printStationList.length) {
|
||
uni.showToast({
|
||
title: '暂无可用打印台',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
this.showPrintStationDropdown = !this.showPrintStationDropdown;
|
||
},
|
||
handleOpenPrintSettings() {
|
||
this.showPrintStationDropdown = false;
|
||
this.showPrintModeDropdown = false;
|
||
this.printStationInputKeyword = '';
|
||
this.showPrintPopup = true;
|
||
// 加载打印台列表
|
||
if (!this.printStationList.length) {
|
||
this.loadPrintStations(1, false);
|
||
}
|
||
},
|
||
handlePrintStationSelect(station) {
|
||
this.printStationId = String(station?.id || '');
|
||
this.printStationName = String(station?.name || '--');
|
||
const name = String(station?.name || '');
|
||
const code = String(station?.customBarcode || '');
|
||
this.printStationInputKeyword = code ? `${name}(${code})` : name;
|
||
this.showPrintStationDropdown = false;
|
||
if (name) {
|
||
uni.showToast({
|
||
title: `已匹配:${name}`,
|
||
icon: 'none'
|
||
});
|
||
setTimeout(() => {
|
||
this.showPrintPopup = false;
|
||
}, 600);
|
||
}
|
||
},
|
||
matchPrintStation(text) {
|
||
if (!text || !Array.isArray(this.printStationList) || !this.printStationList.length) {
|
||
uni.showToast({ title: '暂无可用打印台', icon: 'none' });
|
||
return;
|
||
}
|
||
const kw = text.toLowerCase();
|
||
const matched = this.printStationList.find(station =>
|
||
String(station.name).toLowerCase() === kw
|
||
|| String(station.id).toLowerCase() === kw
|
||
|| String(station.customBarcode || '').toLowerCase() === kw
|
||
);
|
||
if (matched) {
|
||
this.printStationId = String(matched.id);
|
||
this.printStationName = String(matched.name || '--');
|
||
uni.showToast({ title: `已绑定打印台:${matched.name}`, icon: 'success' });
|
||
this.speakVoice('已绑定打印台');
|
||
} else {
|
||
uni.showToast({ title: '未匹配到打印台', icon: 'none' });
|
||
this.speakVoice('未绑定打印台');
|
||
}
|
||
},
|
||
handlePrintStationInput(value) {
|
||
const keyword = this.normalizeKeyword(value);
|
||
// 输入时不显示打印台列表,避免误选
|
||
this.showPrintStationDropdown = false;
|
||
if (!keyword) {
|
||
return;
|
||
}
|
||
// 精确匹配:输入内容与某个打印台名称或ID完全一致时自动选中
|
||
const exactMatch = this.printStationFilteredList.find(station => {
|
||
const kw = keyword.toLowerCase();
|
||
return String(station.name).toLowerCase() === kw
|
||
|| String(station.id).toLowerCase() === kw
|
||
|| String(station.customBarcode || '').toLowerCase() === kw;
|
||
});
|
||
if (exactMatch) {
|
||
this.printStationId = String(exactMatch.id);
|
||
this.printStationName = String(exactMatch.name);
|
||
const name = String(exactMatch.name || '');
|
||
const code = String(exactMatch.customBarcode || '');
|
||
this.printStationInputKeyword = code ? `${name}(${code})` : name;
|
||
uni.showToast({
|
||
title: `已匹配:${name}`,
|
||
icon: 'none'
|
||
});
|
||
setTimeout(() => {
|
||
this.showPrintPopup = false;
|
||
}, 600);
|
||
}
|
||
},
|
||
handlePrintStationInputFocus() {
|
||
// 聚焦时不显示打印台列表,避免误选
|
||
this.showPrintStationDropdown = false;
|
||
},
|
||
handlePrintStationInputBlur() {
|
||
// 延迟关闭,让点击选项事件有机会执行
|
||
setTimeout(() => {
|
||
this.showPrintStationDropdown = false;
|
||
}, 200);
|
||
},
|
||
handlePrintStationInputConfirm() {
|
||
const keyword = this.normalizeKeyword(this.printStationInputKeyword);
|
||
if (!keyword) {
|
||
return;
|
||
}
|
||
// 按回车时,如果有精确匹配则选中,否则选中过滤列表第一个
|
||
if (this.printStationFilteredList.length > 0) {
|
||
const station = this.printStationFilteredList[0];
|
||
this.handlePrintStationSelect(station);
|
||
}
|
||
},
|
||
safeDispatchBroadcast(action, payload) {
|
||
try {
|
||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||
if (task && typeof task.catch === 'function') {
|
||
task.catch(error => {
|
||
console.warn(`[ScatterPickingDetail] broadcast/${action} 调用失败:`, error);
|
||
});
|
||
}
|
||
} catch (error) {
|
||
console.warn(`[ScatterPickingDetail] 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 scanText = this.normalizeScanResult(result);
|
||
console.log('[OrderReview] handleBroadcastResult 扫描结果:', scanText, '原始数据:', result);
|
||
if (!scanText) {
|
||
return;
|
||
}
|
||
// 包材绑定弹窗打开时,扫描只处理包材条码
|
||
if (this.showPackageBindingPopup) {
|
||
this.packageInputCode = scanText;
|
||
this.handlePackageCodeConfirm({ detail: { value: scanText } });
|
||
return;
|
||
}
|
||
// 称重弹窗打开时,处理扫描
|
||
if (this.showWeighPopup) {
|
||
this.packageInputCode = scanText;
|
||
this.handlePackageCodeConfirm({ detail: { value: scanText } });
|
||
return;
|
||
}
|
||
// 打印设置弹窗打开时,扫描结果填入打印台输入框
|
||
if (this.showPrintPopup) {
|
||
this.printStationInputKeyword = scanText;
|
||
this.handlePrintStationInput(scanText);
|
||
return;
|
||
}
|
||
// 详情视图模式下,扫描传给 ReviewDetail 组件处理
|
||
if (this.showDetailView && this.$refs.reviewDetail) {
|
||
// 多商品匹配弹窗已打开时,忽略重复扫描,避免重复提示
|
||
if (this.$refs.reviewDetail.showMultiMatchPopup) {
|
||
return;
|
||
}
|
||
this.keyword = scanText;
|
||
console.log('[OrderReview][handleBroadcastResult] 广播扫描值:', scanText);
|
||
const matched = this.$refs.reviewDetail.handleScanCode(scanText);
|
||
setTimeout(() => { this.keyword = ''; }, 300);
|
||
if (!matched) {
|
||
uni.showToast({ title: '条码不匹配', icon: 'none' });
|
||
uni.vibrateShort({ type: 'medium' });
|
||
}
|
||
return;
|
||
}
|
||
// 列表视图下,广播输入作为打印台匹配
|
||
this.keyword = scanText;
|
||
this.handleSearch();
|
||
},
|
||
handleScanAsProductBarcode(barcode) {
|
||
// 从订单列表中取第一个未复核的订单进入详情
|
||
const target = this.orderList.find(item => {
|
||
if (this.listType === 'single') {
|
||
return !item.isReviewed;
|
||
}
|
||
return (item.unreviewedCount || 0) > 0;
|
||
}) || this.orderList[0];
|
||
if (!target) {
|
||
uni.showToast({ title: '无可用订单进入', icon: 'none' });
|
||
return;
|
||
}
|
||
// 将商品条码缓存,供详情页自动匹配
|
||
try {
|
||
uni.setStorageSync('scan_product_barcode', barcode);
|
||
} catch (e) {
|
||
console.warn('[OrderReview] 缓存商品条码失败:', e);
|
||
}
|
||
this.goPickGoodsDetail(target);
|
||
},
|
||
findOrderByProductBarcode(barcode) {
|
||
if (!barcode || !Array.isArray(this.orderList)) return null;
|
||
const kw = String(barcode).trim().toLowerCase();
|
||
if (!kw) return null;
|
||
for (const order of this.orderList) {
|
||
// 跳过已复核的订单
|
||
if (order.isReviewed) continue;
|
||
const items = Array.isArray(order.detailItems) ? order.detailItems : [];
|
||
for (const item of items) {
|
||
if (!item || typeof item !== 'object') continue;
|
||
// 检查 stock 中的 barcodes 数组
|
||
const stock = item.stock && typeof item.stock === 'object' ? item.stock : null;
|
||
if (stock && Array.isArray(stock.barcodes)) {
|
||
if (stock.barcodes.some(b => String(b || '').trim().toLowerCase() === kw)) {
|
||
return order;
|
||
}
|
||
}
|
||
// 检查 item_snapshot 中的条码
|
||
const snapshot = item.item_snapshot && typeof item.item_snapshot === 'object' ? item.item_snapshot : null;
|
||
if (snapshot) {
|
||
const snapBarcode = String(snapshot.barcode || '').trim().toLowerCase();
|
||
if (snapBarcode === kw) return order;
|
||
const snapCode = String(snapshot.item_code || '').trim().toLowerCase();
|
||
if (snapCode === kw) return order;
|
||
}
|
||
// 检查 item 直接字段
|
||
const itemCode = String(item.item_code || '').trim().toLowerCase();
|
||
if (itemCode === kw) return order;
|
||
}
|
||
}
|
||
return null;
|
||
},
|
||
handleSearch() {
|
||
const text = this.normalizeKeyword(this.keyword);
|
||
if (!text) return;
|
||
this.keyword = '';
|
||
this._autoSelectFirst = true; // 输入搜索选第一个
|
||
// 详情视图模式下,搜索框输入当作条码传给 ReviewDetail
|
||
if (this.showDetailView && this.$refs.reviewDetail) {
|
||
// 已复核订单禁止扫描
|
||
if (this.$refs.reviewDetail.isReadOnly) {
|
||
uni.showToast({ title: '该订单已复核完成,仅可查看', icon: 'none' });
|
||
return;
|
||
}
|
||
// 多商品匹配弹窗已打开时,忽略重复扫描,避免重复提示
|
||
if (this.$refs.reviewDetail.showMultiMatchPopup) {
|
||
return;
|
||
}
|
||
console.log('[OrderReview][handleSearch] 搜索框扫描值:', text);
|
||
const matched = this.$refs.reviewDetail.handleScanCode(text);
|
||
if (!matched) {
|
||
uni.showToast({ title: '条码不匹配', icon: 'none' });
|
||
uni.vibrateShort({ type: 'medium' });
|
||
this.speakVoice('无记录');
|
||
}
|
||
return;
|
||
}
|
||
// D前缀波次:在订单列表中查找商品条码所属订单
|
||
if (this.isDprefixedWave) {
|
||
const matchedOrder = this.findOrderByProductBarcode(text);
|
||
if (matchedOrder) {
|
||
this.goPickGoodsDetail(matchedOrder);
|
||
return;
|
||
}
|
||
// 商品条码未匹配时,尝试用车号/运单号查询后端(支持扫拣货车进入下一个波次)
|
||
if (this.printStationId || this.printMode === 'noPrint') {
|
||
this.requestScanOrder(text);
|
||
} else {
|
||
uni.showToast({ title: '未找到匹配的商品', icon: 'none' });
|
||
this.speakVoice('无记录');
|
||
}
|
||
return;
|
||
}
|
||
// 已绑定打印台或设置为不打印时,切换到搜索订单功能
|
||
if (this.printStationId || this.printMode === 'noPrint') {
|
||
this.requestScanOrder(text);
|
||
return;
|
||
}
|
||
// 未绑定打印台,输入作为打印台匹配
|
||
this.matchPrintStation(text);
|
||
},
|
||
handleSearchBoxDebugTap() {
|
||
this._debugClickCount += 1;
|
||
// 超过2秒未继续点击则重置计数
|
||
if (this._debugClickTimer) {
|
||
clearTimeout(this._debugClickTimer);
|
||
}
|
||
this._debugClickTimer = setTimeout(() => {
|
||
this._debugClickCount = 0;
|
||
}, 2000);
|
||
if (this._debugClickCount >= 10) {
|
||
this._debugClickCount = 0;
|
||
if (this._debugClickTimer) {
|
||
clearTimeout(this._debugClickTimer);
|
||
this._debugClickTimer = null;
|
||
}
|
||
this._debugMode = !this._debugMode;
|
||
if (this._debugMode) {
|
||
// 清空旧日志
|
||
this._debugLogs = [];
|
||
this.debugLog('调试模式', '已开启');
|
||
// #ifdef APP-PLUS
|
||
const filePath = '_doc/print_debug_log.txt';
|
||
uni.showToast({
|
||
title: `调试模式已开启,日志文件:${filePath}`,
|
||
icon: 'none',
|
||
duration: 3000
|
||
});
|
||
// #endif
|
||
// #ifndef APP-PLUS
|
||
uni.showToast({
|
||
title: '调试模式已开启(仅App端可写入文件)',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
// #endif
|
||
} else {
|
||
this.flushDebugLogs();
|
||
uni.showToast({
|
||
title: '调试模式已关闭',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
}
|
||
},
|
||
debugLog(label, data) {
|
||
if (!this._debugMode) return;
|
||
const timestamp = new Date().toLocaleString();
|
||
const text = `[${timestamp}][${label}] ${typeof data === 'string' ? data : JSON.stringify(data, null, 2)}`;
|
||
this._debugLogs.push(text);
|
||
// 每10条写入一次文件
|
||
if (this._debugLogs.length >= 10) {
|
||
this.flushDebugLogs();
|
||
}
|
||
},
|
||
flushDebugLogs() {
|
||
if (!this._debugLogs.length) return;
|
||
const content = this._debugLogs.join('\n') + '\n';
|
||
this._debugLogs = [];
|
||
// #ifdef APP-PLUS
|
||
try {
|
||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, fs => {
|
||
fs.root.getFile('print_debug_log.txt', { create: true }, fileEntry => {
|
||
fileEntry.file(file => {
|
||
const reader = new plus.io.FileReader();
|
||
reader.onloadend = e => {
|
||
const existing = e.target.result || '';
|
||
fileEntry.createWriter(writer => {
|
||
writer.seek(file.size);
|
||
writer.write(content);
|
||
});
|
||
};
|
||
reader.readAsText(file);
|
||
});
|
||
});
|
||
});
|
||
} catch (e) {
|
||
console.warn('[debugLog] 写入文件失败:', e);
|
||
}
|
||
// #endif
|
||
},
|
||
handleCameraScan() {
|
||
uni.scanCode({
|
||
onlyFromCamera: true,
|
||
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
|
||
success: (res) => {
|
||
const scanResult = this.normalizeScanResult(res);
|
||
if (!scanResult) {
|
||
uni.showToast({
|
||
title: '未识别到有效条码',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
// 详情视图模式下,扫码结果直接传给 ReviewDetail
|
||
if (this.showDetailView && this.$refs.reviewDetail) {
|
||
// 已复核订单禁止扫描
|
||
if (this.$refs.reviewDetail.isReadOnly) {
|
||
uni.showToast({ title: '该订单已复核完成,仅可查看', icon: 'none' });
|
||
return;
|
||
}
|
||
// 多商品匹配弹窗已打开时,忽略重复扫描,避免重复提示
|
||
if (this.$refs.reviewDetail.showMultiMatchPopup) {
|
||
return;
|
||
}
|
||
console.log('[OrderReview][handleCameraScan] 摄像头扫描值:', scanResult);
|
||
const matched = this.$refs.reviewDetail.handleScanCode(scanResult);
|
||
if (!matched) {
|
||
uni.showToast({ title: '条码不匹配', icon: 'none' });
|
||
uni.vibrateShort({ type: 'medium' });
|
||
this.speakVoice('无记录');
|
||
}
|
||
return;
|
||
}
|
||
this.keyword = scanResult;
|
||
this.handleSearch();
|
||
},
|
||
fail: (error) => {
|
||
const errMsg = String(error?.errMsg || '').toLowerCase();
|
||
if (errMsg.includes('cancel')) {
|
||
return;
|
||
}
|
||
uni.showToast({
|
||
title: '扫码失败,请重试',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
});
|
||
},
|
||
clearSearch() {
|
||
this.keyword = '';
|
||
},
|
||
handleClearList() {
|
||
this.keyword = '';
|
||
this.orderList = [];
|
||
this.goodsInfoList = [];
|
||
this.paginationTotal = 0;
|
||
this.currentPage = 1;
|
||
this.totalOrders = 0;
|
||
this.listType = '';
|
||
},
|
||
handleClearAll() {
|
||
this.handleClearList();
|
||
// 清除复核明细
|
||
this.showDetailView = false;
|
||
this.detailGoodsList = [];
|
||
this.detailInfo = {
|
||
recordId: '', orderId: 0, waveId: '', waveNo: '--',
|
||
waybillNo: '', matchType: '', recheckStatus: '',
|
||
pickerName: '--', cartNo: '--', status: 'pending',
|
||
unreviewedCount: 0, storeRemark: '', waveIndex: '',
|
||
orderIds: [], interceptStatus: '',
|
||
printStationId: '', printStationName: '', boxNo: '',
|
||
isPrinted: false, listType: ''
|
||
};
|
||
this.reviewedOrderIds = [];
|
||
this.currentOrderIndex = -1;
|
||
// 数量回归1
|
||
this.scanQuantity = 1;
|
||
this.saveSettings();
|
||
},
|
||
async handleRefreshTask() {
|
||
if (!this.taskId) {
|
||
if (this.keyword) {
|
||
this.handleSearch();
|
||
} else {
|
||
this.initializeOrderList();
|
||
this.currentPage = 1;
|
||
}
|
||
return;
|
||
}
|
||
this._autoSelectFirst = false; // 任务刷新保持原顺序
|
||
uni.showLoading({ title: '刷新中...' });
|
||
try {
|
||
const response = await this.$http('order.recheckOrder.scanTask', { task_id: Number(this.taskId) });
|
||
const payload = this.extractScanOrderPayload(response);
|
||
const result = this.normalizeScanOrderResult(payload);
|
||
this.handleScanOrderSuccess(result);
|
||
} catch (error) {
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '刷新失败');
|
||
uni.showToast({ title: message, icon: 'none' });
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
},
|
||
buildScanOrderParams(keyword) {
|
||
const value = this.normalizeKeyword(keyword);
|
||
return {
|
||
keyword: value
|
||
};
|
||
},
|
||
extractScanOrderPayload(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') {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
normalizeScanOrderResult(payload) {
|
||
const listType = String(payload?.list_type || payload?.listType || '').trim();
|
||
const matchType = String(payload?.match_type || payload?.matchType || '').trim();
|
||
const taskId = String(payload?.task_id ?? payload?.taskId ?? '').trim();
|
||
const pickerName = String(payload?.picker_name || payload?.pickerName || '').trim();
|
||
|
||
// 扁平化订单列表模式(散单:运单号/波次号命中)
|
||
const totalOrders = Number(payload?.total_orders ?? payload?.totalOrders ?? 0);
|
||
const totalUnreviewedCount = Number(payload?.unreviewed_count ?? payload?.unreviewedCount ?? 0);
|
||
|
||
if (listType === 'single') {
|
||
const list = Array.isArray(payload?.list) ? payload.list : [];
|
||
return {
|
||
listType: 'single',
|
||
matchType,
|
||
list: list.map(item => this.normalizeScanOrderItem(item)),
|
||
total: Number(payload?.total ?? payload?.count ?? list.length),
|
||
totalOrders,
|
||
totalUnreviewedCount,
|
||
taskId,
|
||
pickerName
|
||
};
|
||
}
|
||
|
||
// 嵌套波次结构模式(团单:车号命中)
|
||
if (listType === 'group') {
|
||
const waves = Array.isArray(payload?.waves || payload?.list) ? (payload?.waves || payload?.list) : [];
|
||
const normalizedWaves = waves.map(wave => {
|
||
const subList = Array.isArray(wave?.list || wave?.items) ? (wave?.list || wave?.items).map(item => this.normalizeScanOrderItem(item)) : [];
|
||
const waveTotalOrders = Number(wave?.order_count ?? wave?.orderCount ?? subList.length);
|
||
const waveUnreviewed = Number(wave?.unreviewed_count ?? wave?.unreviewedCount ?? 0);
|
||
const waveStocks = Array.isArray(wave?.stocks) ? wave.stocks : [];
|
||
return {
|
||
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'),
|
||
unreviewedCount: waveUnreviewed > 0 ? waveUnreviewed : subList.length,
|
||
unprintedCount: Number(wave?.unprinted_count ?? wave?.unprintedCount ?? 0),
|
||
orderCount: Number(wave?.order_count ?? wave?.orderCount ?? 0),
|
||
totalOrders: waveTotalOrders,
|
||
stocks: waveStocks,
|
||
orderIds: (Array.isArray(wave?.order_ids) ? wave.order_ids : Array.isArray(wave?.orderIds) ? wave.orderIds : []).map(id => Number(id)),
|
||
interceptStatus: String(wave?.intercept_status || wave?.interceptStatus || '').trim(),
|
||
firstWaybillNo: String(wave?.first_waybill_no || wave?.firstWaybillNo || '').trim(),
|
||
suggestedPkg: wave?.suggested_package_material || wave?.suggestedPkg || null,
|
||
list: subList
|
||
};
|
||
});
|
||
const calcTotalOrders = normalizedWaves.reduce((sum, w) => sum + w.totalOrders, 0);
|
||
const calcUnreviewed = normalizedWaves.reduce((sum, w) => sum + w.unreviewedCount, 0);
|
||
const groupWaybillNo = String(
|
||
payload?.waybill_no || payload?.waybillNo || ''
|
||
).trim();
|
||
return {
|
||
listType: 'group',
|
||
matchType,
|
||
waves: normalizedWaves,
|
||
waybillNo: groupWaybillNo,
|
||
total: Number(payload?.total ?? payload?.count ?? waves.length),
|
||
totalOrders: calcTotalOrders,
|
||
totalUnreviewedCount: calcUnreviewed,
|
||
taskId,
|
||
pickerName
|
||
};
|
||
}
|
||
|
||
// 单订单详情模式(运单号命中但无波次信息)
|
||
const order = payload?.order && typeof payload.order === 'object' ? payload.order : {};
|
||
const items = Array.isArray(payload?.items) ? payload.items : [];
|
||
const firstItem = items[0] && typeof items[0] === 'object' ? items[0] : {};
|
||
const orderId = Number(
|
||
payload?.order_id
|
||
|| payload?.orderId
|
||
|| order?.order_id
|
||
|| order?.orderId
|
||
|| order?.id
|
||
|| firstItem?.order_id
|
||
|| firstItem?.orderId
|
||
|| 0
|
||
);
|
||
const recheckStatus = String(
|
||
payload?.recheck_status
|
||
|| payload?.recheckStatus
|
||
|| order?.recheck_status
|
||
|| order?.recheckStatus
|
||
|| ''
|
||
).trim().toLowerCase();
|
||
const waybillNo = String(
|
||
payload?.waybill_no
|
||
|| order?.waybill_no
|
||
|| order?.waybillCode
|
||
|| order?.waybill_code
|
||
|| ''
|
||
).trim();
|
||
const cartMatchView = payload?.cart_match_view && typeof payload.cart_match_view === 'object'
|
||
? payload.cart_match_view
|
||
: null;
|
||
const storeRemark = String(
|
||
payload?.list?.[0]?.store_remark
|
||
|| payload?.store_remark
|
||
|| order?.store_remark
|
||
|| order?.storeRemark
|
||
|| ''
|
||
).trim();
|
||
|
||
return {
|
||
listType: 'detail',
|
||
matchType,
|
||
cartMatchView,
|
||
orderId,
|
||
recheckStatus,
|
||
waybillNo,
|
||
order,
|
||
items,
|
||
pickerName,
|
||
storeRemark,
|
||
expresses: Array.isArray(payload?.expresses) ? payload.expresses : [],
|
||
logs: Array.isArray(payload?.logs) ? payload.logs : []
|
||
};
|
||
},
|
||
normalizeScanOrderItem(item) {
|
||
if (!item || typeof item !== 'object') return {};
|
||
return {
|
||
id: item?.id ?? item?.order_id ?? item?.orderId ?? '',
|
||
orderId: item?.order_id ?? item?.orderId ?? item?.id ?? '',
|
||
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'),
|
||
recheckStatus: String(item?.recheck_status || item?.recheckStatus || '').trim().toLowerCase(),
|
||
isReviewed: !!item?.is_reviewed || !!item?.isReviewed,
|
||
isPrinted: !!item?.is_printed || !!item?.isPrinted,
|
||
interceptStatus: String(item?.intercept_status || item?.interceptStatus || '').trim(),
|
||
totalOrders: Number(item?.total_orders ?? item?.totalOrders ?? 0),
|
||
storeRemark: String(item?.store_remark || item?.storeRemark || '').trim(),
|
||
detail: item?.detail && typeof item.detail === 'object' ? item.detail : null,
|
||
items: Array.isArray(item?.items) ? item.items
|
||
: Array.isArray(item?.goods_items) ? item.goods_items
|
||
: Array.isArray(item?.goodsItems) ? item.goodsItems
|
||
: Array.isArray(item?.goods) ? item.goods
|
||
: Array.isArray(item?.stock) ? item.stock
|
||
: Array.isArray(item?.stocks) ? item.stocks
|
||
: [],
|
||
expresses: Array.isArray(item?.expresses) ? item.expresses : [],
|
||
logs: Array.isArray(item?.logs) ? item.logs : []
|
||
};
|
||
},
|
||
handleScanOrderSuccess(result, silent = false) {
|
||
if (!result) {
|
||
if (!silent) {
|
||
uni.showToast({
|
||
title: '未查询到订单',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
return;
|
||
}
|
||
|
||
this.listType = result?.listType || '';
|
||
this.taskId = result?.taskId || '';
|
||
this.scanPickerName = result?.pickerName || '';
|
||
const listType = this.listType;
|
||
|
||
// 散单模式(list_type=single):刷新当前页面列表
|
||
if (listType === 'single') {
|
||
const flatList = Array.isArray(result?.list) ? result.list : [];
|
||
this.orderList = flatList.map((item, index) => ({
|
||
id: String(item?.id || item?.orderId || `scan-${Date.now()}-${index}`),
|
||
waveNo: item?.waveNo || '--',
|
||
waybillNo: item?.waybillNo || '',
|
||
waveIndex: item?.waveIndex || '',
|
||
boxNo: item?.boxNo || '',
|
||
pickerName: item?.pickerName || '--',
|
||
cartNo: item?.cartNo || '--',
|
||
unreviewedCount: item?.recheckStatus === 'fin' ? 0 : 1,
|
||
status: item?.status || 'pending',
|
||
waybillCode: item?.waybillNo || '',
|
||
recheckStatus: item?.recheckStatus || '',
|
||
isReviewed: !!item?.isReviewed,
|
||
isPrinted: !!item?.isPrinted,
|
||
interceptStatus: String(item?.interceptStatus || '').trim(),
|
||
totalOrders: Number(item?.totalOrders ?? 0),
|
||
storeRemark: item?.storeRemark || '',
|
||
detailItems: Array.isArray(item?.items) ? item.items : []
|
||
}));
|
||
this.paginationTotal = result?.total ?? flatList.length;
|
||
this.goodsInfoList = [];
|
||
this.totalOrders = result?.totalOrders ?? 0;
|
||
if (!silent) {
|
||
uni.showToast({
|
||
title: `共匹配 ${flatList.length} 条订单`,
|
||
icon: 'none'
|
||
});
|
||
}
|
||
// D前缀波次:不自动进入详情,等待扫描商品条码定位所属订单
|
||
// 自动选中订单:输入搜索选第一个,任务刷新选最后一个
|
||
this.$nextTick(() => {
|
||
if (this.isDprefixedWave) return;
|
||
const unreviewedItems = this.orderList.filter(item => !item.isReviewed);
|
||
const target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
|
||
if (target) {
|
||
this.goPickGoodsDetail(target);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
|
||
// 团单模式(list_type=group):按波次嵌套展示
|
||
if (listType === 'group') {
|
||
const waves = Array.isArray(result?.waves) ? result.waves : [];
|
||
const groupWaybillNo = result?.waybillNo || '';
|
||
this.orderList = waves.map((wave, wi) => {
|
||
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 || '--',
|
||
unreviewedCount: waveUnreviewed > 0 ? waveUnreviewed : subList.length,
|
||
unprintedCount: Number(wave?.unprintedCount ?? 0),
|
||
orderCount: Number(wave?.orderCount ?? 0),
|
||
totalOrders: Number(wave?.orderCount ?? subList.length),
|
||
stocks: Array.isArray(wave?.stocks) ? wave.stocks : [],
|
||
orderIds: Array.isArray(wave?.orderIds) ? wave.orderIds.map(id => Number(id)) : [],
|
||
interceptStatus: String(wave?.interceptStatus || '').trim(),
|
||
itemsWeight: Number(wave?.itemsWeight ?? 0),
|
||
firstWaybillNo: String(wave?.firstWaybillNo || '').trim(),
|
||
suggestedPkg: wave?.suggestedPkg || null,
|
||
status: wave?.status || 'pending',
|
||
children: subList
|
||
};
|
||
});
|
||
this.paginationTotal = this.orderList.length;
|
||
this.goodsInfoList = [];
|
||
this.totalOrders = this.orderList.reduce((sum, w) => sum + (w.totalOrders || 0), 0);
|
||
if (!silent) {
|
||
uni.showToast({
|
||
title: `共匹配 ${this.orderList.length} 个波次`,
|
||
icon: 'none'
|
||
});
|
||
}
|
||
// 自动选中波次:输入搜索选第一个,任务刷新选最后一个
|
||
this.$nextTick(() => {
|
||
const unreviewedItems = this.orderList.filter(item => (item.unreviewedCount || 0) > 0);
|
||
const target = this._autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
|
||
if (target) {
|
||
this.goPickGoodsDetail(target);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
|
||
// 单订单详情模式(运单号命中,无波次信息)
|
||
const order = result?.order || {};
|
||
const orderId = Number(result?.orderId || 0);
|
||
if (!orderId) {
|
||
uni.showToast({
|
||
title: '未查询到订单',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (String(result?.recheckStatus || '').toLowerCase() === 'fin') {
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '该订单已复核完成,禁止再次进入',
|
||
showCancel: false,
|
||
success: () => {
|
||
uni.navigateBack({
|
||
delta: 1
|
||
});
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (result?.matchType === 'cart') {
|
||
uni.showToast({
|
||
title: '车号命中,已定位订单',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
|
||
// 单订单命中,构造订单项并内联进入复核
|
||
const detailItem = {
|
||
id: String(orderId),
|
||
orderId: orderId,
|
||
waveNo: String(order?.wave_no || order?.waveNo || '--'),
|
||
waveId: String(order?.wave_id || order?.waveId || ''),
|
||
waybillNo: String(result?.waybillNo || '--'),
|
||
recheckStatus: String(result?.recheckStatus || '').toLowerCase(),
|
||
pickerName: String(order?.picker_name || order?.pickerName || '--'),
|
||
cartNo: String(order?.cart_code || order?.cartCode || order?.cart_no || order?.cartNo || '--'),
|
||
status: String(order?.status || 'pending'),
|
||
unreviewedCount: Number(order?.unreviewed_count || order?.unreviewedCount || 0),
|
||
storeRemark: String(result?.storeRemark || ''),
|
||
waveIndex: String(result?.waveIndex || order?.wave_index || order?.waveIndex || '').trim(),
|
||
interceptStatus: '',
|
||
boxNo: String(order?.box_no || order?.boxNo || ''),
|
||
isPrinted: false,
|
||
detailItems: Array.isArray(result?.items) ? result.items : [],
|
||
stocks: Array.isArray(result?.items) ? result.items : [],
|
||
orderIds: []
|
||
};
|
||
this.goPickGoodsDetail(detailItem);
|
||
},
|
||
async requestScanOrder(keyword, silent = false) {
|
||
const normalizedKeyword = this.normalizeKeyword(keyword);
|
||
if (!normalizedKeyword) {
|
||
uni.showToast({
|
||
title: '请输入快递单号或车号',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (!silent) {
|
||
uni.showLoading({
|
||
title: '查询订单中...'
|
||
});
|
||
}
|
||
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);
|
||
} catch (error) {
|
||
if (!silent) {
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '').trim();
|
||
uni.showToast({
|
||
title: message || '订单查询失败',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
} finally {
|
||
if (!silent) {
|
||
uni.hideLoading();
|
||
}
|
||
}
|
||
},
|
||
async toggleUnboundPrintStationOnly() {
|
||
this.showUnboundPrintStationOnly = true;
|
||
this.selectedStationId = this.printStationId || '';
|
||
this.stationListPage = 1;
|
||
this.stationListTotal = 0;
|
||
this.printStationList = [];
|
||
uni.showLoading({
|
||
title: '加载打印台...'
|
||
});
|
||
try {
|
||
await this.loadPrintStations(1, false);
|
||
this.showStationListPopup = true;
|
||
} catch (error) {
|
||
uni.showToast({
|
||
title: '打印台列表加载失败',
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
},
|
||
handleStationListPageChange(page) {
|
||
const targetPage = Math.max(1, Number(page || 1));
|
||
if (targetPage === this.stationListPage) {
|
||
return;
|
||
}
|
||
this.stationListPage = targetPage;
|
||
this.loadPrintStations(targetPage, false);
|
||
},
|
||
handleStationListConfirm() {
|
||
if (!this.selectedStationId) {
|
||
return;
|
||
}
|
||
const station = this.printStationList.find(s => s.id === this.selectedStationId);
|
||
if (!station) {
|
||
return;
|
||
}
|
||
this.showStationListPopup = false;
|
||
this.selectedStationId = '';
|
||
setTimeout(() => {
|
||
this.printStationId = String(station.id);
|
||
this.printStationName = String(station.name || '--');
|
||
uni.showToast({
|
||
title: `已绑定打印台:${station.name}`,
|
||
icon: 'none'
|
||
});
|
||
}, 300);
|
||
},
|
||
handleStationListItemClick(station) {
|
||
if (!station || !station.id) {
|
||
return;
|
||
}
|
||
if (this.selectedStationId === station.id) {
|
||
this.selectedStationId = '';
|
||
} else {
|
||
this.selectedStationId = station.id;
|
||
}
|
||
},
|
||
goPickGoodsDetail(item) {
|
||
if (!item) return;
|
||
|
||
// 切换订单时重置包材/称重取消标志,新订单继续正常弹窗
|
||
this.packageBindingCancelled = false;
|
||
this.weighCancelled = false;
|
||
|
||
// 收集商品明细数据
|
||
let rawItems = [];
|
||
if (Array.isArray(item?.detailItems)) {
|
||
rawItems = item.detailItems;
|
||
} else if (Array.isArray(item?.stocks)) {
|
||
rawItems = item.stocks;
|
||
} else if (Array.isArray(item?.children)) {
|
||
item.children.forEach(child => {
|
||
if (Array.isArray(child?.items)) {
|
||
rawItems = rawItems.concat(child.items);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 构建 goodsList
|
||
const goodsList = rawItems.map((rawItem, index) => {
|
||
const isStockItem = !!rawItem?.stock_id || (!!rawItem?.item_name && !!rawItem?.plan_qty);
|
||
const stockItem = isStockItem ? rawItem : (Array.isArray(rawItem?.stock) && rawItem.stock.length > 0 ? rawItem.stock[0] : null);
|
||
const snapshot = rawItem?.item_snapshot && typeof rawItem.item_snapshot === 'object' ? rawItem.item_snapshot : {};
|
||
const stockImages = stockItem ? (Array.isArray(stockItem.images) ? stockItem.images : []) : [];
|
||
const snapshotImages = [
|
||
...(Array.isArray(snapshot?.images) ? snapshot.images : []),
|
||
...(Array.isArray(snapshot?.image_list) ? snapshot.image_list : [])
|
||
].map(url => String(url || '').trim()).filter(url => !!url);
|
||
const itemImages = (Array.isArray(rawItem?.images) ? rawItem.images : []).map(url => String(url || '').trim()).filter(url => !!url);
|
||
const snapshotSingleImage = String(snapshot?.image || snapshot?.pic || '').trim();
|
||
const images = stockImages.length ? stockImages : (snapshotImages.length ? snapshotImages : (snapshotSingleImage ? [snapshotSingleImage] : itemImages));
|
||
const imageUrl = images.length > 0 ? String(images[0] || '') : '';
|
||
const planQty = Number(stockItem?.plan_qty ?? rawItem?.plan_qty ?? 0);
|
||
const scannedQty = Number(rawItem?.scanned_qty ?? rawItem?.finish_qty ?? rawItem?.scannedQty ?? 0);
|
||
const stockName = stockItem ? String(stockItem.item_name || '').trim() : '';
|
||
const stockBarcodes = stockItem ? (Array.isArray(stockItem.barcodes) ? stockItem.barcodes : []) : [];
|
||
|
||
return {
|
||
id: String(rawItem?.id || stockItem?.stock_id || `item-${index + 1}`),
|
||
lineNo: Number(rawItem?.order_line_no) || (index + 1),
|
||
planQty: isNaN(planQty) ? 0 : planQty,
|
||
scannedQty: isNaN(scannedQty) ? 0 : scannedQty,
|
||
packageRequirement: String(rawItem?.packing_requirements || rawItem?.package_requirement || rawItem?.packageRequirement || rawItem?.packing_requirement || '').trim() || '--',
|
||
skuCode: String(stockItem?.item_code || rawItem?.item_code || snapshot?.item_code || ''),
|
||
skuName: stockName || String(snapshot?.item_name || rawItem?.item_name || '--'),
|
||
location: String(stockItem?.sku_property || snapshot?.sku_property || rawItem?.sku_property || '--'),
|
||
barcode: stockBarcodes.length > 0 ? stockBarcodes.join(', ') : String(snapshot?.barcode || snapshot?.item_code || rawItem?.item_code || '--'),
|
||
barcodes: stockBarcodes.length > 0 ? stockBarcodes : (snapshot?.barcode ? [snapshot.barcode] : []),
|
||
imageUrl,
|
||
images
|
||
};
|
||
});
|
||
|
||
// 设置详情数据
|
||
this.detailGoodsList = goodsList;
|
||
this.detailInfo = {
|
||
recordId: String(item.id || ''),
|
||
orderId: Number(item.id || item.orderId || 0),
|
||
waveId: String(item?.waveId ?? item?.id ?? '').trim(),
|
||
waveNo: String(item.waveNo || '--'),
|
||
waybillNo: String(item?.firstWaybillNo || item.waybillNo || ''),
|
||
matchType: '',
|
||
recheckStatus: String(item.recheckStatus || '').toLowerCase(),
|
||
pickerName: String(this.scanPickerName || item.pickerName || '--'),
|
||
cartNo: String(item.cartNo || '--'),
|
||
status: String(item.status || 'pending'),
|
||
unreviewedCount: Number(item.unreviewedCount || 0),
|
||
storeRemark: String(item?.storeRemark || this.orderList?.[0]?.storeRemark || '').trim(),
|
||
waveIndex: String(item?.waveIndex || '').trim(),
|
||
totalOrders: Number(item?.totalOrders ?? item?.orderCount ?? 0),
|
||
orderIds: Array.isArray(item?.orderIds) ? item.orderIds : [],
|
||
interceptStatus: String(item?.interceptStatus || '').trim(),
|
||
printStationId: String(this.printStationId || ''),
|
||
printStationName: String(this.printStationName || ''),
|
||
boxNo: String(item.boxNo || ''),
|
||
isPrinted: !!item.isPrinted,
|
||
unprintedCount: Number(item?.unprintedCount ?? 0),
|
||
orderCount: Number(item?.orderCount ?? 0),
|
||
listType: String(this.listType || ''),
|
||
itemsWeight: Number(item?.itemsWeight ?? 0),
|
||
suggestedPkg: item?.suggestedPkg || null
|
||
};
|
||
|
||
// 缓存当前订单在列表中的索引
|
||
this.currentOrderIndex = this.orderList.findIndex(o => String(o.id || o.orderId || '') === String(item.id || item.orderId || ''));
|
||
|
||
this.showDetailView = true;
|
||
this.listExpanded = false;
|
||
|
||
// D前缀波次:自动标记所有商品为已扫,跳过逐件扫描
|
||
// 已复核订单不再触发自动复核/打印,仅展示只读详情
|
||
if (this.isDprefixedWave && this.detailGoodsList.length > 0 && !item.isReviewed) {
|
||
this.detailGoodsList = this.detailGoodsList.map(g => ({
|
||
...g,
|
||
scannedQty: g.planQty
|
||
}));
|
||
this.$nextTick(() => {
|
||
this.handleDetailAllScanned();
|
||
});
|
||
}
|
||
|
||
// 先打印后复核:进入详情时自动触发未打印订单的打印
|
||
if (this.effectivePrintMode === 'printFirst' && this.printStationId) {
|
||
const isGroup = this.listType === 'group';
|
||
const isAlreadyPrinted = isGroup
|
||
? (item.unprintedCount || 0) === 0 && (item.orderCount || 0) > 0
|
||
: !!item.isPrinted;
|
||
if (!isAlreadyPrinted) {
|
||
this.autoPrintOrder(item);
|
||
}
|
||
}
|
||
|
||
|
||
},
|
||
backToList() {
|
||
this.showDetailView = false;
|
||
this.detailGoodsList = [];
|
||
// 从详情返回后刷新列表
|
||
// D波次:keyword 是商品条码,scanOrder 不支持,依赖本地已更新的 orderList
|
||
if (this.keyword && !this.isDprefixedWave) {
|
||
this.requestScanOrder(this.keyword, true);
|
||
}
|
||
},
|
||
handleDrawerOrderClick(item) {
|
||
this.showListDrawer = false;
|
||
this.goPickGoodsDetail(item);
|
||
},
|
||
buildRecheckParams() {
|
||
const listType = String(this.detailInfo?.listType || '').trim();
|
||
if (listType === 'group') {
|
||
const waveId = String(this.detailInfo?.waveId || '').trim();
|
||
return waveId ? { wave_id: waveId } : null;
|
||
}
|
||
const orderId = Number(this.detailInfo?.orderId || this.detailInfo?.recordId || 0);
|
||
return orderId > 0 ? { order_id: orderId } : null;
|
||
},
|
||
async callConfirmRecheck() {
|
||
const params = this.buildRecheckParams();
|
||
if (!params) {
|
||
uni.showToast({ title: '缺少订单/波次ID', icon: 'none' });
|
||
return false;
|
||
}
|
||
uni.showLoading({ title: '确认复核中...' });
|
||
try {
|
||
await this.$http('order.recheckOrder.confirmRecheck', params);
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '已确认复核', icon: 'success' });
|
||
// 通知订单复核页面更新列表状态
|
||
uni.$emit('orderReviewCompleted', {
|
||
orderId: this.detailInfo.orderId,
|
||
waveNo: this.detailInfo.waveNo,
|
||
waveId: this.detailInfo.waveId,
|
||
listType: this.detailInfo.listType
|
||
});
|
||
// 先复核后打印:复核完成后发送未打印订单的打印
|
||
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
|
||
: !!this.detailInfo?.isPrinted;
|
||
if (!isAlreadyPrinted) {
|
||
this.autoPrintOrder(this.detailInfo);
|
||
}
|
||
}
|
||
// 刷新订单列表数据
|
||
// 非D波次:keyword 是运单号/波次号,可用 scanOrder 刷新
|
||
// D波次:keyword 是商品条码,scanOrder 不支持,依赖本地更新
|
||
if (this.keyword && !this.isDprefixedWave) {
|
||
this.requestScanOrder(this.keyword, true);
|
||
}
|
||
// 标记当前已复核(本地更新,即使 requestScanOrder 不刷新也能保持正确状态)
|
||
const currentId = String(this.detailInfo?.orderId || this.detailInfo?.recordId || '');
|
||
if (currentId) {
|
||
const id = Number(currentId);
|
||
if (id > 0 && !this.reviewedOrderIds.includes(id)) {
|
||
this.reviewedOrderIds = [...this.reviewedOrderIds, id];
|
||
}
|
||
this.orderList = this.orderList.map(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId === id) {
|
||
return { ...item, isReviewed: true, unreviewedCount: 0 };
|
||
}
|
||
return item;
|
||
});
|
||
}
|
||
this.speakVoice('发货成功');
|
||
return true;
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
const msg = String(error?.message || error?.msg || error?.errMsg || '确认复核失败');
|
||
uni.showToast({ title: msg, icon: 'none' });
|
||
return false;
|
||
}
|
||
},
|
||
handleDetailAllScanned() {
|
||
// 切换订单时的 allScanned 跳过自动弹窗(仅通过 handleGoodsItemClick 触发)
|
||
if (this.skipPackagePopupOnAllScanned) {
|
||
this.skipPackagePopupOnAllScanned = false;
|
||
return;
|
||
}
|
||
// 如果用户取消了包材绑定,不再自动弹出
|
||
if (this.packageBindingCancelled) {
|
||
return;
|
||
}
|
||
// 散单模式不走包材流程
|
||
if (this.listType !== 'single' && this.enablePackageBinding) {
|
||
this.packageInputCode = '';
|
||
this.scannedPackageCode = '';
|
||
this.scannedPackageId = '';
|
||
this.scannedPackageMaterial = null;
|
||
this.suggestedPkg = this.detailInfo?.suggestedPkg || null;
|
||
console.log('[packageBinding] 推荐包材数据:', JSON.stringify(this.suggestedPkg));
|
||
this.showPackageBindingPopup = true;
|
||
return;
|
||
}
|
||
this.afterPackageBinding();
|
||
},
|
||
handleGoodsItemClick() {
|
||
// 点击商品列表项时,如果之前取消过包材绑定则重新弹出
|
||
if (this.packageBindingCancelled && this.listType !== 'single' && this.enablePackageBinding && !this.showPackageBindingPopup) {
|
||
this.packageBindingCancelled = false;
|
||
// 延迟重新打开,等待弹窗关闭动画完成
|
||
setTimeout(() => {
|
||
this.packageInputCode = '';
|
||
this.scannedPackageCode = '';
|
||
this.scannedPackageId = '';
|
||
this.scannedPackageMaterial = null;
|
||
this.suggestedPkg = this.detailInfo?.suggestedPkg || null;
|
||
console.log('[packageBinding] 推荐包材数据(handleGoodsItemClick):', JSON.stringify(this.suggestedPkg));
|
||
this.showPackageBindingPopup = true;
|
||
}, 350);
|
||
return;
|
||
}
|
||
// 如果之前取消过称重,重新弹出称重弹窗
|
||
if (this.weighCancelled && !this.showWeighPopup) {
|
||
this.weighCancelled = false;
|
||
this.weighWeight = 0;
|
||
this.showWeighPopup = true;
|
||
}
|
||
},
|
||
afterPackageBinding() {
|
||
// D前缀波次:跳过称重,确认复核后返回列表,等待下一个商品条码
|
||
if (this.isDprefixedWave) {
|
||
this.handleDprefixedAutoConfirm();
|
||
return;
|
||
}
|
||
// 团购模式始终需要称重,散单根据设置
|
||
const needWeigh = this.listType === 'group' || this.weighAfterReview;
|
||
if (needWeigh) {
|
||
console.log('[weigh] listType:', this.listType, 'itemsWeight:', this.detailInfo?.itemsWeight, 'refWeightG:', this.refWeightG);
|
||
// 需要称重:弹出称重抽屉
|
||
this.weighWeight = 0;
|
||
this.showWeighPopup = true;
|
||
return;
|
||
}
|
||
// 不需要称重
|
||
if (this.autoShip) {
|
||
// 自动发货:直接调用复核API后进下一单
|
||
this.handleAutoConfirmAndNext();
|
||
} else {
|
||
uni.showToast({
|
||
title: '全部商品已扫描完成,可点击确认复核',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
this.speakVoice('全部商品已扫描完成');
|
||
}
|
||
},
|
||
handleWeighInput(e) {
|
||
const val = e?.detail?.value ?? e?.target?.value ?? '';
|
||
const num = parseInt(val, 10);
|
||
this.weighWeight = Number.isFinite(num) && num >= 0 ? num : 0;
|
||
},
|
||
async handlePackageCodeConfirm(e) {
|
||
const code = e?.detail?.value ?? this.packageInputCode ?? '';
|
||
const trimmed = String(code).trim();
|
||
if (!trimmed) {
|
||
uni.showToast({ title: '请输入包材条码', icon: 'none' });
|
||
return;
|
||
}
|
||
this.packageInputCode = '';
|
||
// 调用API搜索包材
|
||
uni.showLoading({ title: '查询包材...', mask: true });
|
||
try {
|
||
const res = await this.$http('setting.packageMaterial.search', { keyword: trimmed });
|
||
const list = Array.isArray(res?.data) ? res.data : [];
|
||
// 精确匹配 material_code
|
||
const matched = list.find(item => String(item.material_code || '') === trimmed);
|
||
if (matched) {
|
||
this.scannedPackageMaterial = matched;
|
||
this.scannedPackageCode = String(matched.material_code || '');
|
||
this.scannedPackageId = String(matched.id || '');
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '包材匹配成功:' + (matched.material_name || trimmed), icon: 'success' });
|
||
this.speakVoice('数据一致');
|
||
} else {
|
||
this.scannedPackageMaterial = null;
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '无记录', icon: 'none' });
|
||
this.speakVoice('无记录');
|
||
}
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
const msg = String(error?.message || error?.msg || '查询包材失败');
|
||
uni.showToast({ title: msg, icon: 'none' });
|
||
}
|
||
},
|
||
handlePackageBindingKeyUp(e) {
|
||
// 检测回车键直接触发确认
|
||
if (e?.key === 'Enter') {
|
||
this.handlePackageBindingConfirm();
|
||
}
|
||
},
|
||
handlePackageBindingInputConfirm() {
|
||
this.handlePackageBindingConfirm();
|
||
},
|
||
async handlePackageBindingConfirm() {
|
||
this.showPackageBindingPopup = false;
|
||
this.packageBindingCancelled = false;
|
||
uni.showLoading({ title: '提交复核中...' });
|
||
try {
|
||
const waybillNo = String(this.detailInfo?.waybillNo || '').trim();
|
||
// 如果输入了包材条码但还未搜索匹配,先搜索
|
||
let finalPackageCode = '';
|
||
if (this.packageInputCode && !this.scannedPackageCode) {
|
||
try {
|
||
const res = await this.$http('setting.packageMaterial.search', { keyword: this.packageInputCode });
|
||
const list = Array.isArray(res?.data) ? res.data : [];
|
||
const matched = list.find(item => String(item.material_code || '') === this.packageInputCode);
|
||
if (matched) {
|
||
finalPackageCode = String(matched.id || '');
|
||
}
|
||
} catch (e) {
|
||
console.warn('[packageBinding] 搜索包材失败:', e);
|
||
}
|
||
} else if (this.scannedPackageCode) {
|
||
finalPackageCode = this.scannedPackageId || this.scannedPackageCode;
|
||
} else if (this.suggestedPkg) {
|
||
// 推荐包材兜底:优先使用 ID,如果后端没返回 ID 则用 code 搜索
|
||
finalPackageCode = this.suggestedPkg.id || this.suggestedPkg.material_id || '';
|
||
if (!finalPackageCode && this.suggestedPkg.code) {
|
||
try {
|
||
const res = await this.$http('setting.packageMaterial.search', { keyword: this.suggestedPkg.code });
|
||
const list = Array.isArray(res?.data) ? res.data : [];
|
||
const matched = list.find(item => String(item.material_code || '') === this.suggestedPkg.code);
|
||
if (matched) {
|
||
finalPackageCode = String(matched.id || '');
|
||
}
|
||
} catch (e) {
|
||
console.warn('[packageBinding] 搜索推荐包材失败:', e);
|
||
}
|
||
}
|
||
if (!finalPackageCode) {
|
||
uni.showToast({ title: '未找到推荐包材的 ID,包材未绑定', icon: 'none' });
|
||
}
|
||
}
|
||
// 并发提交:复核确认 + 包材绑定
|
||
console.log('[packageBinding] 最终绑定数据 - finalPackageCode:', finalPackageCode, 'waybillNo:', waybillNo, 'scannedPackageCode:', this.scannedPackageCode, 'scannedPackageId:', this.scannedPackageId, 'suggestedPkg:', JSON.stringify(this.suggestedPkg));
|
||
const promises = [this.callConfirmRecheckInternal()];
|
||
if (finalPackageCode && waybillNo) {
|
||
promises.push(
|
||
this.$http('order.bindExpressPackageMaterialByWaybill', {
|
||
waybill_code: waybillNo,
|
||
package_material_id: finalPackageCode
|
||
}).catch(pkgErr => {
|
||
console.warn('[packageBinding] 包材绑定失败(不阻塞):', pkgErr);
|
||
})
|
||
);
|
||
}
|
||
await Promise.all(promises);
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '复核提交成功', icon: 'success' });
|
||
this.speakVoice('发货成功');
|
||
// 复核成功后进入称重或下一单流程
|
||
this.afterPackageBinding();
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '复核提交失败');
|
||
uni.showToast({ title: message, icon: 'none' });
|
||
}
|
||
},
|
||
handlePackageBindingSkip() {
|
||
// 取消按钮仅关闭弹窗,不提交复核
|
||
this.showPackageBindingPopup = false;
|
||
this.packageBindingCancelled = true;
|
||
},
|
||
async callConfirmRecheckInternal() {
|
||
const params = this.buildRecheckParams();
|
||
if (!params) {
|
||
throw new Error('缺少订单/波次ID');
|
||
}
|
||
await this.$http('order.recheckOrder.confirmRecheck', params);
|
||
// 通知订单复核页面更新列表状态
|
||
uni.$emit('orderReviewCompleted', {
|
||
orderId: this.detailInfo.orderId,
|
||
waveNo: this.detailInfo.waveNo,
|
||
waveId: this.detailInfo.waveId,
|
||
listType: this.detailInfo.listType
|
||
});
|
||
// 先复核后打印:复核完成后发送未打印订单的打印
|
||
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
|
||
: !!this.detailInfo?.isPrinted;
|
||
if (!isAlreadyPrinted) {
|
||
this.autoPrintOrder(this.detailInfo);
|
||
}
|
||
}
|
||
// 刷新订单列表数据
|
||
if (this.keyword) {
|
||
this.requestScanOrder(this.keyword, true);
|
||
}
|
||
// 标记当前已复核
|
||
const currentId = String(this.detailInfo?.orderId || this.detailInfo?.recordId || '');
|
||
if (currentId) {
|
||
const id = Number(currentId);
|
||
if (id > 0 && !this.reviewedOrderIds.includes(id)) {
|
||
this.reviewedOrderIds = [...this.reviewedOrderIds, id];
|
||
}
|
||
this.orderList = this.orderList.map(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId === id) {
|
||
return { ...item, isReviewed: true, unreviewedCount: 0 };
|
||
}
|
||
return item;
|
||
});
|
||
}
|
||
},
|
||
handleWeighCancel() {
|
||
this.showWeighPopup = false;
|
||
this.weighCancelled = true;
|
||
},
|
||
async handleWeighSave() {
|
||
if (!this.weighWeight || this.weighWeight <= 0) {
|
||
uni.showToast({ title: '请输入有效重量', icon: 'none' });
|
||
return;
|
||
}
|
||
const weighKg = this.weighWeight / 1000;
|
||
const listType = String(this.detailInfo?.listType || '').trim();
|
||
const orderId = Number(this.detailInfo?.orderId || this.detailInfo?.recordId || 0);
|
||
const waybillNo = String(this.detailInfo?.waybillNo || '').trim();
|
||
uni.showLoading({ title: '提交称重中...' });
|
||
try {
|
||
// 团购模式使用运单号模式(order_id=0 + waybill_code)
|
||
if (listType === 'group') {
|
||
if (!waybillNo) {
|
||
uni.showToast({ title: '缺少运单号', icon: 'none' });
|
||
uni.hideLoading();
|
||
return;
|
||
}
|
||
await this.$http('order.recheckOrder.updateExpressWeighingWeight', {
|
||
order_id: 0,
|
||
waybill_code: waybillNo,
|
||
weighing_weight: weighKg
|
||
});
|
||
} else {
|
||
if (!orderId) {
|
||
uni.showToast({ title: '缺少订单ID', icon: 'none' });
|
||
uni.hideLoading();
|
||
return;
|
||
}
|
||
await this.$http('order.recheckOrder.updateExpressWeighingWeight', {
|
||
order_id: orderId,
|
||
weighing_weight: weighKg
|
||
});
|
||
}
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '称重完成', icon: 'success' });
|
||
this.showWeighPopup = false;
|
||
this.weighCancelled = false;
|
||
this.speakVoice('称重完成');
|
||
// 称重完成后进入下一单
|
||
if (this.autoShip) {
|
||
setTimeout(() => this.goToNextOrder(), 500);
|
||
}
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '称重提交失败');
|
||
uni.showToast({ title: message, icon: 'none' });
|
||
}
|
||
},
|
||
async handleConfirmRecheck() {
|
||
// 如果包材绑定被取消过,重新弹出包材弹窗
|
||
if (this.packageBindingCancelled && this.listType !== 'single' && this.enablePackageBinding) {
|
||
this.packageBindingCancelled = false;
|
||
this.packageInputCode = '';
|
||
this.scannedPackageCode = '';
|
||
this.scannedPackageId = '';
|
||
this.scannedPackageMaterial = null;
|
||
this.suggestedPkg = this.detailInfo?.suggestedPkg || null;
|
||
console.log('[packageBinding] 推荐包材数据(handleConfirmRecheck):', JSON.stringify(this.suggestedPkg));
|
||
this.showPackageBindingPopup = true;
|
||
return;
|
||
}
|
||
// 如果之前取消过称重,重新弹出称重弹窗
|
||
if (this.weighCancelled) {
|
||
this.weighCancelled = false;
|
||
this.weighWeight = 0;
|
||
this.showWeighPopup = true;
|
||
return;
|
||
}
|
||
const ok = await this.callConfirmRecheck();
|
||
if (ok && this.autoShip) {
|
||
setTimeout(() => this.goToNextOrder(), 500);
|
||
}
|
||
},
|
||
async handleAutoConfirmAndNext() {
|
||
const ok = await this.callConfirmRecheck();
|
||
if (ok) {
|
||
setTimeout(() => this.goToNextOrder(), 500);
|
||
}
|
||
},
|
||
async handleDprefixedAutoConfirm() {
|
||
// D前缀波次:确认复核后返回列表,等待下一个商品条码扫描定位
|
||
const ok = await this.callConfirmRecheck();
|
||
if (ok) {
|
||
setTimeout(() => {
|
||
this.backToList();
|
||
}, 500);
|
||
}
|
||
},
|
||
goToNextOrder() {
|
||
// 标记当前已复核
|
||
const currentId = String(this.detailInfo?.orderId || this.detailInfo?.recordId || '');
|
||
if (currentId) {
|
||
const id = Number(currentId);
|
||
if (id > 0 && !this.reviewedOrderIds.includes(id)) {
|
||
this.reviewedOrderIds = [...this.reviewedOrderIds, id];
|
||
}
|
||
// 同步更新 orderList 中的状态
|
||
this.orderList = this.orderList.map(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId === id) {
|
||
return { ...item, isReviewed: true, unreviewedCount: 0 };
|
||
}
|
||
return item;
|
||
});
|
||
}
|
||
// 从当前订单之后查找下一个未复核的订单,不回退到已复核的
|
||
const startIndex = Math.max(0, this.currentOrderIndex + 1);
|
||
let nextOrder = null;
|
||
for (let i = startIndex; i < this.orderList.length; i++) {
|
||
const item = this.orderList[i];
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId > 0 && this.reviewedOrderIds.includes(itemId)) continue;
|
||
if (this.listType === 'single') {
|
||
if (!item.isReviewed) { nextOrder = item; break; }
|
||
} else {
|
||
if ((item.unreviewedCount || 0) > 0) { nextOrder = item; break; }
|
||
}
|
||
}
|
||
// 后面没有未复核的,从开头找(回第一单)
|
||
if (!nextOrder) {
|
||
for (let i = 0; i < startIndex; i++) {
|
||
const item = this.orderList[i];
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId > 0 && this.reviewedOrderIds.includes(itemId)) continue;
|
||
if (this.listType === 'single') {
|
||
if (!item.isReviewed) { nextOrder = item; break; }
|
||
} else {
|
||
if ((item.unreviewedCount || 0) > 0) { nextOrder = item; break; }
|
||
}
|
||
}
|
||
}
|
||
if (nextOrder) {
|
||
this.goPickGoodsDetail(nextOrder);
|
||
} else {
|
||
uni.showToast({ title: '所有订单已复核完成', icon: 'success' });
|
||
this.speakVoice('所有订单已复核完成');
|
||
this.backToList();
|
||
}
|
||
},
|
||
handleUpdateScannedQty(index, newQty) {
|
||
if (index < 0 || index >= this.detailGoodsList.length) return;
|
||
if (typeof this.$set === 'function') {
|
||
this.$set(this.detailGoodsList, index, { ...this.detailGoodsList[index], scannedQty: newQty });
|
||
} else {
|
||
this.detailGoodsList[index].scannedQty = newQty;
|
||
}
|
||
},
|
||
handleResetScanQty() {
|
||
this.scanQuantity = 1;
|
||
this.saveSettings();
|
||
},
|
||
async handlePrintAllUnreviewed(item) {
|
||
const target = item && typeof item === 'object' ? item : null;
|
||
if (!target) {
|
||
uni.showToast({
|
||
title: '暂无未复核订单可打印',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
this.printTargetList = [target];
|
||
try {
|
||
await this.requestWavePlatformPrintData();
|
||
} catch (error) {
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '打印数据获取失败');
|
||
this.printMessage = message;
|
||
uni.showToast({
|
||
title: message,
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
this.pendingPrintCount = Number(target.unreviewedCount || 0);
|
||
this.printMessage = `待打印未复核订单 ${this.pendingPrintCount} 条`;
|
||
this.showPrintStationDropdown = false;
|
||
this.showPrintPopup = true;
|
||
},
|
||
buildPrintSendParams() {
|
||
if (!this.printRequestCode) {
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
}
|
||
return {
|
||
type: 'express',
|
||
printStationId: this.printStationId,
|
||
requestCode: this.printRequestCode,
|
||
data: {
|
||
waveGroups: Array.isArray(this.printWaveGroups) ? this.printWaveGroups : []
|
||
}
|
||
};
|
||
},
|
||
async handleConfirmPrint() {
|
||
if (!this.printStationList.length || !this.printStationId || !this.printStationName || this.printStationName === '--') {
|
||
this.printMessage = '请选择打印台';
|
||
uni.showToast({
|
||
title: '请选择打印台',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
if (!Array.isArray(this.printWaveGroups) || !this.printWaveGroups.length) {
|
||
this.printMessage = '未获取到打印数据';
|
||
uni.showToast({
|
||
title: '未获取到打印数据',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
const params = this.buildPrintSendParams();
|
||
this.debugLog('print.send 请求参数', params);
|
||
const effectivePrintCount = Number(this.pendingPrintCount || 0) > 0
|
||
? Number(this.pendingPrintCount || 0)
|
||
: this.printWaveGroups.length;
|
||
uni.showLoading({
|
||
title: '发送打印中...'
|
||
});
|
||
try {
|
||
const response = await this.$http('print.send', params);
|
||
this.debugLog('print.send 返回数据', response);
|
||
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
|
||
if (!success) {
|
||
throw new Error(response?.message || response?.msg || '打印失败');
|
||
}
|
||
this.printMessage = `打印已发送,未复核订单 ${effectivePrintCount} 条`;
|
||
uni.showToast({
|
||
title: `已发起打印${effectivePrintCount}条`,
|
||
icon: 'none'
|
||
});
|
||
this.showPrintPopup = false;
|
||
} catch (error) {
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '打印失败');
|
||
this.printMessage = message;
|
||
uni.showToast({
|
||
title: message,
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
},
|
||
buildOrderPrintDataParams(item) {
|
||
const id = item?.id ?? item?.orderId ?? item?.recordId;
|
||
if (this.listType === 'single') {
|
||
return {
|
||
order_ids: [Number(id)]
|
||
};
|
||
}
|
||
// group 模式:使用接口返回的 order_ids
|
||
const orderIds = Array.isArray(item?.orderIds) ? item.orderIds : [];
|
||
return {
|
||
order_ids: orderIds.length > 0 ? orderIds : [Number(id)]
|
||
};
|
||
},
|
||
extractOrderPrintPayload(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') {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
normalizeOrderPrintGroups(payload) {
|
||
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : [];
|
||
if (groups.length) return groups;
|
||
// 如果返回的不是 waveGroups 结构,尝试包装成 waveGroups
|
||
if (payload && typeof payload === 'object') {
|
||
return [payload];
|
||
}
|
||
return [];
|
||
},
|
||
handleReprint() {
|
||
// 使用当前 detailInfo 作为 item 调用打印
|
||
const item = {
|
||
id: this.detailInfo?.orderId || this.detailInfo?.recordId,
|
||
orderId: this.detailInfo?.orderId,
|
||
orderIds: this.detailInfo?.orderIds,
|
||
waveNo: this.detailInfo?.waveNo,
|
||
waveId: this.detailInfo?.waveId
|
||
};
|
||
this.handlePrintOrder(item);
|
||
},
|
||
async autoPrintOrder(item) {
|
||
if (!item || !this.printStationId) return;
|
||
try {
|
||
const params = this.buildOrderPrintDataParams(item);
|
||
const response = await this.$http('order.print.getOrderPrintData', params);
|
||
const payload = this.extractOrderPrintPayload(response);
|
||
const waveGroups = this.normalizeOrderPrintGroups(payload);
|
||
if (!waveGroups.length) return;
|
||
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
await this.$http('print.send', {
|
||
type: 'express',
|
||
printStationId: this.printStationId,
|
||
requestCode: this.printRequestCode,
|
||
data: { waveGroups }
|
||
});
|
||
console.log('[autoPrint] 自动打印发送成功');
|
||
// 同步更新订单列表中的打印状态
|
||
this.updateOrderPrintStatus(item);
|
||
} catch (error) {
|
||
console.warn('[autoPrint] 自动打印失败:', error?.message || error);
|
||
}
|
||
},
|
||
updateOrderPrintStatus(item) {
|
||
if (!item || !Array.isArray(this.orderList) || !this.orderList.length) return;
|
||
if (this.listType === 'single') {
|
||
const itemId = String(item.id || item.orderId || item.recordId || '');
|
||
if (!itemId) return;
|
||
this.orderList = this.orderList.map(o => {
|
||
const oId = String(o.id || o.orderId || '');
|
||
if (oId === itemId) {
|
||
return { ...o, isPrinted: true };
|
||
}
|
||
return o;
|
||
});
|
||
} else if (this.listType === 'group') {
|
||
// 团单模式:减少对应波次的未打印数量
|
||
const waveNo = String(item.waveNo || item.wave_no || '');
|
||
const itemId = String(item.id || item.orderId || item.recordId || '');
|
||
this.orderList = this.orderList.map(o => {
|
||
const oId = String(o.id || o.orderId || '');
|
||
const oWaveNo = String(o.waveNo || '');
|
||
if (oId === itemId || (waveNo && oWaveNo === waveNo)) {
|
||
const currentUnprinted = Number(o.unprintedCount || 0);
|
||
return { ...o, unprintedCount: Math.max(0, currentUnprinted - 1) };
|
||
}
|
||
return o;
|
||
});
|
||
}
|
||
},
|
||
async handlePrintOrder(item) {
|
||
if (!item) {
|
||
uni.showToast({ title: '打印数据无效', icon: 'none' });
|
||
return;
|
||
}
|
||
|
||
uni.showLoading({ title: '处理打印中...' });
|
||
|
||
try {
|
||
// 1. 获取打印数据
|
||
const params = this.buildOrderPrintDataParams(item);
|
||
const response = await this.$http('order.print.getOrderPrintData', params);
|
||
const payload = this.extractOrderPrintPayload(response);
|
||
const waveGroups = this.normalizeOrderPrintGroups(payload);
|
||
if (!waveGroups.length) {
|
||
throw new Error('未获取到可打印数据');
|
||
}
|
||
|
||
// 2. 检查打印台
|
||
if (!this.printStationId || this.printStationName === '--') {
|
||
throw new Error('无可用的打印台');
|
||
}
|
||
|
||
// 3. 发送打印
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
const sendParams = {
|
||
type: 'express',
|
||
printStationId: this.printStationId,
|
||
requestCode: this.printRequestCode,
|
||
data: {
|
||
waveGroups
|
||
}
|
||
};
|
||
this.debugLog('print.send 请求参数', sendParams);
|
||
const sendResponse = await this.$http('print.send', sendParams);
|
||
this.debugLog('print.send 返回数据', sendResponse);
|
||
const success = sendResponse?.flag !== 'failure' && sendResponse?.code !== '500' && sendResponse?.code !== 500;
|
||
if (!success) {
|
||
throw new Error(sendResponse?.message || sendResponse?.msg || '打印发送失败');
|
||
}
|
||
|
||
// 同步更新订单列表中的打印状态
|
||
this.updateOrderPrintStatus(item);
|
||
|
||
uni.hideLoading();
|
||
uni.showToast({ title: '打印已发送', icon: 'success' });
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '打印失败');
|
||
uni.showToast({ title: message, icon: 'none' });
|
||
}
|
||
},
|
||
handleInterceptCompleted(data) {
|
||
if (!data) return;
|
||
const { orderId } = data;
|
||
if (!Array.isArray(this.orderList) || this.orderList.length === 0) return;
|
||
this.orderList = this.orderList.map(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId === Number(orderId)) {
|
||
return { ...item, interceptStatus: 'intercepted_at_warehouse' };
|
||
}
|
||
return item;
|
||
});
|
||
},
|
||
handleReviewCompleted(data) {
|
||
if (!data) return;
|
||
const { orderId, waveNo, listType } = data;
|
||
if (!Array.isArray(this.orderList) || this.orderList.length === 0) return;
|
||
|
||
const mode = String(listType || this.listType || '').trim();
|
||
|
||
if (mode === 'single') {
|
||
// 散单模式:根据 orderId 匹配并标记为已复核
|
||
let updated = false;
|
||
this.orderList = this.orderList.map(item => {
|
||
const itemId = Number(item.id || item.orderId || 0);
|
||
if (itemId > 0 && itemId === Number(orderId)) {
|
||
updated = true;
|
||
return { ...item, isReviewed: true, unreviewedCount: 0 };
|
||
}
|
||
// 也尝试用运单号或 waveNo 匹配
|
||
if (!updated && waveNo && item.waveNo === waveNo) {
|
||
updated = true;
|
||
return { ...item, isReviewed: true, unreviewedCount: 0 };
|
||
}
|
||
return item;
|
||
});
|
||
// 记录已完成复核的 orderId,供 getReviewStatusText 兜底判断
|
||
const id = Number(orderId);
|
||
if (id > 0 && !this.reviewedOrderIds.includes(id)) {
|
||
this.reviewedOrderIds = [...this.reviewedOrderIds, id];
|
||
}
|
||
} else if (mode === 'group') {
|
||
// 团单模式:找到对应波次,减少 unreviewedCount
|
||
let updated = false;
|
||
this.orderList = this.orderList.map(item => {
|
||
if (item.waveNo === waveNo || String(item.id) === String(orderId)) {
|
||
const currentCount = Number(item.unreviewedCount || 0);
|
||
const newCount = Math.max(0, currentCount - 1);
|
||
updated = true;
|
||
return { ...item, unreviewedCount: newCount };
|
||
}
|
||
return item;
|
||
});
|
||
}
|
||
},
|
||
handlePageChange(page) {
|
||
const targetPage = Math.max(1, Number(page || 1));
|
||
if (targetPage === this.currentPage) {
|
||
return;
|
||
}
|
||
this.currentPage = targetPage;
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.scatter-picking-detail-page {
|
||
height: 100vh;
|
||
background: #f8f9fa;
|
||
}
|
||
|
||
.normar_container {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
|
||
::v-deep .u-popup,
|
||
::v-deep .u-popup-mask {
|
||
z-index: 10090 !important;
|
||
}
|
||
|
||
::v-deep .nav-title .right {
|
||
width: auto;
|
||
min-width: 136rpx;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.detail-area {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.detail-area--empty {
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
|
||
.detail-empty {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.empty-text {
|
||
margin-top: 18rpx;
|
||
font-size: 36rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.bottom-stats-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 16rpx 24rpx;
|
||
padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
|
||
background: #ffffff;
|
||
border-top: 1rpx solid #ebeef5;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.bottom-stats-info {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16rpx;
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.bottom-stats-text {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.bottom-stats-value {
|
||
color: #303133;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.bottom-stats-value--warn {
|
||
color: #fa8c16;
|
||
}
|
||
|
||
.bottom-stats-split {
|
||
color: #c0c4cc;
|
||
margin: 0 6rpx;
|
||
font-size: 30rpx;
|
||
}
|
||
|
||
.bottom-stats-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.bottom-stats-btn {
|
||
padding: 8rpx 20rpx;
|
||
border: none;
|
||
border-radius: 10rpx;
|
||
background: #2979ff;
|
||
}
|
||
|
||
.bottom-stats-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.bottom-stats-btn--list {
|
||
background: #07c160;
|
||
}
|
||
|
||
.bottom-stats-divider-vertical {
|
||
width: 1rpx;
|
||
height: 28rpx;
|
||
background: #dcdfe6;
|
||
margin: 0 12rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.bottom-stats-btn__text {
|
||
font-size: 34rpx;
|
||
color: #ffffff;
|
||
line-height: 1.4;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.nav-settings-btn {
|
||
padding: 8rpx 18rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: 1rpx solid #2979ff;
|
||
border-radius: 6rpx;
|
||
}
|
||
|
||
.nav-settings-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.nav-settings-btn__text {
|
||
font-size: 30rpx;
|
||
color: #2979ff;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.nav-right-action {
|
||
font-size: 32rpx;
|
||
line-height: 36rpx;
|
||
color: #ffffff;
|
||
padding: 8rpx 18rpx;
|
||
border-radius: 6rpx;
|
||
background: #2979ff;
|
||
}
|
||
|
||
.nav-right-action--active {
|
||
color: #ffffff;
|
||
background: #1f67e6;
|
||
}
|
||
|
||
.nav-right-action--bound {
|
||
color: #ffffff;
|
||
background: #07c160;
|
||
}
|
||
|
||
.search-filter {
|
||
background: #ffffff;
|
||
padding: 20rpx 24rpx 16rpx;
|
||
border: 1rpx solid #f0f0f0;
|
||
border-top: none;
|
||
border-radius: 0;
|
||
}
|
||
|
||
/* 设置弹窗 */
|
||
.settings-popup {
|
||
width: 560rpx;
|
||
padding: 36rpx;
|
||
background: #ffffff;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
.settings-popup-title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
margin-bottom: 32rpx;
|
||
}
|
||
|
||
.settings-row {
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.settings-label {
|
||
display: block;
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.settings-options {
|
||
display: flex;
|
||
gap: 16rpx;
|
||
}
|
||
|
||
.settings-option {
|
||
flex: 1;
|
||
text-align: center;
|
||
padding: 16rpx 0;
|
||
font-size: 32rpx;
|
||
color: #303133;
|
||
border: 2rpx solid #dcdfe6;
|
||
border-radius: 10rpx;
|
||
background: #fafafa;
|
||
}
|
||
|
||
.settings-option--active {
|
||
color: #2979ff;
|
||
border-color: #2979ff;
|
||
background: #f0f7ff;
|
||
}
|
||
|
||
.settings-option:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.settings-popup-footer {
|
||
display: flex;
|
||
justify-content: center;
|
||
margin-top: 16rpx;
|
||
}
|
||
|
||
.settings-footer-btn {
|
||
padding: 16rpx 48rpx;
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
border: 1rpx solid #dcdfe6;
|
||
border-radius: 10rpx;
|
||
background: #f5f5f5;
|
||
}
|
||
|
||
.settings-footer-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
/* 称重弹窗 */
|
||
.weigh-popup {
|
||
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
|
||
background: #ffffff;
|
||
border-top-left-radius: 20rpx;
|
||
border-top-right-radius: 20rpx;
|
||
}
|
||
|
||
.weigh-popup-title {
|
||
font-size: 42rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
margin-bottom: 36rpx;
|
||
}
|
||
|
||
.weigh-popup-title--sm {
|
||
font-size: 34rpx;
|
||
color: #606266;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.weigh-section-label {
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
color: #606266;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
|
||
.weigh-section-divider {
|
||
height: 2rpx;
|
||
background: #f0f0f0;
|
||
margin: 20rpx 0;
|
||
}
|
||
|
||
.weigh-popup-body {
|
||
margin-bottom: 32rpx;
|
||
}
|
||
|
||
.weigh-ref-row {
|
||
text-align: center;
|
||
margin-bottom: 16rpx;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.weigh-ref-label {
|
||
font-size: 32rpx;
|
||
color: #909399;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.weigh-ref-value {
|
||
color: #2979ff;
|
||
font-weight: 500;
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
.weigh-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 16rpx;
|
||
}
|
||
|
||
.weigh-label {
|
||
font-size: 36rpx;
|
||
color: #303133;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.weigh-required {
|
||
color: #f56c6c;
|
||
}
|
||
|
||
.weigh-control {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12rpx;
|
||
}
|
||
|
||
.weigh-btn {
|
||
width: 72rpx;
|
||
height: 72rpx;
|
||
line-height: 72rpx;
|
||
text-align: center;
|
||
font-size: 48rpx;
|
||
color: #2979ff;
|
||
border: 2rpx solid #2979ff;
|
||
border-radius: 12rpx;
|
||
background: #f0f7ff;
|
||
}
|
||
|
||
.weigh-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.weigh-input {
|
||
width: 240rpx;
|
||
height: 72rpx;
|
||
border: 2rpx solid #dcdfe6;
|
||
border-radius: 12rpx;
|
||
text-align: center;
|
||
font-size: 40rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.weigh-input--wide {
|
||
width: 360rpx;
|
||
text-align: left;
|
||
padding: 0 16rpx;
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
.weigh-ref-spec {
|
||
font-size: 28rpx;
|
||
color: #c0c4cc;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.weigh-unit {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
margin-left: 4rpx;
|
||
}
|
||
|
||
.weigh-popup-footer {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.weigh-footer-btn {
|
||
flex: 1;
|
||
height: 80rpx;
|
||
line-height: 80rpx;
|
||
text-align: center;
|
||
border-radius: 12rpx;
|
||
font-size: 36rpx;
|
||
}
|
||
|
||
.weigh-footer-btn--cancel {
|
||
background: #f5f5f5;
|
||
color: #909399;
|
||
}
|
||
|
||
.weigh-footer-btn--save {
|
||
background: #2979ff;
|
||
color: #ffffff;
|
||
}
|
||
|
||
.weigh-footer-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
/* 包材绑定弹窗 */
|
||
.package-popup {
|
||
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
|
||
background: #ffffff;
|
||
border-top-left-radius: 20rpx;
|
||
border-top-right-radius: 20rpx;
|
||
}
|
||
|
||
.package-popup-title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
margin-bottom: 32rpx;
|
||
}
|
||
|
||
.package-popup-body {
|
||
margin-bottom: 32rpx;
|
||
}
|
||
|
||
.package-ref-row {
|
||
text-align: center;
|
||
margin-bottom: 20rpx;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.package-ref-label {
|
||
font-size: 32rpx;
|
||
color: #909399;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.package-ref-value {
|
||
color: #2979ff;
|
||
font-weight: 500;
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
.package-ref-spec {
|
||
font-size: 28rpx;
|
||
color: #c0c4cc;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.package-input-row {
|
||
display: flex;
|
||
justify-content: center;
|
||
margin-top: 24rpx;
|
||
}
|
||
|
||
.package-input {
|
||
width: 70%;
|
||
height: 80rpx;
|
||
border: 2rpx solid #dcdfe6;
|
||
border-radius: 12rpx;
|
||
text-align: center;
|
||
font-size: 36rpx;
|
||
color: #303133;
|
||
padding: 0 16rpx;
|
||
}
|
||
|
||
.package-popup-footer {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.package-footer-btn {
|
||
flex: 1;
|
||
height: 80rpx;
|
||
line-height: 80rpx;
|
||
text-align: center;
|
||
border-radius: 12rpx;
|
||
font-size: 36rpx;
|
||
}
|
||
|
||
.package-footer-btn--skip {
|
||
background: #f5f5f5;
|
||
color: #909399;
|
||
}
|
||
|
||
.package-footer-btn--confirm {
|
||
background: #2979ff;
|
||
color: #ffffff;
|
||
}
|
||
|
||
.package-footer-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.scan-qty-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0 16rpx;
|
||
height: 72rpx;
|
||
box-sizing: border-box;
|
||
border: 1rpx solid #2979ff;
|
||
border-radius: 10rpx;
|
||
background: #2979ff;
|
||
}
|
||
|
||
.scan-qty-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.scan-qty-btn__text {
|
||
font-size: 34rpx;
|
||
color: #ffffff;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* 设置数量弹窗 */
|
||
.scan-qty-popup {
|
||
width: 480rpx;
|
||
padding: 36rpx;
|
||
background: #ffffff;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
.scan-qty-popup-title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
margin-bottom: 28rpx;
|
||
}
|
||
|
||
.scan-qty-popup-body {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 12rpx;
|
||
margin-bottom: 28rpx;
|
||
}
|
||
|
||
.scan-qty-input {
|
||
width: 200rpx;
|
||
height: 80rpx;
|
||
border: 2rpx solid #dcdfe6;
|
||
border-radius: 10rpx;
|
||
text-align: center;
|
||
font-size: 40rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.scan-qty-unit {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.scan-qty-popup-footer {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.scan-qty-footer-btn {
|
||
flex: 1;
|
||
height: 72rpx;
|
||
line-height: 72rpx;
|
||
text-align: center;
|
||
border-radius: 10rpx;
|
||
font-size: 34rpx;
|
||
}
|
||
|
||
.scan-qty-footer-btn--cancel {
|
||
background: #f5f5f5;
|
||
color: #909399;
|
||
}
|
||
|
||
.scan-qty-footer-btn--save {
|
||
background: #2979ff;
|
||
color: #ffffff;
|
||
}
|
||
|
||
.scan-qty-footer-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.unbound-print-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0 16rpx;
|
||
height: 72rpx;
|
||
box-sizing: border-box;
|
||
border: 1rpx solid #dcdfe6;
|
||
border-radius: 10rpx;
|
||
background: #fafafa;
|
||
}
|
||
|
||
.unbound-print-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.unbound-print-btn__text {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.unbound-print-btn__text--bound {
|
||
color: #07c160;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.print-station-option {
|
||
padding: 16rpx 20rpx;
|
||
font-size: 34rpx;
|
||
color: #303133;
|
||
border-bottom: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.print-station-option:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.print-station-option--active {
|
||
color: #2979ff;
|
||
background: #f0f7ff;
|
||
}
|
||
|
||
.print-station-option--empty {
|
||
color: #c0c4cc;
|
||
text-align: center;
|
||
}
|
||
|
||
.print-station-option:active {
|
||
background: #f5f5f5;
|
||
}
|
||
|
||
.search-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10rpx;
|
||
}
|
||
|
||
.search-row ::v-deep .u-search {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.search-scan-btn {
|
||
flex-shrink: 0;
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
background: #f5f5f5;
|
||
border-radius: 50%;
|
||
}
|
||
|
||
.search-scan-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.search-scan-btn--disabled {
|
||
background: #f0f0f0;
|
||
}
|
||
|
||
.search-row .unbound-print-btn {
|
||
flex-shrink: 0;
|
||
padding: 0 12rpx;
|
||
height: 56rpx;
|
||
font-size: 24rpx;
|
||
border-radius: 8rpx;
|
||
}
|
||
|
||
.search-row .unbound-print-btn__text {
|
||
font-size: 24rpx;
|
||
}
|
||
|
||
.search-row .scan-qty-btn {
|
||
flex-shrink: 0;
|
||
padding: 0 12rpx;
|
||
height: 56rpx;
|
||
font-size: 24rpx;
|
||
border-radius: 8rpx;
|
||
}
|
||
|
||
.search-row .scan-qty-btn__text {
|
||
font-size: 24rpx;
|
||
}
|
||
|
||
/* 订单列表抽屉 */
|
||
.list-drawer {
|
||
height: 75vh;
|
||
background: #ffffff;
|
||
border-top-left-radius: 20rpx;
|
||
border-top-right-radius: 20rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.list-drawer-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 24rpx 32rpx;
|
||
border-bottom: 1rpx solid #f2f3f5;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.list-drawer-title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
|
||
.list-drawer-close {
|
||
font-size: 34rpx;
|
||
color: #909399;
|
||
padding: 8rpx;
|
||
}
|
||
|
||
.list-drawer-close:active {
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.print-popup {
|
||
height: 70vh;
|
||
background: #ffffff;
|
||
border-top-left-radius: 20rpx;
|
||
border-top-right-radius: 20rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.print-popup-scroll {
|
||
flex: 1;
|
||
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.print-popup-title {
|
||
font-size: 42rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
margin-bottom: 36rpx;
|
||
}
|
||
|
||
.print-row {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
padding: 28rpx 0;
|
||
border-bottom: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.print-row--station {
|
||
position: relative;
|
||
}
|
||
|
||
.print-row--station .print-label {
|
||
padding-top: 10rpx;
|
||
}
|
||
|
||
.print-label {
|
||
min-width: 130rpx;
|
||
width: 130rpx;
|
||
font-size: 36rpx;
|
||
line-height: 40rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.print-value {
|
||
flex: 1;
|
||
font-size: 36rpx;
|
||
line-height: 40rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.print-station-input-wrap {
|
||
flex: 1;
|
||
min-width: 0;
|
||
position: relative;
|
||
}
|
||
|
||
.print-station-dropdown {
|
||
position: absolute;
|
||
left: 0;
|
||
right: 0;
|
||
top: 100%;
|
||
max-height: 600rpx;
|
||
background: #ffffff;
|
||
border: 1rpx solid #ebeef5;
|
||
border-radius: 10rpx;
|
||
z-index: 10091;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.print-station-dropdown-scroll {
|
||
flex: 1;
|
||
max-height: 600rpx;
|
||
}
|
||
|
||
.print-station-option {
|
||
padding: 16rpx 20rpx;
|
||
font-size: 28rpx;
|
||
line-height: 40rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.print-station-option + .print-station-option {
|
||
border-top: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.print-station-option--active {
|
||
color: #2979ff;
|
||
}
|
||
|
||
.print-station-option--row {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.station-option-name {
|
||
font-size: 36rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.station-option-code {
|
||
font-size: 32rpx;
|
||
color: #909399;
|
||
margin-left: 12rpx;
|
||
}
|
||
|
||
.station-list-scroll {
|
||
max-height: 600rpx;
|
||
padding: 0 10rpx;
|
||
}
|
||
|
||
.station-list-pagination {
|
||
padding: 16rpx 10rpx 4rpx;
|
||
border-top: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.station-list-empty {
|
||
text-align: center;
|
||
padding: 60rpx 0;
|
||
font-size: 36rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.station-list-item {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 24rpx 20rpx;
|
||
border-bottom: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.station-list-item--selected {
|
||
background: #f0f7ff;
|
||
}
|
||
|
||
.station-list-item:active {
|
||
background: #f5f6fa;
|
||
}
|
||
|
||
.station-list-item--selected:active {
|
||
background: #e0f0ff;
|
||
}
|
||
|
||
.station-list-item__left {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.station-list-item__name {
|
||
font-size: 38rpx;
|
||
color: #303133;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.station-list-item__name--active {
|
||
color: #2979ff;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.station-list-item__check {
|
||
flex-shrink: 0;
|
||
margin-left: 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.station-list-item__id {
|
||
font-size: 26rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.station-list-confirm {
|
||
padding: 16rpx 10rpx calc(10rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
.safe-bottom-in-popup {
|
||
height: calc(10rpx + env(safe-area-inset-bottom));
|
||
}
|
||
</style> |