zm2000 76c7dc8271 feat(订单复核): 共享条码弹窗、语音播报精简与 App 端 keep-alive 兼容
- 共享条码:扫码命中 has_shared_barcode 商品时弹「库内有相同商品」抽屉,
  列表展示图片/条码/规格/数量,点击卡片确认累加;关闭后同条码不再弹窗
- 商品图全屏预览:支持双击/双指/滚轮缩放(1~5倍)与拖动,图片加载失败占位
- 条码匹配重构:兼容单值及分号/逗号分隔多值条码,归一化去空白+大写后比对
- 语音播报精简:非必要 toast 加 silentVoice 静音;复核/包材绑定成功统一「发货成功」,
  补打成功「打印成功」;错误文案语音映射;命中商品播「数据一致(+复核要求)」
- 交互优化:查询结果默认选中第一行展示明细;含拦截单的团购波次播「有拦截订单」
- 样式:选中行深蓝高亮、打包要求值红字浅红底、工具栏间距改子项 margin(兼容老 WebView)、
  新增共享条码弹窗与图片预览样式
- App 端兼容:keep-alive 仅 H5 生效(App 端退化为普通动态组件避免页面叠层),
  退件页补 mounted/beforeUnmount 兜底注册/注销扫码捕获
2026-10-18 18:16:43 +08:00

