- 拣货页:新增拣货要求横幅与弹窗展示,兼容 pick_mode 5 与 2/3/4 两种字段来源; 显示哪个商品即播报该商品拣货要求,去重串行、只播一次;弹窗样式优化 - 复核发货页:进入详情去重串行播报复核要求,「数据一致」排队到复核要求播报完成后; 复核要求字段优先取 recheck_requirements - 复核详情组件:「包装」改为「复核要求」,要求行改浅红底标签,字号调大; 「数据一致」改为事件上抛由父组件排队播报 - 打包模式页:新增打包要求标签展示与语音播报(去重串行、数据一致排队播报); 扫描重复跳过增加失败态豁免;重查失败恢复待重传状态;映射补充 packing_requirements
5033 lines
173 KiB
Vue
5033 lines
173 KiB
Vue
<template>
|
||
<view class="scatter-picking-detail-page">
|
||
<view class="normar_container">
|
||
<page-nav :title="showDetailView ? '订单复核详情' : title">
|
||
<template #left>
|
||
<view v-if="showDetailView && isIntercepted" class="nav-intercept-btn" @click="handleShowInterceptInfo">
|
||
<text class="nav-intercept-btn__text">拦截信息</text>
|
||
</view>
|
||
</template>
|
||
<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"
|
||
:pickMode="pickMode"
|
||
@updateScannedQty="handleUpdateScannedQty"
|
||
@allScanned="handleDetailAllScanned"
|
||
@resetScanQty="handleResetScanQty"
|
||
@confirmRecheck="handleConfirmRecheck"
|
||
@autoConfirmAndNext="handleAutoConfirmAndNext"
|
||
@reprint="handleReprint"
|
||
@goodsItemClick="handleGoodsItemClick"
|
||
@speakDataConsistent="handleSpeakDataConsistent"
|
||
/>
|
||
<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"
|
||
:pickMode="pickMode"
|
||
: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="showOrderInterceptPopup" mode="bottom" :closeable="false" :closeOnClickOverlay="false" border-radius="20" :z-index="10080" @close="showOrderInterceptPopup = false">
|
||
<view class="order-intercept-popup">
|
||
<view class="order-intercept-popup__header">
|
||
<text class="order-intercept-popup__title">拦截信息</text>
|
||
</view>
|
||
<view class="order-intercept-popup__body">
|
||
<view class="order-intercept-popup__row">
|
||
<text class="order-intercept-popup__label">运单号</text>
|
||
<text class="order-intercept-popup__value">{{ orderInterceptWaybill }}</text>
|
||
</view>
|
||
<view class="order-intercept-popup__tip">该订单已被拦截,请勿复核发货</view>
|
||
</view>
|
||
<view class="order-intercept-popup__footer">
|
||
<view class="order-intercept-popup__btn" @click="handleCloseOrderInterceptPopup">关闭</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
<!-- 称重弹窗 -->
|
||
<u-popup :show="showWeighPopup" mode="bottom" :closeable="true" :closeOnClickOverlay="false" border-radius="20" :z-index="10080" @close="handleWeighCancel">
|
||
<view class="weigh-popup" :style="{ paddingBottom: keyboardHeight ? keyboardHeight + 'px' : '' }">
|
||
<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"
|
||
:adjust-position="false"
|
||
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" :closeOnClickOverlay="false" border-radius="20" :z-index="10080" @close="handlePackageBindingSkip">
|
||
<view class="package-popup" :style="{ paddingBottom: keyboardHeight ? keyboardHeight + 'px' : '' }">
|
||
<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 }}</text></text>
|
||
</view>
|
||
<view v-if="scannedPackageMaterial" class="package-ref-row">
|
||
<text class="package-ref-label">已扫包材:<text class="package-ref-value">{{ scannedPackageMaterial.material_name || '' }}</text></text>
|
||
</view>
|
||
<view class="package-input-row">
|
||
<input
|
||
class="package-input"
|
||
v-model="packageInputCode"
|
||
:focus="packageBindingActivated"
|
||
:adjust-position="false"
|
||
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" :closeOnClickOverlay="false" 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="showPrintFailPopup"
|
||
mode="center"
|
||
:closeable="false"
|
||
:closeOnClickOverlay="false"
|
||
border-radius="16"
|
||
:z-index="10095"
|
||
@close="showPrintFailPopup = false"
|
||
>
|
||
<view class="print-fail-popup">
|
||
<view class="print-fail-popup-title">打印未完成</view>
|
||
<view class="print-fail-popup-body">
|
||
<text class="print-fail-popup-text">{{ printFailBodyText }}</text>
|
||
<view v-if="printFailMessage" class="print-fail-popup-msg">
|
||
<text class="print-fail-popup-msg__text">{{ printFailMessage }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="print-fail-popup-footer">
|
||
<view class="print-fail-footer-btn print-fail-footer-btn--cancel" @click="showPrintFailPopup = false">关闭</view>
|
||
<view class="print-fail-footer-btn print-fail-footer-btn--print" @click="handlePrintFailRetry">打印</view>
|
||
</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,
|
||
showOrderInterceptPopup: false,
|
||
orderInterceptInfo: {},
|
||
interceptContinueNext: false,
|
||
interceptNotifiedIds: [],
|
||
interceptAutoNotifiedIds: [],
|
||
keyboardHeight: 0,
|
||
weighWeight: 0,
|
||
weighAfterReview: false,
|
||
weighCancelled: false,
|
||
packageInputCode: '',
|
||
scannedPackageCode: '',
|
||
scannedPackageId: '',
|
||
scannedPackageMaterial: null,
|
||
suggestedPkg: null,
|
||
enablePackageBinding: true,
|
||
packageBindingActivated: false,
|
||
showPackageBindingPopup: false,
|
||
autoShip: true,
|
||
showPrintFailPopup: false,
|
||
printFailMessage: '',
|
||
pendingShipAction: 'autoNext',
|
||
lastPrintError: '',
|
||
printFailDismissed: false,
|
||
printStationList: [],
|
||
selectedStationId: '',
|
||
stationListPage: 1,
|
||
stationListPageSize: 20,
|
||
stationListTotal: 0,
|
||
printMessage: '',
|
||
pendingPrintCount: 0,
|
||
printRequestCode: '',
|
||
printWaveGroups: [],
|
||
printWavePlatformPrintData: null,
|
||
printTargetList: [],
|
||
goodsInfoList: [],
|
||
orderList: [],
|
||
listType: '', packingRequirements: '',
|
||
recheckReqChain: null,
|
||
pickMode: '',
|
||
totalOrders: 0,
|
||
taskId: '',
|
||
scanPickerName: '',
|
||
reviewedOrderIds: [],
|
||
debugClickCount: 0,
|
||
debugClickTimer: null,
|
||
debugMode: false,
|
||
debugLogs: [],
|
||
autoSelectFirst: false,
|
||
scanKeyword: '',
|
||
dprefixedBarcodeVerified: false,
|
||
// D前缀波次单品单件自动复核防重入标志:同一订单的 allScanned 只处理第一次,
|
||
// 避免 finishDprefixedAutoReview 显式调用与 goodsList watcher 的 allScanned 重复触发导致重复打印面单
|
||
dprefixedAllScannedHandled: false,
|
||
packageBindingCancelled: false,
|
||
skipPackagePopupOnAllScanned: false,
|
||
// 订单全部为"无需复核"商品时的"点击商品卡片触发发货"防重入标志:每次进入新订单复位
|
||
noRecheckAutoAdvanceHandled: false,
|
||
showDetailView: false,
|
||
showListDrawer: false,
|
||
detailGoodsList: [],
|
||
detailInfo: {
|
||
recordId: '',
|
||
orderId: 0,
|
||
waveId: '',
|
||
waveNo: '--',
|
||
waybillNo: '',
|
||
matchType: '',
|
||
recheckStatus: '',
|
||
pickerName: '--',
|
||
cartNo: '--',
|
||
status: 'pending',
|
||
unreviewedCount: 0,
|
||
storeRemark: '',
|
||
storeName: '',
|
||
waveIndex: '',
|
||
orderIds: [],
|
||
interceptStatus: '',
|
||
printStationId: '',
|
||
printStationName: '',
|
||
boxNo: '',
|
||
packingRequirements: ''
|
||
}
|
||
};
|
||
},
|
||
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 => {
|
||
// 拦截订单无法复核,不计入未复核统计
|
||
if (this.isOrderIntercepted(item)) return false;
|
||
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;
|
||
},
|
||
isIntercepted() {
|
||
// 散单模式:波次内任一订单被拦截即显示拦截信息按钮(waveHasIntercept)
|
||
// 其它模式:直接看当前订单/波次的拦截状态
|
||
if (!!this.detailInfo?.waveHasIntercept) return true;
|
||
const status = String(this.detailInfo?.interceptStatus || '').trim();
|
||
return !!status && status !== 'none';
|
||
},
|
||
// 拦截订单弹窗当前订单的运单号(仅显示当前一个订单)
|
||
orderInterceptWaybill() {
|
||
const info = this.orderInterceptInfo || {};
|
||
return String(info.waybillNo || info.waybillCode || info.firstWaybillNo || '--');
|
||
},
|
||
effectivePrintMode() {
|
||
// 散单模式只走先复核后打印或不打印
|
||
if (this.listType === 'single' && this.printMode !== 'noPrint') {
|
||
return 'reviewFirst';
|
||
}
|
||
return this.printMode;
|
||
},
|
||
printFailBodyText() {
|
||
if (this.pendingShipAction === 'groupShip') {
|
||
return '打印失败或超时,未触发发货。请重试打印,打印成功后将进入包材绑定。';
|
||
}
|
||
return '打印失败或超时,未触发发货。请重试打印,打印成功后将自动发货。';
|
||
},
|
||
isDprefixedWave() {
|
||
// 单品单件订单,无需逐件扫描
|
||
// 优先根据 pick_mode=2 判断(scanOrder 接口返回),D前缀波次作为兼容兜底
|
||
if (this.listType !== 'single') return false;
|
||
if (Number(this.pickMode) === 2) return true;
|
||
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.initKeyboardHeightListener();
|
||
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);
|
||
|
||
// 从已复核列表点击跳转,调用详情接口获取订单详情
|
||
const initDetailId = options?.orderId || '';
|
||
const initTableType = options?.tableType || 'dispatch';
|
||
const initWaveId = options?.waveId || '';
|
||
const initMode = String(options?.mode || '').trim();
|
||
if (initDetailId) {
|
||
this.printMode = 'noPrint';
|
||
this.fetchReviewedDetail(initDetailId, initTableType);
|
||
} else if (initWaveId && initMode === 'group') {
|
||
this.listType = 'group';
|
||
this.printMode = 'noPrint';
|
||
this.fetchGroupReviewedDetail(initWaveId);
|
||
}
|
||
},
|
||
onShow() {
|
||
this.safeDispatchBroadcast('setCallbacks', {
|
||
onResult: this.handleBroadcastResult
|
||
});
|
||
this.safeDispatchBroadcast('resume');
|
||
},
|
||
onHide() {
|
||
this.safeDispatchBroadcast('pause');
|
||
},
|
||
onUnload() {
|
||
this.destroyKeyboardHeightListener();
|
||
this.safeDispatchBroadcast('stop');
|
||
uni.$off('orderInterceptCompleted', this.handleInterceptCompleted);
|
||
if (this.debugMode) {
|
||
this.flushDebugLogs();
|
||
}
|
||
if (this.debugClickTimer) {
|
||
clearTimeout(this.debugClickTimer);
|
||
this.debugClickTimer = null;
|
||
}
|
||
},
|
||
methods: {
|
||
initKeyboardHeightListener() {
|
||
// H5 端:监听 visualViewport 高度变化,差值即键盘高度(仅垫高弹窗内容,不整页上推)
|
||
// #ifdef H5
|
||
if (typeof window !== 'undefined' && window.visualViewport) {
|
||
this._baseViewportHeight = window.visualViewport.height;
|
||
this._onViewportResize = () => {
|
||
const vh = window.visualViewport ? window.visualViewport.height : window.innerHeight;
|
||
const diff = this._baseViewportHeight - vh;
|
||
this.keyboardHeight = diff > 0 ? Math.round(diff) : 0;
|
||
};
|
||
window.visualViewport.addEventListener('resize', this._onViewportResize);
|
||
}
|
||
// #endif
|
||
// App/小程序端:使用原生键盘高度回调
|
||
// #ifndef H5
|
||
this._keyboardHeightCb = (res) => {
|
||
this.keyboardHeight = (res && res.height) || 0;
|
||
};
|
||
if (typeof uni.onKeyboardHeightChange === 'function') {
|
||
uni.onKeyboardHeightChange(this._keyboardHeightCb);
|
||
}
|
||
// #endif
|
||
},
|
||
destroyKeyboardHeightListener() {
|
||
// #ifdef H5
|
||
if (typeof window !== 'undefined' && window.visualViewport && this._onViewportResize) {
|
||
window.visualViewport.removeEventListener('resize', this._onViewportResize);
|
||
this._onViewportResize = null;
|
||
}
|
||
// #endif
|
||
// #ifndef H5
|
||
if (this._keyboardHeightCb && typeof uni.offKeyboardHeightChange === 'function') {
|
||
uni.offKeyboardHeightChange(this._keyboardHeightCb);
|
||
this._keyboardHeightCb = null;
|
||
}
|
||
// #endif
|
||
},
|
||
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);
|
||
},
|
||
/**
|
||
* 提取 getWavePlatformPrintData 返回的 locked_wave_groups(打印锁占用的分组)
|
||
* 已打印面单的数据会出现在 locked_wave_groups,而 waveGroups 为空
|
||
* @param {object} payload
|
||
*/
|
||
extractLockedWaveGroups(payload) {
|
||
const groups = Array.isArray(payload?.locked_wave_groups) ? payload.locked_wave_groups : [];
|
||
return groups
|
||
.map(group => (group && typeof group === 'object' ? group : null))
|
||
.filter(group => !!group);
|
||
},
|
||
/**
|
||
* 将 locked_wave_groups 转换为 unlockWavePlatformPrintDataByGroup 所需的 groups 分组条件
|
||
* 每个(波次 + 平台 + 系统快递编码)组合为一个分组
|
||
* @param {Array} lockedWaveGroups 打印锁占用的波次平台分组
|
||
*/
|
||
buildUnlockGroups(lockedWaveGroups) {
|
||
const groups = [];
|
||
(Array.isArray(lockedWaveGroups) ? lockedWaveGroups : []).forEach(waveGroup => {
|
||
const waveId = waveGroup?.wave_id ?? waveGroup?.waveId ?? waveGroup?.id ?? '';
|
||
const platforms = Array.isArray(waveGroup?.platforms) ? waveGroup.platforms : [];
|
||
if (platforms.length) {
|
||
platforms.forEach(platform => {
|
||
groups.push({
|
||
wave_id: waveId,
|
||
platform: platform?.platform ?? platform?.platform_code ?? '',
|
||
sys_logistics_code: platform?.sys_logistics_code ?? platform?.sysLogisticsCode ?? platform?.logistics_code ?? '',
|
||
order_ids: Array.isArray(platform?.order_ids) ? platform.order_ids : []
|
||
});
|
||
});
|
||
} else if (waveId !== '' && waveId != null) {
|
||
// 无平台嵌套时按波次兜底
|
||
groups.push({ wave_id: waveId, platform: '', sys_logistics_code: '', order_ids: [] });
|
||
}
|
||
});
|
||
return groups.filter(group => group.wave_id !== '' && group.wave_id != null);
|
||
},
|
||
/**
|
||
* 按分组解锁波次平台打印锁(order.print.unlockWavePlatformPrintDataByGroup)
|
||
* 将传入的分组中已锁定的订单 print_lock_status 置为 none
|
||
* @param {Array} lockedWaveGroups 打印锁占用的波次平台分组(用于构建 groups 条件)
|
||
* @returns {Promise<object>} 解锁结果(summary / unlocked_order_ids / unlocked_orders 等)
|
||
*/
|
||
async unlockWavePlatformPrintDataByGroup(lockedWaveGroups) {
|
||
const warehouseId = this.resolveWarehouseId();
|
||
if (!warehouseId) {
|
||
throw new Error('缺少仓库ID');
|
||
}
|
||
const groups = this.buildUnlockGroups(lockedWaveGroups);
|
||
if (!groups.length) {
|
||
throw new Error('缺少可解锁的分组条件');
|
||
}
|
||
const waveIds = Array.from(new Set(
|
||
groups.map(g => g.wave_id).filter(id => id !== '' && id != null)
|
||
));
|
||
const params = {
|
||
warehouse_id: warehouseId,
|
||
wave_ids: waveIds,
|
||
group_type: 'platform_express',
|
||
unlock_scope: 'group',
|
||
groups
|
||
};
|
||
this.debugLog('unlockWavePlatformPrintDataByGroup 请求参数', params);
|
||
const response = await this.$http('order.print.unlockWavePlatformPrintDataByGroup', params);
|
||
this.debugLog('unlockWavePlatformPrintDataByGroup 返回数据', response);
|
||
return response;
|
||
},
|
||
/**
|
||
* 获取团购(团单)模式波次平台可打印数据。
|
||
* 已打印面单(打印锁占用)时 getWavePlatformPrintData 返回的 waveGroups 为空、
|
||
* locked_wave_groups 有值,需先按分组解锁打印锁,解锁后重新获取可打印数据
|
||
* @param {object} item 订单/波次对象
|
||
* @returns {Promise<Array>} waveGroups
|
||
*/
|
||
async fetchGroupWavePrintData(item) {
|
||
const warehouseId = this.resolveWarehouseId();
|
||
const waveId = String(item?.waveId || item?.id || '').trim();
|
||
const requestData = async () => {
|
||
const response = await this.$http('order.print.getWavePlatformPrintData', { warehouse_id: warehouseId, wave_ids: [waveId] });
|
||
return this.extractWavePlatformPrintPayload(response);
|
||
};
|
||
let payload = await requestData();
|
||
let waveGroups = this.normalizeWaveGroups(payload);
|
||
const lockedWaveGroups = this.extractLockedWaveGroups(payload);
|
||
// 打印锁占用:waveGroups 为空 + locked_wave_groups 有值 → 先解锁再重新获取
|
||
if (!waveGroups.length && lockedWaveGroups.length) {
|
||
try {
|
||
const unlockResponse = await this.unlockWavePlatformPrintDataByGroup(lockedWaveGroups);
|
||
const unlockPayload = unlockResponse?.data?.data
|
||
|| unlockResponse?.data
|
||
|| unlockResponse?.result
|
||
|| unlockResponse
|
||
|| {};
|
||
const unlockedIds = unlockPayload?.unlocked_order_ids || [];
|
||
const unlockedCount = Array.isArray(unlockedIds) ? unlockedIds.length : 0;
|
||
console.log(`[handlePrintOrder] 波次平台打印锁解锁成功,解锁订单数: ${unlockedCount}`);
|
||
} catch (error) {
|
||
throw new Error(`解锁打印锁失败:${String(error?.message || error?.msg || error?.errMsg || '请稍后重试')}`);
|
||
}
|
||
payload = await requestData();
|
||
waveGroups = this.normalizeWaveGroups(payload);
|
||
}
|
||
return waveGroups;
|
||
},
|
||
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 });
|
||
},
|
||
// 语音播报复核要求(进入详情后调用,去重后串行播报,记录链供后续播报排队,参考打包模式页 speakPackingRequirements)
|
||
speakRecheckRequirements(items) {
|
||
if (!Array.isArray(items) || !items.length) return;
|
||
const reqs = [];
|
||
items.forEach((it) => {
|
||
const v = String((it && it.packageRequirement) || '').trim();
|
||
if (v && v !== '--' && reqs.indexOf(v) === -1) reqs.push(v);
|
||
});
|
||
if (!reqs.length) return;
|
||
let chain = Promise.resolve();
|
||
reqs.forEach((text) => {
|
||
chain = chain.then(() => voice.speak(`${text}`, { minInterval: 800 }));
|
||
});
|
||
this.recheckReqChain = chain;
|
||
},
|
||
// 复核要求播报完成后再播报(避免打断复核要求播报)
|
||
speakAfterRecheckRequirements(text = '') {
|
||
const chain = this.recheckReqChain;
|
||
if (chain && typeof chain.then === 'function') {
|
||
this.recheckReqChain = chain.then(() => voice.speak(`${text}`, { minInterval: 800 })).catch(() => {});
|
||
} else {
|
||
voice.speak(`${text}`, { minInterval: 800 });
|
||
}
|
||
},
|
||
// 子组件(ReviewDetail)数据一致播报统一入口:排队到复核要求播报完成后
|
||
handleSpeakDataConsistent() {
|
||
this.speakAfterRecheckRequirements('数据一致');
|
||
},
|
||
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);
|
||
}
|
||
},
|
||
async matchPrintStation(text) {
|
||
if (!text) {
|
||
uni.showToast({ title: '暂无可用打印台', icon: 'none' });
|
||
return;
|
||
}
|
||
// 打印台列表未加载时自动加载,保证广播扫描/列表视图下无需打开弹窗即可直接匹配绑定
|
||
if (!Array.isArray(this.printStationList) || !this.printStationList.length) {
|
||
try {
|
||
uni.showLoading({ title: '加载打印台...' });
|
||
await this.loadPrintStations(1, false);
|
||
} catch (error) {
|
||
console.warn('[OrderReview][matchPrintStation] 加载打印台失败:', error);
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
}
|
||
if (!Array.isArray(this.printStationList) || !this.printStationList.length) {
|
||
uni.showToast({ title: '暂无可用打印台', icon: 'none' });
|
||
this.speakVoice('未绑定打印台');
|
||
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.dispatchScanToDetail(scanText);
|
||
return;
|
||
}
|
||
// 列表视图下,广播输入作为打印台匹配
|
||
this.keyword = scanText;
|
||
this.handleSearch();
|
||
},
|
||
/**
|
||
* 详情视图下扫描统一入口:把扫描/输入的条码传给 ReviewDetail 商品复核
|
||
* 解决:D波次单品单件详情下 $refs.reviewDetail 未就绪时,扫描条码误落入列表搜索(requestScanOrder 搜索快递单号/波次号)流程
|
||
* 详情视图已打开时绝不降级到列表搜索:组件未挂载则延迟重试,等待组件就绪后再走商品复核
|
||
*/
|
||
dispatchScanToDetail(scanText, retries = 10) {
|
||
const detail = this.$refs.reviewDetail;
|
||
if (detail) {
|
||
// 已复核订单禁止扫描
|
||
if (detail.isReadOnly) {
|
||
uni.showToast({ title: '该订单已复核完成,仅可查看', icon: 'none' });
|
||
return;
|
||
}
|
||
// 多商品匹配弹窗已打开时,忽略重复扫描,避免重复提示
|
||
if (detail.showMultiMatchPopup) {
|
||
return;
|
||
}
|
||
this.keyword = scanText;
|
||
const matched = detail.handleScanCode(scanText);
|
||
setTimeout(() => { this.keyword = ''; }, 300);
|
||
if (!matched) {
|
||
uni.showToast({ title: '条码不匹配', icon: 'none' });
|
||
uni.vibrateShort({ type: 'medium' });
|
||
// 语音"无记录"已由 ReviewDetail.handleScanCode 内部播报,此处不再重复
|
||
}
|
||
return;
|
||
}
|
||
// 详情视图已打开但组件尚未挂载(真机 v-if 渲染滞后):延迟重试,不降级到列表搜索
|
||
if (retries <= 0) return;
|
||
if (!this.showDetailView) {
|
||
// 详情已关闭,交由列表搜索处理
|
||
this.keyword = scanText;
|
||
this.handleSearch();
|
||
return;
|
||
}
|
||
setTimeout(() => {
|
||
this.dispatchScanToDetail(scanText, retries - 1);
|
||
}, 150);
|
||
},
|
||
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);
|
||
},
|
||
/**
|
||
* 按商品条码在订单列表中定位所属订单(散单单品单件 D前缀波次)
|
||
* 条码来源与 goPickGoodsDetail 构建 goodsList / ReviewDetail.handleScanCode 保持一致:
|
||
* - stock 支持对象或数组(遍历每个库存的 barcodes/barcode/item_code)
|
||
* - 商品行本身 barcodes/barcode
|
||
* - item_snapshot 的 barcodes/barcode/item_code
|
||
* - item_code / sku_code / skuCode
|
||
* 匹配含汉字时剥离汉字(与 ReviewDetail extractBarcodeCandidates 一致)
|
||
*/
|
||
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;
|
||
const candidates = this.collectItemBarcodeCandidates(item);
|
||
if (candidates.includes(kw)) {
|
||
return order;
|
||
}
|
||
// 含汉字时剥离后比较(与 ReviewDetail extractBarcodeCandidates 一致)
|
||
if (/[\u4e00-\u9fff]/.test(kw)) {
|
||
const stripped = kw.replace(/[\u4e00-\u9fff]+/g, '');
|
||
if (stripped && candidates.some(c => c.replace(/[\u4e00-\u9fff]+/g, '') === stripped)) {
|
||
return order;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
},
|
||
// 收集订单明细商品的条码候选(小写化去重),供 findOrderByProductBarcode 匹配
|
||
collectItemBarcodeCandidates(item) {
|
||
if (!item || typeof item !== 'object') return [];
|
||
const result = [];
|
||
const snapshot = item.item_snapshot && typeof item.item_snapshot === 'object' ? item.item_snapshot : null;
|
||
const sources = [];
|
||
if (item.stock && typeof item.stock === 'object') {
|
||
sources.push(...(Array.isArray(item.stock) ? item.stock : [item.stock]));
|
||
}
|
||
sources.push(item);
|
||
if (snapshot) sources.push(snapshot);
|
||
sources.forEach(src => {
|
||
if (!src || typeof src !== 'object') return;
|
||
this.normalizeBarcodeValues(src?.barcodes || src?.barcode || [])
|
||
.forEach(b => result.push(String(b || '').trim().toLowerCase()));
|
||
const code = String(src?.item_code || src?.sku_code || src?.skuCode || '').trim().toLowerCase();
|
||
if (code) result.push(code);
|
||
});
|
||
return Array.from(new Set(result.filter(Boolean)));
|
||
},
|
||
/**
|
||
* D前缀波次:按快递面单号(waybillNo)在订单列表中定位所属订单
|
||
* @param {string} waybillNo - 扫描到的快递面单号
|
||
* @returns {Object|null} 匹配到的订单,未匹配返回 null
|
||
*/
|
||
findOrderByWaybillNo(waybillNo) {
|
||
if (!waybillNo || !Array.isArray(this.orderList)) return null;
|
||
const kw = String(waybillNo).trim().toLowerCase();
|
||
if (!kw) return null;
|
||
for (const order of this.orderList) {
|
||
// 跳过已复核的订单
|
||
if (order.isReviewed) continue;
|
||
const orderWaybill = String(order.waybillNo || order.waybillCode || '').trim().toLowerCase();
|
||
if (orderWaybill === kw) {
|
||
return order;
|
||
}
|
||
}
|
||
return null;
|
||
},
|
||
handleSearch() {
|
||
const text = this.normalizeKeyword(this.keyword);
|
||
if (!text) return;
|
||
this.keyword = '';
|
||
this.autoSelectFirst = true; // 输入搜索选第一个
|
||
this.scanKeyword = text; // 记录本次扫描/输入的快递单号或波次号
|
||
// 详情视图模式下,搜索框输入当作条码传给 ReviewDetail
|
||
if (this.showDetailView) {
|
||
this.dispatchScanToDetail(text);
|
||
return;
|
||
}
|
||
// D前缀波次:在订单列表中查找商品条码所属订单
|
||
if (this.isDprefixedWave) {
|
||
const matchedOrder = this.findOrderByProductBarcode(text);
|
||
if (matchedOrder) {
|
||
this.dprefixedBarcodeVerified = true;
|
||
this.goPickGoodsDetail(matchedOrder);
|
||
return;
|
||
}
|
||
// 商品条码未命中时,按快递面单号(waybillNo)定位所属订单并进入复核详情
|
||
const waybillOrder = this.findOrderByWaybillNo(text);
|
||
if (waybillOrder) {
|
||
this.goPickGoodsDetail(waybillOrder);
|
||
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.dispatchScanToDetail(scanResult);
|
||
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: '', storeName: '', waveIndex: '',
|
||
orderIds: [], interceptStatus: '',
|
||
printStationId: '', printStationName: '', boxNo: '',
|
||
isPrinted: false, listType: ''
|
||
};
|
||
this.reviewedOrderIds = [];
|
||
this.currentOrderIndex = -1;
|
||
this.printFailDismissed = false;
|
||
// 重置拦截自动提示去重(每个波次本次会话只自动弹 1 次)
|
||
this.interceptAutoNotifiedIds = [];
|
||
// 数量回归1
|
||
this.scanQuantity = 1;
|
||
this.saveSettings();
|
||
},
|
||
async handleRefreshTask() {
|
||
if (!this.taskId) {
|
||
if (this.keyword) {
|
||
this.handleSearch();
|
||
} else {
|
||
// 无 task_id 且无关键字:不能调用 scanTask 也无法重新搜索,
|
||
// 保持当前列表不清空(initializeOrderList 会清空 orderList,
|
||
// 导致底部统计栏 v-if="orderList.length > 0" 隐藏,刷新按钮/统计行消失)
|
||
uni.showToast({
|
||
title: '暂无任务ID,无法刷新',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
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 pickMode = payload?.pick_mode ?? payload?.pickMode ?? '';
|
||
|
||
// 扁平化订单列表模式(散单:运单号/波次号命中)
|
||
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,
|
||
pickMode,
|
||
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 : [];
|
||
// 团购模式:解析波次内被拦截订单(intercepted),参考散单模式拦截处理
|
||
// totalOrders 取波次总订单数(data.list[x].total_orders),供拦截弹窗展示"运单号-总订单数-波次索引"
|
||
const waveTotalOrderCount = Number(wave?.total_orders ?? wave?.totalOrders ?? wave?.order_count ?? wave?.orderCount ?? 0);
|
||
const waveInterceptList = (Array.isArray(wave?.intercepted) ? wave.intercepted : [])
|
||
.filter(inter => inter && typeof inter === 'object')
|
||
.map(inter => ({
|
||
orderId: Number(inter?.order_id ?? inter?.orderId ?? 0),
|
||
deliveryOrderCode: String(inter?.delivery_order_code || inter?.deliveryOrderCode || '').trim(),
|
||
waybillNo: String(inter?.waybill_no || inter?.waybillNo || '').trim(),
|
||
interceptStatus: String(inter?.intercept_status || inter?.interceptStatus || '').trim(),
|
||
waveIndex: String(inter?.wave_index ?? inter?.waveIndex ?? '').trim(),
|
||
totalOrders: waveTotalOrderCount
|
||
}));
|
||
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(),
|
||
storeName: String(wave?.store_remark || '').trim(),
|
||
suggestedPkg: wave?.suggested_package_material || wave?.suggestedPkg || null,
|
||
interceptList: waveInterceptList,
|
||
hasIntercept: waveInterceptList.length > 0,
|
||
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();
|
||
// 后端返回的当前波次ID(data.wave_id),用于精确匹配进入对应波次
|
||
const currentWaveId = String(payload?.wave_id ?? payload?.waveId ?? '').trim();
|
||
return {
|
||
listType: 'group',
|
||
matchType,
|
||
pickMode,
|
||
waves: normalizedWaves,
|
||
waybillNo: groupWaybillNo,
|
||
waveId: currentWaveId,
|
||
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,
|
||
pickMode,
|
||
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(),
|
||
storeName: String(item?.store_remark || '').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 : [],
|
||
suggestedPkg: item?.suggested_package_material || item?.suggestedPkg || item?.suggested_pkg || null
|
||
};
|
||
},
|
||
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 || '';
|
||
this.pickMode = result?.pickMode || '';
|
||
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 || '',
|
||
storeName: item?.storeName || '',
|
||
detailItems: Array.isArray(item?.items) ? item.items : [],
|
||
suggestedPkg: item?.suggestedPkg || null
|
||
}));
|
||
this.paginationTotal = result?.total ?? flatList.length;
|
||
this.goodsInfoList = [];
|
||
// 刷新订单列表后重置已提示的拦截订单记录
|
||
this.interceptNotifiedIds = [];
|
||
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);
|
||
let target = null;
|
||
if (this.autoSelectFirst) {
|
||
const scanKw = String(this.scanKeyword || '').trim();
|
||
// 扫描快递单号时:优先精确匹配该运单号对应的订单,进入其复核详情
|
||
if (scanKw) {
|
||
target = this.orderList.find(item => String(item.waybillNo || '').trim() === scanKw) || null;
|
||
}
|
||
}
|
||
if (!target) {
|
||
target = this.autoSelectFirst ? unreviewedItems[0] : unreviewedItems.pop();
|
||
}
|
||
if (target) {
|
||
// 扫描快递单号进入详情时,确保顶部显示该运单号(接口未返回运单号时兜底)
|
||
if (this.autoSelectFirst && !String(target.waybillNo || '').trim() && this.scanKeyword) {
|
||
target = { ...target, waybillNo: this.scanKeyword };
|
||
}
|
||
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(),
|
||
storeName: String(wave?.storeName || '').trim(),
|
||
suggestedPkg: wave?.suggestedPkg || null,
|
||
interceptList: Array.isArray(wave?.interceptList) ? wave.interceptList : [],
|
||
hasIntercept: Array.isArray(wave?.interceptList) && wave.interceptList.length > 0,
|
||
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'
|
||
});
|
||
}
|
||
// 自动选中波次:扫描/输入搜索时优先精确匹配后端返回的 wave_id 对应波次,否则选第一个;任务刷新选最后一个
|
||
this.$nextTick(() => {
|
||
const unreviewedItems = this.orderList.filter(item => (item.unreviewedCount || 0) > 0);
|
||
let target = null;
|
||
if (this.autoSelectFirst) {
|
||
// 优先精确匹配 data.wave_id 对应的波次,进入该波次详情并显示其波次号
|
||
const targetWaveId = String(result?.waveId ?? '').trim();
|
||
if (targetWaveId) {
|
||
target = this.orderList.find(wave => String(wave?.waveId ?? wave?.id ?? '').trim() === targetWaveId) || null;
|
||
}
|
||
}
|
||
if (!target) {
|
||
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 || ''),
|
||
storeName: String(order?.store_name || order?.storeName || result?.storeName || '').trim(),
|
||
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'
|
||
});
|
||
// 对应接口 400「扫描关键词不能为空」:同步语音提示
|
||
this.speakVoice('扫描关键词不能为空');
|
||
return;
|
||
}
|
||
|
||
if (!silent) {
|
||
uni.showLoading({
|
||
title: '查询订单中...'
|
||
});
|
||
}
|
||
try {
|
||
// 第4参 toastAfter=false:关闭请求层全局错误 toast,由 handleScanOrderError 统一按 silent 控制提示与语音
|
||
const response = await this.$http('order.recheckOrder.scanOrder', this.buildScanOrderParams(normalizedKeyword), '', false);
|
||
// 检测接口返回的错误信息
|
||
if (response?.flag === 'failure') {
|
||
// 依据后端提示(400 扫描关键词不能为空 / 404 未找到对应订单 / 400 订单未拣货不允许复核等)toast + 语音播报
|
||
const errorMsg = String(response?.message || response?.msg || '').trim();
|
||
this.handleScanOrderError(errorMsg || '订单查询失败', silent);
|
||
return;
|
||
}
|
||
const payload = this.extractScanOrderPayload(response);
|
||
const result = this.normalizeScanOrderResult(payload);
|
||
this.handleScanOrderSuccess(result, silent);
|
||
} catch (error) {
|
||
const message = String(error?.message || error?.msg || error?.errMsg || '').trim();
|
||
this.handleScanOrderError(message || '订单查询失败', silent);
|
||
} finally {
|
||
if (!silent) {
|
||
uni.hideLoading();
|
||
}
|
||
}
|
||
},
|
||
// scanOrder 接口业务失败:toast 展示后端提示,并按提示内容语音播报
|
||
handleScanOrderError(message, silent = false) {
|
||
const raw = String(message || '').trim();
|
||
// 去除后端常见包装前缀:如 "接口错误: 未找到对应订单" -> "未找到对应订单"
|
||
const cleaned = raw.replace(/^接口错误\s*[::]\s*/, '').trim();
|
||
const toastText = cleaned || '订单查询失败';
|
||
if (!silent) {
|
||
uni.showToast({
|
||
title: toastText,
|
||
icon: 'none',
|
||
// 业务错误提示(如未找到对应订单/订单未拣货等)展示 5s,便于 PDA 现场确认
|
||
duration: 5000
|
||
});
|
||
}
|
||
const voiceText = this.resolveScanOrderErrorVoice(toastText);
|
||
if (voiceText) {
|
||
this.speakVoice(voiceText);
|
||
}
|
||
},
|
||
// 将 scanOrder 返回的业务提示映射为语音播报文本(对应接口 400/404 常见错误)
|
||
resolveScanOrderErrorVoice(message) {
|
||
const text = String(message || '').trim();
|
||
if (/未拣货/.test(text)) {
|
||
return '订单未拣货,不允许复核';
|
||
}
|
||
if (/未找到对应订单|未查询到订单|无匹配订单|未找到订单/.test(text)) {
|
||
return '未找到对应订单';
|
||
}
|
||
if (/扫描关键词不能为空|关键词为空|请输入快递单号或车号/.test(text)) {
|
||
return '扫描关键词不能为空';
|
||
}
|
||
// 其他未识别的业务提示:仅 toast 不额外播报,避免朗读非预期文案
|
||
return '';
|
||
},
|
||
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;
|
||
}
|
||
},
|
||
resolvePickerName(detail, logs = []) {
|
||
const pickLog = Array.isArray(logs)
|
||
? logs.find(log => String(log?.operation_code || '').toUpperCase() === 'ORDER_PICK_COMPLETE')
|
||
: null;
|
||
const pickedName = String(pickLog?.operator_name || pickLog?.picker_name || '').trim();
|
||
if (pickedName) {
|
||
return pickedName;
|
||
}
|
||
return String(detail?.operator_name || detail?.picker_name || detail?.pickerName || '').trim() || '--';
|
||
},
|
||
normalizeBarcodeValues(barcodes) {
|
||
if (Array.isArray(barcodes)) {
|
||
return barcodes
|
||
.map(entry => {
|
||
if (entry === null || entry === undefined) {
|
||
return '';
|
||
}
|
||
if (typeof entry === 'string') {
|
||
return entry.trim();
|
||
}
|
||
if (typeof entry === 'object') {
|
||
const val = entry?.barcode || entry?.code || entry?.value || entry?.name || '';
|
||
return String(val || '').trim();
|
||
}
|
||
return String(entry || '').trim();
|
||
})
|
||
.filter(Boolean);
|
||
}
|
||
if (typeof barcodes === 'string') {
|
||
return barcodes.split(/[;,,\s]+/).map(item => item.trim()).filter(Boolean);
|
||
}
|
||
if (barcodes && typeof barcodes === 'object') {
|
||
const val = barcodes?.barcode || barcodes?.code || barcodes?.value || '';
|
||
return val ? [String(val).trim()] : [];
|
||
}
|
||
return [];
|
||
},
|
||
async fetchGroupReviewedDetail(waveId) {
|
||
if (!waveId) {
|
||
return;
|
||
}
|
||
uni.showLoading({ title: '加载详情...' });
|
||
try {
|
||
const response = await this.$http('order.deliveryOrder.list', {
|
||
pagination: {
|
||
page: 1,
|
||
pageSize: 100
|
||
},
|
||
where: {
|
||
wave_id: {
|
||
operator: 'eq',
|
||
value: Number(waveId)
|
||
}
|
||
},
|
||
sort: {
|
||
sortField: 'updated_at',
|
||
sortOrder: 'DESC'
|
||
}
|
||
});
|
||
const data = response?.data || response || {};
|
||
const orders = Array.isArray(data?.list) ? data.list : [];
|
||
if (!orders.length) {
|
||
uni.showToast({ title: '未查询到波次订单', icon: 'none' });
|
||
return;
|
||
}
|
||
const firstOrder = orders[0] || {};
|
||
const firstOrderId = Number(firstOrder?.id || 0);
|
||
if (!firstOrderId) {
|
||
uni.showToast({ title: '缺少波次订单ID', icon: 'none' });
|
||
return;
|
||
}
|
||
|
||
const firstResponse = await this.$http('order.deliveryOrder.detail', {
|
||
id: firstOrderId,
|
||
tableType: 'dispatch'
|
||
});
|
||
const firstPayload = firstResponse?.data || firstResponse || {};
|
||
const firstDetail = firstPayload?.detail || firstPayload?.info || firstPayload || {};
|
||
const responseItems = Array.isArray(firstPayload?.items) ? firstPayload.items
|
||
: Array.isArray(firstDetail.items) ? firstDetail.items
|
||
: Array.isArray(firstDetail.goods_items) ? firstDetail.goods_items
|
||
: Array.isArray(firstDetail.stocks) ? firstDetail.stocks
|
||
: [];
|
||
const allItems = responseItems.map(item => ({
|
||
...item,
|
||
images: Array.isArray(item.image_url) ? item.image_url
|
||
: Array.isArray(item.images) ? item.images
|
||
: [],
|
||
barcodes: this.normalizeBarcodeValues(item?.barcodes || item?.barcode || [])
|
||
}));
|
||
const logs = Array.isArray(firstPayload?.logs) ? firstPayload.logs : Array.isArray(firstDetail?.logs) ? firstDetail.logs : [];
|
||
const pickerName = this.resolvePickerName(firstDetail, logs);
|
||
// 尝试从日志中的 ORDER_PRINT 条目解析波次订单数量(message 中的 order_count)
|
||
let waveOrderCount = Number(firstDetail.order_count ?? firstDetail.orderCount ?? 0);
|
||
if ((!waveOrderCount || waveOrderCount === 0) && Array.isArray(logs) && logs.length > 0) {
|
||
const printLog = logs.find(l => String(l?.operation_code || '').toUpperCase() === 'ORDER_PRINT');
|
||
if (printLog && printLog.message) {
|
||
const m = String(printLog.message).match(/order_count\s*=?\s*(\d+)/i);
|
||
if (m && m[1]) {
|
||
waveOrderCount = Number(m[1]);
|
||
}
|
||
}
|
||
}
|
||
const waybillNo = String(
|
||
firstPayload?.waybill_codes?.[0]
|
||
|| firstDetail.waybill_no
|
||
|| firstDetail.waybillNo
|
||
|| firstDetail.express_code
|
||
|| firstPayload?.expresses?.[0]?.waybill_code
|
||
|| '--'
|
||
);
|
||
const detailItem = {
|
||
id: String(firstDetail.id || waveId || ''),
|
||
orderId: Number(firstDetail.id || firstDetail.order_id || 0),
|
||
waveNo: String(firstDetail.wave_no || firstDetail.waveNo || '--'),
|
||
waveId: String(firstDetail.wave_id || firstDetail.waveId || waveId || ''),
|
||
waybillNo,
|
||
recheckStatus: 'fin',
|
||
pickerName,
|
||
orderCount: Number.isFinite(waveOrderCount) ? waveOrderCount : (Number(firstDetail.order_count ?? firstDetail.orderCount ?? 0) || 0),
|
||
totalOrders: Number.isFinite(waveOrderCount) ? waveOrderCount : (Number(firstDetail.order_count ?? firstDetail.orderCount ?? 0) || 0),
|
||
cartNo: String(firstDetail.basket_number || firstDetail.cart_code || firstDetail.cartCode || firstDetail.cart_no || firstDetail.cartNo || '--'),
|
||
status: 'reviewed',
|
||
unreviewedCount: 0,
|
||
storeRemark: String(firstDetail.remark || firstDetail.store_remark || firstDetail.storeRemark || ''),
|
||
storeName: String(firstDetail.store_name || firstDetail.storeName || '').trim(),
|
||
waveIndex: String(firstDetail.wave_index || firstDetail.waveIndex || '').trim(),
|
||
interceptStatus: String(firstDetail.intercept_status || firstDetail.interceptStatus || ''),
|
||
boxNo: String(firstDetail.box_no || firstDetail.boxNo || ''),
|
||
isPrinted: !!firstDetail.is_printed || !!firstDetail.isPrinted || firstDetail.print_status === 'fin',
|
||
detailItems: allItems,
|
||
stocks: allItems,
|
||
orderIds: []
|
||
};
|
||
this.goPickGoodsDetail(detailItem);
|
||
} catch (error) {
|
||
console.error('[order-review] fetchGroupReviewedDetail error:', error);
|
||
uni.showToast({ title: '加载团购订单详情失败', icon: 'none' });
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
},
|
||
async fetchReviewedDetail(id, tableType = 'dispatch') {
|
||
uni.showLoading({ title: '加载详情...' });
|
||
try {
|
||
const response = await this.$http('order.deliveryOrder.detail', {
|
||
id: Number(id),
|
||
tableType
|
||
});
|
||
const data = response?.data || response || {};
|
||
const detail = data?.detail || data?.info || data || {};
|
||
if (!detail || !detail.id) {
|
||
uni.showToast({ title: '未查询到订单详情', icon: 'none' });
|
||
return;
|
||
}
|
||
// 提取商品明细(items 在 data 层级)
|
||
const responseItems = Array.isArray(data?.items) ? data.items
|
||
: Array.isArray(detail.items) ? detail.items
|
||
: Array.isArray(detail.goods_items) ? detail.goods_items
|
||
: Array.isArray(detail.stocks) ? detail.stocks
|
||
: [];
|
||
const logs = Array.isArray(data?.logs) ? data.logs : Array.isArray(detail?.logs) ? detail.logs : [];
|
||
const pickerName = this.resolvePickerName(detail, logs);
|
||
// 统一商品图片字段名(接口返回 image_url 数组)
|
||
const normalizedItems = responseItems.map(item => ({
|
||
...item,
|
||
images: Array.isArray(item.image_url) ? item.image_url
|
||
: Array.isArray(item.images) ? item.images
|
||
: [],
|
||
barcodes: this.normalizeBarcodeValues(item?.barcodes || item?.barcode || [])
|
||
}));
|
||
// 提取运单号(优先 data.waybill_codes)
|
||
const waybillNo = String(
|
||
data?.waybill_codes?.[0]
|
||
|| detail.waybill_no
|
||
|| detail.waybillNo
|
||
|| detail.express_code
|
||
|| data?.expresses?.[0]?.waybill_code
|
||
|| '--'
|
||
);
|
||
// 构造符合 goPickGoodsDetail 格式的数据
|
||
const detailItem = {
|
||
id: String(detail.id || ''),
|
||
orderId: Number(detail.id || detail.order_id || 0),
|
||
waveNo: String(detail.wave_no || detail.waveNo || '--'),
|
||
waveId: String(detail.wave_id || detail.waveId || ''),
|
||
waybillNo,
|
||
recheckStatus: 'fin',
|
||
pickerName,
|
||
cartNo: String(detail.basket_number || detail.cart_code || detail.cartCode || detail.cart_no || detail.cartNo || '--'),
|
||
status: 'reviewed',
|
||
unreviewedCount: 0,
|
||
storeRemark: String(detail.remark || detail.store_remark || detail.storeRemark || ''),
|
||
storeName: String(detail.store_name || detail.storeName || '').trim(),
|
||
waveIndex: String(detail.wave_index || detail.waveIndex || '').trim(),
|
||
interceptStatus: String(detail.intercept_status || detail.interceptStatus || ''),
|
||
boxNo: String(detail.box_no || detail.boxNo || ''),
|
||
isPrinted: !!detail.is_printed || !!detail.isPrinted || detail.print_status === 'fin',
|
||
detailItems: normalizedItems,
|
||
stocks: normalizedItems,
|
||
orderIds: []
|
||
};
|
||
this.goPickGoodsDetail(detailItem);
|
||
} catch (error) {
|
||
console.error('[order-review] fetchReviewedDetail error:', error);
|
||
uni.showToast({ title: '加载订单详情失败', icon: 'none' });
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
},
|
||
goPickGoodsDetail(item, continueAfterIntercept = false) {
|
||
if (!item) return;
|
||
// 复位"无需复核商品点击卡片触发发货"防重入标志(每次进入新订单重新允许触发一次)
|
||
this.noRecheckAutoAdvanceHandled = false;
|
||
|
||
// 散单模式:被拦截订单不允许进入详情/复核扫描/打印/发货流程
|
||
// 语音提示"此单已拦截",并弹出当前订单的拦截信息(仅显示当前一个订单)
|
||
if (this.listType === 'single' && this.isOrderIntercepted(item)) {
|
||
// 记录当前拦截订单在列表中的位置,关闭弹窗后从其后继续查找下一个未复核订单
|
||
const interceptedIndex = this.orderList.findIndex(o =>
|
||
String(o.id || o.orderId || '') === String(item.id || item.orderId || '')
|
||
);
|
||
if (interceptedIndex >= 0) {
|
||
this.currentOrderIndex = interceptedIndex;
|
||
}
|
||
this.interceptContinueNext = !!continueAfterIntercept;
|
||
// 自动跳转流程:记录本次已提示过的拦截订单,避免后续查找时重复弹窗造成死循环
|
||
if (continueAfterIntercept) {
|
||
const interceptedId = String(item.id || item.orderId || '');
|
||
if (interceptedId && !this.interceptNotifiedIds.includes(interceptedId)) {
|
||
this.interceptNotifiedIds = [...this.interceptNotifiedIds, interceptedId];
|
||
}
|
||
}
|
||
this.speakVoice('此单已拦截');
|
||
this.openOrderInterceptPopup(item);
|
||
return;
|
||
}
|
||
|
||
// 切换订单时重置包材/称重取消标志,新订单继续正常弹窗
|
||
this.packageBindingCancelled = false;
|
||
this.weighCancelled = false;
|
||
this.printFailDismissed = 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);
|
||
// 无需复核商品(need_recheck=N,如虚拟赠品):直接标记为已扫,已扫数量取计划数
|
||
const needRecheck = String(stockItem?.need_recheck ?? rawItem?.need_recheck ?? '').trim().toUpperCase();
|
||
const stockName = stockItem ? String(stockItem.item_name || '').trim() : '';
|
||
const barcodeSource = stockItem?.barcodes || rawItem?.barcodes || rawItem?.barcode || snapshot?.barcodes || snapshot?.barcode || [];
|
||
const stockBarcodes = this.normalizeBarcodeValues(barcodeSource);
|
||
const boxNo = String(stockItem?.box_no ?? stockItem?.boxNo ?? rawItem?.box_no ?? rawItem?.boxNo ?? '').trim();
|
||
|
||
return {
|
||
id: String(rawItem?.id || stockItem?.stock_id || `item-${index + 1}`),
|
||
lineNo: Number(rawItem?.order_line_no) || (index + 1),
|
||
boxNo,
|
||
planQty: isNaN(planQty) ? 0 : planQty,
|
||
// 无需复核商品(need_recheck=N):已扫数量视为计划数,卡片标记为已扫
|
||
scannedQty: needRecheck === 'N' ? (isNaN(planQty) ? 0 : planQty) : (isNaN(scannedQty) ? 0 : scannedQty),
|
||
need_recheck: needRecheck,
|
||
packageRequirement: String(stockItem?.recheck_requirements || rawItem?.recheck_requirements || stockItem?.packing_requirements || 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,
|
||
// 库内是否存在共享同一条码的其他商品(order.recheckOrder.scanOrder 返回的 has_shared_barcode)
|
||
has_shared_barcode: !!(stockItem?.has_shared_barcode ?? rawItem?.has_shared_barcode ?? false)
|
||
};
|
||
});
|
||
|
||
// 提取包装要求(取第一个 stock 的 recheck_requirements)
|
||
let packingRequirements = '';
|
||
for (let i = 0; i < rawItems.length; i++) {
|
||
const raw = rawItems[i];
|
||
const stockItem = raw?.stock_id ? raw : (Array.isArray(raw?.stock) && raw.stock.length > 0 ? raw.stock[0] : null);
|
||
const req = stockItem?.recheck_requirements || raw?.recheck_requirements || stockItem?.packing_requirements || raw?.packing_requirements || '';
|
||
if (req) {
|
||
packingRequirements = String(req).trim();
|
||
break;
|
||
}
|
||
}
|
||
|
||
// 设置详情数据
|
||
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(),
|
||
storeName: String(item?.storeName || this.orderList?.[0]?.storeName || '').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(),
|
||
waveHasIntercept: this.resolveWaveHasIntercept(item),
|
||
interceptList: this.resolveWaveInterceptList(item),
|
||
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,
|
||
packingRequirements
|
||
};
|
||
|
||
// 缓存当前订单在列表中的索引
|
||
this.currentOrderIndex = this.orderList.findIndex(o => String(o.id || o.orderId || '') === String(item.id || item.orderId || ''));
|
||
|
||
this.showDetailView = true;
|
||
this.listExpanded = false;
|
||
|
||
// 进入详情后语音播报复核要求(去重串行播报)
|
||
this.speakRecheckRequirements(this.detailGoodsList);
|
||
|
||
// 团购模式:进入含拦截单的波次时自动弹出拦截信息提示(含波次号、运单号)
|
||
// 每个波次本次会话只自动弹 1 次(按 waveId/waveNo 去重);已复核波次仅展示只读详情,不自动弹窗
|
||
if (
|
||
this.listType === 'group' &&
|
||
String(this.detailInfo?.recheckStatus || '').toLowerCase() !== 'fin' &&
|
||
!!this.detailInfo?.waveHasIntercept &&
|
||
Array.isArray(this.detailInfo?.interceptList) &&
|
||
this.detailInfo.interceptList.length > 0
|
||
) {
|
||
// 数组字段已去下划线前缀(data 中可正常代理到 this),无需再手动补默认值
|
||
if (!Array.isArray(this.interceptAutoNotifiedIds)) {
|
||
this.interceptAutoNotifiedIds = [];
|
||
}
|
||
const waveKey = String(this.detailInfo?.waveId || this.detailInfo?.waveNo || '').trim();
|
||
const alreadyNotified = !!waveKey && this.interceptAutoNotifiedIds.includes(waveKey);
|
||
if (!alreadyNotified) {
|
||
if (waveKey) {
|
||
this.interceptAutoNotifiedIds = [...this.interceptAutoNotifiedIds, waveKey];
|
||
}
|
||
// 团购模式:自动弹出拦截信息时同步语音提示"有拦截订单"
|
||
this.speakVoice('有拦截订单');
|
||
// 真机 App 下 v-if 子组件挂载可能滞后于 $nextTick,延迟重试确保 ReviewDetail 就绪后再打开弹窗
|
||
this.openInterceptInfoWhenReady();
|
||
}
|
||
}
|
||
|
||
// D前缀波次:仅当通过商品条码扫描匹配进入时,自动标记所有商品为已扫并触发复核发货
|
||
// 从订单列表抽屉点击进入时(无条码校验),仅展示详情,需手动扫描商品条码复核
|
||
// 已复核订单不再触发自动复核/打印,仅展示只读详情
|
||
if (this.isDprefixedWave && this.detailGoodsList.length > 0 && !item.isReviewed) {
|
||
if (this.dprefixedBarcodeVerified) {
|
||
// 库内有相同商品时先弹确认框,确认后再自动复核发货
|
||
this.completeDprefixedAutoReview();
|
||
} else {
|
||
// 非扫码进入:不自动标记,等待用户扫描商品条码
|
||
uni.showToast({
|
||
title: '请扫描商品条码进行复核',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
}
|
||
|
||
// 先打印后复核:进入详情时自动触发未打印订单的打印
|
||
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);
|
||
}
|
||
}
|
||
|
||
|
||
},
|
||
// D前缀波次单品单件:自动标记所有商品为已扫并触发复核发货
|
||
// 若库内有相同商品(has_shared_barcode),先弹出"库内有相同商品"确认弹窗,确认后再自动复核发货
|
||
completeDprefixedAutoReview() {
|
||
if (!this.detailGoodsList.length) return;
|
||
const sharedGoods = this.detailGoodsList.find(g => !!g?.has_shared_barcode);
|
||
if (sharedGoods) {
|
||
// 真机 App 下 v-if 子组件挂载可能滞后于 $nextTick,延迟重试确保 ReviewDetail 就绪后再打开弹窗
|
||
this.openSharedBarcodePopupWhenReady(sharedGoods);
|
||
return;
|
||
}
|
||
this.finishDprefixedAutoReview();
|
||
},
|
||
// 打开"库内有相同商品"弹窗;弹窗关闭/确认后继续自动复核发货
|
||
openSharedBarcodePopupWhenReady(sharedGoods, retries = 6) {
|
||
const detail = this.$refs.reviewDetail;
|
||
if (detail) {
|
||
if (detail.showMultiMatchPopup) {
|
||
// 弹窗已打开,稍后重试
|
||
if (retries <= 0) return;
|
||
setTimeout(() => {
|
||
this.openSharedBarcodePopupWhenReady(sharedGoods, retries - 1);
|
||
}, 150);
|
||
return;
|
||
}
|
||
detail.showSharedBarcodePopup(sharedGoods, () => {
|
||
this.finishDprefixedAutoReview();
|
||
});
|
||
return;
|
||
}
|
||
if (retries <= 0) return;
|
||
setTimeout(() => {
|
||
this.openSharedBarcodePopupWhenReady(sharedGoods, retries - 1);
|
||
}, 150);
|
||
},
|
||
// 标记所有商品为已扫并触发复核发货
|
||
finishDprefixedAutoReview() {
|
||
if (!this.detailGoodsList.length) return;
|
||
// 已在自动复核发货流程中(handleDetailAllScanned 已处理),忽略重复进入,避免重复打印面单
|
||
if (this.dprefixedAllScannedHandled) return;
|
||
this.detailGoodsList = this.detailGoodsList.map(g => ({
|
||
...g,
|
||
scannedQty: g.planQty
|
||
}));
|
||
this.$nextTick(() => {
|
||
this.handleDetailAllScanned();
|
||
});
|
||
},
|
||
backToList() {
|
||
this.showDetailView = false;
|
||
this.detailGoodsList = [];
|
||
this.dprefixedBarcodeVerified = false;
|
||
this.dprefixedAllScannedHandled = false;
|
||
this.noRecheckAutoAdvanceHandled = false;
|
||
// 从详情返回后刷新列表
|
||
// D波次:keyword 是商品条码,scanOrder 不支持,依赖本地已更新的 orderList
|
||
if (this.keyword && !this.isDprefixedWave) {
|
||
this.requestScanOrder(this.keyword, true);
|
||
}
|
||
},
|
||
// 详情页导航栏标题左侧的拦截信息按钮:通过 ReviewDetail 组件打开拦截信息弹窗
|
||
handleShowInterceptInfo() {
|
||
if (this.$refs.reviewDetail) {
|
||
this.$refs.reviewDetail.openInterceptInfo();
|
||
}
|
||
},
|
||
// 团购模式自动弹拦截信息:ReviewDetail 是 v-if 渲染的子组件,真机 App 上挂载可能滞后于 $nextTick,
|
||
// 因此轮询等待 $refs 就绪后再打开弹窗,避免出现"只播语音不弹窗"的问题
|
||
openInterceptInfoWhenReady(retries = 6) {
|
||
if (this.$refs.reviewDetail) {
|
||
this.$refs.reviewDetail.openInterceptInfo();
|
||
return;
|
||
}
|
||
if (retries <= 0) return;
|
||
setTimeout(() => {
|
||
this.openInterceptInfoWhenReady(retries - 1);
|
||
}, 150);
|
||
},
|
||
// 判断单个订单是否被拦截(散单模式拦截订单拦截入口使用)
|
||
isOrderIntercepted(item) {
|
||
const status = String(item?.interceptStatus || item?.intercept_status || '').trim();
|
||
return !!status && status !== 'none';
|
||
},
|
||
// 散单模式扫码命中被拦截订单时:弹出仅显示当前订单的拦截信息弹窗
|
||
openOrderInterceptPopup(item) {
|
||
this.orderInterceptInfo = item || {};
|
||
this.showOrderInterceptPopup = true;
|
||
},
|
||
// 关闭拦截订单弹窗:若为自动跳转流程(复核完自动找下一个)触发,则继续查找下一个未复核订单
|
||
handleCloseOrderInterceptPopup() {
|
||
this.showOrderInterceptPopup = false;
|
||
const shouldContinue = this.interceptContinueNext;
|
||
this.interceptContinueNext = false;
|
||
if (shouldContinue) {
|
||
this.goToNextOrder();
|
||
}
|
||
},
|
||
handleDrawerOrderClick(item) {
|
||
this.showListDrawer = false;
|
||
// 已复核订单禁止再次进入复核流程:
|
||
// 订单列表"已复核"以 isReviewed(散单)/ unreviewedCount===0(团单)标记,
|
||
// 而 goPickGoodsDetail 只以 recheckStatus==='fin' 决定只读详情(isDetailReadOnly)。
|
||
// 两者不一致时,从列表点击已复核订单会以可复核状态进入,此处统一兜底为 fin(只读查看)。
|
||
const isReviewed = !!item?.isReviewed
|
||
|| String(item?.recheckStatus || '').trim().toLowerCase() === 'fin'
|
||
|| (this.listType !== 'single' && (item?.unreviewedCount || 0) === 0);
|
||
this.goPickGoodsDetail(isReviewed ? { ...item, recheckStatus: 'fin' } : item);
|
||
},
|
||
// 判断当前订单所属波次是否含有被拦截的订单
|
||
// 散单模式(single):一个波次含多个订单,只要波次内任一订单被拦截,波次内所有订单的复核详情都显示拦截信息按钮
|
||
// 其它模式:直接看当前订单/波次的拦截状态
|
||
resolveWaveHasIntercept(item) {
|
||
if (this.listType !== 'single') {
|
||
// 团单模式:波次 intercepted 中存在被拦截订单即视为波次含拦截(参考散单模式拦截处理)
|
||
const interceptList = Array.isArray(item?.interceptList) ? item.interceptList : [];
|
||
if (interceptList.length > 0) return true;
|
||
const status = String(item?.interceptStatus || '').trim();
|
||
return !!status && status !== 'none';
|
||
}
|
||
const waveNo = String(item?.waveNo || '').trim();
|
||
const hasOrderList = Array.isArray(this.orderList) && this.orderList.length > 0;
|
||
if (!waveNo || !hasOrderList) {
|
||
const status = String(item?.interceptStatus || '').trim();
|
||
return !!status && status !== 'none';
|
||
}
|
||
return this.orderList.some(o => {
|
||
if (String(o?.waveNo || '').trim() !== waveNo) return false;
|
||
const s = String(o?.interceptStatus || '').trim();
|
||
return !!s && s !== 'none';
|
||
});
|
||
},
|
||
// 获取当前订单所属波次的被拦截订单列表
|
||
// 散单模式(single):返回波次内所有被拦截订单;其它模式:返回当前订单自身(若被拦截)
|
||
resolveWaveInterceptList(item) {
|
||
if (this.listType !== 'single') {
|
||
// 团单模式:直接返回波次内被拦截订单列表(intercepted),参考散单模式波次内拦截订单展示
|
||
const interceptList = Array.isArray(item?.interceptList) ? item.interceptList : [];
|
||
if (interceptList.length > 0) return interceptList;
|
||
const status = String(item?.interceptStatus || '').trim();
|
||
if (!status || status === 'none') return [];
|
||
return [item];
|
||
}
|
||
const waveNo = String(item?.waveNo || '').trim();
|
||
const hasOrderList = Array.isArray(this.orderList) && this.orderList.length > 0;
|
||
if (!waveNo || !hasOrderList) {
|
||
const status = String(item?.interceptStatus || '').trim();
|
||
return (!status || status === 'none') ? [] : [item];
|
||
}
|
||
return this.orderList.filter(o => {
|
||
if (String(o?.waveNo || '').trim() !== waveNo) return false;
|
||
const s = String(o?.interceptStatus || '').trim();
|
||
return !!s && s !== 'none';
|
||
});
|
||
},
|
||
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;
|
||
}
|
||
// D前缀波次单品单件自动复核防重入:
|
||
// finishDprefixedAutoReview 的 $nextTick 显式调用与 ReviewDetail goodsList watcher 的
|
||
// allScanned 会对同一订单重复触发,导致同一面单重复打印。仅处理第一次,重复触发直接忽略。
|
||
if (this.isDprefixedWave && this.dprefixedAllScannedHandled) {
|
||
return;
|
||
}
|
||
this.dprefixedAllScannedHandled = true;
|
||
// 团单:全部商品已复核完成时,先判断打印是否成功,打印未成功弹「打印未完成」弹窗
|
||
if (this.listType === 'group') {
|
||
this.handleGroupAllScanned();
|
||
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();
|
||
},
|
||
// 团单全部商品已复核完成:先判断打印是否成功,打印成功才弹包材绑定弹窗
|
||
async handleGroupAllScanned() {
|
||
if (!(await this.ensurePrintedBeforeShip('groupShip'))) {
|
||
return;
|
||
}
|
||
this.openGroupPackageBinding();
|
||
},
|
||
// 弹包材绑定弹窗(打印成功 / 打印失败重试成功后进入包材绑定)
|
||
openGroupPackageBinding() {
|
||
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;
|
||
},
|
||
handleGoodsItemClick() {
|
||
// 打印未完成被关闭后(订单未打印未发货),点击商品列表项只重新弹出打印未完成弹窗,不自动重试打印
|
||
if (this.printFailDismissed && !this.showPrintFailPopup) {
|
||
this.printFailMessage = this.lastPrintError || '打印失败,未触发发货';
|
||
this.showPrintFailPopup = true;
|
||
return;
|
||
}
|
||
// 点击商品列表项时,如果之前取消过包材绑定则重新弹出
|
||
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;
|
||
}
|
||
// 订单所有商品均为"无需复核"(need_recheck=N,如虚拟赠品)或已扫满时:
|
||
// 不直接走下一步流程,操作人员点击商品卡片核对后再触发复核发货流程
|
||
// (自动模式直接发货,手动模式提示点击确认复核)
|
||
// 原因:ReviewDetail 的 allScanned 仅在 goodsList 变化时触发,此类订单商品从不变化,
|
||
// 不会走到 handleDetailAllScanned 发货链路,故点击商品卡片时主动触发一次。
|
||
// 排除 D前缀波次(有自己的自动复核流程 completeDprefixedAutoReview)和已复核只读订单(fin)
|
||
if (
|
||
!this.isDprefixedWave &&
|
||
!this.noRecheckAutoAdvanceHandled &&
|
||
this.detailGoodsList.length > 0 &&
|
||
String(this.detailInfo?.recheckStatus || '').toLowerCase() !== 'fin' &&
|
||
this.detailGoodsList.every(g =>
|
||
String(g.need_recheck || '').trim().toUpperCase() === 'N' ||
|
||
Number(g.scannedQty || 0) >= Number(g.planQty || 0)
|
||
)
|
||
) {
|
||
this.noRecheckAutoAdvanceHandled = true;
|
||
this.handleDetailAllScanned();
|
||
}
|
||
},
|
||
afterPackageBinding() {
|
||
// D前缀波次:跳过称重,确认复核后返回列表,等待下一个商品条码
|
||
if (this.isDprefixedWave) {
|
||
this.handleDprefixedAutoConfirm();
|
||
return;
|
||
}
|
||
// 团购模式始终需要称重,散单根据设置
|
||
const needWeigh = this.listType === 'group' || this.weighAfterReview;
|
||
if (needWeigh && this.listType === 'group') {
|
||
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.speakAfterRecheckRequirements('数据一致');
|
||
} 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;
|
||
// 团单的打印确认已在「全部商品复核完成」时完成,此处直接发货
|
||
await this.doGroupShip();
|
||
},
|
||
// 团单发货:提交复核 + 包材绑定 + 后续流程(包材绑定确认、打印失败重试后共用)
|
||
async doGroupShip() {
|
||
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 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: this.weighWeight
|
||
});
|
||
} else {
|
||
if (!orderId) {
|
||
uni.showToast({ title: '缺少订单ID', icon: 'none' });
|
||
uni.hideLoading();
|
||
return;
|
||
}
|
||
await this.$http('order.recheckOrder.updateExpressWeighingWeight', {
|
||
order_id: orderId,
|
||
weighing_weight: this.weighWeight
|
||
});
|
||
}
|
||
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;
|
||
}
|
||
// 数据一致后先确保打印完成,打印成功前不触发发货
|
||
if (!(await this.ensurePrintedBeforeShip('manual'))) {
|
||
return;
|
||
}
|
||
await this.doShip('manual');
|
||
},
|
||
async handleAutoConfirmAndNext() {
|
||
// 数据一致后先确保打印完成,打印成功前不触发发货
|
||
if (!(await this.ensurePrintedBeforeShip('autoNext'))) {
|
||
return;
|
||
}
|
||
await this.doShip('autoNext');
|
||
},
|
||
async handleDprefixedAutoConfirm() {
|
||
// D前缀波次:数据一致后先确保打印完成,打印成功前不触发发货
|
||
if (!(await this.ensurePrintedBeforeShip('dprefixed'))) {
|
||
return;
|
||
}
|
||
await this.doShip('dprefixed');
|
||
},
|
||
/**
|
||
* 数据一致后、发货前的打印确认:
|
||
* 1. 不打印模式直接放行
|
||
* 2. 未绑定打印台时阻止发货并提示
|
||
* 3. 已打印订单直接放行
|
||
* 4. 未打印则先调用打印并等待结果,打印成功后才允许发货
|
||
* 5. 打印失败/超时不触发发货,弹出提示弹窗(含打印按钮)
|
||
* @param {string} actionType 打印成功后执行的发货动作:autoNext | manual | dprefixed
|
||
* @returns {Promise<boolean>} 是否允许继续发货
|
||
*/
|
||
async ensurePrintedBeforeShip(actionType = 'autoNext') {
|
||
// 记录打印成功后的发货动作,供弹窗重试后继续执行
|
||
this.pendingShipAction = actionType;
|
||
// 不打印模式:直接放行
|
||
if (this.effectivePrintMode === 'noPrint') {
|
||
return true;
|
||
}
|
||
// 需要打印但未绑定打印台:阻止发货并提示
|
||
if (!this.printStationId) {
|
||
this.printFailMessage = '未绑定打印台,请先绑定打印台后再发货';
|
||
this.printFailDismissed = true;
|
||
this.showPrintFailPopup = true;
|
||
return false;
|
||
}
|
||
// 已打印的订单直接放行
|
||
const isGroup = this.listType === 'group';
|
||
const isAlreadyPrinted = isGroup
|
||
? (this.detailInfo?.unprintedCount || 0) === 0 && (this.detailInfo?.orderCount || 0) > 0
|
||
: !!this.detailInfo?.isPrinted;
|
||
if (isAlreadyPrinted) {
|
||
return true;
|
||
}
|
||
// 未打印:先打印并等待结果,打印成功后才允许发货
|
||
uni.showLoading({ title: '打印中...', mask: true });
|
||
const printed = await this.printOrderAndWait(this.detailInfo);
|
||
uni.hideLoading();
|
||
if (printed) {
|
||
this.detailInfo = { ...this.detailInfo, isPrinted: true, unprintedCount: 0 };
|
||
this.updateOrderPrintStatus(this.detailInfo);
|
||
this.printFailDismissed = false;
|
||
this.speakVoice('打印成功');
|
||
return true;
|
||
}
|
||
// 打印失败/超时:不触发发货,弹窗提示并提供打印按钮
|
||
this.printFailMessage = this.lastPrintError || '打印失败,未触发发货';
|
||
this.printFailDismissed = true;
|
||
this.showPrintFailPopup = true;
|
||
this.speakVoice('打印失败');
|
||
return false;
|
||
},
|
||
/**
|
||
* 为 Promise 增加超时控制
|
||
* @param {Promise} promise
|
||
* @param {number} ms 超时毫秒数,默认 10000
|
||
*/
|
||
withTimeout(promise, ms = 10000) {
|
||
let timer = null;
|
||
const timeoutPromise = new Promise((_, reject) => {
|
||
timer = setTimeout(() => reject(new Error('打印请求超时')), ms);
|
||
});
|
||
return Promise.race([Promise.resolve(promise), timeoutPromise]).finally(() => {
|
||
if (timer) clearTimeout(timer);
|
||
});
|
||
},
|
||
/**
|
||
* 打印当前订单并等待结果(含超时),返回是否成功
|
||
* @param {object} item
|
||
* @returns {Promise<boolean>}
|
||
*/
|
||
async printOrderAndWait(item) {
|
||
const target = item || this.detailInfo;
|
||
if (!target || !this.printStationId) {
|
||
this.lastPrintError = '未绑定打印台';
|
||
return false;
|
||
}
|
||
try {
|
||
let waveGroups;
|
||
if (this.listType === 'group') {
|
||
const warehouseId = this.resolveWarehouseId();
|
||
const waveId = String(target?.waveId || target?.id || '').trim();
|
||
const response = await this.$http('order.print.getWavePlatformPrintData', { warehouse_id: warehouseId, wave_ids: [waveId] });
|
||
const payload = this.extractWavePlatformPrintPayload(response);
|
||
waveGroups = this.normalizeWaveGroups(payload);
|
||
} else {
|
||
const params = this.buildOrderPrintDataParams(target);
|
||
const response = await this.$http('order.print.getOrderPrintData', params);
|
||
const payload = this.extractOrderPrintPayload(response);
|
||
waveGroups = this.normalizeOrderPrintGroups(payload);
|
||
}
|
||
if (!waveGroups.length) {
|
||
this.lastPrintError = '未获取到可打印数据';
|
||
return false;
|
||
}
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
const sendParams = {
|
||
type: 'express',
|
||
printStationId: this.printStationId,
|
||
requestCode: this.printRequestCode,
|
||
data: { waveGroups }
|
||
};
|
||
this.debugLog('print.send 请求参数', sendParams);
|
||
const response = await this.withTimeout(this.$http('print.send', sendParams), 10000);
|
||
this.debugLog('print.send 返回数据', response);
|
||
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
|
||
if (!success) {
|
||
this.lastPrintError = String(response?.message || response?.msg || '打印失败');
|
||
return false;
|
||
}
|
||
this.lastPrintError = '';
|
||
return true;
|
||
} catch (error) {
|
||
this.lastPrintError = String(error?.message || error?.msg || error?.errMsg || '打印失败或超时');
|
||
console.warn('[printOrderAndWait] 打印失败/超时:', this.lastPrintError);
|
||
return false;
|
||
}
|
||
},
|
||
/**
|
||
* 散单:解析推荐包材 ID 并发起绑定请求(失败不阻塞复核)
|
||
* 有推荐包材数据时仅传数据提交,页面不显示包材绑定弹窗
|
||
*/
|
||
async bindSuggestedPackageForSingle() {
|
||
const pkg = this.detailInfo?.suggestedPkg || null;
|
||
if (!pkg) return null;
|
||
const waybillNo = String(this.detailInfo?.waybillNo || this.detailInfo?.waybillCode || '').trim();
|
||
if (!waybillNo) {
|
||
console.warn('[packageBinding] 散单缺少运单号,跳过包材绑定');
|
||
return null;
|
||
}
|
||
const pkgCode = String(pkg.code || pkg.material_code || '').trim();
|
||
let finalPackageCode = String(pkg.id || pkg.material_id || '');
|
||
if (!finalPackageCode && pkgCode) {
|
||
try {
|
||
const res = await this.$http('setting.packageMaterial.search', { keyword: pkgCode });
|
||
const list = Array.isArray(res?.data) ? res.data : [];
|
||
const matched = list.find(item => String(item.material_code || '') === pkgCode);
|
||
if (matched) {
|
||
finalPackageCode = String(matched.id || '');
|
||
}
|
||
} catch (e) {
|
||
console.warn('[packageBinding] 散单搜索推荐包材失败:', e);
|
||
}
|
||
}
|
||
if (!finalPackageCode) {
|
||
console.warn('[packageBinding] 散单推荐包材缺少ID,跳过绑定');
|
||
return null;
|
||
}
|
||
return this.$http('order.bindExpressPackageMaterialByWaybill', {
|
||
waybill_code: waybillNo,
|
||
package_material_id: finalPackageCode
|
||
});
|
||
},
|
||
/**
|
||
* 执行发货(确认复核)及后续跳转
|
||
* @param {string} action autoNext | manual | dprefixed
|
||
*/
|
||
async doShip(action = 'autoNext') {
|
||
// 散单:有推荐包材数据时,包材绑定与复核确认并发提交,页面不显示包材绑定弹窗
|
||
const pkgBindPromise = this.listType === 'single'
|
||
? this.bindSuggestedPackageForSingle().catch(err => {
|
||
console.warn('[packageBinding] 散单包材绑定失败(不阻塞):', err);
|
||
})
|
||
: null;
|
||
const ok = await this.callConfirmRecheck();
|
||
if (!ok) return;
|
||
if (pkgBindPromise) {
|
||
await pkgBindPromise;
|
||
}
|
||
this.printFailDismissed = false;
|
||
// 散单称重模式:发货(确认复核)成功后弹出称重弹窗,称重完成后再进入下一单
|
||
if (this.listType === 'single' && this.weighAfterReview && !this.isDprefixedWave) {
|
||
this.weighWeight = 0;
|
||
this.showWeighPopup = true;
|
||
return;
|
||
}
|
||
if (action === 'dprefixed') {
|
||
// D前缀波次:确认复核后返回列表,等待下一个商品条码扫描定位
|
||
setTimeout(() => {
|
||
this.backToList();
|
||
}, 500);
|
||
} else if (action === 'manual' && !this.autoShip) {
|
||
// 手动发货:复核完成后留在当前页,由用户继续操作
|
||
} else {
|
||
setTimeout(() => this.goToNextOrder(), 500);
|
||
}
|
||
},
|
||
handlePrintFailClose() {
|
||
this.showPrintFailPopup = false;
|
||
},
|
||
async handlePrintFailRetry() {
|
||
uni.showLoading({ title: '打印中...', mask: true });
|
||
const printed = await this.printOrderAndWait(this.detailInfo);
|
||
uni.hideLoading();
|
||
if (!printed) {
|
||
this.printFailMessage = this.lastPrintError || '打印失败,请重试';
|
||
this.speakVoice('打印失败');
|
||
return;
|
||
}
|
||
// 打印成功:关闭弹窗,更新打印状态,触发发货
|
||
this.printFailDismissed = false;
|
||
this.showPrintFailPopup = false;
|
||
this.detailInfo = { ...this.detailInfo, isPrinted: true, unprintedCount: 0 };
|
||
this.updateOrderPrintStatus(this.detailInfo);
|
||
this.speakVoice('打印成功');
|
||
// 团单:打印成功后重新进入包材绑定(发货在包材绑定确认时完成)
|
||
if (this.pendingShipAction === 'groupShip') {
|
||
this.openGroupPackageBinding();
|
||
return;
|
||
}
|
||
await this.doShip(this.pendingShipAction || 'autoNext');
|
||
},
|
||
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' && this.interceptNotifiedIds.includes(String(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' && this.interceptNotifiedIds.includes(String(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, true);
|
||
} 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,
|
||
unprintedCount: this.detailInfo?.unprintedCount,
|
||
orderCount: this.detailInfo?.orderCount,
|
||
totalOrders: this.detailInfo?.totalOrders,
|
||
isPrinted: this.detailInfo?.isPrinted
|
||
};
|
||
// isReprint: 手动补打面单,在「不打印」模式下仍允许
|
||
this.handlePrintOrder(item, { isReprint: true });
|
||
},
|
||
async autoPrintOrder(item) {
|
||
if (!item || !this.printStationId) return;
|
||
try {
|
||
let waveGroups;
|
||
if (this.listType === 'group') {
|
||
const warehouseId = this.resolveWarehouseId();
|
||
const waveId = String(item?.waveId || item?.id || '').trim();
|
||
const response = await this.$http('order.print.getWavePlatformPrintData', { warehouse_id: warehouseId, wave_ids: [waveId] });
|
||
const payload = this.extractWavePlatformPrintPayload(response);
|
||
waveGroups = this.normalizeWaveGroups(payload);
|
||
} else {
|
||
const params = this.buildOrderPrintDataParams(item);
|
||
const response = await this.$http('order.print.getOrderPrintData', params);
|
||
const payload = this.extractOrderPrintPayload(response);
|
||
waveGroups = this.normalizeOrderPrintGroups(payload);
|
||
}
|
||
if (!waveGroups.length) return;
|
||
|
||
this.printRequestCode = this.buildPrintRequestCode();
|
||
const response = await this.$http('print.send', {
|
||
type: 'express',
|
||
printStationId: this.printStationId,
|
||
requestCode: this.printRequestCode,
|
||
data: { waveGroups }
|
||
});
|
||
// 检查打印结果:失败时不更新打印状态,发货前 ensurePrintedBeforeShip 会重新打印并拦截发货
|
||
const success = response?.flag !== 'failure' && response?.code !== '500' && response?.code !== 500;
|
||
if (!success) {
|
||
this.lastPrintError = String(response?.message || response?.msg || '打印失败');
|
||
console.warn('[autoPrint] 自动打印失败:', this.lastPrintError);
|
||
return;
|
||
}
|
||
console.log('[autoPrint] 自动打印发送成功');
|
||
// 同步更新订单列表中的打印状态
|
||
this.updateOrderPrintStatus(item);
|
||
} catch (error) {
|
||
this.lastPrintError = String(error?.message || error?.msg || error?.errMsg || '打印失败或超时');
|
||
console.warn('[autoPrint] 自动打印失败:', this.lastPrintError);
|
||
}
|
||
},
|
||
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;
|
||
});
|
||
// 同步 detailInfo 打印状态:波次打印成功后视为已打印,避免发货前 ensurePrintedBeforeShip 重复打印
|
||
if (this.detailInfo) {
|
||
const detailId = String(this.detailInfo.orderId || this.detailInfo.recordId || '');
|
||
const detailWaveNo = String(this.detailInfo.waveNo || '');
|
||
const detailWaveId = String(this.detailInfo.waveId || '');
|
||
const itemWaveId = String(item.waveId || '');
|
||
const matched = detailId === itemId
|
||
|| (waveNo && detailWaveNo === waveNo)
|
||
|| (itemWaveId && detailWaveId === itemWaveId);
|
||
if (matched) {
|
||
this.detailInfo = { ...this.detailInfo, unprintedCount: 0, isPrinted: true };
|
||
}
|
||
}
|
||
}
|
||
},
|
||
async handlePrintOrder(item, options = {}) {
|
||
if (!item) {
|
||
uni.showToast({ title: '打印数据无效', icon: 'none' });
|
||
return;
|
||
}
|
||
|
||
// 不打印模式:仅允许手动「面单补打」,其余自动/列表打印仍禁止
|
||
if (this.effectivePrintMode === 'noPrint' && !options?.isReprint) {
|
||
uni.showToast({ title: '当前为不打印模式,无法打印', icon: 'none' });
|
||
return;
|
||
}
|
||
// 散单模式:被拦截订单禁止打印面单
|
||
if (this.listType === 'single' && this.isOrderIntercepted(item)) {
|
||
uni.showToast({ title: '该订单已拦截,禁止打印', icon: 'none' });
|
||
this.speakVoice('此单已拦截');
|
||
return;
|
||
}
|
||
|
||
uni.showLoading({ title: '处理打印中...' });
|
||
|
||
try {
|
||
// 1. 获取打印数据(团购模式:若打印锁占用则先按分组解锁,解锁后重新获取可打印数据)
|
||
let waveGroups;
|
||
if (this.listType === 'group') {
|
||
waveGroups = await this.fetchGroupWavePrintData(item);
|
||
} else {
|
||
const params = this.buildOrderPrintDataParams(item);
|
||
const response = await this.$http('order.print.getOrderPrintData', params);
|
||
const payload = this.extractOrderPrintPayload(response);
|
||
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;
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.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;
|
||
flex: 1;
|
||
}
|
||
|
||
.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-intercept-btn {
|
||
padding: 4rpx 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: 1rpx solid #fa3534;
|
||
border-radius: 6rpx;
|
||
background: #fef0f0;
|
||
}
|
||
|
||
.nav-intercept-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.nav-intercept-btn__text {
|
||
font-size: 26rpx;
|
||
color: #fa3534;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.order-intercept-popup {
|
||
background: #ffffff;
|
||
border-top-left-radius: 20rpx;
|
||
border-top-right-radius: 20rpx;
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
}
|
||
|
||
.order-intercept-popup__header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 24rpx 32rpx;
|
||
border-bottom: 1rpx solid #f2f3f5;
|
||
}
|
||
|
||
.order-intercept-popup__title {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
}
|
||
|
||
.order-intercept-popup__body {
|
||
padding: 24rpx 32rpx;
|
||
}
|
||
|
||
.order-intercept-popup__row {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 12rpx 0;
|
||
}
|
||
|
||
.order-intercept-popup__label {
|
||
width: 160rpx;
|
||
font-size: 30rpx;
|
||
color: #000000;
|
||
}
|
||
|
||
.order-intercept-popup__value {
|
||
flex: 1;
|
||
font-size: 36rpx;
|
||
color: #303133;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.order-intercept-popup__tip {
|
||
margin-top: 20rpx;
|
||
padding: 16rpx;
|
||
background: #fef0f0;
|
||
border-radius: 8rpx;
|
||
font-size: 28rpx;
|
||
color: #fa3534;
|
||
text-align: center;
|
||
}
|
||
|
||
.order-intercept-popup__footer {
|
||
padding: 16rpx 32rpx 32rpx;
|
||
}
|
||
|
||
.order-intercept-popup__btn {
|
||
height: 88rpx;
|
||
line-height: 88rpx;
|
||
text-align: center;
|
||
background: #2979ff;
|
||
border-radius: 12rpx;
|
||
color: #ffffff;
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
.order-intercept-popup__btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
/* 打印失败弹窗 */
|
||
.print-fail-popup {
|
||
width: 580rpx;
|
||
padding: 36rpx;
|
||
background: #ffffff;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
.print-fail-popup-title {
|
||
font-size: 34rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
text-align: center;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.print-fail-popup-body {
|
||
margin-bottom: 28rpx;
|
||
}
|
||
|
||
.print-fail-popup-text {
|
||
font-size: 30rpx;
|
||
color: #606266;
|
||
line-height: 1.6;
|
||
display: block;
|
||
}
|
||
|
||
.print-fail-popup-msg {
|
||
margin-top: 16rpx;
|
||
padding: 16rpx 20rpx;
|
||
background: #fef0f0;
|
||
border-radius: 8rpx;
|
||
}
|
||
|
||
.print-fail-popup-msg__text {
|
||
font-size: 28rpx;
|
||
color: #f56c6c;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.print-fail-popup-footer {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.print-fail-footer-btn {
|
||
flex: 1;
|
||
height: 80rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 10rpx;
|
||
font-size: 30rpx;
|
||
}
|
||
|
||
.print-fail-footer-btn--cancel {
|
||
margin-right: 20rpx;
|
||
background: #f5f5f5;
|
||
color: #606266;
|
||
}
|
||
|
||
.print-fail-footer-btn--print {
|
||
background: #2979ff;
|
||
color: #ffffff;
|
||
}
|
||
|
||
/* 设置弹窗 */
|
||
.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: #000000;
|
||
font-weight: 500;
|
||
font-size: 34rpx;
|
||
}
|
||
|
||
.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> |