5284 lines
184 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<top-nav v-if="!embedded" />
<view class="page-main order-review-one">
<view class="container">
<view class="content-panel">
<view class="panel-left">
<!-- 选中订单时:复核扫描标签 + 数量步进器 -->
<view v-if="hasSelection" class="scan-qty-bar">
<view class="scan-qty-label">复核扫描</view>
<view class="scan-qty-stepper">
<text class="scan-qty-text">数量</text>
<view class="scan-qty-btn" @click="handleScanQtyMinus">−</view>
<input class="scan-qty-input" v-model="scanQty" type="number" />
<view class="scan-qty-btn" @click="handleScanQtyPlus">+</view>
</view>
</view>
<view class="search-bar">
<input
class="search-input"
v-model="keyword"
:placeholder="searchPlaceholder"
:focus="searchFocus"
:adjust-position="false"
confirm-type="search"
@confirm="handleConfirm"
@focus="handleSearchFocus"
@blur="handleSearchBlur"
/>
</view>
<!-- 扫描复核结果(order.recheckOrder.scanOrder) -->
<template v-if="scanActive">
<!-- 散单:参考团单模式的扁平订单列表(复核状态 | 运单号 | 打印状态) -->
<view v-if="scanListType === 'single' && scanOrderList.length > 0" class="table-wrap table-wrap--current-wave table-wrap--current-wave-sticky">
<scroll-view class="left-reviewed-list left-reviewed-list--current-wave left-reviewed-list--current-wave-body" scroll-y>
<view class="table-body">
<view
v-for="(item, index) in scanOrderList"
:key="`scan-${index}`"
:class="['table-row', 'scan-row', index % 2 === 1 ? 'table-row--alt' : '', selectedPendingOrderKey === getScanOrderKey(item) ? 'table-row--selected' : '', getWaveReviewStatus(item) === '已复核' ? 'scan-row--reviewed' : '', isIntercepted(item) || isInterceptedDone(item) ? 'scan-row--intercept' : '']"
@click="handleScanOrderClick(item)"
>
<text :class="['table-cell', 'cell-review-status', getWaveReviewStatus(item) === '未复核' ? 'cell-review-status--unreviewed' : '']">{{ getWaveReviewStatus(item) }}</text>
<text class="table-cell cell-wave-index">{{ formatWaveIndex(item) }}</text>
<text class="table-cell cell-wave-no">{{ getScanOrderNo(item) }}</text>
<text :class="['table-cell', 'cell-print-status', getWavePrintStatus(item) === '未打印' ? 'cell-print-status--unprinted' : '']">{{ getWavePrintStatus(item) }}</text>
<view v-if="isIntercepted(item)" class="cell-intercept">拦截</view>
<view v-else-if="isInterceptedDone(item)" class="cell-intercept cell-intercept--done">已拦截</view>
</view>
</view>
</scroll-view>
</view>
<view v-else-if="scanListType === 'single'" class="empty-panel empty-panel--left">暂无匹配订单</view>
<!-- 团购:嵌套波次列表 -->
<view v-else-if="scanListType === 'group' && scanOrderList.length > 0" class="table-wrap table-wrap--current-wave table-wrap--current-wave-sticky">
<scroll-view class="left-reviewed-list left-reviewed-list--current-wave left-reviewed-list--current-wave-body" scroll-y>
<view class="table-body">
<view
v-for="(wave, wIndex) in scanOrderList"
:key="`wave-${wave.wave_id || wIndex}`"
:class="['table-row', 'wave-group-header', wIndex % 2 === 1 ? 'table-row--alt' : '', selectedWaveKey === getWaveKey(wave) ? 'table-row--selected' : '', getWaveReviewStatus(wave) === '已复核' ? 'scan-row--reviewed' : '', getWaveInterceptLabel(wave) ? 'scan-row--intercept' : '']"
@click="handleWaveClick(wave)"
>
<text :class="['table-cell', 'cell-review-status', getWaveReviewStatus(wave) === '未复核' ? 'cell-review-status--unreviewed' : '']">{{ getWaveReviewStatus(wave) }}</text>
<text class="table-cell cell-wave-no">{{ wave.wave_no || wave.wave_id || '-' }}</text>
<text :class="['table-cell', 'cell-print-status', getWavePrintStatus(wave) === '未打印' ? 'cell-print-status--unprinted' : '']">{{ getWavePrintStatus(wave) }}</text>
<view
v-if="getWaveInterceptLabel(wave)"
:class="['cell-intercept', getWaveInterceptLabel(wave) === '已拦截' ? 'cell-intercept--done' : '']"
>{{ getWaveInterceptLabel(wave) }}</view>
</view>
</view>
</scroll-view>
</view>
<view v-else-if="scanListType === 'group'" class="empty-panel empty-panel--left">暂无匹配波次</view>
</template>
<!-- 初始空状态:引导查询 -->
<view v-else class="empty-panel empty-panel--left">请输入关键词查询</view>
<!-- 左侧列表底部信息栏 -->
<view v-if="scanActive && scanOrderList.length > 0" class="left-summary-bar">
<text class="left-summary-text">波次总单数:<text class="left-summary-num">{{ waveTotalOrders }}</text></text>
<text class="left-summary-sep">|</text>
<text class="left-summary-text">剩余未复核:<text class="left-summary-num left-summary-num--orange">{{ waveUnreviewedCount }}</text></text>
<button class="left-summary-refresh" @click="handleRefresh">刷新</button>
</view>
</view>
<view class="panel-right">
<!-- 顶部操作区:按钮 / 下拉框 / 提示信息 -->
<view class="review-toolbar">
<button class="tool-btn tool-btn--blue" @click="openSettingsDialog">设置</button>
<button
:class="['tool-btn', interceptMode ? 'tool-btn--intercept' : 'tool-btn--confirm']"
:disabled="!hasSelection || interceptLocked || reviewLocked || (!interceptMode && !allProductsScanned)"
@click="handleConfirmReview"
>{{ interceptMode ? '确认拦截' : '确认复核' }}</button>
<button class="tool-btn" @click="handleClear">清空</button>
<button class="tool-btn tool-btn--blue-outline" @click="handleBatchQuickReview">批量快捷复核</button>
<button class="tool-btn tool-btn--blue-outline" @click="handleSingleReviewList">散单复核列表</button>
<button class="tool-btn tool-btn--orange" :disabled="!hasSelection" @click="handleRePrintLabel">面单补打</button>
<button v-if="scanListType === 'group'" class="tool-btn tool-btn--blue" :disabled="!hasSelection" @click="handleAddPackageMaterial">包材</button>
<button class="tool-btn tool-btn--blue" :disabled="!hasSelection" @click="handleWeigh">称重</button>
<picker
:range="printerOptions"
@change="handlePrinterChange"
@cancel="handlePrinterCancel"
@pickstart="handlePrinterPickStart"
@pickend="handlePrinterPickEnd"
>
<view
:class="['tool-select', 'tool-select--printer', printerOpened ? 'tool-select--open' : '']"
@click="handlePrinterSelectStart"
>
<text class="tool-select-text">{{ selectedPrinter || '选择打印台' }}</text>
<view class="tool-select-arrow">
<svg class="tool-select-arrow-icon" viewBox="0 0 24 24">
<path d="M6 9l6 6 6-6" fill="none" stroke="#909399" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</view>
</view>
</picker>
<text v-if="hasSelection" class="tool-info-text tool-info-text--blue">拣货人:{{ pickerName || '-' }}</text>
<text v-if="hasSelection" class="tool-info-text tool-info-text--blue">货主:{{ storeRemark || '-' }}</text>
<text v-if="hasSelection && scanListType === 'single'" class="tool-info-text tool-info-text--gray">波次:{{ selectedWaveNo || '-' }}</text>
<text v-if="hasSelection && scanListType === 'single'" class="tool-info-text tool-info-text--orange">蓝号:{{ selectedWaveIndex || '-' }}</text>
</view>
<template v-if="hasSelection">
<!-- 团购模式:波次推荐包材(order.recheckOrder.scanOrder → data.list[].suggested_package_material.name)显示在商品明细上方 -->
<view v-if="scanListType === 'group' && recommendedPackageMaterialName" class="recommend-pack-bar">
<text class="recommend-pack-bar-label">推荐包材</text>
<text class="recommend-pack-bar-name">{{ recommendedPackageMaterialName }}</text>
</view>
<!-- 商品明细标签 -->
<view class="detail-tab">
<view class="detail-tab-left">
<text v-if="scanListType === 'group'" class="detail-tab-tag">订单数:{{ currentOrderCount || '-' }}</text>
<text class="detail-tab-tag">篮号:{{ basketSummary || '-' }}</text>
<text class="detail-tab-text">商品明细</text>
</view>
<text class="detail-tab-summary">已扫<text class="detail-tab-summary--em">{{ scannedCount }}</text>/{{ totalCount }}件</text>
</view>
<!-- 商品明细内容区 -->
<view class="table-wrap table-wrap--detail table-wrap--detail-sticky">
<view class="table-header table-header--sticky">
<view v-if="showBasketColumn" class="table-cell cell-basket" :style="getColStyle('basket')" ref="detail-header-basket">篮号<view class="col-resizer" @mousedown.prevent.stop="startResize('basket', $event)"></view></view>
<view class="table-cell cell-total" :style="getColStyle('total')" ref="detail-header-total">总数<view class="col-resizer" @mousedown.prevent.stop="startResize('total', $event)"></view></view>
<view class="table-cell cell-scanned" :style="getColStyle('scanned')" ref="detail-header-scanned">已扫<view class="col-resizer" @mousedown.prevent.stop="startResize('scanned', $event)"></view></view>
<view class="table-cell cell-name" :style="getColStyle('name')" ref="detail-header-name">商品名称<view class="col-resizer" @mousedown.prevent.stop="startResize('name', $event)"></view></view>
<view class="table-cell cell-image" :style="getColStyle('image')" ref="detail-header-image">图片<view class="col-resizer" @mousedown.prevent.stop="startResize('image', $event)"></view></view>
<view class="table-cell cell-barcode" :style="getColStyle('barcode')" ref="detail-header-barcode">条码<view class="col-resizer" @mousedown.prevent.stop="startResize('barcode', $event)"></view></view>
<view class="table-cell cell-spec" :style="getColStyle('spec')" ref="detail-header-spec">规格<view class="col-resizer" @mousedown.prevent.stop="startResize('spec', $event)"></view></view>
<view v-if="showPackColumn" class="table-cell cell-pack" :style="getColStyle('pack')" ref="detail-header-pack">打包要求<view class="col-resizer" @mousedown.prevent.stop="startResize('pack', $event)"></view></view>
</view>
<scroll-view v-if="hasSelection && displayOrders.length > 0" class="table-scroll table-scroll--detail table-scroll--detail-body" scroll-y>
<view class="table-body">
<view
v-for="(order, index) in displayOrders"
:key="order.barcode || index"
:class="['table-row', index % 2 === 1 ? 'table-row--alt' : '', isProductScanned(order) ? 'detail-row--scanned' : '']"
@click.prevent="handleProductRowClick(order)"
@contextmenu.prevent="handleNoBarcodeReviewDirect(order)"
@longtap = "handleProductRowClick(order)"
>
<text v-if="showBasketColumn" class="table-cell cell-basket" :style="getColStyle('basket')">{{ order.basketNo || '-' }}</text>
<text class="table-cell cell-total" :style="getColStyle('total')">{{ order.quantity }}</text>
<text class="table-cell cell-scanned" :style="getColStyle('scanned')">{{ order.scannedQty }}</text>
<text class="table-cell cell-name" :style="getColStyle('name')">{{ order.productName }}</text>
<view class="table-cell cell-image" :style="getColStyle('image')">
<image v-if="order.image" class="item-image" :src="order.image" mode="aspectFit" />
<text v-else class="cell-image-empty">-</text>
</view>
<text class="table-cell cell-barcode" :style="getColStyle('barcode')">{{ order.barcode }}</text>
<text class="table-cell cell-spec" :style="getColStyle('spec')">{{ order.spec }}</text>
<text v-if="showPackColumn" class="table-cell cell-pack cell-pack-value" :style="getColStyle('pack')">{{ order.packingRequirements }}</text>
</view>
</view>
</scroll-view>
<view v-else class="empty-panel empty-panel--right-inline">暂无匹配数据</view>
</view>
<!-- 合计栏 -->
<view class="detail-total">
<text class="detail-total-text">合计 <text class="detail-total-num">{{ totalQuantity }}</text></text>
</view>
</template>
<!-- 未选中引导提示 -->
<view v-else class="detail-empty-tip">在左侧列表选择订单后,在此查看商品明细</view>
</view>
</view>
</view>
</view>
<!-- 称重弹窗 -->
<view v-if="weighDialogVisible" class="weigh-mask" @click.self="closeWeighDialog">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">{{ weighDialogTitle }}</text>
<text class="weigh-dialog-close" @click="closeWeighDialog">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="weigh-stepper">
<view class="weigh-label-inline">
<text class="weigh-required">*</text>
<text class="weigh-input-label">重量(g)</text>
</view>
<view class="weigh-step-btn" @click="handleWeighMinus">−</view>
<input
class="weigh-input"
v-model="weighInputValue"
type="digit"
:adjust-position="false"
focus
placeholder="请输入重量(g)"
placeholder-class="weigh-input-placeholder"
confirm-type="done"
@confirm="confirmWeigh"
/>
<view class="weigh-step-btn" @click="handleWeighPlus">+</view>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closeWeighDialog">取消</button>
<button class="weigh-btn weigh-btn--confirm" @click="confirmWeigh">保存</button>
</view>
</view>
</view>
<!-- 包材绑定弹窗(仅团购波次,order.bindExpressPackageMaterialByWaybill) -->
<view v-if="packageMaterialDialogVisible" class="weigh-mask" @click.self="closePackageMaterialDialog">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">包材绑定</text>
<text class="weigh-dialog-close" @click="closePackageMaterialDialog">✕</text>
</view>
<view class="weigh-dialog-body">
<!-- 推荐包材(与页面商品明细上方推荐包材条一致:值取波次 suggested_package_material.name;为空时不显示) -->
<view v-if="recommendedPackageMaterialName" class="weigh-info-row">
<text class="weigh-info-label">推荐包材</text>
<text class="weigh-info-value">{{ recommendedPackageMaterialName }}</text>
</view>
<!-- 扫描/输入包材条码:回车触发搜索(setting.packageMaterial.search),唯一命中自动选中 -->
<view class="pm-scan-row">
<input
class="weigh-input"
v-model="packageMaterialInput"
:adjust-position="false"
focus
placeholder="扫描/输入包材条码"
placeholder-class="weigh-input-placeholder"
confirm-type="search"
@confirm="handlePackageMaterialSearch"
/>
</view>
<view v-if="pmSearching" class="pm-tip">搜索中…</view>
<!-- 搜索结果(单选自动命中;多条时列表选择) -->
<scroll-view v-if="pmSearchList.length > 0" class="pm-result-scroll" scroll-y>
<view
v-for="(item, index) in pmSearchList"
:key="String(item.id ?? index)"
:class="['pm-result-item', String(pmSelectedMaterial?.id) === String(item.id) ? 'pm-result-item--active' : '']"
@click="handlePackageMaterialSelect(item)"
>
<view class="pm-result-main">
<text class="pm-result-name">{{ item.material_name || '未命名包材' }}</text>
<text class="pm-result-code">编码:{{ item.material_code || '-' }}</text>
</view>
<view class="pm-result-meta">
<text v-if="item.material_type" class="pm-result-tag">{{ item.material_type }}</text>
<text v-if="item.spec" class="pm-result-spec">规格 {{ item.spec }}</text>
</view>
<text v-if="String(pmSelectedMaterial?.id) === String(item.id)" class="pm-result-check">✓</text>
</view>
</scroll-view>
<view v-if="pmSearched && !pmSearching && pmSearchList.length === 0" class="pm-tip">未找到匹配的包材</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closePackageMaterialDialog">取消</button>
<button class="weigh-btn weigh-btn--confirm" :disabled="pmBinding" @click="confirmPackageMaterial">保存</button>
</view>
</view>
</view>
<!-- 库内有相同商品弹窗(命中共享条码 has_shared_barcode 时) -->
<view v-if="sharedBarcodeDrawerVisible" class="weigh-mask" @click.self="closeSharedBarcodeDrawer">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">库内有相同商品</text>
<text class="weigh-dialog-close" @click="closeSharedBarcodeDrawer">✕</text>
</view>
<view class="weigh-dialog-body">
<scroll-view v-if="sharedBarcodeMatches.length > 0" class="shared-barcode-list" scroll-y>
<view
v-for="(item, index) in sharedBarcodeMatches"
:key="`shared-${index}`"
:class="['shared-barcode-item', index === sharedBarcodeSelectedIndex ? 'shared-barcode-item--active' : '']"
@click="confirmSharedBarcodeItem(index)"
>
<view class="shared-barcode-thumb" @click.stop="previewSharedImage(item.image)">
<image
v-if="item.image && !sharedBarcodeImgError[index]"
class="shared-barcode-image"
:src="item.image"
mode="aspectFit"
@error="onSharedImageError(index)"
/>
<view v-else class="shared-barcode-image-placeholder">📷</view>
</view>
<view class="shared-barcode-main">
<text class="shared-barcode-name">{{ item.productName || '-' }}</text>
<text class="shared-barcode-code">条码:{{ item.barcode || '-' }}</text>
<text class="shared-barcode-spec">规格:{{ item.spec || item.location || item.basketNo || '-' }}</text>
<text class="shared-barcode-qty">数量 {{ item.quantity || 0 }} / 已扫 {{ item.scannedQty || 0 }}</text>
</view>
</view>
</scroll-view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--confirm" @click="closeSharedBarcodeDrawer">关闭</button>
</view>
</view>
</view>
<!-- 共享条码商品图片预览(自绘全屏预览,支持双击/双指缩放、滚轮缩放与拖动查看) -->
<view v-if="sharedImagePreviewVisible" class="shared-img-preview-mask" @click.self="closeSharedImagePreview">
<text class="shared-img-preview-close" @click.stop="closeSharedImagePreview">✕</text>
<view
class="shared-img-preview-stage"
@touchstart="onPreviewTouchStart"
@touchmove.prevent="onPreviewTouchMove"
@touchend="onPreviewTouchEnd"
@touchcancel="onPreviewTouchEnd"
@wheel="onPreviewWheel"
@click="onPreviewStageClick"
>
<image
class="shared-img-preview-img"
:src="sharedImagePreviewUrl"
mode="aspectFit"
:style="sharedImageStyle"
/>
</view>
<text class="shared-img-preview-hint">双击或双指缩放查看</text>
</view>
<!-- 设置弹窗 -->
<view v-if="settingsVisible" class="weigh-mask" @click.self="closeSettingsDialog">
<view class="weigh-dialog weigh-dialog--settings">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">复核设置</text>
<text class="weigh-dialog-close" @click="closeSettingsDialog">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="setting-row">
<text class="setting-row-label">复核流程</text>
<view class="setting-seg setting-seg--nowrap">
<text :class="['setting-seg-item', selectedReviewProcess === '先打印后复核' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('先打印后复核')">先打印后复核</text>
<text :class="['setting-seg-item', selectedReviewProcess === '先复核后打印' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('先复核后打印')">先复核后打印</text>
<text :class="['setting-seg-item', selectedReviewProcess === '不打印' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('不打印')">不打印</text>
</view>
</view>
<view class="setting-row">
<text class="setting-row-label">称重模式</text>
<view class="setting-seg">
<text :class="['setting-seg-item', selectedWeigh === '称重' ? 'setting-seg-item--on' : '']" @click="setWeighSetting('称重')">称重</text>
<text :class="['setting-seg-item', selectedWeigh === '不称重' ? 'setting-seg-item--on' : '']" @click="setWeighSetting('不称重')">不称重</text>
</view>
</view>
<view class="setting-row">
<text class="setting-row-label">绑定包材</text>
<view class="setting-seg">
<text :class="['setting-seg-item', settingBindPackage ? 'setting-seg-item--on' : '']" @click="setSettingBindPackage(true)">开启</text>
<text :class="['setting-seg-item', !settingBindPackage ? 'setting-seg-item--on' : '']" @click="setSettingBindPackage(false)">关闭</text>
</view>
</view>
<view class="setting-row">
<text class="setting-row-label">包材软键盘</text>
<view class="setting-seg">
<text :class="['setting-seg-item', settingPmKeyboard ? 'setting-seg-item--on' : '']" @click="setSettingPmKeyboard(true)">激活</text>
<text :class="['setting-seg-item', !settingPmKeyboard ? 'setting-seg-item--on' : '']" @click="setSettingPmKeyboard(false)">不激活</text>
</view>
</view>
<view class="setting-row">
<text class="setting-row-label">发货模式</text>
<view class="setting-seg">
<text :class="['setting-seg-item', settingShipMode === 'auto' ? 'setting-seg-item--on' : '']" @click="setSettingShipMode('auto')">自动发货</text>
<text :class="['setting-seg-item', settingShipMode === 'manual' ? 'setting-seg-item--on' : '']" @click="setSettingShipMode('manual')">手动发货</text>
</view>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--close" @click="closeSettingsDialog">关闭</button>
</view>
</view>
</view>
<!-- 无条码复核弹窗(长按商品明细行触发) -->
<view v-if="noBarcodeReviewVisible" class="weigh-mask" @click.self="closeNoBarcodeReview">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">无条码复核</text>
<text class="weigh-dialog-close" @click="closeNoBarcodeReview">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="no-barcode-review-content">
<text class="no-barcode-review-title">将商品「{{ noBarcodeReviewTarget?.productName || '-' }}」标记为已复核?</text>
<view class="no-barcode-review-count">
<text class="no-barcode-review-count-item">已扫 {{ noBarcodeReviewScanned }}/{{ noBarcodeReviewTotal }} 件</text>
<text class="no-barcode-review-arrow">→</text>
<text class="no-barcode-review-count-item no-barcode-review-count-item--done">{{ noBarcodeReviewTotal }}/{{ noBarcodeReviewTotal }} 件</text>
</view>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closeNoBarcodeReview">关闭</button>
<button class="weigh-btn weigh-btn--confirm" @click="confirmNoBarcodeReview">无条码复核</button>
</view>
</view>
</view>
<!-- 确认复核弹窗(自绘,样式参考称重弹窗) -->
<view v-if="confirmReviewVisible" class="weigh-mask" @click.self="closeConfirmReview">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">确认复核</text>
<text class="weigh-dialog-close" @click="closeConfirmReview">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="confirm-review-content">
<text class="confirm-review-text">{{ confirmReviewOrderNo ? `确认对「${confirmReviewOrderNo}」执行复核操作?` : '确认执行复核操作?' }}</text>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closeConfirmReview">取消</button>
<button class="weigh-btn weigh-btn--confirm" @click="confirmReviewConfirm">确认</button>
</view>
</view>
</view>
<!-- 批量快捷复核弹窗 -->
<view v-if="batchReviewVisible" class="weigh-mask" @click.self="closeBatchReview">
<view class="weigh-dialog batch-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">批量快捷复核</text>
<text class="weigh-dialog-close" @click="closeBatchReview">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="batch-review-desc">对每个订单执行前置检查并自动完成拣货(如需)后标记复核;各订单独立事务,支持部分失败。</view>
<view class="batch-review-label">{{ scanListType === 'group' ? '波次 ID' : '订单 ID' }}</view>
<textarea
class="batch-review-input"
v-model="batchReviewInput"
:adjust-position="false"
:placeholder="scanListType === 'group' ? '支持多个波次ID,逗号、空格或换行分隔;也可直接粘贴ID列表' : '支持多个订单ID,逗号、空格或换行分隔;也可直接粘贴ID列表'"
placeholder-class="batch-review-placeholder"
/>
<view class="batch-review-actions">
<view class="batch-review-status">已解析 <text class="batch-review-status-num">{{ batchParsedCount }}</text> 个有效ID</view>
<button class="batch-review-fill" @click="fillBatchUnreviewedOrders">{{ scanListType === 'group' ? '填入当前未复核波次' : '填入当前未复核订单' }}({{ batchFillableCount }})</button>
</view>
<view v-if="batchReviewError" class="batch-review-error">{{ batchReviewError }}</view>
<!-- 批量复核结果:成功/失败切换显示 -->
<view v-if="batchResultDone" class="batch-result-box">
<view class="batch-result-head">
<text class="batch-result-head-line"></text>
<text class="batch-result-head-text">执行结果</text>
<text class="batch-result-head-line"></text>
</view>
<view class="batch-result-tabs">
<text
:class="['batch-result-tab', batchResultTab === 'success' ? 'batch-result-tab--active' : '']"
@click="batchResultTab = 'success'"
>成功({{ batchResultSuccessCount }})</text>
<text
:class="['batch-result-tab', batchResultTab === 'failed' ? 'batch-result-tab--active' : '']"
@click="batchResultTab = 'failed'"
>失败({{ batchResultFailedCount }})</text>
</view>
<view class="batch-result-table">
<view class="batch-result-row batch-result-row--header">
<text class="batch-result-cell batch-result-cell--id">订单 ID</text>
<text class="batch-result-cell batch-result-cell--waybill">运单号</text>
<text class="batch-result-cell batch-result-cell--reason">原因</text>
<text class="batch-result-cell batch-result-cell--note">说明</text>
</view>
<scroll-view v-if="currentBatchResultRows.length > 0" class="batch-result-scroll" scroll-y>
<view
v-for="(row, index) in currentBatchResultRows"
:key="`br-${index}`"
:class="['batch-result-row', batchResultTab === 'failed' ? 'batch-result-row--failed' : 'batch-result-row--success', index % 2 === 1 ? 'batch-result-row--alt' : '']"
>
<text class="batch-result-cell batch-result-cell--id">{{ row.order_id }}</text>
<text class="batch-result-cell batch-result-cell--waybill">{{ row.waybill_no || '-' }}</text>
<text class="batch-result-cell batch-result-cell--reason">{{ row.reason || '-' }}</text>
<text class="batch-result-cell batch-result-cell--note">{{ row.note }}</text>
</view>
</scroll-view>
<view v-else class="batch-result-empty">暂无明细</view>
</view>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closeBatchReview">取消</button>
<button class="weigh-btn weigh-btn--confirm" @click="confirmBatchReview">执行复核</button>
</view>
</view>
</view>
<!-- 真机扫码捕获:保持隐藏 input 聚焦,WebView 才会持续派发按键 -->
<input
v-if="enableHiddenInputCapture"
class="scan-hidden-input"
v-model="scanHiddenValue"
:focus="scanInputFocus"
:adjust-position="false"
confirm-type="done"
@focus="handleHiddenScanFocus"
@input="handleHiddenScanInput"
@confirm="handleHiddenScanConfirm"
@blur="handleHiddenScanBlur"
/>
</view>
</template>
<script>
import TopNav from '@/components/top-nav.vue'
import {
scanReviewOrder,
scanReviewTask,
fetchPrintList,
confirmIntercept,
confirmRecheck,
batchQuickRecheck,
batchQuickRecheckByWave,
updateExpressWeighingWeight,
searchPackageMaterial,
bindExpressPackageMaterialByWaybill,
getOrderPrintData,
getWavePlatformPrintData,
unlockWavePlatformPrintDataByGroup,
sendPrint,
} from '@/api/order'
import { diagDrop, diagNote } from '@/core/scan-diag'
// 扫码枪识别参数
// 无回车结束符时:停止输入超过该毫秒数视为一次完整扫码,自动提交
const SCAN_IDLE_TIMEOUT = 300
// 自动提交所需的最短内容长度,避免正常输入过程中的短暂停顿触发误识别
const SCAN_MIN_LENGTH = 2
// 手动输入识别:相邻按键间隔超过该毫秒数视为手动输入,不自动提交,需按回车后才查询
// 扫码枪连续按键间隔通常 <30ms,手动键盘输入间隔通常 >100ms
const SCAN_BURST_MAX_GAP = 100
// 订单复核设置项本地存储 key(uni storage)
const SETTING_KEY_BIND_PACKAGE = 'orderSettingBindPackage'
const SETTING_KEY_PM_KEYBOARD = 'orderSettingPmKeyboard'
const SETTING_KEY_SHIP_MODE = 'orderSettingShipMode'
const SETTING_KEY_REVIEW_PROCESS = 'orderSettingReviewProcess'
const SETTING_KEY_WEIGH = 'orderSettingWeigh'
export default {
name: 'OrderReviewOnePage',
components: {
TopNav,
},
props: {
// 在布局壳内渲染时为 true,隐藏内嵌顶栏;独立访问时不传,显示顶栏
embedded: {
type: Boolean,
default: false,
},
},
data() {
return {
keyword: '',
// 当前生效的查询关键词(搜索成功后保存,供刷新按钮回退使用)
activeKeyword: '',
// 条码输入框激活状态:进入商品条码流程时自动聚焦,键盘输入时保持激活
searchFocus: false,
searchFocused: false,
// 扫码枪无结束符自动识别:静默计时器与最后按键时间
scanTimer: null,
lastScanKeyTime: 0,
// 手动输入识别:是否为扫码枪快速输入(相邻按键间隔均小于阈值),仅扫码枪允许静默自动提交
scanBurstConfirmed: false,
// ---- 扫码枪真机兼容(移植自 login.vue)----
// 页面激活状态:keep-alive 切换 / 页面隐藏时暂停扫码聚焦抢占
pageActive: true,
// 原生层(plus.key)监听
plusKeyListener: null,
plusKeyBuffer: '',
plusKeyTimer: null,
plusKeyStartedAt: 0,
plusKeyLastAt: 0,
// DOM 全局监听目标
globalKeyListener: null,
globalKeyTargets: [],
// 隐藏 input 捕获(真机 WebView 未聚焦不派发 keydown 的兜底)
enableHiddenInputCapture: false,
scanInputFocus: false,
scanHiddenValue: '',
scanHiddenTimer: null,
scanHiddenRefocusTimer: null,
scanFocusResumeTimer: null,
scanKeyboardSuppressTimers: [],
scanHiddenFocused: false,
// 去重:同一扫码内容短时间内的重复提交保护
lastSubmittedScan: { code: '', at: 0 },
// 当前拣货任务 ID(搜索成功后保存,供刷新按钮按 task_id 调用 scanTask)
currentTaskId: null,
// 复核扫描数量(默认 1)
scanQty: 1,
// 明细表列宽拖拽:记录每列覆盖宽度(px)与拖拽状态
detailColWidths: {},
resizingCol: null,
// 扫描复核结果(order.recheckOrder.scanOrder)
scanActive: false,
scanListType: '',
// 拣货模式(pick_mode=3 散单分播,商品明细显示“篮号”列)
currentPickMode: null,
scanOrderList: [],
// 已复核保留项缓存:服务端 scanOrder/scanTask 会去掉已复核数据,
// 复核成功后本地缓存该订单/波次,刷新时回填到左侧列表,保证保留已复核项
reviewedKeepList: [],
// 选中订单元信息
selectedWaveKey: '',
selectedOrderNo: '',
selectedItemsWeight: null,
selectedWaveNo: '',
selectedWaveIndex: '',
selectedPackageMaterial: null,
// 推荐包材原始对象(suggested_package_material,团购模式明细上方展示推荐包材用)
selectedPackageMaterialInfo: null,
displayOrders: [],
selectedPendingOrderKey: '',
currentOrderHeader: null,
currentWaybillInfo: null,
// 复核命中播报:同单内已播过复核要求的商品条码(去重,切单/清空时重置)
spokenRecheckKeys: [],
// 库内有相同商品(共享条码 has_shared_barcode)弹窗状态
sharedBarcodeDrawerVisible: false,
sharedBarcodeMatches: [],
sharedBarcodeCode: '',
sharedBarcodeSelectedIndex: -1,
sharedBarcodeDismissed: [],
// 共享条码弹窗图片加载失败标记(index → true,用于显示占位图标)
sharedBarcodeImgError: {},
// 共享条码弹窗商品图片预览(自绘全屏预览,避免 uni.previewImage 图片被放大)
sharedImagePreviewVisible: false,
sharedImagePreviewUrl: '',
// 图片预览缩放状态(1~5 倍)与拖动偏移
sharedImageScale: 1,
sharedImageOffsetX: 0,
sharedImageOffsetY: 0,
// 预览手势临时状态(非渲染数据)
previewPinchDistance: 0,
previewPinchStartScale: 1,
previewPanStartX: 0,
previewPanStartY: 0,
previewPanStartOffsetX: 0,
previewPanStartOffsetY: 0,
previewPanMoved: false,
previewLastClickAt: 0,
previewCloseTimer: null,
// 右侧顶部操作区
selectedPrinter: '',
selectedPrinterId: '',
printerOpened: false,
printerList: [],
// 面单补打
warehouseId: '',
printRequestCode: '',
printSending: false,
selectedReviewProcess: '先打印后复核',
selectedWeigh: '不称重',
// 称重弹窗
weighDialogVisible: false,
// 复核前自动称重模式:商品全部扫完且“是否称重=称重”时自动弹出的称重弹窗(标题“称重(复核前)”,保存后直接复核)
weighReviewMode: false,
weighInputValue: '',
// 包材绑定弹窗(order.bindExpressPackageMaterialByWaybill,仅团购波次)
packageMaterialDialogVisible: false,
// 扫描/输入包材条码
packageMaterialInput: '',
// 绑定目标运单号(团购波次 first_waybill_no,打开弹窗时解析)
pmBindWaybill: '',
// 搜索结果(setting.packageMaterial.search → data[])
pmSearchList: [],
// 搜索请求中
pmSearching: false,
// 本次已发起过搜索(无结果提示用)
pmSearched: false,
// 绑定请求中
pmBinding: false,
// 选中的包材 { id, material_code, material_name, material_type, spec, status }
pmSelectedMaterial: null,
// 团单自动流程:包材绑定成功后是否接着弹“称重(复核前)”(手动发货)
pmPendingWeigh: false,
// 团单自动流程:包材绑定保存成功即触发复核(自动发货)
pmAutoRecheck: false,
// 团单自动发货:复核后强制按运单称重所用运单号(复核刷新会清空选中,需提前记录本波次运单)
pmAfterReviewWeighWaybill: '',
// 团单自动发货:待称重波次去重键(称重保存成功后据此切下一个未复核波次)
pmAfterReviewReviewKey: '',
// 团单自动发货:复核后称重尚未完成(取消后仍保留,点商品行可再次弹称重)
pmPostReviewWeighPending: false,
// 无条码复核弹窗(长按商品明细行触发)
noBarcodeReviewVisible: false,
noBarcodeReviewTarget: null,
// 确认复核弹窗(自绘,样式参考称重弹窗)
confirmReviewVisible: false,
confirmReviewOrderNo: '',
// 批量快捷复核弹窗
batchReviewVisible: false,
batchReviewInput: '',
// 批量复核内联错误提示(显示在已解析行下方)
batchReviewError: '',
// 批量复核结果(内联显示在已解析行下方,成功/失败切换)
batchResultDone: false,
batchResultTab: 'success',
batchSuccessList: [],
batchFailedList: [],
// 拦截确认模式(点击左侧"拦截"后,确认按钮变为"确认拦截")
interceptMode: false,
// 已拦截锁定:选中行为已拦截订单时,确认拦截按钮置为禁用
interceptLocked: false,
interceptTarget: null,
// 顶部提示信息
pickerName: '',
storeRemark: '',
// 左侧底部汇总
waveTotalOrders: 0,
waveUnreviewedCount: 0,
// 商品明细统计
scannedCount: 0,
totalCount: 0,
// 设置弹窗
settingsVisible: false,
// 绑定包材:开启(true)/关闭(false)
settingBindPackage: true,
// 包材软键盘:激活(true)/不激活(false)
settingPmKeyboard: false,
// 发货模式:auto 自动发货 / manual 手动发货(默认自动发货)
settingShipMode: 'auto',
}
},
computed: {
hasSelection() {
return !!(this.selectedPendingOrderKey || this.selectedWaveKey)
},
// 图片预览缩放样式:先平移后缩放(transform-origin 居中)
sharedImageStyle() {
return {
transform: `translate(${this.sharedImageOffsetX}px, ${this.sharedImageOffsetY}px) scale(${this.sharedImageScale})`,
}
},
// 称重弹窗标题:复核前自动称重模式显示“称重(复核前)”,手动点“称重”按钮仍为“称重”
weighDialogTitle() {
return this.weighReviewMode ? '称重(复核前)' : '称重'
},
searchPlaceholder() {
return this.hasSelection ? '扫描商品条码(全部扫完后回车确认)' : '输入运单号/车号,回车查询'
},
totalQuantity() {
return this.displayOrders.reduce((sum, order) => sum + (Number(order.quantity) || 0), 0)
},
printerOptions() {
return this.printerList.map(
(item) => item?.name || (item?.id ? `打印台${item.id}` : '未命名打印台')
)
},
reviewLocked() {
// 已复核锁定:选中项为已复核订单/波次时,确认复核按钮禁用
return this.currentOrderHeader
? this.getWaveReviewStatus(this.currentOrderHeader) === '已复核'
: false
},
noBarcodeReviewScanned() {
return this.noBarcodeReviewTarget ? Number(this.noBarcodeReviewTarget.scannedQty) || 0 : 0
},
noBarcodeReviewTotal() {
return this.noBarcodeReviewTarget ? Number(this.noBarcodeReviewTarget.quantity) || 0 : 0
},
// 商品是否全部扫完:数量>0 的商品已扫数量都 >= 总数(无数量商品视为已扫完)
allProductsScanned() {
const rows = this.displayOrders || []
if (rows.length === 0) {
return false
}
return rows.every((order) => {
const qty = Number(order?.quantity) || 0
const scanned = Number(order?.scannedQty) || 0
return qty <= 0 || scanned >= qty
})
},
// pick_mode=3 散单分播模式:商品明细显示“篮号”列(位置在总数列前)
showBasketColumn() {
return this.scanListType === 'single' && Number(this.currentPickMode) === 3
},
// 商品明细标签行左侧:团购模式显示当前波次订单总数(total_orders / order_count)
currentOrderCount() {
if (this.scanListType !== 'group' || !this.currentOrderHeader) {
return ''
}
return this.getRowValue(this.currentOrderHeader, ['total_orders', 'order_count', 'orderCount'])
},
// 商品明细标签行左侧:当前明细行的篮号(box_no 去重后合并,散单/团购均显示)
basketSummary() {
const rows = Array.isArray(this.displayOrders) ? this.displayOrders : []
const values = []
const seen = new Set()
for (const row of rows) {
const value = String(row?.basketNo ?? '').trim()
if (value && !seen.has(value)) {
seen.add(value)
values.push(value)
}
}
return values.join('、')
},
// 打包要求列:只要有一个商品带打包要求(recheck_requirements)就显示,全部为空时整列隐藏
showPackColumn() {
const rows = Array.isArray(this.displayOrders) ? this.displayOrders : []
return rows.some((row) => {
const value = String(row?.packingRequirements ?? '').trim()
return value !== ''
})
},
// 团购模式:波次推荐包材名称(suggested_package_material.name;非对象时兜底已格式化串)
recommendedPackageMaterialName() {
const info = this.selectedPackageMaterialInfo
if (info && typeof info === 'object') {
return info.name || info.code || ''
}
return this.selectedPackageMaterial || ''
},
// 任一弹窗打开(扫码链路防误触发主订单查询用)
anyDialogOpen() {
return !!(
this.weighDialogVisible ||
this.noBarcodeReviewVisible ||
this.confirmReviewVisible ||
this.batchReviewVisible ||
this.packageMaterialDialogVisible ||
this.sharedBarcodeDrawerVisible ||
this.settingsVisible
)
},
// 批量复核已解析的有效ID数(逗号/空格/换行分隔,去重)
batchParsedCount() {
return this.parseBatchOrderIds(this.batchReviewInput).length
},
// 当前可填入的未复核订单数
batchFillableCount() {
if (this.scanListType === 'group') {
return this.collectCurrentUnreviewedWaves().length
}
return this.collectCurrentUnreviewedOrders().length
},
batchResultSuccessCount() {
return this.batchSuccessList.length
},
batchResultFailedCount() {
return this.batchFailedList.length
},
// 当前切换标签对应的结果行
currentBatchResultRows() {
return this.batchResultTab === 'failed' ? this.batchFailedList : this.batchSuccessList
},
},
watch: {
hasSelection(val) {
// 进入商品条码流程(已选中订单)时,激活条码输入框(真机隐藏捕获时不抢占焦点)
if (val && !this.enableHiddenInputCapture) {
this.activateSearchInput()
}
},
// 输入内容变化时清除批量复核内联错误,并隐藏上一次结果
batchReviewInput() {
if (this.batchReviewError) {
this.batchReviewError = ''
}
if (this.batchResultDone) {
this.resetBatchResult()
}
},
},
methods: {
getRowValue(row, keys = []) {
for (const key of keys) {
const value = row?.[key]
if (value !== undefined && value !== null && value !== '') {
return value
}
}
return ''
},
normalizeOrderRow(row) {
const rawBarcode = this.getRowValue(row, ['barcode', 'bar_code', 'goods_barcode', 'sku_barcode', 'barcodes'])
const barcode = Array.isArray(rawBarcode) ? (rawBarcode[0] || '') : rawBarcode
const rawImage = this.getRowValue(row, ['images', 'image', 'image_url', 'imageUrl'])
const image = Array.isArray(rawImage) ? (rawImage[0] || '') : rawImage
return {
blueNo: this.getRowValue(row, ['blueNo', 'blue_no', 'lanhao', 'lan_hao', 'blue_no_code', 'stock_id', 'item_code']),
quantity: this.getRowValue(row, ['plan_qty', 'quantity', 'qty', 'num', 'count']),
scanMark: this.getRowValue(row, ['scanMark', 'scan_mark', 'scanStatus', 'scan_status']),
barcode,
productName: this.getRowValue(row, ['productName', 'product_name', 'goods_name', 'sku_name', 'item_name']),
color: this.getRowValue(row, ['color', 'color_name']),
spec: this.getRowValue(row, ['sku_property', 'spec', 'spec_name', 'size', 'sku_spec']),
location: this.getRowValue(row, ['location', 'location_code', 'loc_code', 'stock_location', 'storage_location', '库位']),
image,
packingRequirements: this.getRowValue(row, ['recheck_requirements', 'recheckRequirements']),
// 篮号(pick_mode=3 散单分播,明细行 box_no 等字段)
basketNo: this.getRowValue(row, ['box_no', 'boxNo', 'basket_no', 'basketNo', 'seed_no', 'seedNo']),
// 共享条码:库内存在相同条码的其它商品(has_shared_barcode,布尔)
hasSharedBarcode: !!this.getRowValue(row, ['has_shared_barcode', 'hasSharedBarcode']),
scannedQty: this.getRowValue(row, ['scanned_qty', 'scannedQty', 'scan_qty', 'scanQty', 'scanned_count', 'scannedCount']) || 0,
}
},
parseItemSnapshot(snapshotRaw) {
if (!snapshotRaw) {
return {}
}
if (typeof snapshotRaw === 'string') {
try {
const parsed = JSON.parse(snapshotRaw)
return typeof parsed === 'object' && parsed ? parsed : {}
} catch (error) {
return {}
}
}
return typeof snapshotRaw === 'object' ? snapshotRaw : {}
},
normalizeOrderDetailItem(item) {
const snapshot = this.parseItemSnapshot(this.getRowValue(item, ['item_snapshot', 'itemSnapshot']))
const merged = {
...item,
...snapshot,
}
// 共享条码:优先取行内(stockItem)的 has_shared_barcode,否则取快照(rawItem)的,默认 false
merged.has_shared_barcode = !!(item?.has_shared_barcode ?? snapshot?.has_shared_barcode ?? false)
return this.normalizeOrderRow(merged)
},
handleConfirm() {
// 提交后重置扫码快速输入标记,下一轮输入重新识别手动/扫码
this.scanBurstConfirmed = false
// 已选中列表项时,回车走商品条码匹配流程;否则走关键词查询
if (this.hasSelection) {
this.handleBarcodeMatch()
} else {
this.handleSearch()
}
},
handleSearchFocus() {
this.searchFocused = true
},
handleSearchBlur() {
this.searchFocused = false
// 输入框失焦后重置,便于后续键盘输入再次激活
this.searchFocus = false
},
activateSearchInput() {
// 请求聚焦条码输入框(实际焦点由 @focus 事件确认)
this.searchFocus = true
},
/**
* 全局键盘监听:扫码枪识别
* 扫码枪本质是模拟键盘的 HID 设备,字符走浏览器标准 keydown 事件。
* 策略:非聚焦时对可打印字符 / Tab / Enter(前缀键)主动抢焦点;
* 可打印字符同时手动缓冲进 keyword,避免"聚焦发生在该字符 keydown 之后"导致首字符丢失;
* 回车且有内容时作为结束符立即提交;无回车结束符则由静默防抖自动提交。
*/
handleGlobalKeydown(event) {
if (!this.isPageActive()) {
return
}
const key = event.key
const activeEl = typeof document !== 'undefined' ? document.activeElement : null
const inInput = !!(activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA'))
// 焦点已在输入框内(搜索/条码输入框或数量步进器):走浏览器默认输入,仅刷新防抖计时
if (inInput) {
this.touchScanInput()
return
}
// 真机使用隐藏 input 捕获时,非聚焦态由隐藏 input 处理,DOM 不再回填(避免双写)
if (this.enableHiddenInputCapture) {
return
}
// 组合键(Ctrl/Alt/Meta)不处理,避免误抢焦点
if (event.ctrlKey || event.altKey || event.metaKey) {
return
}
// 只对可打印字符(key.length === 1)和 Tab/Enter(扫码枪前缀键)响应
const isPrintable = !!key && key.length === 1
const isPrefixKey = key === 'Tab' || key === 'Enter'
if (!isPrintable && !isPrefixKey) {
return
}
event.preventDefault()
// 可打印字符:手动缓冲进输入框,保证首字符不丢失
if (isPrintable) {
this.keyword = (this.keyword || '') + key
}
// 主动聚焦输入框,后续字符走浏览器默认输入
this.searchFocus = true
// 回车且已有缓冲内容:视为扫码结束符,立即提交
if (key === 'Enter' && (this.keyword || '').trim()) {
this.handleConfirm()
}
this.touchScanInput()
},
/** 刷新扫码静默计时:记录最后按键时间并重置防抖定时器 */
touchScanInput() {
const now = Date.now()
const gap = now - this.lastScanKeyTime
// 手动输入识别:相邻按键间隔过大 → 视为手动输入,禁用静默自动提交(需按回车后才查询)
if (this.lastScanKeyTime > 0 && gap > SCAN_BURST_MAX_GAP) {
this.scanBurstConfirmed = false
} else if ((this.keyword || '').trim().length >= 2) {
// 连续快速输入且内容达标 → 视为扫码枪输入,允许静默自动提交
this.scanBurstConfirmed = true
}
this.lastScanKeyTime = now
if (this.scanTimer) {
clearTimeout(this.scanTimer)
}
this.scanTimer = setTimeout(() => this.checkScanIdle(), SCAN_IDLE_TIMEOUT)
},
/** 静默防抖:距最后按键超过阈值且缓冲内容达标时,视为一次完整扫码并自动提交 */
checkScanIdle() {
this.scanTimer = null
// 弹窗打开时静默防抖不触发主订单查询,避免把弹窗内扫码内容误当订单条码
if (this.anyDialogOpen) {
this.scanBurstConfirmed = false
return
}
const elapsed = Date.now() - this.lastScanKeyTime
const buffer = (this.keyword || '').trim()
// 仅扫码枪快速输入(scanBurstConfirmed)允许静默自动提交;手动输入需按回车后才查询
if (this.scanBurstConfirmed && elapsed >= SCAN_IDLE_TIMEOUT && buffer.length >= SCAN_MIN_LENGTH) {
this.handleConfirm()
}
},
// ---- 真机兼容:捕获模式 / plus.key / 隐藏 input / 聚焦保持 ----
/** 页面是否激活(keep-alive 切换 / 页面隐藏时暂停扫码聚焦抢占) */
isPageActive() {
return this.pageActive !== false
},
/** APP-PLUS 平台判断(uni-app 条件编译) */
isAppPlus() {
// #ifdef APP-PLUS
return true
// #endif
// #ifndef APP-PLUS
return false
// #endif
},
hasPlusKeyboardSupport() {
// #ifdef APP-PLUS
return typeof plus !== 'undefined' && !!plus?.key?.addEventListener
// #endif
// #ifndef APP-PLUS
return false
// #endif
},
hasDomKeyboardSupport() {
return typeof window !== 'undefined' || typeof document !== 'undefined'
},
/**
* 选择扫码捕获模式:
* - 桌面 H5/Electron:DOM 全局 keydown 监听(document/window,capture)
* - 真机(App / 平板浏览器):未聚焦时 WebView/浏览器不派发 keydown,改用隐藏 input 捕获 + 强制聚焦 + plus.key 原生监听
*/
setupScanCaptureMode() {
this.enableHiddenInputCapture = this.isRealDevice()
},
/** 是否真机(App 或移动端浏览器/平板) */
isRealDevice() {
// #ifdef APP-PLUS
return true
// #endif
return this.isMobileBrowser()
},
/** 移动端浏览器/平板检测:uni 运行环境平台 + UA 双保险 */
isMobileBrowser() {
try {
const info =
typeof uni !== 'undefined' && uni.getSystemInfoSync ? uni.getSystemInfoSync() : null
if (info && info.platform) {
const p = String(info.platform).toLowerCase()
if (p === 'android' || p === 'ios') {
return true
}
}
} catch (e) {
// 忽略:继续用 UA 判断
}
try {
if (typeof navigator !== 'undefined' && navigator.userAgent) {
return /Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent)
}
} catch (e) {
// 忽略
}
return false
},
attachGlobalKeyboardListener() {
if (this.globalKeyListener) {
return
}
const hasWindow = typeof window !== 'undefined'
const hasDocument = typeof document !== 'undefined'
const targets = []
if (hasDocument) {
targets.push(document)
} else if (hasWindow) {
targets.push(window)
}
if (!targets.length) {
return
}
this.globalKeyTargets = targets
this.globalKeyListener = this.handleGlobalKeydown
this.globalKeyTargets.forEach((target) => {
target.addEventListener('keydown', this.globalKeyListener, true)
})
},
removeGlobalKeyboardListener() {
if (!this.globalKeyTargets || !this.globalKeyListener) {
return
}
this.globalKeyTargets.forEach((target) => {
target.removeEventListener('keydown', this.globalKeyListener, true)
})
this.globalKeyTargets = []
this.globalKeyListener = null
},
parsePlusKeyCodeToChar(keyCode) {
if (keyCode >= 48 && keyCode <= 57) {
return String.fromCharCode(keyCode)
}
if (keyCode >= 65 && keyCode <= 90) {
return String.fromCharCode(keyCode)
}
if (keyCode >= 96 && keyCode <= 105) {
return String(keyCode - 96)
}
if (keyCode === 189 || keyCode === 109) {
return '-'
}
if (keyCode === 190 || keyCode === 110) {
return '.'
}
if (keyCode === 191 || keyCode === 111) {
return '/'
}
return ''
},
attachPlusKeyboardListener() {
if (!this.hasPlusKeyboardSupport()) {
return
}
if (this.plusKeyListener) {
return
}
this.plusKeyListener = (event) => {
if (!this.isPageActive()) {
return
}
const keyCode = Number(event?.keyCode || 0)
const isEnter = keyCode === 13 || keyCode === 66
const text = this.parsePlusKeyCodeToChar(keyCode)
if (text) {
const now = Date.now()
if (!this.plusKeyBuffer) {
this.plusKeyStartedAt = now
}
this.plusKeyLastAt = now
this.plusKeyBuffer += text
this.clearPlusKeyTimer()
this.plusKeyTimer = setTimeout(() => this.flushPlusKeyBuffer('timer'), 420)
return
}
if (isEnter) {
this.flushPlusKeyBuffer('enter')
}
}
// #ifdef APP-PLUS
plus.key.addEventListener('keydown', this.plusKeyListener)
// #endif
},
removePlusKeyboardListener() {
this.clearPlusKeyTimer()
this.plusKeyBuffer = ''
this.plusKeyStartedAt = 0
this.plusKeyLastAt = 0
if (!this.plusKeyListener) {
return
}
// #ifdef APP-PLUS
if (this.hasPlusKeyboardSupport()) {
plus.key.removeEventListener('keydown', this.plusKeyListener)
}
// #endif
this.plusKeyListener = null
},
flushPlusKeyBuffer(trigger = 'timer') {
if (!this.isPageActive()) {
return
}
const code = (this.plusKeyBuffer || '').trim()
this.plusKeyBuffer = ''
this.plusKeyStartedAt = 0
this.plusKeyLastAt = 0
this.clearPlusKeyTimer()
if (!code) {
return
}
this.submitScanCode(code, 'plus')
},
handleHiddenScanFocus() {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
this.scanHiddenFocused = true
this.scanInputFocus = true
this.clearHiddenRefocusTimer()
this.suppressSoftKeyboardBurst()
},
handleHiddenScanBlur() {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
this.scanHiddenFocused = false
this.scanInputFocus = false
this.clearHiddenRefocusTimer()
this.scanHiddenRefocusTimer = setTimeout(() => {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
// 用户已手动聚焦其它输入框(搜索框/数量步进器)时,不抢回焦点
const activeEl = typeof document !== 'undefined' ? document.activeElement : null
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA')) {
return
}
if (!this.scanHiddenFocused) {
this.scheduleScanInputFocus(220)
}
}, 500)
},
handleHiddenScanInput(event) {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
const value = event?.detail?.value || ''
this.scanHiddenValue = value
// 回填到可见搜索/条码输入框,与浏览器模式表现一致
this.keyword = value
this.clearHiddenScanTimer()
this.scanHiddenTimer = setTimeout(() => {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
this.processHiddenScanValue('timer')
}, 320)
},
handleHiddenScanConfirm(event) {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
const value = event?.detail?.value || this.scanHiddenValue || ''
this.scanHiddenValue = value
this.processHiddenScanValue('confirm')
},
processHiddenScanValue(trigger = 'timer') {
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
return
}
const code = (this.scanHiddenValue || '').trim()
this.clearHiddenScanTimer()
if (!code) {
return
}
this.scanHiddenValue = ''
this.dismissSoftKeyboard()
this.submitScanCode(code, 'hidden')
this.ensureScanInputFocus()
},
ensureScanInputFocus() {
if (!this.isPageActive()) {
return
}
if (!this.enableHiddenInputCapture) {
this.scanInputFocus = false
this.suppressSoftKeyboardBurst()
return
}
if (!this.scanInputFocus) {
this.scanInputFocus = true
}
},
scheduleScanInputFocus(delay = 0) {
if (!this.isPageActive()) {
return
}
this.clearScanFocusResumeTimer()
this.scanFocusResumeTimer = setTimeout(() => {
if (!this.isPageActive()) {
return
}
this.ensureScanInputFocus()
}, delay)
},
suppressSoftKeyboardBurst() {
if (!this.isPageActive()) {
return
}
this.clearKeyboardSuppressTimers()
uni.hideKeyboard?.()
;[80, 180, 320].forEach((delay) => {
const timer = setTimeout(() => {
if (!this.isPageActive()) {
return
}
uni.hideKeyboard?.()
}, delay)
this.scanKeyboardSuppressTimers.push(timer)
})
},
dismissSoftKeyboard() {
if (!this.isPageActive()) {
return
}
if (typeof document !== 'undefined') {
document.activeElement?.blur?.()
}
uni.hideKeyboard?.()
},
/** 统一扫码提交入口:回填 keyword 并走现有确认流程(搜索/商品条码) */
submitScanCode(code, source) {
if (!this.isPageActive()) {
return
}
const trimmed = (code || '').trim()
if (!trimmed) {
return
}
// 去重:plus.key 与隐藏 input 可能同时捕获同一扫码,短时间重复内容忽略
const now = Date.now()
if (
this.lastSubmittedScan &&
this.lastSubmittedScan.code === trimmed &&
now - this.lastSubmittedScan.at < 600
) {
return
}
this.lastSubmittedScan = { code: trimmed, at: now }
this.keyword = trimmed
this.handleConfirm()
},
clearPlusKeyTimer() {
if (this.plusKeyTimer) {
clearTimeout(this.plusKeyTimer)
this.plusKeyTimer = null
}
},
clearHiddenScanTimer() {
if (this.scanHiddenTimer) {
clearTimeout(this.scanHiddenTimer)
this.scanHiddenTimer = null
}
},
clearHiddenRefocusTimer() {
if (this.scanHiddenRefocusTimer) {
clearTimeout(this.scanHiddenRefocusTimer)
this.scanHiddenRefocusTimer = null
}
},
clearScanFocusResumeTimer() {
if (this.scanFocusResumeTimer) {
clearTimeout(this.scanFocusResumeTimer)
this.scanFocusResumeTimer = null
}
},
clearKeyboardSuppressTimers() {
if (!Array.isArray(this.scanKeyboardSuppressTimers)) {
this.scanKeyboardSuppressTimers = []
return
}
this.scanKeyboardSuppressTimers.forEach((timer) => {
clearTimeout(timer)
})
this.scanKeyboardSuppressTimers = []
},
handleBarcodeMatch() {
const barcode = this.keyword.trim()
if (!barcode) {
return
}
const code = this.normalizeScanBarcode(barcode)
// 查找所有条码匹配的商品(兼容单值/分号、逗号分隔的多值条码)
const matches = this.displayOrders.filter((order) => this.isBarcodeMatched(order, code))
if (matches.length === 0) {
uni.showToast({ title: '无记录', icon: 'none' })
return
}
// 命中共享条码商品(has_shared_barcode,库内存在同条码的其它商品):弹出「库内有相同商品」抽屉
const sharedItem = matches.find((order) => this.isSharedBarcode(order))
if (sharedItem) {
// 已关闭过该条码的弹窗:不再弹出,自动分配到第一个未扫完的共享条码商品
if (this.sharedBarcodeDismissed.includes(code)) {
const target = this.pickSharedTarget(matches)
if (target) {
this.applyScannedMatch(target)
} else {
uni.showToast({ title: '超出订单数', icon: 'none' })
}
return
}
this.sharedBarcodeMatches = matches
this.sharedBarcodeCode = code
this.sharedBarcodeSelectedIndex = matches.indexOf(sharedItem)
this.sharedBarcodeImgError = {}
this.keyword = ''
this.sharedBarcodeDrawerVisible = true
uni.showToast({ title: '库内有相同商品', icon: 'none' })
return
}
// 无共享条码:按原逻辑累加第一个匹配商品
this.applyScannedMatch(matches[0])
},
// 条码归一化:去空白 + 大写,供比对
normalizeScanBarcode(value) {
return String(value || '').replace(/\s+/g, '').toUpperCase()
},
// 商品条码是否命中(兼容单值/分号、逗号分隔的多值条码)
isBarcodeMatched(order, code) {
if (!order || !code) {
return false
}
const raw = String(order?.barcode ?? '').trim()
if (!raw) {
return false
}
return raw
.split(/[;,,|\s]+/)
.some((part) => this.normalizeScanBarcode(part) === code)
},
// 是否为共享条码商品(has_shared_barcode)
isSharedBarcode(order) {
return !!order?.hasSharedBarcode
},
// 累加一个匹配商品的已扫数量(原 handleBarcodeMatch 命中逻辑)
applyScannedMatch(target) {
if (!target) {
return
}
target.scannedQty = (Number(target.scannedQty) || 0) + 1
this.syncDetailStats(this.currentOrderHeader, this.displayOrders)
this.keyword = ''
// 复核命中商品:播报「数据一致」,并按商品去重追加该商品复核要求
this.speakDataConsistent(target)
// 关闭自动发货(手动发货)且商品全部扫完时:播报「全部商品已扫描完成」
if (this.settingShipMode === 'manual' && this.allProductsScanned) {
uni.showToast({ title: '全部商品已扫描完成', icon: 'none' })
}
// 商品明细全部扫完时:按“是否称重=称重”自动进入称重(复核前)
this.autoOpenWeighAfterScan()
},
// 共享条码已关闭后:自动分配到第一个未扫完的共享条码商品,否则第一个未扫完的匹配商品
pickSharedTarget(matches) {
const list = Array.isArray(matches) ? matches : []
const notFull = (order) => (Number(order?.quantity) || 0) > (Number(order?.scannedQty) || 0)
return (
list.find((order) => this.isSharedBarcode(order) && notFull(order)) ||
list.find((order) => notFull(order)) ||
null
)
},
// 库内有相同商品:点击商品卡片即视为确认,对选中商品累加扫描数量并关闭
confirmSharedBarcodeItem(index) {
const matches = this.sharedBarcodeMatches || []
const target = index >= 0 ? matches[index] : null
this.sharedBarcodeDrawerVisible = false
this.sharedBarcodeMatches = []
this.sharedBarcodeSelectedIndex = -1
this.sharedBarcodeCode = ''
this.sharedBarcodeImgError = {}
if (target) {
this.applyScannedMatch(target)
}
this.scheduleScanInputFocus(150)
},
// 图片加载失败:显示占位图标
onSharedImageError(index) {
this.$set(this.sharedBarcodeImgError, index, true)
},
// 点击商品图片:自绘全屏预览(mode=aspectFit,避免 uni.previewImage 被放大)
previewSharedImage(src) {
if (!src) {
return
}
this.sharedImagePreviewUrl = src
this.resetPreviewZoom()
this.sharedImagePreviewVisible = true
},
// 关闭商品图片预览
closeSharedImagePreview() {
if (this.previewCloseTimer) {
clearTimeout(this.previewCloseTimer)
this.previewCloseTimer = null
}
this.sharedImagePreviewVisible = false
this.sharedImagePreviewUrl = ''
this.resetPreviewZoom()
},
// 复位预览缩放与拖动偏移
resetPreviewZoom() {
this.sharedImageScale = 1
this.sharedImageOffsetX = 0
this.sharedImageOffsetY = 0
this.previewPinchDistance = 0
this.previewPinchStartScale = 1
this.previewPanMoved = false
this.previewLastClickAt = 0
},
// 缩放范围限制:1 ~ 5 倍
clampPreviewScale(value) {
return Math.min(5, Math.max(1, Number(value) || 1))
},
// 双击切换缩放(放大到 2.5 倍,或恢复 1 倍)
togglePreviewZoom() {
if (this.sharedImageScale > 1.01) {
this.resetPreviewZoom()
} else {
this.sharedImageScale = 2.5
}
},
// 计算两指间距离
getPreviewTouchDistance(touches) {
if (!touches || touches.length < 2) {
return 0
}
const dx = touches[0].clientX - touches[1].clientX
const dy = touches[0].clientY - touches[1].clientY
return Math.sqrt(dx * dx + dy * dy)
},
onPreviewTouchStart(e) {
const touches = e && e.touches ? e.touches : []
if (touches.length >= 2) {
this.previewPinchDistance = this.getPreviewTouchDistance(touches)
this.previewPinchStartScale = this.sharedImageScale
return
}
if (touches.length === 1) {
const touch = touches[0]
this.previewPanStartX = touch.clientX
this.previewPanStartY = touch.clientY
this.previewPanStartOffsetX = this.sharedImageOffsetX
this.previewPanStartOffsetY = this.sharedImageOffsetY
this.previewPanMoved = false
}
},
onPreviewTouchMove(e) {
const touches = e && e.touches ? e.touches : []
if (touches.length >= 2 && this.previewPinchDistance > 0) {
const distance = this.getPreviewTouchDistance(touches)
this.sharedImageScale = this.clampPreviewScale(
this.previewPinchStartScale * (distance / this.previewPinchDistance)
)
return
}
if (touches.length === 1 && this.sharedImageScale > 1.01) {
const touch = touches[0]
const deltaX = touch.clientX - this.previewPanStartX
const deltaY = touch.clientY - this.previewPanStartY
if (Math.abs(deltaX) > 3 || Math.abs(deltaY) > 3) {
this.previewPanMoved = true
}
this.sharedImageOffsetX = this.previewPanStartOffsetX + deltaX
this.sharedImageOffsetY = this.previewPanStartOffsetY + deltaY
}
},
onPreviewTouchEnd() {
this.previewPinchDistance = 0
this.previewPinchStartScale = 1
},
// 点击预览区:单击延时关闭(等待双击判定),双击切换缩放
onPreviewStageClick() {
if (this.previewPanMoved) {
this.previewPanMoved = false
return
}
const now = Date.now()
if (now - this.previewLastClickAt < 400) {
if (this.previewCloseTimer) {
clearTimeout(this.previewCloseTimer)
this.previewCloseTimer = null
}
this.previewLastClickAt = 0
this.togglePreviewZoom()
return
}
this.previewLastClickAt = now
this.previewCloseTimer = setTimeout(() => {
this.previewCloseTimer = null
this.closeSharedImagePreview()
}, 400)
},
// 桌面端滚轮缩放
onPreviewWheel(e) {
if (!e) {
return
}
if (e.cancelable) {
e.preventDefault()
}
const delta = e.deltaY || 0
if (!delta) {
return
}
const factor = delta > 0 ? 0.9 : 1.1
this.sharedImageScale = this.clampPreviewScale(this.sharedImageScale * factor)
},
// 关闭抽屉:将当前条码加入已忽略列表,后续相同条码不再弹窗
closeSharedBarcodeDrawer() {
const code = this.sharedBarcodeCode
this.sharedBarcodeDrawerVisible = false
this.sharedBarcodeMatches = []
this.sharedBarcodeSelectedIndex = -1
this.sharedBarcodeCode = ''
this.sharedBarcodeImgError = {}
if (code && !this.sharedBarcodeDismissed.includes(code)) {
this.sharedBarcodeDismissed.push(code)
}
this.scheduleScanInputFocus(150)
},
// 重置共享条码弹窗状态(切单/清空时调用)
resetSharedBarcodeState() {
this.sharedBarcodeDrawerVisible = false
this.sharedBarcodeMatches = []
this.sharedBarcodeCode = ''
this.sharedBarcodeSelectedIndex = -1
this.sharedBarcodeDismissed = []
this.sharedBarcodeImgError = {}
},
// 复核命中商品:播报「数据一致」;该商品带复核要求时,同单内只播一次「数据一致,{复核要求}」
speakDataConsistent(order) {
const key = String(order?.barcode ?? '').trim()
const requirement = String(order?.packingRequirements ?? '').trim()
let text = '数据一致'
if (requirement && (!key || !this.spokenRecheckKeys.includes(key))) {
if (key) {
this.spokenRecheckKeys.push(key)
}
text = `数据一致,${requirement}`
}
uni.showToast({ title: text, icon: 'none' })
},
handleScanQtyPlus() {
this.scanQty = (Number(this.scanQty) || 0) + 1
},
handleScanQtyMinus() {
const value = Number(this.scanQty) || 0
this.scanQty = value > 1 ? value - 1 : 1
},
getColStyle(key) {
const w = this.detailColWidths[key]
if (w) {
return { width: `${w}px`, flex: 'none' }
}
return {}
},
startResize(key, event) {
const el = this.$refs[`detail-header-${key}`]
const dom = el && el.$el ? el.$el : el
const startWidth = dom ? (dom.getBoundingClientRect ? dom.getBoundingClientRect().width : 0) : 0
this.resizingCol = { key, startX: event.clientX, startWidth }
if (typeof document !== 'undefined') {
document.addEventListener('mousemove', this.onResizeMove)
document.addEventListener('mouseup', this.onResizeEnd)
}
},
onResizeMove(event) {
if (!this.resizingCol) return
const { key, startX, startWidth } = this.resizingCol
const next = Math.max(60, Math.round(startWidth + (event.clientX - startX)))
this.detailColWidths = { ...this.detailColWidths, [key]: next }
},
onResizeEnd() {
this.resizingCol = null
if (typeof document !== 'undefined') {
document.removeEventListener('mousemove', this.onResizeMove)
document.removeEventListener('mouseup', this.onResizeEnd)
}
},
async handleSearch() {
const query = this.keyword.trim()
// 清空关键词:回到初始空状态
if (!query) {
this.scanActive = false
this.scanOrderList = []
this.reviewedKeepList = []
this.clearSelection()
return
}
try {
// 新查询上下文:清空上一轮已复核保留项缓存
this.reviewedKeepList = []
const body = await scanReviewOrder({ keyword: query })
const payload = body?.data || body?.result || body || {}
this.applyScanResult(payload)
this.activeKeyword = query
this.keyword = ''
} catch (error) {
uni.showToast({
title: '查询失败',
icon: 'none',
silentVoice: true,
})
}
},
applyScanResult(payload) {
const list = Array.isArray(payload?.list) ? payload.list : []
if (list.length === 0) {
const message = payload?.msg || payload?.message || '未找到对应订单'
uni.showToast({
title: this.resolveScanOrderErrorVoice(message),
icon: 'none',
})
}
this.scanActive = true
this.scanListType = payload?.list_type || ''
// 保留服务端返回的全部数据;刷新后回填本地已复核缓存项(服务端会去掉已复核数据)
this.scanOrderList = this.mergeReviewedKeptItems(list)
this.pickerName = this.getRowValue(payload, ['picker_name', 'pickerName']) || ''
// 记录仓库ID(团购面单补打需要)
const scanWarehouseId = this.getRowValue(payload, ['warehouse_id', 'warehouseId'])
if (scanWarehouseId !== '') {
this.warehouseId = scanWarehouseId
}
// 汇总数据:波次总单数优先取接口顶层字段,缺失时按列表累加(团购模式为波次列表)
const topTotal = this.getRowValue(payload, ['total_orders'])
this.waveTotalOrders =
topTotal !== ''
? topTotal
: list.reduce((sum, row) => sum + (Number(row?.total_orders) || 0), 0)
// 剩余未复核数:前端统计并排除拦截/已拦截订单
this.waveUnreviewedCount = this.countUnreviewedExcludingIntercepted(list)
this.clearSelection()
// 记录拣货模式:优先响应顶层,缺失时兜底首行(pick_mode=3 散单分播)
const modeTop = this.getRowValue(payload, ['pick_mode', 'pickMode'])
const modeRow = list.length > 0 ? this.getRowValue(list[0], ['pick_mode', 'pickMode']) : ''
this.currentPickMode = modeTop !== '' ? modeTop : modeRow
// 记录拣货任务 ID,供刷新按钮按 task_id 调用 scanTask
this.currentTaskId = this.extractTaskId(payload, list)
// 默认选中第一行,右侧立即展示其商品明细(不再需要手动点第一行)
this.autoSelectFirstResult()
},
// 扫码/查询订单错误文案 → 语音播报文案映射
resolveScanOrderErrorVoice(message) {
const text = String(message || '').trim()
if (text.includes('未拣货')) {
return '订单未拣货,不允许复核'
}
if (text.includes('关键词不能为空') || text.includes('关键词为空')) {
return '扫描关键词不能为空'
}
return '未找到对应订单'
},
// 默认选中左侧复核列表第一行,展示其商品明细
autoSelectFirstResult() {
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
if (rows.length === 0) {
return
}
if (this.scanListType === 'group') {
this.handleWaveClick(rows[0])
} else {
this.handleScanOrderClick(rows[0])
}
},
// 将本地缓存的已复核订单/波次按原位置插回列表,保证保留已复核数据且位置不变
mergeReviewedKeptItems(list) {
const rows = Array.isArray(list) ? list : []
const kept = Array.isArray(this.reviewedKeepList) ? this.reviewedKeepList : []
if (kept.length === 0) {
return rows
}
// 当前列表已有 key 集合(服务端可能仍返回部分已复核项,避免重复)
const existing = new Set()
for (const row of rows) {
const key = this.getReviewKeepKey(row)
if (key !== '') {
existing.add(key)
}
}
// 需要回填的项:按原位置升序
const missing = kept
.filter((entry) => {
const key = this.getReviewKeepKey(entry.item)
return key !== '' && !existing.has(key)
})
.sort((a, b) => a.index - b.index)
if (missing.length === 0) {
return rows
}
const result = rows.slice()
for (const entry of missing) {
const pos = Math.min(entry.index, result.length)
result.splice(pos, 0, entry.item)
}
return result
},
clearSelection() {
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
this.spokenRecheckKeys = []
this.resetSharedBarcodeState()
this.selectedPendingOrderKey = ''
this.selectedWaveKey = ''
this.selectedOrderNo = ''
this.selectedItemsWeight = null
this.selectedWaveNo = ''
this.selectedWaveIndex = ''
this.selectedPackageMaterial = null
this.selectedPackageMaterialInfo = null
this.displayOrders = []
this.currentOrderHeader = null
this.currentWaybillInfo = null
this.storeRemark = ''
this.scannedCount = 0
this.totalCount = 0
this.currentTaskId = null
this.currentPickMode = null
// 复核前自动称重模式复位(清空/切单/刷新时避免残留)
this.weighReviewMode = false
// 复核后称重待完成状态复位
this.clearPostReviewWeighState()
},
// 从响应顶层或列表行内提取拣货任务 ID
extractTaskId(payload, list) {
const topId = this.getRowValue(payload, ['task_id', 'taskId', 'pick_task_id', 'pickTaskId'])
if (topId !== '') {
return topId
}
const rows = Array.isArray(list) ? list : []
for (const row of rows) {
const rowId = this.getRowValue(row, ['task_id', 'taskId', 'pick_task_id', 'pickTaskId'])
if (rowId !== '') {
return rowId
}
// 团购模式:波次下订单可能携带任务 ID
if (row && Array.isArray(row.orders)) {
for (const order of row.orders) {
const orderId = this.getRowValue(order, ['task_id', 'taskId', 'pick_task_id', 'pickTaskId'])
if (orderId !== '') {
return orderId
}
}
}
}
return null
},
syncDetailStats(source, list) {
// 汇总商品件数:已扫 = scannedQty 之和,总数 = quantity 之和
const rows = Array.isArray(list) ? list : []
this.scannedCount = rows.reduce((sum, row) => sum + (Number(row?.scannedQty) || 0), 0)
this.totalCount = rows.reduce((sum, row) => sum + (Number(row?.quantity) || 0), 0)
this.storeRemark = this.getRowValue(source, ['store_remark', 'storeRemark']) || ''
},
handleConfirmReview() {
// 已复核订单/波次:确认复核按钮已禁用,此处兜底拦截重复操作
if (this.reviewLocked) {
uni.showToast({ title: '该订单已复核,无需重复操作', icon: 'none', silentVoice: true })
return
}
// 已拦截订单:确认拦截按钮已禁用,此处兜底拦截重复操作
if (this.interceptLocked) {
uni.showToast({ title: '该订单已拦截,无需重复操作', icon: 'none', silentVoice: true })
return
}
// 拦截确认模式下,弹窗确认后执行拦截;否则执行确认复核
if (this.interceptMode) {
const orderNo = this.interceptTarget?.orderNo || this.selectedOrderNo || ''
uni.showModal({
title: '确认拦截',
content: `确认对订单「${orderNo}」执行拦截操作?`,
confirmText: '确定',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
this.doConfirmIntercept()
}
},
})
return
}
// 商品未全部扫完:不可确认复核(按钮已禁用,此处兜底拦截)
if (!this.allProductsScanned) {
uni.showToast({ title: '请先扫完所有商品,再进行复核', icon: 'none', silentVoice: true })
return
}
// 确认复核:打开自绘确认弹窗(样式参考称重弹窗),确认后调用接口
this.confirmReviewOrderNo =
this.selectedOrderNo || this.getScanOrderNo(this.currentOrderHeader) || ''
this.confirmReviewVisible = true
},
closeConfirmReview() {
this.confirmReviewVisible = false
this.confirmReviewOrderNo = ''
this.scheduleScanInputFocus(150)
},
confirmReviewConfirm() {
this.confirmReviewVisible = false
this.confirmReviewOrderNo = ''
this.doConfirmRecheck()
this.scheduleScanInputFocus(150)
},
// 执行确认复核:调用 order.recheckOrder.confirmRecheck
// 团购波次分组(scanListType==='group')传 wave_id,普通订单传 order_id
// enableAutoNext=true 时复核刷新后自动选中下一个未复核订单/波次;false 则留待调用方自行切换
async doConfirmRecheck(enableAutoNext = true) {
let params
if (this.scanListType === 'group') {
const waveId = this.getRowValue(this.currentOrderHeader, ['wave_id', 'waveId'])
if (waveId === '') {
uni.showToast({ title: '未找到波次ID,无法复核', icon: 'none', silentVoice: true })
return false
}
params = { wave_id: waveId }
} else {
const orderId = this.getScanOrderId(this.currentOrderHeader)
if (orderId === '') {
uni.showToast({ title: '未找到订单ID,无法复核', icon: 'none', silentVoice: true })
return false
}
params = { order_id: orderId }
}
try {
const body = await confirmRecheck(params)
const payload = body?.data || body?.result || body || {}
// 成功判定(实际接口约定):flag==='success' 且 code===1
const flagOk = body?.flag === 'success' || payload?.flag === 'success'
const codeOk =
body?.code === 1 ||
body?.code === '1' ||
payload?.code === 1 ||
payload?.code === '1'
if (!flagOk || !codeOk) {
const message =
body?.message || body?.msg || payload?.message || payload?.msg || '复核失败'
uni.showModal({
title: '复核失败',
content: String(message),
showCancel: false,
confirmText: '确定',
})
return false
}
uni.showToast({ title: '发货成功', icon: 'success' })
// 本地标记为已复核并缓存(服务端 scanOrder/scanTask 后续查询会去掉已复核数据,缓存用于回填)
this.keepReviewedItem()
// 复核后不刷新列表,本地联动更新左侧底部“剩余未复核”统计
this.refreshWaveSummary()
// 记录当前复核行的 key,供自动切下一未复核订单/波次定位
const reviewedKey = this.getReviewKeepKey(this.currentOrderHeader)
// 复核后不调 scanTask/handleRefresh(避免复核后多余的网络请求);enableAutoNext=false
// (自动发货复核后先称重)暂不切下一波次,由称重保存后切换
if (enableAutoNext) {
this.autoSelectNextPendingOrder(reviewedKey)
}
return true
} catch (error) {
uni.showToast({ title: '网络异常,请检查网络', icon: 'none' })
return false
}
},
// 当前订单复核完成后:自动选中「当前复核行之后的第一个」未复核订单/波次,并展示其商品详情;
// reviewedKey 为刷新前记录的当前已复核行去重键,无后续未复核项时从头循环查找
autoSelectNextPendingOrder(reviewedKey = '') {
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
if (rows.length === 0) {
return
}
const isPending = (row) => {
if (this.getWaveReviewStatus(row) !== '未复核') {
return false
}
// 散单模式排除已拦截/拦截中订单,避免自动进入拦截确认态
if (this.scanListType !== 'group' && this.isInterceptExcluded(row)) {
return false
}
return true
}
// 当前已复核行位置(刷新后该行仍保留在原位)
const startIndex = reviewedKey
? rows.findIndex((row) => this.getReviewKeepKey(row) === reviewedKey)
: -1
const from = startIndex >= 0 ? startIndex + 1 : 0
// 先从当前位置之后找;无则从头循环查找
let target = null
for (let i = from; i < rows.length; i++) {
if (isPending(rows[i])) {
target = rows[i]
break
}
}
if (!target) {
for (let i = 0; i < from; i++) {
if (isPending(rows[i])) {
target = rows[i]
break
}
}
}
if (target) {
if (this.scanListType === 'group') {
this.handleWaveClick(target)
} else {
this.handleScanOrderClick(target)
}
} else {
// 当前查询结果已全部复核完成:提示并回到初始引导态(输入运单号/车号查询下一批)
this.finishAllReviewed()
}
},
// 当前查询结果全部复核完成:toast 提示 + 清空回初始查询态
finishAllReviewed() {
uni.showToast({ title: '所有订单已复核完成', icon: 'none' })
this.reviewedKeepList = []
this.scanOrderList = []
this.scanActive = false
this.scanListType = ''
this.activeKeyword = ''
this.keyword = ''
this.clearSelection()
this.scheduleScanInputFocus(150)
},
// 复核成功后:将当前选中订单/波次标记为已复核并缓存(含原位置),
// applyScanResult 刷新时按原位置回填到左侧列表,保证保留已复核数据且位置不变
keepReviewedItem() {
const row = this.currentOrderHeader
if (!row || typeof row !== 'object') {
return
}
const key = this.getReviewKeepKey(row)
if (key === '') {
return
}
// 在列表中查找原始行(兼容 detail 包装)与原位置
let target = row
let index = -1
for (let i = 0; i < this.scanOrderList.length; i++) {
if (this.getReviewKeepKey(this.scanOrderList[i]) === key) {
target = this.scanOrderList[i]
index = i
break
}
}
const src = this.getScanOrderSource(target)
if (this.scanListType === 'group') {
// 团购波次:全部订单已复核
src.unreviewed_count = 0
src.reviewed_count = Number(src.total_orders) || Number(src.order_count) || 1
src.review_status = 'reviewed'
if (Array.isArray(src.orders)) {
src.orders.forEach((o) => {
o.is_reviewed = true
})
}
} else {
// 散单订单:标记已复核
src.is_reviewed = true
src.review_status = 'reviewed'
src.unreviewed_count = 0
src.reviewed_count = 1
}
const exists = this.reviewedKeepList.some((entry) => this.getReviewKeepKey(entry.item) === key)
if (!exists) {
this.reviewedKeepList.push({
item: target,
index: index >= 0 ? index : this.scanOrderList.length,
})
}
},
// 已复核保留项去重键:团购按波次ID,散单按订单ID
getReviewKeepKey(row) {
if (!row || typeof row !== 'object') {
return ''
}
if (this.scanListType === 'group') {
return `wave:${this.getRowValue(row, ['wave_id', 'waveId'])}`
}
return `order:${this.getScanOrderId(row)}`
},
// 清空“复核后称重待完成”状态(含暂存运单与去重键)
clearPostReviewWeighState() {
this.pmPostReviewWeighPending = false
this.pmAfterReviewWeighWaybill = ''
this.pmAfterReviewReviewKey = ''
},
// 复核后称重被取消:重新选中刚复核的波次(右侧展示其商品明细,点商品行可再次弹称重)
reselectReviewedWave() {
const key = this.pmAfterReviewReviewKey
if (!key) {
return
}
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
const idx = rows.findIndex((row) => this.getReviewKeepKey(row) === key)
if (idx >= 0) {
this.handleWaveClick(rows[idx])
} else {
// 波次不在列表(异常兜底):清除待称重状态,避免卡住
this.clearPostReviewWeighState()
}
},
// 执行确认拦截:调用 order.recheckOrder.confirmIntercept
async doConfirmIntercept() {
const orderNo = this.interceptTarget?.orderNo || this.selectedOrderNo || ''
const orderId = this.interceptTarget?.orderId ?? ''
if (orderId === '' || orderId === null || orderId === undefined) {
uni.showToast({ title: '订单ID为空,无法拦截', icon: 'none', silentVoice: true })
return
}
try {
const body = await confirmIntercept({ ids: [orderId] })
const payload = body?.data || body?.result || body || {}
const successList = Array.isArray(payload?.success) ? payload.success : []
const failedList = Array.isArray(payload?.failed) ? payload.failed : []
const successCount =
payload?.success_count != null ? Number(payload.success_count) : successList.length
const failedCount =
payload?.failed_count != null ? Number(payload.failed_count) : failedList.length
if (failedCount > 0) {
const reasons = failedList
.map((f) => {
const id = f?.order_id ?? f?.orderId ?? f?.id ?? ''
const reason = f?.reason ?? f?.msg ?? f?.message ?? ''
return `订单${id}${reason ? `:${reason}` : ''}`
})
.join('\n')
uni.showModal({
title: '拦截结果',
content: `成功 ${successCount} 单,失败 ${failedCount} 单${reasons ? `\n失败原因:\n${reasons}` : ''}`,
showCancel: false,
confirmText: '确定',
})
} else {
uni.showToast({ title: `拦截成功:${successCount} 单`, icon: 'none', silentVoice: true })
}
// 拦截完成,退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
// 同步刷新左侧列表:本地即时将该行标记为已拦截,并从服务端刷新列表
if (successCount > 0) {
const successIds = successList
.map((s) => s?.order_id ?? s?.orderId ?? s?.id ?? '')
.filter((id) => id !== '')
const ids = successIds.length > 0 ? successIds : [orderId]
ids.forEach((id) => this.markRowIntercepted(id))
this.handleRefresh(false)
}
} catch (error) {
// 接口调用失败:保留拦截确认模式,便于重试
uni.showToast({ title: '拦截失败,请重试', icon: 'none', silentVoice: true })
}
},
handleClear() {
this.scanOrderList = []
this.activeKeyword = ''
this.keyword = ''
this.reviewedKeepList = []
this.clearSelection()
uni.showToast({ title: '已清空', icon: 'none', silentVoice: true })
},
// 刷新左侧列表;showToast=false 时静默刷新(拦截成功后自动同步,不弹提示打扰)
handleRefresh(showToast = true) {
const notify = (title) => {
if (showToast) {
uni.showToast({ title, icon: 'none', silentVoice: true })
}
}
// 优先按拣货任务 ID 拉取复核扫描视图;无任务 ID 时回退到关键词查询
const taskId = this.currentTaskId
if (taskId !== null && taskId !== undefined && taskId !== '') {
return scanReviewTask({ task_id: Number(taskId) })
.then((body) => {
const payload = body?.data || body?.result || body || {}
this.applyScanResult(payload)
notify('刷新成功')
})
.catch(() => {
notify('刷新失败')
})
}
const query = (this.activeKeyword || this.keyword).trim()
if (!query) {
notify('请输入关键词')
return Promise.resolve()
}
return scanReviewOrder({ keyword: query })
.then((body) => {
const payload = body?.data || body?.result || body || {}
this.applyScanResult(payload)
notify('刷新成功')
})
.catch(() => {
notify('刷新失败')
})
},
// 批量快捷复核:打开弹窗
handleBatchQuickReview() {
this.batchReviewInput = ''
this.batchReviewError = ''
this.resetBatchResult()
this.batchReviewVisible = true
},
closeBatchReview() {
this.batchReviewVisible = false
this.batchReviewInput = ''
this.batchReviewError = ''
this.resetBatchResult()
this.scheduleScanInputFocus(150)
},
// 重置批量复核结果(关闭/输入变化时调用)
resetBatchResult() {
this.batchResultDone = false
this.batchResultTab = 'success'
this.batchSuccessList = []
this.batchFailedList = []
},
// 解析输入文本中的有效订单ID(逗号/中文逗号/空格/换行/分号分隔,去重)
parseBatchOrderIds(text) {
const raw = String(text || '').trim()
if (!raw) {
return []
}
const parts = raw.split(/[,,\s;;]+/)
const ids = []
for (const part of parts) {
const p = part.trim()
if (p && !ids.includes(p)) {
ids.push(p)
}
}
return ids
},
// 收集当前列表中的未复核订单ID(散单按行;团购按波次下 orders[]),排除拦截/已拦截
collectCurrentUnreviewedOrders() {
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
const ids = []
const add = (row) => {
if (this.getWaveReviewStatus(row) === '未复核' && !this.isInterceptExcluded(row)) {
const id = this.getScanOrderId(row)
if (id !== '' && !ids.includes(String(id))) {
ids.push(String(id))
}
}
}
for (const row of rows) {
if (this.scanListType === 'group') {
const subOrders = Array.isArray(row?.orders) ? row.orders : []
if (subOrders.length > 0) {
subOrders.forEach(add)
}
} else {
add(row)
}
}
return ids
},
// 将当前未复核项填入输入框(团购按波次ID,散单按订单ID)
fillBatchUnreviewedOrders() {
if (this.scanListType === 'group') {
this.batchReviewInput = this.collectCurrentUnreviewedWaves().join(',')
} else {
this.batchReviewInput = this.collectCurrentUnreviewedOrders().join(',')
}
this.batchReviewError = ''
},
// 收集当前列表中的未复核波次ID(团购模式)
collectCurrentUnreviewedWaves() {
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
const ids = []
for (const row of rows) {
if (this.getWaveReviewStatus(row) === '未复核') {
const id = this.getRowValue(row, ['wave_id', 'waveId'])
if (id !== '' && !ids.includes(String(id))) {
ids.push(String(id))
}
}
}
return ids
},
// 确认批量快捷复核:直接执行(散单按订单ID调 batchQuickRecheck;团购按波次ID调 batchQuickRecheckByWave)
confirmBatchReview() {
const ids = this.parseBatchOrderIds(this.batchReviewInput)
if (ids.length === 0) {
// 内联提示显示在「已解析」行下方(团购按波次,散单按订单)
this.batchReviewError =
this.scanListType === 'group' ? '请至少输入一个有效波次 ID' : '请至少输入一个有效订单 ID'
return
}
this.doBatchQuickRecheck(ids)
},
// 执行批量快捷复核:团购按波次ID调用 batchQuickRecheckByWave,散单按订单ID调用 batchQuickRecheck
async doBatchQuickRecheck(ids) {
if (!ids || ids.length === 0) {
return
}
try {
const body =
this.scanListType === 'group'
? await batchQuickRecheckByWave({ wave_ids: ids.join(',') })
: await batchQuickRecheck({ ids: ids.join(',') })
const payload = body?.data || body?.result || body || {}
const successList = Array.isArray(payload?.success) ? payload.success : []
const failedList = Array.isArray(payload?.failed) ? payload.failed : []
const successCount =
payload?.success_count != null ? Number(payload.success_count) : successList.length
const failedCount =
payload?.failed_count != null ? Number(payload.failed_count) : failedList.length
// 组装成功/失败行:订单ID / 运单号 / 原因 / 说明
const toRow = (item, type) => ({
order_id: item?.order_id ?? item?.orderId ?? item?.id ?? '',
waybill_no: item?.delivery_order_code ?? item?.waybill_no ?? item?.waybillNo ?? '',
reason: item?.reason ?? (type === 'success' ? '' : item?.msg ?? item?.message ?? ''),
note:
item?.note ??
item?.remark ??
item?.description ??
(type === 'success' ? '复核成功' : ''),
})
this.batchSuccessList = successList.map((s) => toRow(s, 'success'))
this.batchFailedList = failedList.map((f) => toRow(f, 'failed'))
// 成功订单:本地标记已复核并静默刷新(服务端去掉已复核数据,回填保留)
const successIds = successList
.map((s) => s?.order_id ?? s?.orderId ?? s?.id ?? '')
.filter((id) => id !== '')
if (successIds.length > 0) {
successIds.forEach((id) => this.markReviewedByOrderId(id))
// 团购:整波次全部订单已复核时,标记波次已复核并缓存保留
if (this.scanListType === 'group') {
this.finalizeBatchGroupReview()
}
await this.handleRefresh(false)
}
// 内联展示结果(默认切到有数据的一侧)
this.batchResultTab = successCount > 0 ? 'success' : 'failed'
this.batchResultDone = true
this.batchReviewError = ''
} catch (error) {
uni.showToast({ title: '批量复核失败,请重试', icon: 'none', silentVoice: true })
}
},
// 团购批量复核后:若某波次下所有订单均已复核,标记整波已复核并缓存(刷新回填保留已复核波次)
finalizeBatchGroupReview() {
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
rows.forEach((wave, index) => {
const subs = Array.isArray(wave?.orders) ? wave.orders : []
if (subs.length === 0) {
return
}
const allReviewed = subs.every((o) => {
const src = this.getScanOrderSource(o)
return !!(src && (src.is_reviewed === true || this.getWaveReviewStatus(o) === '已复核'))
})
if (!allReviewed || this.getWaveReviewStatus(wave) === '已复核') {
return
}
const src = this.getScanOrderSource(wave)
if (src && typeof src === 'object') {
src.unreviewed_count = 0
src.reviewed_count = Number(src.total_orders) || Number(src.order_count) || subs.length
src.review_status = 'reviewed'
}
const key = this.getReviewKeepKey(wave)
if (key !== '') {
const exists = this.reviewedKeepList.some(
(entry) => this.getReviewKeepKey(entry.item) === key
)
if (!exists) {
this.reviewedKeepList.push({ item: wave, index })
}
}
})
},
// 批量复核成功后:按订单ID将该行标记为已复核并缓存(供刷新回填保留已复核项)
markReviewedByOrderId(orderId) {
if (orderId === '' || orderId === null || orderId === undefined) {
return
}
const target = String(orderId)
const rows = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
for (let i = 0; i < rows.length; i++) {
const row = rows[i]
// 散单:扁平行按订单ID匹配
if (String(this.getScanOrderId(row)) === target) {
const src = this.getScanOrderSource(row)
if (src && typeof src === 'object') {
src.is_reviewed = true
src.review_status = 'reviewed'
src.unreviewed_count = 0
src.reviewed_count = 1
}
const key = this.getReviewKeepKey(row)
if (key !== '') {
const exists = this.reviewedKeepList.some(
(entry) => this.getReviewKeepKey(entry.item) === key
)
if (!exists) {
this.reviewedKeepList.push({ item: row, index: i })
}
}
return
}
// 团购:波次下订单匹配(仅本地标记,波次整体保留由服务端刷新决定)
if (Array.isArray(row?.orders)) {
const sub = row.orders.find((o) => String(this.getScanOrderId(o)) === target)
if (sub) {
const src = this.getScanOrderSource(sub)
if (src && typeof src === 'object') {
src.is_reviewed = true
src.review_status = 'reviewed'
}
return
}
}
}
},
handleSingleReviewList() {
uni.showToast({ title: '散单复核列表', icon: 'none', silentVoice: true })
},
// 面单补打:先取打印数据(团购/散单模式区分),再发送到所选打印台
async handleRePrintLabel() {
// 未选中订单时提示
if (!this.hasSelection) {
uni.showToast({ title: '请先在左侧选择订单', icon: 'none', silentVoice: true })
return
}
// 未选择打印台时提示
if (!this.selectedPrinterId) {
uni.showToast({ title: '未选择打印台,无法补打', icon: 'none', silentVoice: true })
return
}
// 防止重复点击
if (this.printSending) {
return
}
this.printSending = true
uni.showLoading({ title: '补打处理中...' })
try {
// 1. 获取打印数据(团购:打印锁占用时先解锁再重新获取)
let waveGroups = []
if (this.scanListType === 'group') {
waveGroups = await this.fetchGroupWavePrintData(this.currentOrderHeader)
} else {
const orderId = this.getScanOrderId(this.currentOrderHeader)
if (orderId === '') {
throw new Error('未找到订单ID,无法补打')
}
const body = await getOrderPrintData({ order_ids: [Number(orderId)] })
const payload = this.extractPrintPayload(body)
waveGroups = this.normalizeWaveGroups(payload)
}
if (!waveGroups.length) {
throw new Error('未获取到可打印数据')
}
// 2. 发送打印
this.printRequestCode = this.buildPrintRequestCode()
const response = await sendPrint({
type: 'express',
printStationId: this.selectedPrinterId,
requestCode: this.printRequestCode,
data: { waveGroups },
})
// 成功判定(后端约定):flag=success 且 code=200;失败码 1001(不支持的打印类型)/504(打印任务发送失败)
const success =
response?.flag !== 'failure' &&
response?.code !== '500' &&
response?.code !== 500 &&
response?.code !== 1001 &&
response?.code !== 504
if (!success) {
throw new Error(response?.message || response?.msg || '打印发送失败')
}
uni.hideLoading()
uni.showToast({ title: '打印成功', icon: 'success' })
// 静默刷新左侧列表,同步服务端打印状态
this.handleRefresh(false)
} catch (error) {
uni.hideLoading()
uni.showToast({ title: '打印失败', icon: 'none' })
} finally {
this.printSending = false
this.scheduleScanInputFocus(150)
}
},
// 生成打印请求码(唯一)
buildPrintRequestCode() {
const timePart = Date.now().toString(36)
const randomPart = Math.random().toString(36).slice(2, 10)
return `PRINT_${timePart}_${randomPart}`
},
// 解析仓库ID:面单补打团单模式按接口约定 warehouse_id 须与用户上下文 store_id 一致。
// 优先取扫码结果记录值(本次会话上下文),兜底读本地存储(含 user.info 持久化的 store_id/warehouse_id)
resolveWarehouseId() {
const candidates = [
this.warehouseId,
uni.getStorageSync('warehouse_id'),
uni.getStorageSync('warehouseId'),
uni.getStorageSync('store_id'),
uni.getStorageSync('storeId'),
]
for (const value of candidates) {
const numeric = Number(value)
if (Number.isFinite(numeric) && numeric > 0) {
return numeric
}
}
return 0
},
// 从打印接口响应中提取数据体(兼容多层包裹结构)
extractPrintPayload(response) {
const candidates = [response?.data?.data, response?.data, response?.result, response]
for (const current of candidates) {
if (current && typeof current === 'object') {
return current
}
}
return {}
},
// 提取可打印的 waveGroups
normalizeWaveGroups(payload) {
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : []
return groups
.map((group) => (group && typeof group === 'object' ? group : null))
.filter((group) => !!group)
},
// 提取被打印锁占用的分组(已打印面单的数据)
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 转换为解锁分组条件(波次+平台+系统快递编码 组合为一个分组)
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)
},
// 团购模式:按分组解锁波次平台打印锁
async unlockGroupWavePrintLock(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))
)
return unlockWavePlatformPrintDataByGroup({
warehouse_id: warehouseId,
wave_ids: waveIds,
group_type: 'platform_express',
unlock_scope: 'group',
groups,
})
},
// 团购模式获取波次平台可打印数据;打印锁占用时先解锁再重新获取
async fetchGroupWavePrintData(item) {
const warehouseId = this.resolveWarehouseId()
if (!warehouseId) {
throw new Error('缺少仓库ID')
}
const waveId = String(this.getRowValue(item, ['wave_id', 'waveId', 'id']) || '').trim()
if (!waveId) {
throw new Error('未找到波次ID')
}
const requestData = async () => {
const body = await getWavePlatformPrintData({
warehouse_id: warehouseId,
wave_ids: [waveId],
})
return this.extractPrintPayload(body)
}
let payload = await requestData()
let waveGroups = this.normalizeWaveGroups(payload)
const lockedWaveGroups = this.extractLockedWaveGroups(payload)
// 打印锁占用:waveGroups 为空 + locked_wave_groups 有值 → 先解锁再重新获取
if (!waveGroups.length && lockedWaveGroups.length) {
try {
await this.unlockGroupWavePrintLock(lockedWaveGroups)
} catch (error) {
throw new Error(
`解锁打印锁失败:${String(error?.message || error?.msg || error?.errMsg || '请稍后重试')}`
)
}
payload = await requestData()
waveGroups = this.normalizeWaveGroups(payload)
}
return waveGroups
},
// 商品明细全部扫完(allProductsScanned)且“是否称重”下拉为“称重”时,
// 自动弹出称重(复核前)弹窗;保存重量后由 confirmWeigh 直接继续执行确认复核
autoOpenWeighAfterScan() {
// 团购模式:无论“是否称重”下拉,商品全部扫完都强制走称重流程;
// 散单模式:仍按“是否称重=称重”才自动弹称重(复核前)
if (this.scanListType !== 'group' && this.selectedWeigh !== '称重') {
return
}
// 避免与其它弹窗重叠、或在已复核/拦截锁定等状态下重复弹出
if (
this.weighDialogVisible ||
this.confirmReviewVisible ||
this.noBarcodeReviewVisible ||
this.batchReviewVisible
) {
return
}
if (!this.hasSelection || this.reviewLocked || this.interceptLocked) {
return
}
if (!this.allProductsScanned) {
return
}
// 团购模式:全部扫完 → 先弹“包材绑定”;
// 自动发货:绑定保存成功即触发复核;手动发货:绑定成功后再弹“称重(复核前)”
if (this.scanListType === 'group') {
if (this.settingBindPackage) {
const waybill = this.getWaveRepresentWaybill(this.currentOrderHeader)
if (waybill) {
const autoShip = this.settingShipMode === 'auto'
// 自动发货:绑定后直接复核,不再称重;手动发货:绑定后继续称重
this.pmPendingWeigh = !autoShip
this.pmAutoRecheck = autoShip
this.pmBindWaybill = waybill
this.resetPackageMaterialSearch()
const preset = this.recommendedAsMaterial()
if (preset) {
this.pmSelectedMaterial = preset
}
this.packageMaterialDialogVisible = true
return
}
}
}
// 复核前自动称重模式:标题显示“称重(复核前)”,保存后直接执行复核
this.weighReviewMode = true
this.weighInputValue = ''
this.weighDialogVisible = true
},
handleWeigh() {
// 未选中订单时提示先选择
if (!this.hasSelection) {
uni.showToast({ title: '请先在左侧选择订单', icon: 'none', silentVoice: true })
return
}
// 手动称重:非复核前自动称重模式,标题保持“称重”
this.weighReviewMode = false
this.weighInputValue = ''
this.weighDialogVisible = true
},
closeWeighDialog() {
this.weighDialogVisible = false
this.weighReviewMode = false
if (this.pmPostReviewWeighPending) {
// 复核后称重被取消:保留待称重状态,重新选中刚复核的波次,点商品行可再次弹称重(不再自动切下一波次)
this.reselectReviewedWave()
this.scheduleScanInputFocus(150)
return
}
this.pmAfterReviewWeighWaybill = ''
this.pmAfterReviewReviewKey = ''
this.pmPostReviewWeighPending = false
this.scheduleScanInputFocus(150)
},
// 包材绑定:仅团购波次,按波次首单运单号(first_waybill_no)绑定包材
handleAddPackageMaterial() {
if (!this.hasSelection) {
uni.showToast({ title: '请先在左侧选择订单', icon: 'none', silentVoice: true })
return
}
if (this.scanListType !== 'group') {
uni.showToast({ title: '仅团购波次支持包材绑定', icon: 'none', silentVoice: true })
return
}
const waybill = this.getWaveRepresentWaybill(this.currentOrderHeader)
if (!waybill) {
uni.showToast({ title: '未找到波次运单号,无法绑定包材', icon: 'none', silentVoice: true })
return
}
this.pmBindWaybill = waybill
this.pmPendingWeigh = false
this.pmAutoRecheck = false
this.resetPackageMaterialSearch()
// 有推荐包材:静默预选为待绑定包材(输入框保持原提示);直接点保存即绑定推荐包材,扫码可更换
const preset = this.recommendedAsMaterial()
if (preset) {
this.pmSelectedMaterial = preset
}
this.packageMaterialDialogVisible = true
},
// 把选中订单/波次的推荐包材(suggested_package_material)映射为可绑定的包材对象
recommendedAsMaterial() {
const info = this.selectedPackageMaterialInfo
if (!info || typeof info !== 'object') {
return null
}
const id = info.id ?? info.package_material_id
if (id === undefined || id === null || id === '') {
return null
}
return {
id,
material_code: info.code || info.material_code || '',
material_name: info.name || info.material_name || '',
material_type: info.type || info.material_type || '',
spec: info.spec || '',
}
},
resetPackageMaterialSearch() {
this.packageMaterialInput = ''
this.pmSearchList = []
this.pmSearching = false
this.pmSearched = false
this.pmBinding = false
this.pmSelectedMaterial = null
},
resetPackageMaterialDialog() {
this.packageMaterialDialogVisible = false
this.pmBindWaybill = ''
this.resetPackageMaterialSearch()
},
closePackageMaterialDialog() {
this.resetPackageMaterialDialog()
// 取消包材绑定:中断“绑定后继续称重/复核”的自动衔接
this.pmPendingWeigh = false
this.pmAutoRecheck = false
this.scheduleScanInputFocus(150)
},
// 扫描/输入包材条码回车 → 关键字搜索(setting.packageMaterial.search),唯一命中自动选中
async handlePackageMaterialSearch() {
const keyword = (this.packageMaterialInput || '').trim()
if (keyword === '') {
uni.showToast({ title: '请扫描或输入包材条码', icon: 'none', silentVoice: true })
return
}
if (this.pmSearching) {
return
}
this.pmSearching = true
this.pmSearched = false
try {
const body = await searchPackageMaterial({ keyword })
const payload = body?.data || body?.result || body || {}
const raw = Array.isArray(payload) ? payload : payload.list || payload.data || []
const list = Array.isArray(raw) ? raw : []
this.pmSearchList = list
this.pmSearched = true
if (list.length === 1) {
// 唯一命中:自动选中,并直接在输入框回显包材名称
const item = list[0]
this.pmSelectedMaterial = item
this.packageMaterialInput = item.material_name || item.material_code || keyword
this.pmSearchList = []
this.pmSearched = false
uni.showToast({ title: '数据一致', icon: 'none' })
} else if (list.length > 1) {
this.pmSelectedMaterial = null
uni.showToast({ title: `命中 ${list.length} 条,请选择`, icon: 'none', silentVoice: true })
} else {
this.pmSelectedMaterial = null
uni.showToast({ title: '无记录', icon: 'none' })
}
} catch (error) {
uni.showToast({ title: '包材搜索失败,请重试', icon: 'none', silentVoice: true })
} finally {
this.pmSearching = false
}
},
// 从搜索结果列表选择包材:选中后直接在输入框回显包材名称并收起列表
handlePackageMaterialSelect(item) {
if (!item) {
return
}
this.pmSelectedMaterial = item
this.packageMaterialInput = item.material_name || item.material_code || ''
this.pmSearchList = []
this.pmSearched = false
},
// 保存:按运单号绑定包材(order.bindExpressPackageMaterialByWaybill)
async confirmPackageMaterial() {
if (this.pmBinding) {
return
}
if (this.scanListType !== 'group') {
uni.showToast({ title: '仅团购波次支持包材绑定', icon: 'none', silentVoice: true })
return
}
const waybill = this.pmBindWaybill || this.getWaveRepresentWaybill(this.currentOrderHeader)
if (!waybill) {
uni.showToast({ title: '未找到波次运单号,无法绑定包材', icon: 'none', silentVoice: true })
return
}
// 未点选但搜索结果唯一命中时自动采用;仍未选时兜底采用推荐包材
let material = this.pmSelectedMaterial
if (!material && this.pmSearchList.length === 1) {
material = this.pmSearchList[0]
}
if (!material) {
material = this.recommendedAsMaterial()
}
const materialId = material?.id ?? material?.package_material_id
if (materialId === undefined || materialId === null || materialId === '') {
uni.showToast({ title: '请先扫描并选择包材', icon: 'none', silentVoice: true })
return
}
this.pmBinding = true
try {
const body = await bindExpressPackageMaterialByWaybill({
waybill_code: waybill,
package_material_id: materialId,
})
const payload = body?.data || body?.result || body || {}
const flagOk = body?.flag === 'success' || payload?.flag === 'success'
const code = body?.code ?? payload?.code
const codeOk = code === 200 || code === '200' || code === 1 || code === '1'
const hasData = !!body?.data || !!payload?.data || !!(body?.order_id ?? payload?.order_id)
if (!flagOk || !(codeOk || hasData)) {
const message = body?.message || body?.msg || payload?.message || payload?.msg || '包材绑定失败'
uni.showModal({
title: '包材绑定失败',
content: String(message),
showCancel: false,
confirmText: '确定',
})
return
}
uni.showToast({ title: '发货成功', icon: 'none' })
const autoRecheck = this.pmAutoRecheck
const continueWeigh = this.pmPendingWeigh
this.resetPackageMaterialDialog()
if (autoRecheck) {
// 团购自动发货:包材绑定保存即触发复核;复核成功后强制按本波次运单继续称重
this.pmAutoRecheck = false
this.pmPendingWeigh = false
// doConfirmRecheck 内部刷新会 clearSelection → clearPostReviewWeighState 清空暂存,
// 因此先用局部变量记录,复核完成后再回填,避免被刷新清掉导致不再弹称重
const reviewWaybill = this.getWaveRepresentWaybill(this.currentOrderHeader) || ''
const reviewKey = this.getReviewKeepKey(this.currentOrderHeader)
// 复核后先不自动切波次(称重完成后由 confirmWeigh 切换)
const reviewed = await this.doConfirmRecheck(false)
if (!reviewed) {
this.scheduleScanInputFocus(150)
return
}
if (reviewWaybill) {
// 复核后称重:普通称重(不再触发复核),保存成功后切下一未复核波次;
// 取消时保留待称重状态,点商品行可再次弹称重
this.pmAfterReviewWeighWaybill = reviewWaybill
this.pmAfterReviewReviewKey = reviewKey
this.pmPostReviewWeighPending = true
this.weighReviewMode = false
this.weighInputValue = ''
this.weighDialogVisible = true
} else {
this.scheduleScanInputFocus(150)
}
return
}
if (continueWeigh) {
// 团购手动发货:包材绑定成功后继续弹“称重(复核前)”,保存重量后走复核
this.pmPendingWeigh = false
this.weighReviewMode = true
this.weighInputValue = ''
this.weighDialogVisible = true
} else {
this.scheduleScanInputFocus(150)
}
} catch (error) {
uni.showToast({ title: '包材绑定失败,请重试', icon: 'none', silentVoice: true })
} finally {
this.pmBinding = false
}
},
handleWeighPlus() {
this.weighInputValue = String((Number(this.weighInputValue) || 0) + 1)
},
// ---- 设置弹窗 ----
openSettingsDialog() {
this.settingsVisible = true
},
closeSettingsDialog() {
this.settingsVisible = false
this.scheduleScanInputFocus(150)
},
// 页面进入时从本地存储加载设置项
loadSettings() {
const bind = uni.getStorageSync(SETTING_KEY_BIND_PACKAGE)
const kb = uni.getStorageSync(SETTING_KEY_PM_KEYBOARD)
const mode = uni.getStorageSync(SETTING_KEY_SHIP_MODE)
const rp = uni.getStorageSync(SETTING_KEY_REVIEW_PROCESS)
const wg = uni.getStorageSync(SETTING_KEY_WEIGH)
if (bind === 'on' || bind === 'off') {
this.settingBindPackage = bind === 'on'
}
if (kb === 'on' || kb === 'off') {
this.settingPmKeyboard = kb === 'on'
}
if (mode === 'auto' || mode === 'manual') {
this.settingShipMode = mode
}
if (rp === '先打印后复核' || rp === '先复核后打印' || rp === '不打印') {
this.selectedReviewProcess = rp
}
if (wg === '不称重' || wg === '称重') {
this.selectedWeigh = wg
}
},
setSettingBindPackage(val) {
this.settingBindPackage = !!val
uni.setStorageSync(SETTING_KEY_BIND_PACKAGE, this.settingBindPackage ? 'on' : 'off')
},
setSettingPmKeyboard(val) {
this.settingPmKeyboard = !!val
uni.setStorageSync(SETTING_KEY_PM_KEYBOARD, this.settingPmKeyboard ? 'on' : 'off')
},
setSettingShipMode(mode) {
this.settingShipMode = mode === 'auto' ? 'auto' : 'manual'
uni.setStorageSync(SETTING_KEY_SHIP_MODE, this.settingShipMode)
},
// 复核流程:先打印后复核 / 先复核后打印 / 不打印(原工具栏下拉,移至复核设置)
setReviewProcess(val) {
if (val === '先复核后打印' || val === '不打印') {
this.selectedReviewProcess = val
} else {
this.selectedReviewProcess = '先打印后复核'
}
uni.setStorageSync(SETTING_KEY_REVIEW_PROCESS, this.selectedReviewProcess)
},
// 称重模式:不称重 / 称重(原“是否称重”工具栏下拉,移至复核设置)
setWeighSetting(val) {
this.selectedWeigh = val === '称重' ? '称重' : '不称重'
uni.setStorageSync(SETTING_KEY_WEIGH, this.selectedWeigh)
},
handleWeighMinus() {
const value = Number(this.weighInputValue) || 0
this.weighInputValue = String(Math.max(0, value - 1))
},
async confirmWeigh() {
const weight = (this.weighInputValue || '').trim()
if (weight === '') {
uni.showToast({ title: '请输入称重重量', icon: 'none', silentVoice: true })
return
}
const numeric = Number(weight)
if (!Number.isInteger(numeric) || numeric <= 0) {
uni.showToast({ title: '重量必须为正整数(g)', icon: 'none', silentVoice: true })
return
}
// 团购模式按运单号提交(order_id=0);其余按订单 ID 提交
let params
if (this.scanListType === 'group') {
// 复核后强制称重(自动发货):优先用复核前记录的运单号;否则取当前选中波次运单
const waybillCode =
this.pmAfterReviewWeighWaybill || this.getWaveRepresentWaybill(this.currentOrderHeader)
if (!waybillCode) {
uni.showToast({ title: '未找到波次运单号,无法称重', icon: 'none', silentVoice: true })
return
}
params = {
order_id: 0,
waybill_code: waybillCode,
weighing_weight: numeric,
}
} else {
const orderId = this.getScanOrderId(this.currentOrderHeader)
if (orderId === '') {
uni.showToast({ title: '未找到订单ID,无法称重', icon: 'none', silentVoice: true })
return
}
params = {
order_id: orderId,
weighing_weight: numeric,
}
}
try {
const body = await updateExpressWeighingWeight(params)
const payload = body?.data || body?.result || body || {}
// 成功判定(实际接口约定):flag==='success' 且 code===200
const flagOk = body?.flag === 'success' || payload?.flag === 'success'
const codeOk =
body?.code === 200 ||
body?.code === '200' ||
payload?.code === 200 ||
payload?.code === '200'
if (!flagOk || !codeOk) {
const message =
body?.message || body?.msg || payload?.message || payload?.msg || '称重保存失败'
uni.showModal({
title: '称重失败',
content: String(message),
showCancel: false,
confirmText: '确定',
})
return
}
uni.showToast({ title: `保存成功:${numeric} g`, icon: 'none', silentVoice: true })
this.weighDialogVisible = false
// 复核前自动称重模式:保存成功后直接继续执行确认复核(不弹二次确认弹窗)
const shouldContinueReview = this.weighReviewMode
this.weighReviewMode = false
// 自动发货复核后称重成功:切到下一个未复核波次
const nextReviewKey = this.pmAfterReviewReviewKey
this.pmAfterReviewWeighWaybill = ''
this.pmAfterReviewReviewKey = ''
this.pmPostReviewWeighPending = false
if (shouldContinueReview) {
await this.doConfirmRecheck()
return
}
if (nextReviewKey) {
this.autoSelectNextPendingOrder(nextReviewKey)
}
this.scheduleScanInputFocus(150)
} catch (error) {
uni.showToast({ title: '保存失败,请重试', icon: 'none', silentVoice: true })
}
},
// 点击商品明细行(单击):
// ① 可无条码复核的行(未复核 + 本行未扫完)→ 弹确认窗:关闭 / 无条码复核
// ② 其余情况沿用原逻辑(复核后称重待完成 → 重新弹称重;否则走 autoOpenWeighAfterScan)
handleProductRowClick(order) {
if (!order) {
return
}
if (this.canNoBarcodeReview(order)) {
diagNote('no-barcode-review-open', {
item: order?.productName || order?.barcode || '',
source: 'click',
})
this.openNoBarcodeReview(order)
return
}
// 复核后称重待完成(团购自动发货,取消称重后):点商品行直接重新弹普通称重
if (this.pmPostReviewWeighPending) {
this.weighReviewMode = false
this.weighInputValue = ''
this.weighDialogVisible = true
return
}
this.autoOpenWeighAfterScan()
},
// 无条码复核:单击商品行弹窗确认(详见 handleProductRowClick),右键直接执行(见 handleNoBarcodeReviewDirect)
handleNoBarcodeReviewDirect(order) {
// 事件到没到、被哪个条件拦住,都留痕
diagNote('no-barcode-review-direct', {
item: order?.productName || order?.barcode || '',
locked: this.reviewLocked,
scanned: this.isProductScanned(order),
})
if (!order) {
return
}
// 已复核订单/波次(波次级锁定):禁止无条码复核
if (this.reviewLocked) {
diagDrop('无条码复核-blocked', { reason: 'review-locked' })
uni.showToast({ title: '该订单已复核,无法无条码复核', icon: 'none', silentVoice: true })
return
}
// 已扫完(数量>0 且已扫>=总数)的行:无条码复核无意义,直接不弹窗
if (this.isProductScanned(order)) {
diagDrop('无条码复核-blocked', { reason: 'already-scanned' })
uni.showToast({ title: '超出订单数', icon: 'none' })
return
}
this.openNoBarcodeReview(order)
this.confirmNoBarcodeReview()
},
// 本行能否无条码复核(单击弹窗与右键直执行共用同一判据)
canNoBarcodeReview(order) {
if (!order) {
return false
}
if (this.reviewLocked || this.isProductScanned(order)) {
return false
}
return (Number(order.quantity) || 0) > 0
},
// 打开无条码复核确认窗(不执行,等点“无条码复核”)
openNoBarcodeReview(order) {
this.noBarcodeReviewTarget = order
this.noBarcodeReviewVisible = true
},
// 商品是否已扫完(已扫数量 >= 总数,数量>0)
isProductScanned(order) {
const qty = Number(order?.quantity) || 0
const scanned = Number(order?.scannedQty) || 0
return qty > 0 && scanned >= qty
},
closeNoBarcodeReview() {
this.noBarcodeReviewVisible = false
this.noBarcodeReviewTarget = null
this.scheduleScanInputFocus(150)
},
confirmNoBarcodeReview() {
const target = this.noBarcodeReviewTarget
if (!target) {
this.closeNoBarcodeReview()
return
}
const total = Number(target.quantity) || 0
const scanned = Number(target.scannedQty) || 0
if (total <= 0) {
uni.showToast({ title: '该商品无数量,无法标记', icon: 'none', silentVoice: true })
return
}
if (scanned >= total) {
uni.showToast({ title: '超出订单数', icon: 'none' })
this.closeNoBarcodeReview()
return
}
// 将该商品已扫数量置为总数(无条码复核)
target.scannedQty = total
// 同步已扫/总数统计
this.syncDetailStats(this.currentOrderHeader, this.displayOrders)
this.speakDataConsistent(target)
this.closeNoBarcodeReview()
// 商品明细全部扫完时:按“是否称重=称重”自动进入称重(复核前)
this.autoOpenWeighAfterScan()
},
handlePrinterSelectStart() {
// 打印台列表为空时,重新拉取
if (this.printerList.length === 0) {
this.loadPrinters()
}
this.printerOpened = true
},
handlePrinterPickStart() {
this.printerOpened = true
},
handlePrinterPickEnd() {
this.printerOpened = false
},
handlePrinterChange(event) {
const printer = this.printerList[Number(event.detail.value)] || null
this.selectedPrinter = printer ? this.getPrinterName(printer) : ''
this.selectedPrinterId = printer ? this.getPrinterId(printer) : ''
this.printerOpened = false
},
handlePrinterCancel() {
this.printerOpened = false
},
getPrinterId(item) {
return item?.id ?? item?.printer_id ?? ''
},
getPrinterName(item) {
return item?.name || item?.printer_name || ''
},
// 拉取当前仓库打印台列表(print.getList)
async loadPrinters() {
try {
const body = await fetchPrintList({ page: 1, pageSize: 100 })
const payload = body?.data || body?.result || body || {}
const list = Array.isArray(payload?.list) ? payload.list : []
this.printerList = list
} catch (error) {
// 拉取失败时静默处理,打印台下拉为空
}
},
getScanOrderSource(item) {
if (item && typeof item === 'object' && item.detail && typeof item.detail === 'object') {
return item.detail
}
return item || {}
},
getScanOrderNo(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['waybill_no'])
},
getWaveIndex(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['wave_index', 'waveIndex'])
},
formatWaveIndex(item) {
const value = this.getWaveIndex(item)
return value !== '' ? `[${value}]` : '-'
},
getScanOrderId(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['id', 'order_id', 'orderId'])
},
getScanOrderKey(item) {
return this.getScanOrderNo(item) || this.getScanOrderId(item) || ''
},
formatWeight(value) {
if (value === undefined || value === null || value === '') {
return '-'
}
return String(value)
},
getWavePrintStatus(wave) {
// 打印状态:优先按 未打印数量 判断,其次按 已打印数量/标志位
const printedCount = this.getRowValue(wave, ['printed_count', 'printedCount'])
const unprintedCount = this.getRowValue(wave, ['unprinted_count', 'unprintedCount'])
if (unprintedCount !== '') {
return Number(unprintedCount) === 0 ? '已打印' : '未打印'
}
if (printedCount !== '') {
return Number(printedCount) > 0 ? '已打印' : '未打印'
}
const printed = this.getRowValue(wave, ['print_status', 'printStatus', 'is_printed', 'isPrinted'])
if (printed === true || printed === 1 || printed === '1' || printed === '是') {
return '已打印'
}
if (printed === false || printed === 0 || printed === '0' || printed === '否') {
return '未打印'
}
return '-'
},
getWaveReviewStatus(wave) {
// 复核状态:优先按 未复核数量 判断,其次按 已复核数量
const reviewedCount = this.getRowValue(wave, ['reviewed_count', 'reviewedCount'])
const unreviewedCount = this.getRowValue(wave, ['unreviewed_count', 'unreviewedCount'])
if (unreviewedCount !== '') {
return Number(unreviewedCount) === 0 ? '已复核' : '未复核'
}
if (reviewedCount !== '') {
return Number(reviewedCount) > 0 ? '已复核' : '未复核'
}
// 散单订单:按 is_reviewed 布尔/标志位判断
const reviewed = this.getRowValue(wave, ['is_reviewed', 'isReviewed'])
if (reviewed === true || reviewed === 1 || reviewed === '1' || reviewed === '是' || reviewed === 'Y' || reviewed === 'yes') {
return '已复核'
}
if (reviewed === false || reviewed === 0 || reviewed === '0' || reviewed === '否' || reviewed === 'N' || reviewed === 'no') {
return '未复核'
}
return this.getRowValue(wave, ['review_status', 'reviewStatus', 'wave_status', 'waveStatus']) || '-'
},
// 获取订单拦截状态(requested=已申请拦截 / intercepted_at_warehouse=仓库已拦截 / none=无)
getInterceptStatus(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['intercept_status', 'interceptStatus']) || ''
},
// 是否有拦截(intercept_status === 'requested')
isIntercepted(item) {
return this.getInterceptStatus(item) === 'requested'
},
// 是否已拦截(intercept_status === 'intercepted_at_warehouse')
isInterceptedDone(item) {
const status = this.getInterceptStatus(item)
return status === 'intercepted_at_warehouse' || status === 'intercepted'
},
// 统计团购波次下订单的拦截情况(wave.orders[] 携带 intercept_status)
getWaveInterceptCount(wave) {
const orders = Array.isArray(wave?.orders) ? wave.orders : []
let intercept = 0
let intercepted = 0
for (const order of orders) {
if (this.isIntercepted(order)) {
intercept += 1
} else if (this.isInterceptedDone(order)) {
intercepted += 1
}
}
return { intercept, intercepted }
},
// 团购波次拦截标志文案('' 表示无拦截);有已拦截订单优先显示"已拦截"
getWaveInterceptLabel(wave) {
const { intercept, intercepted } = this.getWaveInterceptCount(wave)
if (intercepted > 0) return '已拦截'
if (intercept > 0) return '拦截'
return ''
},
// 获取团购波次的代表运单号(优先 first_waybill_no 波次首张快递单号,兜底 scanOrder 返回的 waybill_no),供称重接口运单号模式使用
getWaveRepresentWaybill(wave) {
if (!wave || typeof wave !== 'object') {
return ''
}
// 优先:波次首张快递单号
const first = this.getRowValue(wave, ['first_waybill_no', 'firstWaybillNo'])
if (first !== '') {
return first
}
// 兜底:scanOrder 返回的 waybill_no
return this.getScanOrderNo(wave)
},
// 拦截成功后:本地将左侧列表对应订单行状态更新为已拦截
markRowIntercepted(orderId) {
if (orderId === '' || orderId === null || orderId === undefined) {
return
}
const target = String(orderId)
const mark = (row) => {
const rowId = this.getScanOrderId(row)
if (rowId !== '' && String(rowId) === target) {
const src = this.getScanOrderSource(row)
if (src && typeof src === 'object') {
src.intercept_status = 'intercepted_at_warehouse'
}
return true
}
return false
}
for (const row of this.scanOrderList) {
if (mark(row)) {
return
}
// 团购模式:波次下订单也可能携带拦截状态
if (row && Array.isArray(row.orders)) {
for (const order of row.orders) {
if (mark(order)) {
return
}
}
}
}
},
// 是否处于拦截/已拦截状态(不计入剩余未复核)
isInterceptExcluded(item) {
const status = this.getInterceptStatus(item)
return status === 'requested' || status === 'intercepted_at_warehouse' || status === 'intercepted'
},
// 剩余未复核数统计:排除拦截/已拦截订单
countUnreviewedExcludingIntercepted(list) {
const rows = Array.isArray(list) ? list : []
let count = 0
for (const row of rows) {
// 团购波次:波次下订单列表(orders[] 可识别订单级拦截状态)
const subOrders = Array.isArray(row?.orders) ? row.orders : []
if (subOrders.length > 0) {
const rowUnreviewed = Number(this.getRowValue(row, ['unreviewed_count', 'unreviewedCount'])) || 0
// 波次内被拦截(含已拦截)且未复核的订单数
const interceptedUnreviewed = subOrders.filter(
(o) => this.isInterceptExcluded(o) && this.getWaveReviewStatus(o) === '未复核'
).length
count += Math.max(0, rowUnreviewed - interceptedUnreviewed)
continue
}
// 散单订单:被拦截(含已拦截)的不计入未复核
if (this.isInterceptExcluded(row)) {
continue
}
if (this.getWaveReviewStatus(row) === '未复核') {
count += 1
}
}
return count
},
// 复核完成后本地联动左侧底部汇总(复核后不刷新列表,按当前 scanOrderList 重算剩余未复核)
refreshWaveSummary() {
const list = Array.isArray(this.scanOrderList) ? this.scanOrderList : []
this.waveUnreviewedCount = this.countUnreviewedExcludingIntercepted(list)
},
handleScanOrderClick(item) {
// 切换选中订单时退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
this.spokenRecheckKeys = []
this.resetSharedBarcodeState()
const src = this.getScanOrderSource(item)
this.selectedPendingOrderKey = this.getScanOrderKey(item)
this.selectedOrderNo = this.getScanOrderNo(item)
this.selectedItemsWeight = this.getRowValue(item, ['items_weight', 'itemsWeight'])
this.selectedWaveNo = this.getRowValue(item, ['wave_no', 'waveNo'])
this.selectedWaveIndex = this.getRowValue(item, ['wave_index', 'waveIndex'])
const pkg = this.getRowValue(item, ['suggested_package_material', 'suggestedPackageMaterial'])
this.selectedPackageMaterial = pkg ? this.formatPackageMaterial(pkg) : null
this.selectedPackageMaterialInfo = pkg && typeof pkg === 'object' ? pkg : null
// 直接使用接口行内自带的商品明细(散单:stock / stocks,单订单详情:items / detail.items)
const detailSource = this.getRowValue(item, ['detail'])
const inlineItems = Array.isArray(item?.items)
? item.items
: Array.isArray(item?.stock)
? item.stock
: Array.isArray(item?.stocks)
? item.stocks
: detailSource && Array.isArray(detailSource.items)
? detailSource.items
: null
this.currentOrderHeader = src
this.currentWaybillInfo = null
this.displayOrders = (inlineItems || []).map((inlineItem) => this.normalizeOrderDetailItem(inlineItem))
this.syncDetailStats(src, this.displayOrders)
// 该行有拦截标识时:点击行即进入拦截确认模式(顶部确认按钮变为"确认拦截")
if (this.isIntercepted(item)) {
const orderNo = this.getScanOrderNo(item) || this.getRowValue(src, ['order_id', 'orderId'])
this.interceptMode = true
this.interceptLocked = false
this.interceptTarget = {
orderNo,
orderId: this.getScanOrderId(item),
}
uni.showToast({ title: `已进入拦截确认:${orderNo}`, icon: 'none', silentVoice: true })
return
}
// 已拦截订单:进入拦截锁定态,确认拦截按钮禁用,不可再次拦截
if (this.isInterceptedDone(item)) {
const orderNo = this.getScanOrderNo(item) || this.getRowValue(src, ['order_id', 'orderId'])
this.interceptMode = true
this.interceptLocked = true
this.interceptTarget = {
orderNo,
orderId: this.getScanOrderId(item),
}
uni.showToast({ title: '此单已拦截', icon: 'none' })
}
},
getWaveKey(wave) {
return String(this.getRowValue(wave, ['wave_id', 'waveId', 'wave_no', 'waveNo']) || '')
},
formatPackageMaterial(value) {
if (!value) {
return null
}
if (typeof value === 'object') {
const name = value.name || value.code || ''
const type = value.type ? `(${value.type})` : ''
return name ? `${name}${type}` : String(value)
}
return String(value)
},
handleWaveClick(wave) {
// 团购模式:点击波次在右侧展示该波次的商品明细(stocks);切换时退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
this.spokenRecheckKeys = []
this.resetSharedBarcodeState()
this.selectedWaveKey = this.getWaveKey(wave)
// 复核后称重待完成:切到其它波次时取消该状态(避免残留自动弹称重)
if (
this.pmPostReviewWeighPending &&
this.getReviewKeepKey(wave) !== this.pmAfterReviewReviewKey
) {
this.clearPostReviewWeighState()
}
this.selectedPendingOrderKey = ''
this.selectedOrderNo = this.getRowValue(wave, ['wave_no', 'waveNo']) || ''
this.selectedItemsWeight = this.getRowValue(wave, ['items_weight', 'itemsWeight'])
const pkg = this.getRowValue(wave, ['suggested_package_material', 'suggestedPackageMaterial'])
this.selectedPackageMaterial = pkg ? this.formatPackageMaterial(pkg) : null
this.selectedPackageMaterialInfo = pkg && typeof pkg === 'object' ? pkg : null
this.currentOrderHeader = wave
this.currentWaybillInfo = null
// scanTask 团购模式波次视图使用 orders[],兼容 scanOrder 的 stocks[]
const stocks = Array.isArray(wave.stocks)
? wave.stocks
: Array.isArray(wave.orders)
? wave.orders
: []
this.displayOrders = stocks.map((stock) => this.normalizeOrderDetailItem(stock))
this.syncDetailStats(wave, this.displayOrders)
// 已复核波次:商品明细统一置为全部已扫(复核后重选/取消称重重选该波次时保持已扫状态,
// 避免长按商品行误弹“无条码复核”)
if (this.getWaveReviewStatus(wave) === '已复核') {
this.markAllProductsScanned()
}
// 团购波次含拦截单:进入时播报「有拦截订单」
if (this.getWaveInterceptLabel(wave)) {
uni.showToast({ title: '有拦截订单', icon: 'none' })
}
},
// 将当前商品明细全部置为已扫(已复核/复核后重选波次展示用)
markAllProductsScanned() {
const rows = this.displayOrders || []
rows.forEach((row) => {
const qty = Number(row?.quantity) || 0
if (qty > 0) {
row.scannedQty = qty
}
})
if (rows.length > 0) {
this.syncDetailStats(this.currentOrderHeader, rows)
}
},
},
mounted() {
this.loadPrinters()
this.loadSettings()
// 扫码枪识别:真机/H5 双链路(隐藏 input + plus.key + DOM 全局监听)
this.setupScanCaptureMode()
this.attachPlusKeyboardListener()
this.attachGlobalKeyboardListener()
this.suppressSoftKeyboardBurst()
this.scheduleScanInputFocus(260)
// 页面进入即聚焦搜索框(H5 无隐藏捕获时)
this.$nextTick(() => {
if (!this.enableHiddenInputCapture) {
this.activateSearchInput()
}
})
},
activated() {
// keep-alive 从其它页切回时:恢复扫码链路与隐藏 input 焦点
this.pageActive = true
this.setupScanCaptureMode()
this.attachPlusKeyboardListener()
this.attachGlobalKeyboardListener()
this.suppressSoftKeyboardBurst()
this.scheduleScanInputFocus(260)
},
deactivated() {
// keep-alive 切到其它页时:暂停扫码链路,避免隐藏 input 抢占其它页焦点
this.pageActive = false
this.removePlusKeyboardListener()
this.removeGlobalKeyboardListener()
this.clearScanFocusResumeTimer()
this.clearKeyboardSuppressTimers()
this.clearHiddenScanTimer()
this.clearPlusKeyTimer()
this.clearHiddenRefocusTimer()
this.scanHiddenFocused = false
this.scanInputFocus = false
},
beforeUnmount() {
this.pageActive = false
this.onResizeEnd()
this.removePlusKeyboardListener()
this.removeGlobalKeyboardListener()
this.clearScanFocusResumeTimer()
this.clearKeyboardSuppressTimers()
this.clearHiddenScanTimer()
this.clearPlusKeyTimer()
this.clearHiddenRefocusTimer()
// 清理扫码静默防抖定时器,避免泄漏
if (this.scanTimer) {
clearTimeout(this.scanTimer)
this.scanTimer = null
}
},
}
</script>
<script module="remInject" lang="renderjs">
import { applyRemBase } from '../../render-common/rem-base.js'
export default {
mounted() {
// #ifndef APP-PLUS
// rem 基准统一走 render-common/rem-base.js(满格 1rem = 100px,>1280 宽不再放大字体),
// 字号偏大靠改 CSS 的 font-size 值(已全局 ×0.85),不动基准
// 各页面不再各算一份,避免系数漂移
// 真机(APP-PLUS)rem 由 App.vue 全局纯 CSS(html { font-size: 7.8125vw !important }=100/1280)承担。
// ⚠️ 这里用 #ifndef,不要写成 `#ifdef APP-PLUS + return`:后者会让 esbuild 报
// “semicolon-after-return”,且以后往 mounted 里补的视图层代码会变成真机永不执行。
this._remResizeHandler = applyRemBase
applyRemBase()
window.addEventListener('resize', this._remResizeHandler)
// #endif
},
beforeDestroy() {
if (this._remResizeHandler) {
window.removeEventListener('resize', this._remResizeHandler)
this._remResizeHandler = null
}
}
}
</script>
<style>
/* 基准(src/styles/base.css 的 .page):box-sizing / flex: 1 / min-height: 0 / display: flex /
flex-direction: column / 底色,本页只写差异项 */
.page {
height: 100%;
overflow: hidden;
}
/* 隐藏扫码输入框:样式在全局基准 src/styles/base.css */
/* 基准(src/styles/base.css 的 .page-main):box-sizing / flex: 1 / min-height: 0 /
display: flex / flex-direction: column / 四周内间距(上 0.05、左右下 0.25),本页只写差异项 */
.page-main {
overflow-y: auto;
}
/* 订单复核页:锁定高度链,仅列表区内部滚动,页面不整体滚动 */
.page-main.order-review-one {
overflow: hidden;
}
.page-main.order-review-one > .container {
height: 100%;
min-height: 0;
flex: 1 1 0;
overflow: hidden;
}
.order-review-one {
width: 100%;
}
.container {
background: var(--wms-page-bg);
border-radius: 0.13rem;
margin: 0;
/* 内间距归零:到页边的留白由 .page-main 的 --wms-page-pad 统一负责,避免叠加成 35px */
padding: 0;
width: 100%;
min-height: 100%;
flex: 1 1 auto;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.content-panel {
display: flex;
align-items: stretch;
/* 左右面板间距由 .panel-left 的 margin-right 提供(与另外两页一致) */
flex: 1;
min-height: 0;
background-color: var(--wms-page-bg);
}
.panel-left {
/* 窄侧栏:与退件/打包页统一为 380px(3.8rem,约占设计宽 1280 的 30%);
整列透明(灰底,与右栏一致),内容自己做成白卡片(搜索 / 列表 / 底部信息栏),
风格对齐退件页左栏(灰底 + 白 .rp-card)。留白由卡片自己的内边距提供,
故这里不再写 border-right / padding-right,可用内容宽 = 380px */
width: 3.8rem;
flex-shrink: 0;
margin-right: var(--wms-panel-gap);
display: flex;
flex-direction: column;
}
.panel-right {
flex: 1;
min-width: 0;
background-color: var(--wms-page-bg);
display: flex;
flex-direction: column;
}
.left-reviewed-list {
margin-top: 0.1rem;
max-height: 9.01rem;
}
.left-reviewed-list--current-wave {
margin-top: 0;
flex: 1;
min-height: 0;
max-height: none;
}
.left-reviewed-list--current-wave-body {
width: 100%;
min-height: 0;
height: 100%;
}
.search-bar {
display: flex;
align-items: center;
gap: 0.15rem;
/* 白卡片(与退件页左栏同风格);卡片间距用 margin-bottom,与 .scan-qty-bar 一致 */
padding: 0.15rem;
box-sizing: border-box;
background-color: var(--wms-card-bg);
border-radius: 0.07rem;
margin-bottom: 0.15rem;
}
.scan-qty-bar {
display: flex;
align-items: center;
justify-content: space-between;
/* 左栏 380px 下这一行放不下:允许换行(必要时步进器掉到第二行),避免横向溢出 */
flex-wrap: wrap;
gap: 0.1rem;
margin-bottom: 0.15rem;
padding: 0.1rem 0.15rem;
background-color: var(--wms-card-bg);
border-radius: 0.07rem;
}
.scan-qty-text {
font-size: 0.18rem;
color: var(--wms-text);
}
.scan-qty-label {
font-size: 0.2rem;
font-weight: 600;
color: var(--wms-white);
background-color: var(--wms-warning);
/* 左栏 380px:内边距由 0.1965 收到 0.0982,为步进器让出宽度 */
padding: 0.05rem 0.1rem;
border-radius: 0.07rem;
}
.scan-qty-stepper {
display: flex;
align-items: center;
gap: 0.05rem;
}
.scan-qty-btn {
/* 控件 36px(正方形步进按钮) */
width: 0.36rem;
height: 0.36rem;
display: flex;
align-items: center;
justify-content: center;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
background-color: var(--wms-card-bg);
color: var(--wms-text);
font-size: 0.22rem;
user-select: none;
}
.scan-qty-btn:active {
background-color: #f0f2f5;
}
.scan-qty-input {
/* 左栏 380px:0.9011 → 0.6rem,保证“复核扫描 + 数量步进器”能在一行内放下 */
width: 0.6rem;
height: 0.36rem; /* 控件 36px */
text-align: center;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
font-size: 0.2rem;
background-color: var(--wms-card-bg);
}
.search-input {
flex: 1;
height: 0.36rem;
border: 0.01rem solid #e5e5e5;
border-radius: 0.07rem;
padding: 0 0.15rem;
font-size: 0.2rem;
background-color: var(--wms-card-bg);
}
.table-scroll {
width: 100%;
}
.table-scroll--detail {
max-height: none;
}
.table-scroll--detail-body {
flex: 1;
min-height: 0;
height: 100%;
}
.table-wrap {
min-width: 8.03rem;
}
.table-wrap--current-wave {
/* 左栏 380px 下卡片满宽:四列实际合计 ≈ 340px(再减滚动条),留白由卡片内边距提供 */
min-width: 3.4rem;
}
.table-wrap--current-wave-sticky {
/* 列表(表头 + 行)一起做成一张白卡片:圆角 + overflow 裁掉表头/行的直角 */
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
box-sizing: border-box;
background-color: var(--wms-card-bg);
border-radius: 0.07rem;
/* 卡片间距全由上方卡片的 margin-bottom 提供(flex 下外边距不合并) */
margin-top: 0;
}
.table-wrap--current-wave-sticky .table-header {
flex-shrink: 0;
}
.table-wrap--detail-sticky {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow-x: auto;
}
.empty-panel {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border: 0.01rem solid #e6ebf5;
border-radius: 0.07rem;
background-color: var(--wms-card-bg);
color: var(--wms-text-placeholder);
font-size: 0.2rem;
}
.empty-panel--left {
/* 卡片间距全由上方卡片的 margin-bottom 提供 */
margin-top: 0;
flex: 1;
min-height: 0;
align-items: flex-start;
padding-top: 0.35rem;
}
.left-summary-bar {
display: flex;
align-items: center;
/* 左栏 380px 下这一行放不下:允许换行(必要时刷新按钮掉到第二行),避免横向溢出 */
flex-wrap: wrap;
gap: 0.1rem;
/* 左栏改灰底后,底部信息栏独立成一张白卡片(不再贴分栏线,故无负边距与上下分隔线) */
margin-top: 0.15rem;
padding: 0.1rem 0.15rem;
box-sizing: border-box;
background-color: var(--wms-card-bg);
border-radius: 0.07rem;
}
.left-summary-text {
font-size: 0.18rem;
color: var(--wms-text);
}
.left-summary-sep {
font-size: 0.18rem;
color: var(--wms-border-strong);
}
.left-summary-num {
font-weight: 700;
color: var(--wms-primary);
}
.left-summary-num--orange {
color: var(--wms-warning);
}
.left-summary-refresh {
margin: 0 0 0 auto;
flex-shrink: 0;
height: 0.36rem; /* 控件 36px */
line-height: 0.36rem;
padding: 0 0.15rem;
font-size: 0.17rem;
border-radius: 0.07rem;
background-color: var(--wms-primary);
color: var(--wms-white);
}
.empty-panel--right-inline {
flex: 1;
min-height: 0;
min-width: 8.03rem;
border-top: none;
}
.table-wrap--detail-sticky .table-header,
.table-wrap--detail-sticky .table-body {
min-width: 8.03rem;
}
.table-wrap--detail-sticky .table-header {
flex-shrink: 0;
}
.table-scroll--detail-body {
flex: 1;
min-height: 0;
}
.table-wrap--detail .table-cell {
align-self: stretch;
display: flex;
align-items: center;
border-right: 0.01rem solid var(--wms-border-strong);
box-sizing: border-box;
position: relative;
}
.col-resizer {
position: absolute;
top: 0;
right: -0.05rem;
width: 0.11rem;
height: 100%;
cursor: col-resize;
z-index: 3;
user-select: none;
}
.table-wrap--detail .table-header,
.table-wrap--detail .table-body {
border-color: var(--wms-border-strong);
}
.table-wrap--detail .table-row {
border-top-color: var(--wms-border-strong);
}
/* 明细表左侧边线与右侧一致(1rpx #d0d5e0),数据行去掉占位边框保持对齐 */
.table-wrap--detail .table-header {
border-left: 0.01rem solid var(--wms-border-strong);
}
.table-wrap--detail .table-row {
border-left: none;
}
.table-wrap--detail .table-body {
border-left: 0.01rem solid var(--wms-border-strong);
}
.table-wrap--detail .table-cell:last-child {
border-right: none;
}
/* 商品明细数据行:内容过长时换行显示完整(不再单行省略) */
.table-wrap--detail .table-body .table-cell {
white-space: normal;
overflow: visible;
text-overflow: clip;
word-break: break-all;
line-height: 1.4;
padding-top: 0.1rem;
padding-bottom: 0.1rem;
}
.table-header,
.table-row {
display: flex;
align-items: center;
}
.table-header {
height: 0.52rem;
border: 0.01rem solid #e6ebf5;
border-bottom: none;
border-left: 0.05rem solid transparent;
background-color: #f6f8fc;
}
.table-header .table-cell {
font-weight: 700;
color: var(--wms-text-secondary);
}
.table-header--sticky {
/* 老 WebView 只认带前缀的 sticky(新 Chrome 前缀也有效、无副作用) */
position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 2;
}
.table-body {
border: 0.01rem solid #e6ebf5;
}
.table-row {
min-height: 0.56rem;
border-top: 0.01rem solid #eef2f8;
border-left: 0.05rem solid transparent;
box-sizing: border-box;
/* 行内文字不允许选中:单击/右键就是操作(无条码复核),
免得 Android 上轻点/长按先弹文字选择把手、或右键先弹系统菜单 */
user-select: none;
-webkit-user-select: none;
}
.table-row:first-child {
border-top: none;
}
.table-row--alt {
background-color: #fafafa;
}
/* 已扫商品行(已扫数量>=总数):绿色背景高亮,字体白色 */
.detail-row--scanned {
background-color: var(--wms-success);
}
.detail-row--scanned .table-cell {
color: var(--wms-white);
}
.table-row--selected {
background-color: #a6c8ff;
}
.table-cell {
padding: 0 0.1rem;
font-size: 0.2rem;
color: var(--wms-text);
line-height: 1.4;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.cell-barcode {
flex: 1;
min-width: 0;
}
.cell-name {
flex: 1;
min-width: 0;
}
.cell-scanned {
width: 1.23rem;
justify-content: center;
font-weight: 700;
}
.cell-total {
width: 1.23rem;
justify-content: center;
font-weight: 700;
}
.cell-basket {
width: 1.15rem;
justify-content: center;
}
/* 仅商品明细表体数值单元格(篮号/总数/已扫)加大字号,表头标题不变 */
.table-wrap--detail .table-body .cell-basket,
.table-wrap--detail .table-body .cell-total,
.table-wrap--detail .table-body .cell-scanned {
font-size: 0.22rem;
}
.cell-spec {
flex: 0.6;
min-width: 0;
}
.cell-image {
width: 1.23rem;
justify-content: center;
}
.item-image {
width: 0.59rem;
height: 0.59rem;
border-radius: 0.07rem;
background-color: #f2f4f8;
margin: 0.05rem 0;
}
.cell-image-empty {
color: var(--wms-text-placeholder);
}
.cell-pack {
flex: 1;
min-width: 0;
}
.cell-pack-value {
color: var(--wms-danger-strong);
background-color: #fdecea;
}
/* 已扫行(绿底白字)也统一显示:打包要求值保持红字 + 浅红底 */
.detail-row--scanned .cell-pack-value {
color: var(--wms-danger-strong);
}
.cell-index {
width: 0.98rem;
}
.cell-pending-order {
flex: 1;
min-width: 0;
}
.cell-weight {
width: 1.07rem;
}
.cell-review-status {
/* 四列按 380px 面板重新配平:状态 72 / 序号 50 / 运单号(弹性)/ 打印状态 72 */
width: 0.72rem;
}
.cell-wave-index {
width: 0.5rem;
}
/* 散单行:复核状态、波次序号、运单号三列间隔 8rpx */
.scan-row .cell-review-status {
padding-right: 0;
margin-right: 0.05rem;
}
.scan-row .cell-wave-index {
padding-left: 0;
padding-right: 0;
margin-right: 0.05rem;
}
/* 运单号为弹性列:默认单行完整显示;左栏收窄到 380px 后列宽只剩约 120px,
13 位单号改为按需换行(与拦截行一致),保证号码完整可读 */
.scan-row .cell-wave-no {
padding-left: 0;
min-width: 0.9rem;
white-space: normal;
overflow: visible;
text-overflow: clip;
word-break: break-all;
}
/* 有拦截标志的行(散单订单/团购波次):运单号列被拦截标签挤压,长号换行显示完整 */
.scan-row--intercept .cell-wave-no {
white-space: normal;
overflow: visible;
text-overflow: clip;
word-break: break-all;
}
/* 已复核行:整行字体灰色 */
.scan-row--reviewed .table-cell {
color: var(--wms-text-placeholder);
}
.cell-review-status--unreviewed {
color: var(--wms-warning);
}
.cell-wave-no {
flex: 1;
min-width: 0;
padding-left: 0.04rem;
white-space: nowrap;
overflow: visible;
}
.cell-print-status {
width: 0.72rem;
text-align: right;
padding-right: 0.2rem;
}
.cell-print-status--unprinted {
color: #34c759;
}
/* 左侧列表:拦截标识(intercept_status=requested 时显示;点击整行进入拦截确认) */
.cell-intercept {
flex-shrink: 0;
height: 0.36rem; /* 控件 36px */
line-height: 0.36rem;
padding: 0 0.15rem;
margin: 0 0.1rem 0 0.04rem;
font-size: 0.17rem;
color: var(--wms-white);
background-color: var(--wms-danger-strong);
border-radius: 0.07rem;
user-select: none;
}
/* 已拦截状态(intercept_status=intercepted_at_warehouse):灰色标签,区别于待确认的红色拦截 */
.cell-intercept--done {
background-color: var(--wms-text-muted);
}
/* 称重/复核/批量弹窗共用遮罩
z-index 取 998:uni-app H5 内置 toast(uni-toast)z-index 为 999,
若遮罩 >999 会把弹窗内 uni.showToast 提示盖住看不到,故需低于 999 */
.weigh-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.45);
display: flex;
align-items: center;
justify-content: center;
z-index: 998;
}
.weigh-dialog {
width: 5.49rem;
max-width: 92%;
background-color: var(--wms-card-bg);
border-radius: 0.13rem;
box-shadow: 0 0.07rem 0.33rem rgba(0, 0, 0, 0.18);
overflow: hidden;
display: flex;
flex-direction: column;
}
/* 复核设置弹窗:加宽,便于三个复核流程选项单行放下 */
.weigh-dialog--settings {
width: 7.05rem;
max-width: 96%;
}
.weigh-dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.25rem 0.25rem 0.15rem;
border-bottom: 0.01rem solid #eef2f8;
}
.weigh-dialog-title {
font-size: 0.22rem;
font-weight: 700;
color: var(--wms-text);
}
.weigh-dialog-close {
font-size: 0.21rem;
color: var(--wms-text-placeholder);
padding: 0.05rem;
cursor: pointer;
user-select: none;
}
.weigh-dialog-body {
padding: 0.2rem 0.25rem;
}
.weigh-info-row {
display: flex;
align-items: center;
gap: 0.15rem;
padding: 0.1rem 0;
}
.weigh-info-label {
width: 1.15rem;
flex-shrink: 0;
font-size: 0.18rem;
color: var(--wms-text-muted);
}
.weigh-info-value {
flex: 1;
min-width: 0;
font-size: 0.25rem;
color: var(--wms-text);
word-break: break-all;
}
/* 包材绑定弹窗:扫描输入行 */
.pm-scan-row {
display: flex;
margin-top: 0.15rem;
}
/* 包材绑定弹窗:搜索结果列表 */
.pm-tip {
margin-top: 0.1rem;
font-size: 0.17rem;
color: var(--wms-text-muted);
text-align: center;
}
.pm-result-scroll {
max-height: 2.46rem;
margin-top: 0.15rem;
border: 0.01rem solid #e6ebf5;
border-radius: 0.07rem;
box-sizing: border-box;
}
.pm-result-item {
display: flex;
align-items: center;
gap: 0.1rem;
padding: 0.1rem 0.15rem;
border-bottom: 0.01rem solid #f0f2f6;
cursor: pointer;
}
.pm-result-item:last-child {
border-bottom: none;
}
.pm-result-item--active {
background-color: #eaf2ff;
}
/* 库内有相同商品弹窗:匹配商品列表 */
.shared-barcode-list {
max-height: 2.8rem;
border: 0.01rem solid #e6ebf5;
border-radius: 0.07rem;
box-sizing: border-box;
}
.shared-barcode-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.1rem;
padding: 0.12rem 0.15rem;
border-bottom: 0.01rem solid #f0f2f6;
cursor: pointer;
}
.shared-barcode-item:last-child {
border-bottom: none;
}
.shared-barcode-item--active {
background-color: #eaf2ff;
}
.shared-barcode-thumb {
flex-shrink: 0;
width: 0.72rem;
height: 0.72rem;
border-radius: 0.07rem;
overflow: hidden;
background-color: #f2f4f8;
}
.shared-barcode-image {
width: 100%;
height: 100%;
}
.shared-barcode-image-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.44rem;
color: #c0c4cc;
background-color: #f2f4f8;
}
.shared-barcode-main {
display: flex;
flex-direction: column;
min-width: 0;
flex: 1;
}
.shared-barcode-name {
font-size: 0.26rem;
font-weight: 600;
color: var(--wms-text);
line-height: 1.4;
word-break: break-all;
}
.shared-barcode-code {
font-size: 0.24rem;
color: #000000;
margin-top: 0.04rem;
line-height: 1.4;
word-break: break-all;
}
.shared-barcode-spec {
font-size: 0.2rem;
color: #000000;
margin-top: 0.04rem;
line-height: 1.4;
word-break: break-all;
}
.shared-barcode-qty {
font-size: 0.2rem;
color: var(--wms-warning);
margin-top: 0.02rem;
line-height: 1.4;
word-break: break-all;
}
/* 共享条码商品图片全屏预览 */
.shared-img-preview-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.92);
z-index: 9999;
overflow: hidden;
}
.shared-img-preview-stage {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
}
.shared-img-preview-img {
width: 90%;
height: 90%;
transform-origin: center center;
will-change: transform;
}
.shared-img-preview-hint {
position: absolute;
bottom: 0.5rem;
left: 50%;
transform: translateX(-50%);
padding: 0.06rem 0.16rem;
font-size: 0.24rem;
color: rgba(255, 255, 255, 0.75);
background-color: rgba(0, 0, 0, 0.4);
border-radius: 0.3rem;
pointer-events: none;
white-space: nowrap;
}
.shared-img-preview-close {
position: absolute;
top: 0.3rem;
right: 0.3rem;
width: 0.6rem;
height: 0.6rem;
line-height: 0.6rem;
text-align: center;
font-size: 0.36rem;
color: #ffffff;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 50%;
z-index: 2;
}
.pm-result-main {
display: flex;
flex-direction: column;
min-width: 0;
flex: 1;
}
.pm-result-name {
font-size: 0.2rem;
font-weight: 600;
color: var(--wms-text);
}
.pm-result-code {
font-size: 0.15rem;
color: var(--wms-text-muted);
margin-top: 0.02rem;
}
.pm-result-meta {
display: flex;
align-items: center;
gap: 0.1rem;
flex-shrink: 0;
}
.pm-result-tag {
font-size: 0.15rem;
color: var(--wms-warning);
background-color: #fff3e6;
padding: 0.02rem 0.1rem;
border-radius: 0.13rem;
}
.pm-result-spec {
font-size: 0.15rem;
color: var(--wms-text-muted);
}
.pm-result-check {
flex-shrink: 0;
color: var(--wms-primary);
font-size: 0.21rem;
font-weight: 700;
}
/* 设置弹窗 */
.setting-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.15rem;
padding: 0.15rem 0.04rem;
border-bottom: 0.01rem solid #f0f2f6;
}
.setting-row:last-child {
border-bottom: none;
}
.setting-row-label {
flex-shrink: 0;
font-size: 0.22rem;
color: var(--wms-text);
}
.setting-seg {
display: flex;
align-items: center;
flex-wrap: wrap;
row-gap: 0.05rem;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
overflow: hidden;
}
.setting-seg-item {
padding: 0.05rem 0.25rem;
font-size: 0.21rem;
color: var(--wms-text-secondary);
background-color: var(--wms-card-bg);
cursor: pointer;
user-select: none;
border-left: 0.01rem solid var(--wms-border-alt);
white-space: nowrap;
}
.setting-seg-item:first-child {
border-left: none;
}
.setting-seg-item--on {
background-color: var(--wms-primary);
color: var(--wms-white);
}
/* 复核流程:三个选项单行均分显示,间隔加大,不换行 */
.setting-seg--nowrap {
flex-wrap: nowrap;
gap: 0.1rem;
}
.setting-seg--nowrap .setting-seg-item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 0.05rem 0.05rem;
text-align: center;
border-left: none;
}
.weigh-label-inline {
display: flex;
align-items: center;
gap: 0.05rem;
flex-shrink: 0;
margin-right: 0.05rem;
}
.weigh-required {
color: var(--wms-danger-strong);
font-size: 0.21rem;
line-height: 1;
}
.weigh-input-label {
font-size: 0.2rem;
color: var(--wms-text);
}
.weigh-stepper {
display: flex;
align-items: center;
gap: 0.05rem;
}
.weigh-step-btn {
flex-shrink: 0;
/* 不写死宽度:高度取控件 36px,宽度由内容(− / +)+ 左右内边距自然撑开 */
height: 0.36rem;
padding: 0 0.15rem;
display: flex;
align-items: center;
justify-content: center;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
background-color: var(--wms-card-bg);
color: var(--wms-text);
font-size: 0.25rem;
user-select: none;
}
.weigh-step-btn:active {
background-color: #f0f2f5;
}
.weigh-input {
flex: 1;
min-width: 0;
height: 0.36rem;
text-align: center;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
font-size: 0.3rem;
color: var(--wms-text);
background-color: var(--wms-card-bg);
}
/* 输入提示(placeholder)保持小字号浅色,不随输入值放大(uni-app placeholder-class 生效于各端) */
.weigh-input-placeholder {
font-size: 0.2rem;
color: var(--wms-text-placeholder);
}
.weigh-input-unit {
flex-shrink: 0;
font-size: 0.18rem;
color: var(--wms-text-muted);
}
.weigh-dialog-footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 0.15rem;
padding: 0.15rem 0.25rem 0.25rem;
border-top: 0.01rem solid #eef2f8;
}
.weigh-btn {
height: 0.36rem;
line-height: 0.36rem;
padding: 0 0.3rem;
margin: 0;
font-size: 0.2rem;
border-radius: 0.07rem;
}
.weigh-btn--cancel {
background-color: var(--wms-card-bg);
color: var(--wms-text-secondary);
border: 0.01rem solid var(--wms-border-alt);
}
.weigh-btn--confirm {
background-color: var(--wms-primary);
color: var(--wms-white);
}
.weigh-btn--close {
background-color: var(--wms-text-muted);
color: var(--wms-white);
}
/* 无条码复核弹窗内容 */
.no-barcode-review-content {
padding: 0.05rem 0.04rem;
}
.no-barcode-review-title {
font-size: 0.21rem;
color: var(--wms-text);
line-height: 1.5;
word-break: break-all;
}
.no-barcode-review-count {
display: flex;
align-items: center;
gap: 0.15rem;
margin-top: 0.15rem;
padding: 0.15rem 0.15rem;
background-color: #f6f8fc;
border-radius: 0.07rem;
}
.no-barcode-review-count-item {
font-size: 0.18rem;
color: var(--wms-text-muted);
}
.no-barcode-review-count-item--done {
color: var(--wms-primary);
font-weight: 700;
}
.no-barcode-review-arrow {
font-size: 0.18rem;
color: var(--wms-text-disabled);
}
/* 确认复核弹窗内容 */
.confirm-review-content {
padding: 0.05rem 0.04rem;
}
.confirm-review-text {
font-size: 0.21rem;
color: var(--wms-text);
line-height: 1.5;
word-break: break-all;
}
/* 批量快捷复核弹窗 */
.batch-dialog {
width: 9.01rem;
max-width: 96%;
}
.batch-review-desc {
font-size: 0.18rem;
color: var(--wms-text-secondary);
line-height: 1.6;
}
.batch-review-label {
margin-top: 0.15rem;
font-size: 0.2rem;
color: var(--wms-text);
font-weight: 700;
}
.batch-review-input {
margin-top: 0.1rem;
width: 100%;
box-sizing: border-box;
height: 1.64rem;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
padding: 0.15rem;
font-size: 0.18rem;
color: var(--wms-text);
background-color: var(--wms-card-bg);
line-height: 1.5;
}
.batch-review-placeholder {
font-size: 0.17rem;
color: var(--wms-text-placeholder);
}
.batch-review-status {
font-size: 0.18rem;
color: var(--wms-text-muted);
}
/* 已解析状态 + 填入按钮:同一行展示 */
.batch-review-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.15rem;
margin-top: 0.15rem;
}
.batch-review-status-num {
color: var(--wms-primary);
font-weight: 700;
}
/* 批量复核内联错误提示(已解析行下方,红色) */
.batch-review-error {
margin-top: 0.1rem;
font-size: 0.17rem;
color: var(--wms-danger-strong);
line-height: 1.4;
}
.batch-review-fill {
flex-shrink: 0;
height: 0.36rem; /* 控件 36px */
line-height: 0.36rem;
padding: 0 0.2rem;
margin: 0;
font-size: 0.18rem;
border-radius: 0.07rem;
background-color: #ecf5ff;
color: var(--wms-primary);
border: 0.01rem solid #b3d8ff;
}
/* 批量复核结果表格 */
.batch-result-table {
border: 0.01rem solid var(--wms-border-strong);
border-radius: 0.07rem;
overflow: hidden;
}
.batch-result-row {
display: flex;
align-items: center;
min-height: 0.5rem; /* 表格行 50px(行高不受控件 36px 影响) */
border-bottom: 0.01rem solid var(--wms-border-strong);
}
.batch-result-row:last-child {
border-bottom: none;
}
.batch-result-row--header {
background-color: #f6f8fc;
}
.batch-result-row--header .batch-result-cell {
font-weight: 700;
color: var(--wms-text-secondary);
}
.batch-result-row--alt {
background-color: #fafafa;
}
.batch-result-cell {
display: flex;
align-items: center;
align-self: stretch;
padding: 0.05rem 0.1rem;
font-size: 0.18rem;
color: #000;
line-height: 1.4;
white-space: normal;
word-break: break-all;
border-left: 0.01rem solid var(--wms-border-strong);
}
.batch-result-cell:first-child {
border-left: none;
}
.batch-result-cell--id {
width: 1.8rem;
flex-shrink: 0;
}
.batch-result-cell--waybill {
flex: 1;
min-width: 0;
}
.batch-result-cell--reason {
width: 1.64rem;
flex-shrink: 0;
}
.batch-result-cell--note {
width: 2.46rem;
flex-shrink: 0;
}
.batch-result-scroll {
max-height: 2.62rem;
}
.batch-result-empty {
padding: 0.2rem 0;
text-align: center;
font-size: 0.18rem;
color: var(--wms-text-placeholder);
}
/* 批量复核结果(内联展示在已解析行下方) */
.batch-result-box {
margin-top: 0.15rem;
}
/* 执行结果分隔标题 */
.batch-result-head {
display: flex;
align-items: center;
gap: 0.15rem;
margin: 0.04rem 0 0.1rem;
}
.batch-result-head-line {
flex: 1;
height: 0.01rem;
background-color: var(--wms-border-alt);
}
.batch-result-head-text {
font-size: 0.18rem;
color: var(--wms-text-muted);
font-weight: 700;
}
.batch-result-tabs {
display: flex;
align-items: center;
gap: 0.1rem;
margin-bottom: 0.05rem;
}
.batch-result-tab {
height: 0.36rem; /* 控件 36px(批量结果表格的 tab,与表格行高解耦) */
line-height: 0.36rem;
padding: 0 0.25rem;
font-size: 0.18rem;
border-radius: 0.07rem;
border: 0.01rem solid var(--wms-border-alt);
color: var(--wms-text-secondary);
background-color: var(--wms-card-bg);
cursor: pointer;
user-select: none;
}
.batch-result-tab--active {
color: var(--wms-primary);
border-color: var(--wms-primary);
background-color: #ecf5ff;
font-weight: 700;
}
/* 左侧订单/波次列表:整行内容完整显示不省略;需换行时优先对运单号/波次号列换行 */
.table-wrap--current-wave .table-cell:not(.cell-wave-no) {
white-space: nowrap;
overflow: visible;
text-overflow: clip;
}
.wave-group-header {
cursor: pointer;
background-color: #f6f8fc;
}
.wave-group-header:active {
background-color: #d6e8ff;
}
.review-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
max-width: 100%;
margin-bottom: 0.1rem;
padding: 0.1rem 0.15rem;
background-color: var(--wms-card-bg);
overflow: hidden;
}
.tool-btn {
height: 0.36rem; /* 控件 36px */
line-height: 0.36rem;
padding: 0 0.15rem;
margin: 0;
font-size: 0.18rem;
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
background-color: var(--wms-card-bg);
color: var(--wms-text);
}
.tool-btn--confirm {
background-color: #34c759;
border-color: #34c759;
color: var(--wms-white);
}
.tool-btn--blue-outline {
color: var(--wms-primary);
border-color: var(--wms-primary);
background-color: #eaf2ff;
}
.tool-btn--orange {
background-color: var(--wms-warning);
border-color: var(--wms-warning);
color: var(--wms-white);
}
.tool-btn--gray {
background-color: var(--wms-text-muted);
border-color: var(--wms-text-muted);
color: var(--wms-white);
}
.tool-btn--blue {
background-color: var(--wms-primary);
border-color: var(--wms-primary);
color: var(--wms-white);
}
.tool-btn--intercept {
background-color: var(--wms-danger-strong);
border-color: var(--wms-danger-strong);
color: var(--wms-white);
}
/* 确认拦截按钮禁用态(已拦截订单):深灰字体 + 浅灰底,明确不可点击 */
.tool-btn[disabled] {
color: var(--wms-text-secondary);
background-color: #f2f2f2;
border-color: var(--wms-border-alt);
cursor: not-allowed;
}
.tool-select {
display: flex;
align-items: center;
gap: 0.05rem;
min-width: 1.15rem;
max-width: 100%;
height: 0.36rem; /* 控件 36px(与同排 .tool-btn 齐高) */
padding: 0 0.1rem;
font-size: 0.17rem;
color: var(--wms-text);
border: 0.01rem solid var(--wms-border-alt);
border-radius: 0.07rem;
background-color: var(--wms-card-bg);
box-sizing: border-box;
overflow: hidden;
}
.tool-select--wide {
width: 1.97rem;
min-width: 1.97rem;
}
.tool-select--printer {
min-width: 2.13rem;
justify-content: space-between;
}
.tool-select--open {
border-color: var(--wms-primary);
}
.tool-select-text {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
font-size: 0.17rem;
color: var(--wms-text);
line-height: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tool-select-arrow {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 0.36rem; /* 控件 36px */
height: 0.36rem;
}
.tool-select-arrow-icon {
/* 图标要小于控件:0.2rem(20px) 放在 0.36rem(36px) 下拉里(原来是 0.3rem,几乎顶满控件) */
display: block;
width: 0.2rem;
height: 0.2rem;
transition: transform 0.2s ease;
}
.tool-select--open .tool-select-arrow-icon {
transform: rotate(180deg);
}
.tool-info-text {
font-size: 0.18rem;
color: var(--wms-text-secondary);
display: inline-flex;
align-items: center;
padding: 0.05rem 0.1rem;
border-radius: 0.07rem;
}
.tool-info-text--blue {
color: var(--wms-primary);
background-color: #eaf2ff;
}
.tool-info-text--gray {
color: var(--wms-text-muted);
background-color: #f0f2f5;
}
.tool-info-text--orange {
color: var(--wms-warning);
background-color: #fff3e6;
}
/* 工具栏控件间距:不用 flex gap(老 WebView 不支持 flex 容器的 gap,真机按钮会挤在一起),
改用子项外边距;放在所有子控件样式之后,确保覆盖 .tool-btn 的 margin:0 */
.review-toolbar > * {
margin-right: 0.15rem;
margin-bottom: 0.1rem;
}
.review-toolbar > *:last-child {
margin-right: 0;
}
/* 团购模式推荐包材条(显示在商品明细上方) */
.recommend-pack-bar {
display: flex;
align-items: center;
gap: 0.15rem;
margin-bottom: 0.1rem;
padding: 0.1rem 0.15rem;
background-color: #fff8ef;
border: 0.01rem solid #ffe3c2;
border-radius: 0.07rem;
box-sizing: border-box;
}
.recommend-pack-bar-label {
flex-shrink: 0;
font-size: 0.18rem;
color: var(--wms-text-muted);
}
.recommend-pack-bar-name {
flex: 1;
min-width: 0;
font-size: 0.22rem;
font-weight: 600;
color: var(--wms-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-tab {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.1rem;
padding: 0.05rem 0.15rem;
border-radius: 0.07rem;
background-color: #f6f8fc;
}
.detail-tab-left {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
}
.detail-tab-left > * + * {
margin-left: 0.1rem;
}
.detail-tab-text {
flex-shrink: 0;
font-size: 0.2rem;
font-weight: 600;
color: var(--wms-text);
}
.detail-tab-tag {
flex-shrink: 0;
padding: 0.02rem 0.1rem;
font-size: 0.17rem;
color: var(--wms-text-secondary);
background-color: #eef2f8;
border-radius: 0.07rem;
white-space: nowrap;
}
.detail-tab-summary {
flex-shrink: 0;
font-size: 0.18rem;
color: #555;
}
.detail-tab-summary--em {
color: var(--wms-primary);
font-weight: 700;
}
.detail-total {
display: flex;
align-items: center;
justify-content: flex-start;
margin-top: 0.2rem;
padding: 0.15rem 0.2rem;
background-color: #f6f8fc;
border: 0.01rem solid #e6ebf5;
border-radius: 0;
}
.detail-total-text {
font-size: 0.2rem;
color: var(--wms-text);
}
.detail-total-num {
font-weight: 700;
color: var(--wms-primary);
margin-left: 0.35rem;
}
.detail-empty-tip {
display: flex;
align-items: center;
justify-content: center;
height: 2.13rem;
color: var(--wms-text-placeholder);
font-size: 0.18rem;
background-color: var(--wms-card-bg);
}
.empty {
text-align: center;
color: var(--wms-text-placeholder);
font-size: 0.2rem;
padding: 0.2rem 0;
}
</style>