- 称重页(weighing):占位页重写为完整称重功能 按运单号查询订单(index.toOrder)+订单详情(order.detail), 校验拣货/复核/打包状态(团单跳过打包校验)后展示订单信息, 支持手动/步进调整重量并提交称重(updateExpressWeighingWeight), 支持扫描枪扫运单号、扫描记录本地缓存(最多50条)、软键盘模式恢复 - 扫描去重(scan.js):由「锁定单一事件类型」改为「按键去重」 修复真机 keydown/keyup 触发不稳定导致丢字符、广播扫描未扫完就发送、首扫不完整 - API:新增 fetchOrderByWaybill、fetchOrderDetailForWeigh"
6755 lines
247 KiB
Vue
6755 lines
247 KiB
Vue
<template>
|
||
<view class="page order-review-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="handleSearchInputConfirm"
|
||
@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 tool-btn--confirm"
|
||
:disabled="!hasSelection || reviewLocked || !allProductsScanned"
|
||
@click="handleConfirmReview"
|
||
>确认复核</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>
|
||
<button class="tool-btn tool-btn--blue" :disabled="!hasInterceptInfo" @click="handleShowInterceptInfo">拦截信息</button>
|
||
<view class="tool-select-wrap">
|
||
<view
|
||
:class="['tool-select', 'tool-select--printer', printerOpened ? 'tool-select--open' : '']"
|
||
@click="togglePrinterDropdown"
|
||
>
|
||
<text class="tool-select-text">{{ selectedPrinter || '选择打印台' }}</text>
|
||
<view class="tool-select-arrow">
|
||
<view class="tool-select-arrow-icon"></view>
|
||
</view>
|
||
</view>
|
||
|
||
<view v-if="printerOpened" class="tool-select-dropdown">
|
||
<scroll-view scroll-y class="tool-select-dropdown-scroll">
|
||
<view
|
||
v-for="(name, index) in printerOptions"
|
||
:key="`printer-${index}`"
|
||
:class="['tool-select-option', selectedPrinterIndex === index ? 'tool-select-option--selected' : '']"
|
||
@click="handlePrinterOptionClick(index)"
|
||
>{{ name }}</view>
|
||
<view v-if="printerOptions.length === 0" class="tool-select-option tool-select-option--empty">暂无打印台</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
|
||
<view v-if="printerOpened" class="tool-select-mask" @click="closePrinterDropdown"></view>
|
||
<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>
|
||
</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 v-if="showTopBasketTag && scanListType === 'single'" class="detail-tab-tag">波次:{{ selectedWaveNo || '-' }}</text>
|
||
<text v-if="showTopBasketTag && scanListType === 'single'" class="detail-tab-tag detail-tab-tag--orange">篮号:{{ selectedWaveIndex || '-' }}</text>
|
||
<text v-else-if="showTopBasketTag" class="detail-tab-tag detail-tab-tag--orange">篮号:{{ selectedWaveIndex || '-' }}</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.boxNo || '-' }}</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')"
|
||
@click.stop="handleImageCellClick(order, $event)"
|
||
@longtap.stop="handleImageCellLongtap(order, $event)"
|
||
@contextmenu.stop="handleImageCellContextmenu(order, $event)"
|
||
>
|
||
<view v-if="order.image" class="cell-image-wrap">
|
||
<image class="item-image" :src="order.image" mode="aspectFit" />
|
||
<view v-if="order.imageList && order.imageList.length > 1" class="cell-image-badge">{{ order.imageList.length }}</view>
|
||
</view>
|
||
<text v-else class="cell-image-empty">-</text>
|
||
</view>
|
||
<text class="table-cell cell-barcode" :style="getColStyle('barcode')">
|
||
<text class="cell-barcode-value">{{ order.barcode }}<text v-if="order.barcodeExtra" class="cell-barcode-extra">{{ order.barcodeExtra }}</text></text>
|
||
</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')"><text v-if="order.packingRequirements" class="cell-pack-value-inner">{{ order.packingRequirements }}</text></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 weigh-mask--keyboard" @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"
|
||
:focus="weighInputFocus"
|
||
:adjust-position="false"
|
||
placeholder="请输入重量(g)"
|
||
placeholder-class="weigh-input-placeholder"
|
||
confirm-type="done"
|
||
@focus="onWeighInputFocus"
|
||
@blur="onWeighInputBlur"
|
||
@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>
|
||
|
||
<!-- 拦截信息弹窗(点击左侧拦截/已拦截标签弹出;单订单/波次两形态,对齐 ReviewDetail) -->
|
||
<view v-if="interceptInfoVisible" class="weigh-mask" @click.self="closeInterceptInfo">
|
||
<view class="weigh-dialog">
|
||
<view class="weigh-dialog-header">
|
||
<text class="weigh-dialog-title">拦截信息</text>
|
||
<text class="weigh-dialog-close" @click="closeInterceptInfo">✕</text>
|
||
</view>
|
||
<view class="weigh-dialog-body">
|
||
<!-- 波次形态:波次号 + 拦截单运单号列表 -->
|
||
<template v-if="interceptInfo.isWave">
|
||
<view class="weigh-info-row">
|
||
<text class="weigh-info-label">波次号</text>
|
||
<text class="weigh-info-value">{{ interceptInfo.waveNo || '-' }}</text>
|
||
</view>
|
||
<view class="intercept-tip">该波次以下订单已被拦截,请勿复核发货</view>
|
||
<scroll-view class="intercept-info-scroll" scroll-y>
|
||
<view
|
||
v-for="(w, wi) in interceptInfo.list"
|
||
:key="`intercept-waybill-${wi}`"
|
||
class="intercept-waybill-row"
|
||
>
|
||
<text class="intercept-waybill-text">{{ w }}</text>
|
||
</view>
|
||
</scroll-view>
|
||
</template>
|
||
<!-- 单订单形态:运单号 + 提示 -->
|
||
<template v-else>
|
||
<view class="weigh-info-row">
|
||
<text class="weigh-info-label">运单号</text>
|
||
<text class="weigh-info-value">{{ interceptInfo.waybillNo || '-' }}</text>
|
||
</view>
|
||
<view class="intercept-tip">该订单已被拦截,请勿复核发货</view>
|
||
</template>
|
||
</view>
|
||
<view class="weigh-dialog-footer">
|
||
<button class="weigh-btn weigh-btn--close" @click="closeInterceptInfo">关闭</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 包材绑定弹窗(仅团购波次,order.bindExpressPackageMaterialByWaybill) -->
|
||
<view v-if="packageMaterialDialogVisible" class="weigh-mask weigh-mask--keyboard" @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"
|
||
:focus="settingPmKeyboard"
|
||
:adjust-position="false"
|
||
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 v-if="sharedImagePreviewList.length > 1" class="shared-img-preview-prev" @click.stop="prevPreviewImage">‹</text>
|
||
<text v-if="sharedImagePreviewList.length > 1" class="shared-img-preview-next" @click.stop="nextPreviewImage">›</text>
|
||
<text v-if="sharedImagePreviewList.length > 1" class="shared-img-preview-count">{{ sharedImagePreviewIndex + 1 }}/{{ sharedImagePreviewList.length }}</text>
|
||
<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">
|
||
<view :class="['setting-seg-item', selectedReviewProcess === '先打印后复核' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('先打印后复核')">先打印后复核</view>
|
||
<view :class="['setting-seg-item', selectedReviewProcess === '先复核后打印' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('先复核后打印')">先复核后打印</view>
|
||
<view :class="['setting-seg-item', selectedReviewProcess === '不打印' ? 'setting-seg-item--on' : '']" @click="setReviewProcess('不打印')">不打印</view>
|
||
</view>
|
||
</view>
|
||
<view class="setting-row">
|
||
<text class="setting-row-label">称重模式</text>
|
||
<view class="setting-seg">
|
||
<view :class="['setting-seg-item', selectedWeigh === '称重' ? 'setting-seg-item--on' : '']" @click="setWeighSetting('称重')">称重</view>
|
||
<view :class="['setting-seg-item', selectedWeigh === '不称重' ? 'setting-seg-item--on' : '']" @click="setWeighSetting('不称重')">不称重</view>
|
||
</view>
|
||
</view>
|
||
<view class="setting-row">
|
||
<text class="setting-row-label">绑定包材</text>
|
||
<view class="setting-seg">
|
||
<view :class="['setting-seg-item', settingBindPackage ? 'setting-seg-item--on' : '']" @click="setSettingBindPackage(true)">开启</view>
|
||
<view :class="['setting-seg-item', !settingBindPackage ? 'setting-seg-item--on' : '']" @click="setSettingBindPackage(false)">关闭</view>
|
||
</view>
|
||
</view>
|
||
<view class="setting-row">
|
||
<text class="setting-row-label">包材软键盘</text>
|
||
<view class="setting-seg">
|
||
<view :class="['setting-seg-item', settingPmKeyboard ? 'setting-seg-item--on' : '']" @click="setSettingPmKeyboard(true)">激活</view>
|
||
<view :class="['setting-seg-item', !settingPmKeyboard ? 'setting-seg-item--on' : '']" @click="setSettingPmKeyboard(false)">不激活</view>
|
||
</view>
|
||
</view>
|
||
<view class="setting-row">
|
||
<text class="setting-row-label">发货模式</text>
|
||
<view class="setting-seg">
|
||
<view :class="['setting-seg-item', settingShipMode === 'auto' ? 'setting-seg-item--on' : '']" @click="setSettingShipMode('auto')">自动发货</view>
|
||
<view :class="['setting-seg-item', settingShipMode === 'manual' ? 'setting-seg-item--on' : '']" @click="setSettingShipMode('manual')">手动发货</view>
|
||
</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="printFailVisible" class="weigh-mask">
|
||
<view class="weigh-dialog">
|
||
<view class="weigh-dialog-header">
|
||
<text class="weigh-dialog-title">打印未完成</text>
|
||
</view>
|
||
<view class="weigh-dialog-body">
|
||
<view class="confirm-review-content">
|
||
<text class="confirm-review-text">{{ printFailBodyText }}</text>
|
||
<view v-if="printFailMessage" class="print-fail-msg">
|
||
<text class="print-fail-msg__text">{{ printFailMessage }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="weigh-dialog-footer">
|
||
<button class="weigh-btn weigh-btn--cancel" @click="handlePrintFailClose">关闭</button>
|
||
<button class="weigh-btn weigh-btn--confirm" @click="handlePrintFailRetry">打印</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,
|
||
confirmRecheck,
|
||
batchQuickRecheck,
|
||
batchQuickRecheckByWave,
|
||
updateExpressWeighingWeight,
|
||
searchPackageMaterial,
|
||
bindExpressPackageMaterialByWaybill,
|
||
getOrderPrintData,
|
||
getWavePlatformPrintData,
|
||
unlockWavePlatformPrintDataByGroup,
|
||
sendPrint,
|
||
} from '@/api/order'
|
||
import { diagAnomaly, diagDrop, diagNote } from '@/core/scan-diag'
|
||
import { getVoice } from '@/core/voice'
|
||
|
||
// 扫码枪识别参数
|
||
// 无回车结束符时:停止输入超过该毫秒数视为一次完整扫码,自动提交
|
||
const SCAN_IDLE_TIMEOUT = 300
|
||
// 自动提交所需的最短内容长度,避免正常输入过程中的短暂停顿触发误识别
|
||
const SCAN_MIN_LENGTH = 2
|
||
// 手动输入识别:相邻按键间隔超过该毫秒数视为手动输入,不自动提交,需按回车后才查询
|
||
// 扫码枪连续按键间隔通常 <30ms,手动键盘输入间隔通常 >100ms
|
||
const SCAN_BURST_MAX_GAP = 100
|
||
// plus.key 自动提交的最短码长:运单/商品条码均 >= 8 位,短于此视为误触/单字符手动输入,
|
||
// 不自动提交(防软键盘单字符停顿触发查询),回车查询不受影响
|
||
const PLUS_SCAN_MIN_LENGTH = 4
|
||
|
||
// Android KeyEvent 符号键映射(KEYCODE_* → 字符)。
|
||
// 重要:这些 keyCode 与 ASCII 字母/数字区间重叠,必须优先于 ASCII 分支判断,
|
||
// 否则 KEYCODE_EQUALS=70 会被 ASCII 的 [65..90] 分支误读为 'F'。
|
||
const ANDROID_PUNCT_MAP = {
|
||
55: ',', // KEYCODE_COMMA
|
||
56: '.', // KEYCODE_PERIOD
|
||
62: ' ', // KEYCODE_SPACE
|
||
68: '`', // KEYCODE_GRAVE
|
||
69: '-', // KEYCODE_MINUS
|
||
70: '=', // KEYCODE_EQUALS
|
||
71: '[', // KEYCODE_LEFT_BRACKET
|
||
72: ']', // KEYCODE_RIGHT_BRACKET
|
||
73: '\\', // KEYCODE_BACKSLASH
|
||
74: ';', // KEYCODE_SEMICOLON
|
||
75: "'", // KEYCODE_APOSTROPHE
|
||
76: '/', // KEYCODE_SLASH
|
||
77: '@', // KEYCODE_AT
|
||
81: '+', // KEYCODE_PLUS
|
||
}
|
||
|
||
// 订单复核设置项本地存储 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,
|
||
plusKeyUpListener: 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: '',
|
||
sharedImagePreviewList: [],
|
||
sharedImagePreviewIndex: 0,
|
||
// 图片预览缩放状态(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,
|
||
// 发货前打印确认(对齐 WMS_PDA ensurePrintedBeforeShip)
|
||
lastPrintError: '',
|
||
printFailVisible: false,
|
||
printFailMessage: '',
|
||
printFailDismissed: false,
|
||
pendingShipAction: '',
|
||
printFlowRunning: false,
|
||
confirmRechecking: false,
|
||
selectedReviewProcess: '先打印后复核',
|
||
selectedWeigh: '不称重',
|
||
// 称重弹窗
|
||
weighDialogVisible: false,
|
||
// 复核前自动称重模式:商品全部扫完且“是否称重=称重”时自动弹出的称重弹窗(标题“称重(复核前)”,保存后直接复核)
|
||
weighReviewMode: false,
|
||
weighInputValue: '',
|
||
// 称重输入框聚焦控制:弹窗打开后延迟置 true 弹出软键盘(称重需手动输入,弹出后不自动隐藏)
|
||
weighInputFocus: false,
|
||
// 包材绑定弹窗(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: [],
|
||
// 拦截信息弹窗(点击拦截标签弹出):isWave=true 波次形态 / false 单订单形态
|
||
interceptInfoVisible: false,
|
||
interceptInfo: {
|
||
isWave: false,
|
||
waveNo: '',
|
||
waybillNo: '',
|
||
list: [],
|
||
},
|
||
// 顶部提示信息
|
||
pickerName: '',
|
||
storeRemark: '',
|
||
// 左侧底部汇总
|
||
waveTotalOrders: 0,
|
||
waveUnreviewedCount: 0,
|
||
// 商品明细统计
|
||
scannedCount: 0,
|
||
totalCount: 0,
|
||
// 设置弹窗
|
||
settingsVisible: false,
|
||
// 绑定包材:开启(true)/关闭(false)
|
||
settingBindPackage: true,
|
||
// 包材软键盘:激活(true)/不激活(false)
|
||
settingPmKeyboard: false,
|
||
// 发货模式:auto 自动发货 / manual 手动发货(默认自动发货)
|
||
settingShipMode: 'auto',
|
||
// D前缀波次(单品单件 pick_mode=2 / 波次号 D 前缀)自动复核
|
||
dprefixedBarcodeVerified: false,
|
||
dprefixedAllScannedHandled: false,
|
||
sharedBarcodeDprefixed: false,
|
||
// 单品单件波次列表复用模式:输入车号/波次号查询后开启,
|
||
// 开启后扫条码在波次列表内定位订单复核发货(不重新查询、不清列表)
|
||
dprefixedWaveList: false,
|
||
// 免验自动推进(need_recheck=N 或已扫满时点击商品卡片触发发货链路)
|
||
noRecheckAutoAdvanceHandled: false,
|
||
// 散单复核后称重:保存成功后据此切下一个未复核订单
|
||
weighAfterReviewKey: '',
|
||
// 进入详情播报免复核商品打包要求的串行链(避免多条语音互相打断)
|
||
recheckSpeakChain: null,
|
||
}
|
||
},
|
||
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 ? '称重(复核前)' : '称重'
|
||
},
|
||
// 打印模式(对齐 WMS_PDA effectivePrintMode):散单强制先复核后打印/不打印,团购按设置
|
||
effectivePrintMode() {
|
||
if (this.scanListType === 'single' && this.selectedReviewProcess !== '不打印') {
|
||
return 'reviewFirst'
|
||
}
|
||
if (this.selectedReviewProcess === '先打印后复核') return 'printFirst'
|
||
if (this.selectedReviewProcess === '先复核后打印') return 'reviewFirst'
|
||
return 'noPrint'
|
||
},
|
||
// D前缀波次(单品单件):散单 + pick_mode=2 或波次号以 D 开头,无需逐件扫描。
|
||
// 按「当前选中订单行」判定,避免混单时整批普通散单被误判为 D 前缀自动复核
|
||
isDprefixedWave() {
|
||
if (this.scanListType !== 'single') return false
|
||
return this.isDprefixedRow(this.currentOrderHeader)
|
||
},
|
||
printFailBodyText() {
|
||
return this.pendingShipAction === 'groupShip'
|
||
? '打印失败或超时,未触发发货。请重试打印,打印成功后将进入包材绑定。'
|
||
: '打印失败或超时,未触发发货。请重试打印,打印成功后将自动发货。'
|
||
},
|
||
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}` : '未命名打印台')
|
||
)
|
||
},
|
||
// 当前选中打印台在列表中的下标(-1 表示未选中),用于下拉列表高亮
|
||
selectedPrinterIndex() {
|
||
const target = String(this.selectedPrinterId ?? '')
|
||
if (!target) return -1
|
||
return this.printerList.findIndex((item) => String(this.getPrinterId(item) ?? '') === target)
|
||
},
|
||
reviewLocked() {
|
||
// 已复核锁定:选中项为已复核订单/波次时,确认复核按钮禁用
|
||
return this.currentOrderHeader
|
||
? this.getWaveReviewStatus(this.currentOrderHeader) === '已复核'
|
||
: false
|
||
},
|
||
// 当前选中项是否含拦截信息(团购按波次内拦截单,散单按订单拦截状态)
|
||
hasInterceptInfo() {
|
||
if (!this.currentOrderHeader) return false
|
||
if (this.scanListType === 'group') {
|
||
return !!this.getWaveInterceptLabel(this.currentOrderHeader)
|
||
}
|
||
return this.isOrderIntercepted(this.currentOrderHeader)
|
||
},
|
||
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 || this.isRecheckExempt(order) || scanned >= qty
|
||
})
|
||
},
|
||
// pick_mode=3(先拣后分)散单分播:商品明细总数列前新增“篮号”列(值取 item.boxNo)
|
||
showBasketColumn() {
|
||
return this.scanListType === 'single' && Number(this.currentPickMode) === 3
|
||
},
|
||
// 顶部商品明细标签行的“篮号”:pick_mode=2(单品单件)/3(先拣后分)时不显示
|
||
showTopBasketTag() {
|
||
const mode = Number(this.currentPickMode)
|
||
return mode !== 2 && mode !== 3
|
||
},
|
||
// 商品明细标签行左侧:团购模式显示当前波次订单数(order_count)
|
||
currentOrderCount() {
|
||
if (this.scanListType !== 'group' || !this.currentOrderHeader) {
|
||
return ''
|
||
}
|
||
return this.getRowValue(this.currentOrderHeader, ['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 ||
|
||
this.printFailVisible
|
||
)
|
||
},
|
||
// 批量复核已解析的有效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.isRealDevice()) {
|
||
this.activateSearchInput()
|
||
}
|
||
},
|
||
// 称重弹窗打开:延迟到渲染完成后再聚焦,弹出软键盘且不被焦点竞争/上一弹窗销毁隐藏
|
||
weighDialogVisible(val) {
|
||
this.clearWeighFocusTimer()
|
||
if (val) {
|
||
this.restoreSoftInputMode()
|
||
this.weighInputFocus = false
|
||
this.$nextTick(() => {
|
||
this.weighFocusTimer = setTimeout(() => {
|
||
if (this.weighDialogVisible && this.isPageActive()) {
|
||
this.weighInputFocus = true
|
||
// 聚焦后延迟再强制唤出软键盘(窗口模式已恢复,仍兜底强制 show,避免个别 ROM 不弹)
|
||
setTimeout(() => {
|
||
if (this.weighDialogVisible && this.isPageActive()) {
|
||
this.showSoftKeyboard()
|
||
}
|
||
}, 250)
|
||
}
|
||
}, 320)
|
||
})
|
||
} else {
|
||
this.weighInputFocus = false
|
||
}
|
||
},
|
||
// 输入内容变化时清除批量复核内联错误,并隐藏上一次结果
|
||
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 ''
|
||
},
|
||
// 免复核商品判定:need_recheck 去空白转大写后为 'N'(缺失按需复核处理)
|
||
isRecheckExempt(order) {
|
||
return String(order?.needRecheck || '').trim().toUpperCase() === 'N'
|
||
},
|
||
// 把条码值统一展开成字符串数组:支持 barcodes[] 数组,以及 "a;b;c" / "a,b,c" / "a,b,c" / "a|b" 等多值串
|
||
normalizeBarcodeList(value) {
|
||
if (Array.isArray(value)) {
|
||
return value
|
||
.map((v) => String(v ?? '').trim())
|
||
.filter((v) => v !== '')
|
||
}
|
||
const raw = String(value ?? '').trim()
|
||
if (!raw) return []
|
||
return raw
|
||
.split(/[;,,|\s]+/)
|
||
.map((v) => v.trim())
|
||
.filter((v) => v !== '')
|
||
},
|
||
// 单行是否为 D 前缀单品单件:优先行内 wave_no 以 D 开头;行内 pick_mode 缺失时回退顶层 currentPickMode
|
||
isDprefixedRow(row) {
|
||
if (!row || typeof row !== 'object') return false
|
||
const src = this.getScanOrderSource(row)
|
||
if (String(this.getRowValue(src, ['wave_no', 'waveNo']) || '').startsWith('D')) return true
|
||
const rowPickMode = this.getRowValue(row, ['pick_mode', 'pickMode'])
|
||
if (rowPickMode !== '') return Number(rowPickMode) === 2
|
||
return Number(this.currentPickMode) === 2
|
||
},
|
||
normalizeOrderRow(row) {
|
||
const rawBarcode = this.getRowValue(row, ['barcode', 'bar_code', 'goods_barcode', 'sku_barcode', 'barcodes'])
|
||
// 条码可能是数组(barcodes[])或多值字符串("a;b;c"):统一展开成列表,扫码匹配基于完整列表
|
||
const barcodeList = this.normalizeBarcodeList(rawBarcode)
|
||
// 显示只展示前 5 个,多出的折叠为「+N」(单独蓝色展示);完整列表仍存 barcodeList 供扫码匹配
|
||
const barcode = barcodeList.length > 5 ? barcodeList.slice(0, 5).join('、') : barcodeList.join('、')
|
||
const barcodeExtra = barcodeList.length > 5 ? `+${barcodeList.length - 5}` : ''
|
||
const rawImage = this.getRowValue(row, ['images', 'image', 'image_url', 'imageUrl'])
|
||
const imageList = Array.isArray(rawImage)
|
||
? rawImage.map((v) => String(v == null ? '' : v).trim()).filter((v) => v !== '')
|
||
: (rawImage ? [String(rawImage).trim()] : [])
|
||
const image = imageList[0] || ''
|
||
// 免复核判定:need_recheck 去空白转大写后为 'N'(缺失按需复核处理)
|
||
const needRecheck = this.getRowValue(row, ['need_recheck', 'needRecheck']) || ''
|
||
const exemptRecheck = String(needRecheck).trim().toUpperCase() === 'N'
|
||
const quantity = this.getRowValue(row, ['plan_qty', 'quantity', 'qty', 'num', 'count'])
|
||
const rawScanned = this.getRowValue(row, ['scanned_qty', 'scannedQty', 'scan_qty', 'scanQty', 'scanned_count', 'scannedCount']) || 0
|
||
// 免复核商品:已扫数量直接等于计划数量(不参与扫码、无需复核)
|
||
const scannedQty = exemptRecheck ? Number(quantity) || 0 : rawScanned
|
||
return {
|
||
blueNo: this.getRowValue(row, ['blueNo', 'blue_no', 'lanhao', 'lan_hao', 'blue_no_code', 'stock_id', 'item_code']),
|
||
quantity,
|
||
scanMark: this.getRowValue(row, ['scanMark', 'scan_mark', 'scanStatus', 'scan_status']),
|
||
barcode,
|
||
barcodeList,
|
||
barcodeExtra,
|
||
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,
|
||
imageList,
|
||
packingRequirements: this.getRowValue(row, ['recheck_requirements', 'recheckRequirements']),
|
||
// 免验标记:need_recheck=N 表示无需复核(对齐 WMS_PDA,缺失按需复核处理)
|
||
needRecheck,
|
||
// 篮号(pick_mode=3 散单分播,明细行 box_no 等字段)
|
||
basketNo: this.getRowValue(row, ['box_no', 'boxNo', 'basket_no', 'basketNo', 'seed_no', 'seedNo']),
|
||
// 明细行“篮号”列取值(先拣后分 pick_mode=3:item.boxNo)
|
||
boxNo: this.getRowValue(row, ['boxNo', 'box_no']),
|
||
// 共享条码:库内存在相同条码的其它商品(has_shared_barcode,布尔)
|
||
hasSharedBarcode: !!this.getRowValue(row, ['has_shared_barcode', 'hasSharedBarcode']),
|
||
scannedQty,
|
||
}
|
||
},
|
||
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)
|
||
},
|
||
// 搜索框回车(@confirm):真机搜索框聚焦时,扫码枪的 Enter 也会触发 @confirm,
|
||
// 此时 plus.key 已缓冲完整条码(随后 Enter keyup 会 flush),跳过 @confirm 避免重复查询。
|
||
handleSearchInputConfirm() {
|
||
if (this.isRealDevice() && this.plusKeyBuffer && String(this.plusKeyBuffer).trim()) {
|
||
console.log('[order-scan] skip input confirm, plusKeyBuffer=', this.plusKeyBuffer)
|
||
return
|
||
}
|
||
this.handleConfirm()
|
||
},
|
||
handleConfirm() {
|
||
// 提交后重置扫码快速输入标记,下一轮输入重新识别手动/扫码
|
||
this.scanBurstConfirmed = false
|
||
console.log('[order-scan] handleConfirm keyword=', this.keyword, 'hasSelection=', this.hasSelection, 'packageMaterialDialogVisible=', this.packageMaterialDialogVisible)
|
||
// 包材绑定弹窗打开时:扫码/回车值进入包材搜索流程,而不是订单/商品条码查询
|
||
if (this.packageMaterialDialogVisible) {
|
||
const code = (this.keyword || '').trim()
|
||
if (code) {
|
||
this.packageMaterialInput = code
|
||
this.keyword = ''
|
||
this.handlePackageMaterialSearch()
|
||
}
|
||
return
|
||
}
|
||
// 已选中列表项时,回车走商品条码匹配流程;否则走关键词查询。
|
||
// 散单单品单件例外:波次列表复用模式下,扫条码在列表内定位对应订单整单复核发货
|
||
// (支持扫描波次内任意订单商品条码,不受当前选中订单限制)
|
||
if (this.dprefixedWaveList || (this.hasSelection && this.scanListType === 'single' && this.isDprefixedWave)) {
|
||
this.handleDprefixedScanLocate()
|
||
} else 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
|
||
}
|
||
|
||
// 桌面端:主动聚焦输入框,后续字符走浏览器默认输入;
|
||
// 移动端(平板 H5/真机):不抢焦点(避免弹软键盘),字符已手动缓冲进 keyword,
|
||
// 由静默防抖/回车提交走查询,不聚焦输入框也能扫码查询
|
||
if (!this.isRealDevice()) {
|
||
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
|
||
// 包材绑定弹窗打开时:扫码值应进入包材搜索流程(交给 handleConfirm 统一路由),不静默丢弃
|
||
if (this.packageMaterialDialogVisible) {
|
||
const elapsed = Date.now() - this.lastScanKeyTime
|
||
const buffer = (this.keyword || '').trim()
|
||
if (this.scanBurstConfirmed && elapsed >= SCAN_IDLE_TIMEOUT && buffer.length >= SCAN_MIN_LENGTH) {
|
||
this.handleConfirm()
|
||
} else {
|
||
this.scanBurstConfirmed = false
|
||
}
|
||
return
|
||
}
|
||
// 其它弹窗打开时静默防抖不触发主订单查询,避免把弹窗内扫码内容误当订单条码
|
||
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() {
|
||
// 真机(APP-PLUS)逻辑层无 DOM:document.activeElement 恒为 null,
|
||
// handleHiddenScanBlur 里「用户已聚焦其它输入框时不抢回焦点」的判断永远失效,
|
||
// 隐藏 input 会把搜索框焦点抢回并 hideKeyboard 收掉软键盘(弹一下又隐藏、无法输入)。
|
||
// 现 plus.key 已按 Android 原生 keycode 完整捕获扫码,真机彻底关闭隐藏 input。
|
||
if (this.isAppPlus()) {
|
||
this.enableHiddenInputCapture = false
|
||
return
|
||
}
|
||
// H5/Electron:有 DOM → 关闭隐藏捕获;小程序等无 DOM 且无 plus.key 平台 → 开启兜底
|
||
this.enableHiddenInputCapture = !this.hasDomKeyboardSupport()
|
||
},
|
||
/** 是否真机(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) {
|
||
// Android Enter=66 在 ASCII 里是 'B',必须先排除,交给 isPlusEnterKey 处理
|
||
if (keyCode === 66) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'android'
|
||
return ''
|
||
}
|
||
// ---- Android 原生 keycode ----
|
||
if (keyCode >= 7 && keyCode <= 16) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'android'
|
||
return String(keyCode - 7) // 0-9
|
||
}
|
||
if (keyCode >= 29 && keyCode <= 54) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'android'
|
||
return String.fromCharCode(keyCode - 29 + 65) // A-Z
|
||
}
|
||
// Android 符号键:必须放在 ASCII 分支之前(防止 70('=') → 'F' 这类误读)
|
||
if (this._plusKeyStyle !== 'ascii' && ANDROID_PUNCT_MAP[keyCode] !== undefined) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'android'
|
||
return ANDROID_PUNCT_MAP[keyCode]
|
||
}
|
||
// ---- ASCII/DOM 风格(其它设备兑底)----
|
||
if (keyCode >= 48 && keyCode <= 57) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'ascii'
|
||
return String.fromCharCode(keyCode)
|
||
}
|
||
if (keyCode >= 65 && keyCode <= 90) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'ascii'
|
||
return String.fromCharCode(keyCode)
|
||
}
|
||
if (keyCode >= 96 && keyCode <= 105) {
|
||
this._plusKeyStyle = this._plusKeyStyle || 'ascii'
|
||
return String(keyCode - 96)
|
||
}
|
||
if (keyCode === 189 || keyCode === 109) {
|
||
return '-'
|
||
}
|
||
if (keyCode === 190 || keyCode === 110) {
|
||
return '.'
|
||
}
|
||
if (keyCode === 191 || keyCode === 111) {
|
||
return '/'
|
||
}
|
||
return ''
|
||
},
|
||
// 判断是否为 Enter:Android 原生 Enter=66;ASCII 风格为 13
|
||
// (13 在 Android 风格下是数字键 '6',所以用 text 能否解析来消歧)
|
||
isPlusEnterKey(keyCode, text) {
|
||
if (text) {
|
||
return false
|
||
}
|
||
if (keyCode === 66) {
|
||
return true
|
||
}
|
||
if (keyCode === 13) {
|
||
return this._plusKeyStyle !== 'android'
|
||
}
|
||
return false
|
||
},
|
||
// 统一处理 plus.key 按键(keydown / keyup)
|
||
handlePlusKeyEvent(event, type) {
|
||
const keyCode = Number(event?.keyCode || 0)
|
||
const now = Date.now()
|
||
if (!this.isPageActive()) {
|
||
return
|
||
}
|
||
// 先排除修饰键(Shift=59/60)
|
||
if (keyCode === 59 || keyCode === 60) {
|
||
console.log('[order-scan][plus] shift', type, 'keyCode=', keyCode)
|
||
return
|
||
}
|
||
const text = this.parsePlusKeyCodeToChar(keyCode)
|
||
const isEnter = this.isPlusEnterKey(keyCode, text)
|
||
// 无法映射的按键:忽略
|
||
if (!text && !isEnter) {
|
||
console.log('[order-scan][plus] unmapped', type, 'keyCode=', keyCode)
|
||
return
|
||
}
|
||
// 去重:同一键的 keydown/keyup 成对到达时只处理一次(type 不同 + keyCode 相同 + 间隔 <20ms)。
|
||
// 不再锁定单一事件类型:真机 keydown/keyup 触发不稳定,锁定错乱会丢字符
|
||
// (表现为「第一次扫码条码不完整、第二次才完整」)。
|
||
if (this._plusLastKeyCode === keyCode && this._plusLastKeyType !== type && now - this._plusLastKeyAt < 20) {
|
||
console.log('[order-scan][plus] dedup', type, 'keyCode=', keyCode)
|
||
return
|
||
}
|
||
this._plusLastKeyCode = keyCode
|
||
this._plusLastKeyType = type
|
||
this._plusLastKeyAt = now
|
||
console.log('[order-scan][plus] char', type, 'keyCode=', keyCode, 'text=', text, 'isEnter=', isEnter, 'searchFocused=', this.searchFocused, 'buffer=', this.plusKeyBuffer)
|
||
if (text) {
|
||
// 相邻字符间隔过大 = 软键盘手动输入(字符已由 input 的 v-model 接收):
|
||
// 清空 plus.key 缓冲不自动查询,回车查询仍走 @confirm。
|
||
// 扫码枪字符间隔 <30ms(日志实测),不会被误伤;不再用 searchFocused 判断,
|
||
// 因为真机 reLaunch 后焦点残留会导致搜索框意外聚焦,误 skip 扫码枪字符。
|
||
const gap = this._plusLastCharAt ? now - this._plusLastCharAt : 0
|
||
this._plusLastCharAt = now
|
||
// 仅 buffer 非空(同一串扫码内部)才判定间隔:跨扫码的首字符间隔天然 >100ms,
|
||
// 若一起判定会把每串扫码的首字符误丢(如 011000000228 被截成 11000000228)
|
||
if (this.plusKeyBuffer && gap > SCAN_BURST_MAX_GAP) {
|
||
this.clearPlusKeyTimer()
|
||
this.plusKeyBuffer = ''
|
||
this.plusKeyStartedAt = 0
|
||
this.plusKeyLastAt = 0
|
||
console.log('[order-scan][plus] skip-manual gap=', gap, text)
|
||
return
|
||
}
|
||
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')
|
||
}
|
||
},
|
||
attachPlusKeyboardListener() {
|
||
if (!this.hasPlusKeyboardSupport()) {
|
||
return
|
||
}
|
||
if (this.plusKeyListener || this.plusKeyUpListener) {
|
||
return
|
||
}
|
||
this._plusLastCharAt = 0
|
||
this.plusKeyListener = (event) => this.handlePlusKeyEvent(event, 'keydown')
|
||
this.plusKeyUpListener = (event) => this.handlePlusKeyEvent(event, 'keyup')
|
||
// #ifdef APP-PLUS
|
||
// 同时监听 keydown 与 keyup:部分真机只触发其一,由 handlePlusKeyEvent 锁定避免重复采集
|
||
plus.key.addEventListener('keydown', this.plusKeyListener)
|
||
plus.key.addEventListener('keyup', this.plusKeyUpListener)
|
||
console.log('[order-scan] plus listener attached')
|
||
// #endif
|
||
},
|
||
removePlusKeyboardListener() {
|
||
this.clearPlusKeyTimer()
|
||
this.plusKeyBuffer = ''
|
||
this.plusKeyStartedAt = 0
|
||
this.plusKeyLastAt = 0
|
||
this._plusKeyEventType = null
|
||
console.log('[order-scan] removePlusKeyboardListener has=', !!(this.plusKeyListener || this.plusKeyUpListener))
|
||
if (!this.plusKeyListener && !this.plusKeyUpListener) {
|
||
return
|
||
}
|
||
// #ifdef APP-PLUS
|
||
if (this.hasPlusKeyboardSupport()) {
|
||
if (this.plusKeyListener) {
|
||
plus.key.removeEventListener('keydown', this.plusKeyListener)
|
||
}
|
||
if (this.plusKeyUpListener) {
|
||
plus.key.removeEventListener('keyup', this.plusKeyUpListener)
|
||
}
|
||
}
|
||
// #endif
|
||
this.plusKeyListener = null
|
||
this.plusKeyUpListener = null
|
||
},
|
||
flushPlusKeyBuffer(trigger = 'timer') {
|
||
if (!this.isPageActive()) {
|
||
return
|
||
}
|
||
const code = (this.plusKeyBuffer || '').trim()
|
||
this.plusKeyBuffer = ''
|
||
this.plusKeyStartedAt = 0
|
||
this.plusKeyLastAt = 0
|
||
this.clearPlusKeyTimer()
|
||
console.log('[order-scan][plus] flush trigger=', trigger, 'code=', code)
|
||
if (!code) {
|
||
return
|
||
}
|
||
// 过短内容(误触/软键盘单字符或短词停顿)不自动提交,回车查询不受影响
|
||
if (code.length < PLUS_SCAN_MIN_LENGTH) {
|
||
console.log('[order-scan][plus] drop-too-short', 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
|
||
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)
|
||
},
|
||
// 清理称重输入框延迟聚焦定时器(弹窗关闭/页面离开时)
|
||
clearWeighFocusTimer() {
|
||
if (this.weighFocusTimer) {
|
||
clearTimeout(this.weighFocusTimer)
|
||
this.weighFocusTimer = null
|
||
}
|
||
},
|
||
// 强制锁定横屏兜底(setStyle 已禁用:见布局壳 lockLandscape 说明,
|
||
// reLaunch/热恢复时 setStyle 触发原生层 ViewOptions.updateViewData NPE 导致白屏)
|
||
lockLandscape() {
|
||
// #ifdef APP-PLUS
|
||
try {
|
||
const screen = plus && plus.screen
|
||
if (screen && typeof screen.lockOrientation === 'function') {
|
||
screen.lockOrientation('landscape')
|
||
console.log('[order] lockOrientation=landscape done')
|
||
}
|
||
return true
|
||
} catch (e) {
|
||
console.log('[order] lockOrientation 异常:', e && e.message)
|
||
}
|
||
// #endif
|
||
return false
|
||
},
|
||
// 恢复窗口软键盘模式:登录/打包页会把窗口设为 ALWAYS_HIDDEN(3)(窗口级、跨页持续),
|
||
// 导致订单复核页称重/包材输入框聚焦后软键盘弹出又被系统立刻隐藏。
|
||
// 这里重置为 ADJUST_NOTHING(0x30=48) | STATE_UNSPECIFIED(0):键盘可正常弹出,且不调整窗口避免旧 WebView 失焦
|
||
restoreSoftInputMode() {
|
||
// #ifdef APP-PLUS
|
||
try {
|
||
if (typeof plus !== 'undefined' && plus.android && plus.android.runtimeMainActivity) {
|
||
const main = plus.android.runtimeMainActivity()
|
||
const win = plus.android.invoke(main, 'getWindow')
|
||
plus.android.invoke(win, 'setSoftInputMode', 48)
|
||
console.log('[order-scan][kb] setSoftInputMode=ADJUST_NOTHING(48)')
|
||
}
|
||
} catch (e) {
|
||
console.log('[order-scan][kb] restoreSoftInputMode failed:', e && e.message)
|
||
}
|
||
// #endif
|
||
},
|
||
// 称重输入框聚焦/失焦诊断日志(定位键盘被谁收起的时序)
|
||
onWeighInputFocus() {
|
||
console.log('[kb-diag] weigh input FOCUS', Date.now())
|
||
},
|
||
onWeighInputBlur() {
|
||
console.log('[kb-diag] weigh input BLUR', Date.now())
|
||
},
|
||
// 强制唤出软键盘:对当前已聚焦的输入框调 InputMethodManager.showSoftInput(SHOW_FORCED)
|
||
showSoftKeyboard() {
|
||
// #ifdef APP-PLUS
|
||
try {
|
||
const main = plus.android.runtimeMainActivity()
|
||
const win = plus.android.invoke(main, 'getWindow')
|
||
const focused = plus.android.invoke(win, 'getCurrentFocus')
|
||
const imm = plus.android.invoke(main, 'getSystemService', 'input_method')
|
||
if (focused) {
|
||
// SHOW_FORCED = 2(强制显示)
|
||
plus.android.invoke(imm, 'showSoftInput', focused, 2)
|
||
console.log('[order-scan][kb] showSoftInput SHOW_FORCED done')
|
||
} else {
|
||
console.log('[order-scan][kb] showSoftInput skipped: no focused view')
|
||
}
|
||
} catch (e) {
|
||
console.log('[order-scan][kb] showSoftKeyboard failed:', e && e.message)
|
||
}
|
||
// #endif
|
||
},
|
||
suppressSoftKeyboardBurst() {
|
||
if (!this.isPageActive()) {
|
||
return
|
||
}
|
||
// 真机(APP-PLUS):订单复核页需手动输入(搜索/数量/包材条码),且已关闭隐藏 input,
|
||
// 不再压制软键盘;uni.hideKeyboard 会断开输入框按键连接,真机禁用
|
||
if (this.isAppPlus()) {
|
||
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()
|
||
console.log('[order-scan] submitScanCode source=', source, 'code=', trimmed, 'hasSelection=', this.hasSelection)
|
||
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()
|
||
},
|
||
// 商品条码是否命中(支持 barcodeList 数组多值,兼容单值/分号、逗号分隔的多值串)
|
||
isBarcodeMatched(order, code) {
|
||
if (!order || !code) {
|
||
return false
|
||
}
|
||
const list = order?.barcodeList
|
||
if (Array.isArray(list) && list.length) {
|
||
return list.some((part) => this.normalizeScanBarcode(part) === code)
|
||
}
|
||
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 命中逻辑);步长 = 复核扫描数量设置 scanQty
|
||
applyScannedMatch(target) {
|
||
if (!target) {
|
||
return
|
||
}
|
||
const total = Number(target.quantity) || 0
|
||
const scanned = Number(target.scannedQty) || 0
|
||
// 已扫满(数量>0 且已扫>=总数):不再累加。
|
||
// 免复核商品提示「该商品无需复核」,普通商品提示「该商品已复核完成」(对齐 WMS_PDA)
|
||
if (total > 0 && scanned >= total) {
|
||
this.keyword = ''
|
||
const msg = this.isRecheckExempt(target) ? '该商品无需复核' : '该商品已复核完成'
|
||
uni.showToast({ title: msg, icon: 'none' })
|
||
return
|
||
}
|
||
const step = Number(this.scanQty) || 1
|
||
// 已扫值不能大于总数(数量>0 时截断到总数)
|
||
target.scannedQty = total > 0 ? Math.min(scanned + step, total) : scanned + step
|
||
// 数量为单次生效:本次扫码用完后回到 1,避免下次扫描误按旧数量累加
|
||
this.scanQty = 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
|
||
const dprefixed = this.sharedBarcodeDprefixed
|
||
this.sharedBarcodeDrawerVisible = false
|
||
this.sharedBarcodeMatches = []
|
||
this.sharedBarcodeSelectedIndex = -1
|
||
this.sharedBarcodeCode = ''
|
||
this.sharedBarcodeImgError = {}
|
||
this.sharedBarcodeDprefixed = false
|
||
if (dprefixed) {
|
||
// D前缀波次自动复核:确认共享条码后继续标记全部已扫并触发发货
|
||
this.finishDprefixedAutoReview()
|
||
return
|
||
}
|
||
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.sharedImagePreviewList = [src]
|
||
this.sharedImagePreviewIndex = 0
|
||
this.sharedImagePreviewUrl = src
|
||
this.resetPreviewZoom()
|
||
this.sharedImagePreviewVisible = true
|
||
},
|
||
// 打开商品图片全屏预览(支持多图翻页):imageList 为图片地址列表,index 为初始下标
|
||
previewProductImages(imageList, index) {
|
||
const list = (imageList || [])
|
||
.map((v) => String(v == null ? '' : v).trim())
|
||
.filter((v) => v !== '')
|
||
if (!list.length) {
|
||
return
|
||
}
|
||
const idx = Math.max(0, Math.min(Number(index) || 0, list.length - 1))
|
||
this.sharedImagePreviewList = list
|
||
this.sharedImagePreviewIndex = idx
|
||
this.sharedImagePreviewUrl = list[idx]
|
||
this.resetPreviewZoom()
|
||
this.sharedImagePreviewVisible = true
|
||
},
|
||
// 预览内切换图片(翻页后复位缩放与拖动)
|
||
showPreviewImageAt(index) {
|
||
const list = this.sharedImagePreviewList || []
|
||
if (!list.length) {
|
||
return
|
||
}
|
||
const idx = Math.max(0, Math.min(Number(index), list.length - 1))
|
||
this.sharedImagePreviewIndex = idx
|
||
this.sharedImagePreviewUrl = list[idx]
|
||
this.resetPreviewZoom()
|
||
},
|
||
nextPreviewImage() {
|
||
if ((this.sharedImagePreviewList || []).length <= 1) {
|
||
return
|
||
}
|
||
this.showPreviewImageAt(this.sharedImagePreviewIndex + 1)
|
||
},
|
||
prevPreviewImage() {
|
||
if ((this.sharedImagePreviewList || []).length <= 1) {
|
||
return
|
||
}
|
||
this.showPreviewImageAt(this.sharedImagePreviewIndex - 1)
|
||
},
|
||
// 点击商品明细图片单元格:有图时拦截冒泡并放大预览,无图时不拦截以保持行点击(无条码复核等)
|
||
handleImageCellClick(order, event) {
|
||
if (!order || !order.image) {
|
||
return
|
||
}
|
||
this.stopImageCellEvent(event)
|
||
this.previewProductImages(order.imageList || [order.image], 0)
|
||
},
|
||
// 图片单元格长按:有图时拦截冒泡,避免触发行长按(无条码复核)
|
||
handleImageCellLongtap(order, event) {
|
||
if (!order || !order.image) {
|
||
return
|
||
}
|
||
this.stopImageCellEvent(event)
|
||
},
|
||
// 图片单元格右键:有图时拦截冒泡,避免触发行右键(无条码复核直接执行)
|
||
handleImageCellContextmenu(order, event) {
|
||
if (!order || !order.image) {
|
||
return
|
||
}
|
||
this.stopImageCellEvent(event)
|
||
},
|
||
// 阻止图片单元格事件冒泡(真机 WebView 上原生 stopPropagation 更可靠)
|
||
stopImageCellEvent(event) {
|
||
if (!event) {
|
||
return
|
||
}
|
||
if (typeof event.stopPropagation === 'function') {
|
||
event.stopPropagation()
|
||
}
|
||
if (typeof event.preventDefault === 'function') {
|
||
event.preventDefault()
|
||
}
|
||
},
|
||
// 关闭商品图片预览
|
||
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' })
|
||
},
|
||
// 进入详情时播报免复核商品(need_recheck=N)的打包要求,按文本去重后串行播报(对齐 WMS_PDA)
|
||
speakNoRecheckPackRequirements(items) {
|
||
if (!Array.isArray(items) || items.length === 0) {
|
||
return
|
||
}
|
||
const reqs = []
|
||
items.forEach((it) => {
|
||
if (!this.isRecheckExempt(it)) {
|
||
return
|
||
}
|
||
const v = String(it?.packingRequirements || '').trim()
|
||
if (v && v !== '--' && !reqs.includes(v)) {
|
||
reqs.push(v)
|
||
}
|
||
})
|
||
if (!reqs.length) {
|
||
return
|
||
}
|
||
// 串行播报:core/voice.js 每次播放都会重建音频实例,并发会互相打断,用 Promise 链 + 估时排队
|
||
const prev = this.recheckSpeakChain
|
||
let chain = prev && typeof prev.then === 'function' ? prev : Promise.resolve()
|
||
reqs.forEach((text) => {
|
||
chain = chain.then(() => this.speakVoiceOneByOne(text))
|
||
})
|
||
this.recheckSpeakChain = chain.catch(() => {})
|
||
},
|
||
// 播报单条语音并按文本长度估时等待(纯语音播报,不弹 toast)
|
||
speakVoiceOneByOne(text) {
|
||
const content = String(text || '').trim()
|
||
if (!content) {
|
||
return Promise.resolve()
|
||
}
|
||
getVoice().play(content)
|
||
const ms = Math.min(5000, Math.max(800, content.length * 300))
|
||
return new Promise((resolve) => {
|
||
setTimeout(resolve, ms)
|
||
})
|
||
},
|
||
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)
|
||
}
|
||
},
|
||
// 提取订单行所有商品条码(含 items/stock/stocks/detail.items 明细行与订单行本身),
|
||
// 返回归一化(去空白 + 大写)后的去重数组,供条码定位订单使用
|
||
extractOrderBarcodes(row) {
|
||
if (!row || typeof row !== 'object') return []
|
||
const result = []
|
||
const push = (r) => {
|
||
if (!r || typeof r !== 'object') return
|
||
const raw = this.getRowValue(r, [
|
||
'barcode', 'bar_code', 'goods_barcode', 'sku_barcode', 'barcodes',
|
||
])
|
||
for (const b of this.normalizeBarcodeList(raw)) {
|
||
const code = this.normalizeScanBarcode(b)
|
||
if (code) result.push(code)
|
||
}
|
||
}
|
||
// 订单行内商品明细(items / stock / stocks / detail.items)
|
||
const detailSource = this.getRowValue(row, ['detail'])
|
||
const inlineItems = Array.isArray(row?.items)
|
||
? row.items
|
||
: Array.isArray(row?.stock)
|
||
? row.stock
|
||
: Array.isArray(row?.stocks)
|
||
? row.stocks
|
||
: detailSource && Array.isArray(detailSource.items)
|
||
? detailSource.items
|
||
: null
|
||
if (Array.isArray(inlineItems)) inlineItems.forEach(push)
|
||
// 订单行本身(含 detail 包裹)
|
||
push(this.getScanOrderSource(row))
|
||
return [...new Set(result)]
|
||
},
|
||
// 判断查询关键词是否为商品条码(命中返回列表首行订单的商品条码)。
|
||
// 仅「扫商品条码定位」才返回 true,输入车号/运单号查询返回 false,
|
||
// 用于 D 前缀单品单件是否自动复核的判定(applyScanResult 的 isBarcodeSearch)
|
||
isKeywordOrderBarcode(payload, query) {
|
||
const code = this.normalizeScanBarcode(query)
|
||
if (!code) return false
|
||
const list = Array.isArray(payload?.list) ? payload.list : []
|
||
if (list.length === 0) return false
|
||
return this.extractOrderBarcodes(list[0]).includes(code)
|
||
},
|
||
// 在散单列表中查找商品条码命中的订单行(扫描波次内任意商品条码定位对应订单)
|
||
findOrderByBarcode(list, code) {
|
||
const rows = Array.isArray(list) ? list : []
|
||
for (const row of rows) {
|
||
if (this.extractOrderBarcodes(row).includes(code)) return row
|
||
}
|
||
return null
|
||
},
|
||
// 散单单品单件:扫商品条码 → 在波次列表内定位对应订单并整单自动复核发货。
|
||
// 支持扫描波次内任意订单的商品条码,不受「当前选中订单」限制;列表保持不变。
|
||
handleDprefixedScanLocate() {
|
||
const barcode = this.keyword.trim()
|
||
if (!barcode) return
|
||
const code = this.normalizeScanBarcode(barcode)
|
||
const target = this.findOrderByBarcode(this.scanOrderList, code)
|
||
if (!target) {
|
||
uni.showToast({ title: '无记录', icon: 'none' })
|
||
return
|
||
}
|
||
this.keyword = ''
|
||
// 已复核:不重复发货
|
||
if (this.getWaveReviewStatus(target) === '已复核') {
|
||
uni.showToast({ title: '该订单已复核', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
// 拦截/已拦截订单:只选中展示拦截信息,不自动复核发货
|
||
const blocked = this.isOrderIntercepted(target)
|
||
this.dprefixedBarcodeVerified = !blocked
|
||
this.handleScanOrderClick(target)
|
||
},
|
||
async handleSearch() {
|
||
const query = this.keyword.trim()
|
||
console.log('[order-scan] handleSearch query=', query)
|
||
// 新查询:退出单品单件波次列表复用模式(由 applyScanResult 按结果重新判定)
|
||
this.dprefixedWaveList = false
|
||
|
||
// 清空关键词:回到初始空状态
|
||
if (!query) {
|
||
this.scanActive = false
|
||
this.scanOrderList = []
|
||
this.reviewedKeepList = []
|
||
this.clearSelection()
|
||
return
|
||
}
|
||
|
||
let body = null
|
||
try {
|
||
// 新查询上下文:清空上一轮已复核保留项缓存
|
||
this.reviewedKeepList = []
|
||
body = await scanReviewOrder({ keyword: query })
|
||
const payload = body?.data || body?.result || body || {}
|
||
// 仅当查询词命中首行订单商品条码(扫商品条码定位)时才视为条码搜索,
|
||
// 避免输入车号/运单号查询时误触发 D 前缀单品单件自动复核
|
||
this.applyScanResult(payload, this.isKeywordOrderBarcode(payload, query))
|
||
this.activeKeyword = query
|
||
this.keyword = ''
|
||
} catch (error) {
|
||
// 「接口返回成功却提示查询失败」排查:
|
||
// - hasBody=true → 接口已成功返回,异常发生在 applyScanResult 结果处理阶段(error 堆栈可定位)
|
||
// - hasBody=false → 接口请求失败或超时(timedOut 标记硬超时),与后端返回成功与否无关
|
||
const detail = {
|
||
query,
|
||
hasBody: !!body,
|
||
timedOut: !!error?.timedOut,
|
||
errMsg: String(error?.errMsg || error?.message || ''),
|
||
}
|
||
console.error('[order scanOrder] 查询异常:', { ...detail, error })
|
||
// 只写本地诊断(面板/logcat),避免网络波动频繁触发时刷爆服务端上报
|
||
diagAnomaly('scan-order-query-fail', detail, { report: false })
|
||
uni.showToast({
|
||
title: error?.timedOut ? '查询超时,请重试' : '查询失败',
|
||
icon: 'none',
|
||
silentVoice: true,
|
||
})
|
||
}
|
||
},
|
||
applyScanResult(payload, isBarcodeSearch = false) {
|
||
const list = Array.isArray(payload?.list) ? payload.list : []
|
||
console.log('[order-scan] applyScanResult listLen=', list.length, 'msg=', payload?.msg || payload?.message || '')
|
||
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
|
||
}
|
||
|
||
// 汇总数据:波次总单数
|
||
if (this.scanListType === 'single') {
|
||
// 散单:扁平订单列表,每行一个订单,总数 = 列表行数(含刷新后回填的已复核项)
|
||
this.waveTotalOrders = this.scanOrderList.length
|
||
} else {
|
||
// 团购:各波次的订单数(total_orders / order_count)累加
|
||
this.waveTotalOrders = this.scanOrderList.reduce(
|
||
(sum, row) =>
|
||
sum +
|
||
(Number(
|
||
this.getRowValue(row, ['total_orders', 'totalOrders', 'order_count', 'orderCount'])
|
||
) || 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)
|
||
|
||
// D前缀波次:本次查询即商品条码定位(关键词=商品条码),标记已校验,自动复核时直接标记全部已扫。
|
||
// 按即将选中的第一行判定(混单时仅定位到的 D 前缀订单触发自动复核,普通散单不受影响)
|
||
const firstRow = this.scanOrderList.length > 0 ? this.scanOrderList[0] : null
|
||
this.dprefixedBarcodeVerified = isBarcodeSearch && this.isDprefixedRow(firstRow)
|
||
// 单品单件波次列表复用模式:输入车号/波次号查询(非条码定位)且列表含 D 前缀订单时开启;
|
||
// 开启后扫条码在列表内定位订单复核发货,不重新查询、不清列表
|
||
this.dprefixedWaveList =
|
||
!isBarcodeSearch &&
|
||
this.scanListType === 'single' &&
|
||
this.scanOrderList.some((row) => this.isDprefixedRow(row))
|
||
|
||
// 默认选中第一行,右侧立即展示其商品明细(不再需要手动点第一行)
|
||
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
|
||
}
|
||
// 跳过已复核完成的行(该波次所有订单已复核完成时不进入复核流程)
|
||
const firstPending = rows.find((row) => this.getWaveReviewStatus(row) !== '已复核')
|
||
if (!firstPending) {
|
||
// 全部已复核:保留列表数据仅做查看,不选中任何行(保持无选中态,广播扫描继续走订单查询)
|
||
uni.showToast({ title: '已复核', icon: 'none' })
|
||
return
|
||
}
|
||
if (this.scanListType === 'group') {
|
||
this.handleWaveClick(firstPending)
|
||
} else {
|
||
this.handleScanOrderClick(firstPending)
|
||
}
|
||
},
|
||
// 将本地缓存的已复核订单/波次按原位置插回列表,保证保留已复核数据且位置不变
|
||
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.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()
|
||
// 自动复核相关标记复位
|
||
this.dprefixedBarcodeVerified = false
|
||
this.dprefixedAllScannedHandled = false
|
||
this.sharedBarcodeDprefixed = false
|
||
this.noRecheckAutoAdvanceHandled = false
|
||
this.weighAfterReviewKey = ''
|
||
// 打印失败弹窗状态复位(清空/切单/重新扫描后清除「打印未完成」上下文,避免残留误弹)
|
||
this.printFailVisible = false
|
||
this.printFailDismissed = false
|
||
this.lastPrintError = ''
|
||
this.pendingShipAction = ''
|
||
},
|
||
// 从响应顶层或列表行内提取拣货任务 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.allProductsScanned) {
|
||
uni.showToast({ title: '请先扫完所有商品,再进行复核', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
// 团购:确认复核入口重新走“打印→包材绑定/称重”链路(复核在包材确认或称重后完成)
|
||
if (this.scanListType === 'group') {
|
||
// 包材/称重弹窗已打开时不再重复重开(避免清空已选包材或打断称重)
|
||
if (this.packageMaterialDialogVisible || this.weighDialogVisible) {
|
||
return
|
||
}
|
||
this.startGroupReviewFlow()
|
||
return
|
||
}
|
||
// 散单:打开自绘确认弹窗(样式参考称重弹窗),确认后打印→发货
|
||
this.confirmReviewOrderNo =
|
||
this.selectedOrderNo || this.getScanOrderNo(this.currentOrderHeader) || ''
|
||
this.confirmReviewVisible = true
|
||
},
|
||
closeConfirmReview() {
|
||
this.confirmReviewVisible = false
|
||
this.confirmReviewOrderNo = ''
|
||
this.scheduleScanInputFocus(150)
|
||
},
|
||
async confirmReviewConfirm() {
|
||
this.confirmReviewVisible = false
|
||
this.confirmReviewOrderNo = ''
|
||
if (!(await this.ensurePrintedBeforeShip('manual'))) {
|
||
return
|
||
}
|
||
await this.doShip('manual')
|
||
this.scheduleScanInputFocus(150)
|
||
},
|
||
// 执行确认复核:调用 order.recheckOrder.confirmRecheck
|
||
// 团购波次分组(scanListType==='group')传 wave_id,普通订单传 order_id
|
||
// enableAutoNext=true 时复核刷新后自动选中下一个未复核订单/波次;false 则留待调用方自行切换
|
||
async doConfirmRecheck(enableAutoNext = true) {
|
||
// 弱网防重入:上一次确认复核未完成时忽略本次触发,避免重复复核/重复发货
|
||
if (this.confirmRechecking) {
|
||
return false
|
||
}
|
||
this.confirmRechecking = true
|
||
try {
|
||
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 }
|
||
}
|
||
const body = await confirmRecheck(params)
|
||
const payload = body?.data || body?.result || body || {}
|
||
// 成功判定:flag==='success' 且 code 为 1 或 200(与称重/包材接口的 200 约定统一,兼容历史 1)
|
||
const flagOk = body?.flag === 'success' || payload?.flag === 'success'
|
||
const codeOk =
|
||
body?.code === 1 ||
|
||
body?.code === '1' ||
|
||
body?.code === 200 ||
|
||
body?.code === '200' ||
|
||
payload?.code === 1 ||
|
||
payload?.code === '1' ||
|
||
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 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
|
||
} finally {
|
||
this.confirmRechecking = false
|
||
}
|
||
},
|
||
// 散单:静默绑定推荐包材(失败不阻塞复核;对齐 WMS_PDA bindSuggestedPackageForSingle)
|
||
async bindSuggestedPackageForSingle() {
|
||
if (this.scanListType !== 'single') return null
|
||
const info = this.selectedPackageMaterialInfo
|
||
if (!info || typeof info !== 'object') return null
|
||
const src = this.getScanOrderSource(this.currentOrderHeader)
|
||
const waybill = String(
|
||
this.getRowValue(src, [
|
||
'waybill_no',
|
||
'waybillNo',
|
||
'waybillCode',
|
||
'delivery_order_code',
|
||
'express_no',
|
||
'expressNo',
|
||
]) || ''
|
||
).trim()
|
||
if (!waybill) {
|
||
console.warn('[packageBinding] 散单缺少运单号,跳过包材绑定')
|
||
return null
|
||
}
|
||
const pkgCode = String(info.code || info.material_code || '').trim()
|
||
let finalPackageCode = String(info.id ?? info.package_material_id ?? '')
|
||
if (!finalPackageCode && pkgCode) {
|
||
// 无包材ID仅有编码:按编码搜索包材ID(setting.packageMaterial.search)
|
||
try {
|
||
const body = await searchPackageMaterial({ keyword: pkgCode })
|
||
const payload = body?.data || body?.result || body || {}
|
||
const raw = Array.isArray(payload) ? payload : payload.list || payload.data || []
|
||
const list = Array.isArray(raw) ? raw : []
|
||
const matched = list.find(
|
||
(item) => String(item?.material_code || item?.code || '') === pkgCode
|
||
)
|
||
if (matched) {
|
||
finalPackageCode = String(matched.id || matched.package_material_id || '')
|
||
}
|
||
} catch (e) {
|
||
console.warn('[packageBinding] 散单搜索推荐包材失败:', e)
|
||
}
|
||
}
|
||
if (!finalPackageCode) {
|
||
console.warn('[packageBinding] 散单推荐包材缺少ID,跳过绑定')
|
||
return null
|
||
}
|
||
return bindExpressPackageMaterialByWaybill({
|
||
waybill_code: waybill,
|
||
package_material_id: finalPackageCode,
|
||
})
|
||
},
|
||
// 散单发货(对齐 WMS_PDA doShip):并发静默绑包材 + 确认复核;复核后按需称重/进下一单
|
||
async doShip(action = 'autoNext') {
|
||
const pkgPromise =
|
||
this.scanListType === 'single'
|
||
? this.bindSuggestedPackageForSingle().catch((err) => {
|
||
console.warn('[packageBinding] 散单包材绑定失败(不阻塞):', err)
|
||
})
|
||
: null
|
||
const ok = await this.doConfirmRecheck(false)
|
||
if (!ok) return
|
||
this.printFailDismissed = false
|
||
if (pkgPromise) {
|
||
await pkgPromise
|
||
}
|
||
// 散单称重模式:复核(发货)成功后弹称重,称重完成后再进下一单
|
||
if (this.scanListType === 'single' && this.selectedWeigh === '称重' && !this.isDprefixedWave) {
|
||
this.weighAfterReviewKey = this.getReviewKeepKey(this.currentOrderHeader)
|
||
this.weighReviewMode = false
|
||
this.weighInputValue = ''
|
||
this.weighDialogVisible = true
|
||
return
|
||
}
|
||
if (action === 'dprefixed') {
|
||
// D前缀波次:复核后清空选中、回到列表等待下一个商品条码(保留左侧列表,已复核项本地标记)
|
||
this.keyword = ''
|
||
const savedPickMode = this.currentPickMode
|
||
this.clearSelection()
|
||
// 恢复拣货模式:波次列表复用模式下继续扫条码时,isDprefixedRow 的顶层兜底判定依赖它
|
||
this.currentPickMode = savedPickMode
|
||
// 波次列表复用模式:发货后检查是否还有未复核订单,全部复核完则收尾回初始态
|
||
if (this.dprefixedWaveList) {
|
||
const hasPending = this.scanOrderList.some(
|
||
(row) =>
|
||
this.getWaveReviewStatus(row) === '未复核' && !this.isInterceptExcluded(row)
|
||
)
|
||
if (!hasPending) {
|
||
this.finishAllReviewed()
|
||
return
|
||
}
|
||
}
|
||
this.scheduleScanInputFocus(150)
|
||
return
|
||
}
|
||
if (action === 'manual' && this.settingShipMode !== 'auto') {
|
||
// 手动发货:复核完成后留在当前页,由用户继续操作
|
||
return
|
||
}
|
||
const reviewedKey = this.getReviewKeepKey(this.currentOrderHeader)
|
||
this.autoSelectNextPendingOrder(reviewedKey)
|
||
},
|
||
// 当前订单复核完成后:自动选中「当前复核行之后的第一个」未复核订单/波次,并展示其商品详情;
|
||
// 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.dprefixedWaveList = false
|
||
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()
|
||
}
|
||
},
|
||
handleClear() {
|
||
this.scanOrderList = []
|
||
this.activeKeyword = ''
|
||
this.keyword = ''
|
||
this.reviewedKeepList = []
|
||
this.dprefixedWaveList = false
|
||
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
|
||
}
|
||
// 散单被拦截订单禁止补打(对齐 WMS_PDA isOrderIntercepted:interceptStatus 非空且 ≠ none,语音播报)
|
||
if (this.scanListType !== 'group' && this.isOrderIntercepted(this.currentOrderHeader)) {
|
||
uni.showToast({ title: '该订单已拦截,禁止打印', icon: 'none' })
|
||
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(this.resolvePrintSendFailMessage(response))
|
||
}
|
||
uni.hideLoading()
|
||
uni.showToast({ title: '打印成功', icon: 'success' })
|
||
// 静默刷新左侧列表,同步服务端打印状态
|
||
this.handleRefresh(false)
|
||
} catch (error) {
|
||
uni.hideLoading()
|
||
// toast 触发全局语音播报「打印失败」(showModal 不经过 uni.showToast 包装器,无语音)
|
||
uni.showToast({ title: '打印失败', icon: 'none' })
|
||
uni.showModal({
|
||
title: '打印失败',
|
||
content: this.resolvePrintErrorText(error),
|
||
showCancel: false,
|
||
confirmText: '知道了',
|
||
})
|
||
} finally {
|
||
this.printSending = false
|
||
this.scheduleScanInputFocus(150)
|
||
}
|
||
},
|
||
// 根据打印接口失败码映射为可读文案(print.send 约定:1001 不支持的打印类型 / 504 发送失败 / 500 服务异常)
|
||
resolvePrintSendFailMessage(response) {
|
||
const code = response?.code
|
||
if (code === 1001 || code === '1001') return '不支持的打印类型'
|
||
if (code === 504 || code === '504') return '打印任务发送失败,请稍后重试'
|
||
if (code === 500 || code === '500') return '打印服务异常,请稍后重试'
|
||
const msg = response?.message || response?.msg
|
||
return msg ? String(msg) : '打印发送失败'
|
||
},
|
||
// 从打印错误对象提取可读原因(兼容 Error / 网络层 errMsg / 硬超时)
|
||
resolvePrintErrorText(error) {
|
||
if (!error) return '打印失败,请重试'
|
||
if (error?.timedOut) return '网络超时,请稍后重试'
|
||
const raw = String(error?.message || error?.msg || error?.errMsg || '').trim()
|
||
if (!raw || raw === 'Error') return '打印失败,请重试'
|
||
if (/timeout/i.test(raw)) return '网络超时,请稍后重试'
|
||
if (/request:fail/i.test(raw)) return '网络异常,请检查网络'
|
||
return raw
|
||
},
|
||
// 生成打印请求码(唯一)
|
||
buildPrintRequestCode() {
|
||
const timePart = Date.now().toString(36)
|
||
const randomPart = Math.random().toString(36).slice(2, 10)
|
||
return `PRINT_${timePart}_${randomPart}`
|
||
},
|
||
// 为 Promise 增加超时控制(对齐 WMS_PDA withTimeout)
|
||
withTimeout(promise, ms = 10000) {
|
||
let timer = null
|
||
const timeoutPromise = new Promise((_, reject) => {
|
||
timer = setTimeout(() => reject(new Error('打印请求超时')), ms)
|
||
})
|
||
return Promise.race([Promise.resolve(promise), timeoutPromise]).finally(() => {
|
||
if (timer) clearTimeout(timer)
|
||
})
|
||
},
|
||
// 当前订单/波次是否已打印(对齐 WMS_PDA):团购 = 未打印数量 0 且 订单数 > 0;散单 = is_printed 标志
|
||
isAlreadyPrinted(item) {
|
||
const target = item || this.currentOrderHeader
|
||
if (!target || typeof target !== 'object') return false
|
||
if (this.scanListType === 'group') {
|
||
const unprintedCount = Number(this.getRowValue(target, ['unprinted_count', 'unprintedCount'])) || 0
|
||
const orderCount = Number(this.getRowValue(target, ['total_orders', 'order_count', 'orderCount'])) || 0
|
||
return unprintedCount === 0 && orderCount > 0
|
||
}
|
||
const printed = this.getRowValue(target, ['is_printed', 'isPrinted'])
|
||
return printed === true || printed === 1 || printed === '1' || printed === '是'
|
||
},
|
||
// 打印当前订单/波次并等待结果(含超时),返回是否成功
|
||
async printOrderAndWait(item) {
|
||
const target = item || this.currentOrderHeader
|
||
if (!target) {
|
||
this.lastPrintError = '缺少打印目标'
|
||
return false
|
||
}
|
||
if (!this.selectedPrinterId) {
|
||
this.lastPrintError = '未绑定打印台'
|
||
return false
|
||
}
|
||
try {
|
||
let waveGroups = []
|
||
if (this.scanListType === 'group') {
|
||
waveGroups = await this.fetchGroupWavePrintData(target)
|
||
} else {
|
||
const orderId = this.getScanOrderId(target)
|
||
if (orderId === '') {
|
||
this.lastPrintError = '未找到订单ID'
|
||
return false
|
||
}
|
||
const body = await getOrderPrintData({ order_ids: [Number(orderId)] })
|
||
const payload = this.extractPrintPayload(body)
|
||
waveGroups = this.normalizeWaveGroups(payload)
|
||
}
|
||
if (!waveGroups.length) {
|
||
this.lastPrintError = '未获取到可打印数据'
|
||
return false
|
||
}
|
||
this.printRequestCode = this.buildPrintRequestCode()
|
||
const response = await this.withTimeout(
|
||
sendPrint({
|
||
type: 'express',
|
||
printStationId: this.selectedPrinterId,
|
||
requestCode: this.printRequestCode,
|
||
data: { waveGroups },
|
||
}),
|
||
10000
|
||
)
|
||
const success =
|
||
response?.flag !== 'failure' &&
|
||
response?.code !== '500' &&
|
||
response?.code !== 500 &&
|
||
response?.code !== 1001 &&
|
||
response?.code !== 504
|
||
if (!success) {
|
||
this.lastPrintError = String(response?.message || response?.msg || '打印失败')
|
||
return false
|
||
}
|
||
this.lastPrintError = ''
|
||
return true
|
||
} catch (error) {
|
||
this.lastPrintError = String(error?.message || error?.msg || error?.errMsg || '打印失败或超时')
|
||
return false
|
||
}
|
||
},
|
||
// 本地标记当前订单/波次已打印(打印成功后同步,不刷新列表、不清空选中)
|
||
markCurrentPrinted() {
|
||
const row = this.currentOrderHeader
|
||
if (!row || typeof row !== 'object') return
|
||
const src = this.getScanOrderSource(row)
|
||
if (!src || typeof src !== 'object') return
|
||
if (this.scanListType === 'group') {
|
||
src.unprinted_count = 0
|
||
const orderCount = this.getRowValue(src, ['total_orders', 'order_count', 'orderCount'])
|
||
if (this.getRowValue(src, ['printed_count', 'printedCount']) === '') {
|
||
src.printed_count = Number(orderCount) || 1
|
||
}
|
||
} else {
|
||
src.is_printed = true
|
||
}
|
||
},
|
||
// 发货前打印确认(对齐 WMS_PDA ensurePrintedBeforeShip)
|
||
async ensurePrintedBeforeShip(actionType = 'autoNext') {
|
||
this.pendingShipAction = actionType
|
||
if (this.effectivePrintMode === 'noPrint') {
|
||
return true
|
||
}
|
||
if (!this.selectedPrinterId) {
|
||
this.printFailMessage = '未绑定打印台,请先绑定打印台后再发货'
|
||
this.printFailDismissed = true
|
||
this.printFailVisible = true
|
||
return false
|
||
}
|
||
if (this.isAlreadyPrinted(this.currentOrderHeader)) {
|
||
return true
|
||
}
|
||
// 打印请求进行中:忽略并发触发,避免重复打印
|
||
if (this.printFlowRunning) {
|
||
return false
|
||
}
|
||
this.printFlowRunning = true
|
||
try {
|
||
uni.showLoading({ title: '打印中...', mask: true })
|
||
const printed = await this.printOrderAndWait(this.currentOrderHeader)
|
||
uni.hideLoading()
|
||
if (printed) {
|
||
this.printFailDismissed = false
|
||
this.markCurrentPrinted()
|
||
uni.showToast({ title: '打印成功', icon: 'success' })
|
||
return true
|
||
}
|
||
this.printFailMessage = this.lastPrintError || '打印失败,未触发发货'
|
||
this.printFailDismissed = true
|
||
this.printFailVisible = true
|
||
uni.showToast({ title: '打印失败', icon: 'none' })
|
||
return false
|
||
} finally {
|
||
this.printFlowRunning = false
|
||
}
|
||
},
|
||
handlePrintFailClose() {
|
||
this.printFailVisible = false
|
||
},
|
||
async handlePrintFailRetry() {
|
||
uni.showLoading({ title: '打印中...', mask: true })
|
||
const printed = await this.printOrderAndWait(this.currentOrderHeader)
|
||
uni.hideLoading()
|
||
if (!printed) {
|
||
this.printFailMessage = this.lastPrintError || '打印失败,请重试'
|
||
uni.showToast({ title: '打印失败', icon: 'none' })
|
||
return
|
||
}
|
||
this.printFailDismissed = false
|
||
this.printFailVisible = false
|
||
this.markCurrentPrinted()
|
||
uni.showToast({ title: '打印成功', icon: 'success' })
|
||
if (this.pendingShipAction === 'groupShip') {
|
||
this.startGroupReviewFlow()
|
||
return
|
||
}
|
||
await this.doShip(this.pendingShipAction || 'autoNext')
|
||
},
|
||
// 解析仓库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
|
||
},
|
||
// 商品明细全部扫完后进入自动复核发货链路(对齐 WMS_PDA handleDetailAllScanned)
|
||
autoOpenWeighAfterScan() {
|
||
// 避免与其它弹窗重叠、或在已复核/拦截锁定等状态下重复弹出
|
||
if (
|
||
this.weighDialogVisible ||
|
||
this.confirmReviewVisible ||
|
||
this.noBarcodeReviewVisible ||
|
||
this.batchReviewVisible ||
|
||
this.packageMaterialDialogVisible ||
|
||
this.sharedBarcodeDrawerVisible ||
|
||
this.settingsVisible ||
|
||
this.printFailVisible
|
||
) {
|
||
return
|
||
}
|
||
if (!this.hasSelection || this.reviewLocked) {
|
||
return
|
||
}
|
||
if (!this.allProductsScanned) {
|
||
return
|
||
}
|
||
// D前缀波次自动复核防重入(finishDprefixedAutoReview 与明细变化可能重复触发)
|
||
if (this.isDprefixedWave && this.dprefixedAllScannedHandled) {
|
||
return
|
||
}
|
||
this.dprefixedAllScannedHandled = true
|
||
// 团购:先打印确认 → 包材绑定(或回退称重复核前)
|
||
if (this.scanListType === 'group') {
|
||
this.startGroupReviewFlow()
|
||
return
|
||
}
|
||
// 散单:不走包材弹窗,直接进入发货/称重决策
|
||
this.afterPackageBinding()
|
||
},
|
||
// 团单复核完成的统一入口:
|
||
// 有运单号且开包材绑定 → 打印→绑包材;有运单号但关绑定 → 打印→称重(复核前);
|
||
// 无运单号 → 无法绑包材也无法称重,打印确认后直接复核(wave_id)不称重
|
||
startGroupReviewFlow() {
|
||
const waybill = this.getWaveRepresentWaybill(this.currentOrderHeader)
|
||
if (this.settingBindPackage && waybill) {
|
||
this.handleGroupAllScanned()
|
||
return
|
||
}
|
||
if (!waybill) {
|
||
this.handleGroupDirectReview()
|
||
return
|
||
}
|
||
this.handleGroupFallbackWeigh()
|
||
},
|
||
// 团单无运单号:打印确认后直接复核(无法按运单号绑包材/称重)
|
||
async handleGroupDirectReview() {
|
||
if (!(await this.ensurePrintedBeforeShip('groupShip'))) {
|
||
return
|
||
}
|
||
await this.doConfirmRecheck()
|
||
},
|
||
// 团单:全部商品复核完成时先确保打印成功,打印成功才进入包材绑定
|
||
async handleGroupAllScanned() {
|
||
if (!(await this.ensurePrintedBeforeShip('groupShip'))) {
|
||
return
|
||
}
|
||
this.openGroupPackageBinding()
|
||
},
|
||
// 团单回退(未开包材绑定/无运单):先打印确认 → 称重(复核前)→ 复核
|
||
async handleGroupFallbackWeigh() {
|
||
if (!(await this.ensurePrintedBeforeShip('groupShip'))) {
|
||
return
|
||
}
|
||
this.weighReviewMode = true
|
||
this.weighInputValue = ''
|
||
this.weighDialogVisible = true
|
||
},
|
||
// 弹包材绑定弹窗(打印成功 / 打印失败重试成功后进入)
|
||
openGroupPackageBinding() {
|
||
this.restoreSoftInputMode()
|
||
const waybill = this.getWaveRepresentWaybill(this.currentOrderHeader)
|
||
if (!waybill) {
|
||
// 无运单号:回退到称重(复核前)
|
||
this.weighReviewMode = true
|
||
this.weighInputValue = ''
|
||
this.weighDialogVisible = true
|
||
return
|
||
}
|
||
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
|
||
},
|
||
// 包材绑定 / 发货之后的分叉(对齐 WMS_PDA afterPackageBinding)
|
||
afterPackageBinding() {
|
||
if (this.isDprefixedWave) {
|
||
this.handleDprefixedAutoConfirm()
|
||
return
|
||
}
|
||
// 团购始终称重(复核已在包材绑定确认时完成);散单按“称重模式”设置
|
||
const needWeigh = this.scanListType === 'group' || this.selectedWeigh === '称重'
|
||
if (needWeigh && this.scanListType === 'group') {
|
||
this.pmAfterReviewWeighWaybill = this.getWaveRepresentWaybill(this.currentOrderHeader) || ''
|
||
this.pmAfterReviewReviewKey = this.getReviewKeepKey(this.currentOrderHeader)
|
||
this.pmPostReviewWeighPending = true
|
||
this.weighReviewMode = false
|
||
this.weighInputValue = ''
|
||
this.weighDialogVisible = true
|
||
return
|
||
}
|
||
// 散单:自动发货则直接打印→发货(需要称重时复核后弹称重);手动发货提示点击确认复核
|
||
if (this.settingShipMode === 'auto') {
|
||
this.handleAutoConfirmAndNext()
|
||
} else {
|
||
uni.showToast({ title: '全部商品已扫描完成,可点击确认复核', icon: 'none', duration: 2000 })
|
||
}
|
||
},
|
||
// 散单自动发货:先打印确认 → 发货
|
||
async handleAutoConfirmAndNext() {
|
||
if (!(await this.ensurePrintedBeforeShip('autoNext'))) {
|
||
return
|
||
}
|
||
await this.doShip('autoNext')
|
||
},
|
||
// D前缀波次:先打印确认 → 发货
|
||
async handleDprefixedAutoConfirm() {
|
||
if (!(await this.ensurePrintedBeforeShip('dprefixed'))) {
|
||
return
|
||
}
|
||
await this.doShip('dprefixed')
|
||
},
|
||
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
|
||
}
|
||
// 散单复核后称重被取消:保留 weighAfterReviewKey 待称重状态,点商品行/手动称重可补录,保存后再切下一单
|
||
if (this.scanListType === 'single' && this.weighAfterReviewKey) {
|
||
this.scheduleScanInputFocus(150)
|
||
return
|
||
}
|
||
this.pmAfterReviewWeighWaybill = ''
|
||
this.pmAfterReviewReviewKey = ''
|
||
this.weighAfterReviewKey = ''
|
||
this.pmPostReviewWeighPending = false
|
||
this.scheduleScanInputFocus(150)
|
||
},
|
||
// 包材绑定:仅团购波次,按波次首单运单号(first_waybill_no)绑定包材
|
||
handleAddPackageMaterial() {
|
||
this.restoreSoftInputMode()
|
||
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
|
||
},
|
||
// 保存包材:自动流程(包材绑定后复核)走并发复核;手动「包材」按钮仅绑定
|
||
async confirmPackageMaterial() {
|
||
if (this.pmBinding) {
|
||
return
|
||
}
|
||
if (this.pmAutoRecheck || this.pmPendingWeigh) {
|
||
await this.doGroupShip()
|
||
} else {
|
||
await this.bindPackageOnly()
|
||
}
|
||
},
|
||
// 解析本次绑定的运单号(优先弹窗打开时记录的 pmBindWaybill,兜底当前波次运单)
|
||
resolvePmBindWaybill() {
|
||
return this.pmBindWaybill || this.getWaveRepresentWaybill(this.currentOrderHeader)
|
||
},
|
||
// 解析待绑定的包材 ID(选中 > 唯一命中 > 推荐包材)
|
||
resolvePackageMaterialId() {
|
||
let material = this.pmSelectedMaterial
|
||
if (!material && this.pmSearchList.length === 1) {
|
||
material = this.pmSearchList[0]
|
||
}
|
||
if (!material) {
|
||
material = this.recommendedAsMaterial()
|
||
}
|
||
return material?.id ?? material?.package_material_id
|
||
},
|
||
// 仅绑定包材(手动「包材」按钮,不触发复核)
|
||
async bindPackageOnly() {
|
||
if (this.scanListType !== 'group') {
|
||
uni.showToast({ title: '仅团购波次支持包材绑定', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
const waybill = this.resolvePmBindWaybill()
|
||
if (!waybill) {
|
||
uni.showToast({ title: '未找到波次运单号,无法绑定包材', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
const materialId = this.resolvePackageMaterialId()
|
||
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' })
|
||
this.resetPackageMaterialDialog()
|
||
this.scheduleScanInputFocus(150)
|
||
} catch (error) {
|
||
uni.showToast({ title: '包材绑定失败,请重试', icon: 'none', silentVoice: true })
|
||
} finally {
|
||
this.pmBinding = false
|
||
}
|
||
},
|
||
// 团单发货:提交复核 + 包材绑定并发(包材绑定失败不阻塞发货),随后进入称重/下一波次
|
||
async doGroupShip() {
|
||
if (this.scanListType !== 'group') {
|
||
uni.showToast({ title: '仅团购波次支持包材绑定', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
const waybill = this.resolvePmBindWaybill()
|
||
if (!waybill) {
|
||
uni.showToast({ title: '未找到波次运单号,无法绑定包材', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
const materialId = this.resolvePackageMaterialId()
|
||
if (materialId === undefined || materialId === null || materialId === '') {
|
||
uni.showToast({ title: '请先扫描并选择包材', icon: 'none', silentVoice: true })
|
||
return
|
||
}
|
||
this.pmBinding = true
|
||
uni.showLoading({ title: '提交复核中...' })
|
||
try {
|
||
// 并发提交:复核确认 + 包材绑定(包材绑定失败不阻塞)
|
||
const bindPromise = bindExpressPackageMaterialByWaybill({
|
||
waybill_code: waybill,
|
||
package_material_id: materialId,
|
||
}).catch((pkgErr) => {
|
||
console.warn('[packageBinding] 包材绑定失败(不阻塞):', pkgErr)
|
||
})
|
||
const [reviewed] = await Promise.all([this.doConfirmRecheck(false), bindPromise])
|
||
uni.hideLoading()
|
||
if (!reviewed) {
|
||
// doConfirmRecheck 已弹出失败提示
|
||
return
|
||
}
|
||
this.pmPendingWeigh = false
|
||
this.pmAutoRecheck = false
|
||
this.resetPackageMaterialDialog()
|
||
this.afterPackageBinding()
|
||
} catch (error) {
|
||
uni.hideLoading()
|
||
uni.showToast({ title: '提交复核失败,请重试', icon: 'none' })
|
||
} 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 || '称重保存失败'
|
||
const rawMsg = String(message)
|
||
// 散单称重前置打包校验(single_weigh_require_pack):订单未打包时接口返回 400「订单未打包」,
|
||
// 给出明确指引并保持当前选中态(不切单),用户打包后可重新称重
|
||
if (rawMsg.includes('未打包')) {
|
||
uni.showModal({
|
||
title: '称重失败',
|
||
content: '订单未打包,请先打包后再称重',
|
||
showCancel: false,
|
||
confirmText: '确定',
|
||
})
|
||
getVoice().play('订单未打包,请先打包后再称重')
|
||
return
|
||
}
|
||
uni.showModal({
|
||
title: '称重失败',
|
||
content: rawMsg,
|
||
showCancel: false,
|
||
confirmText: '确定',
|
||
})
|
||
getVoice().play('称重失败')
|
||
return
|
||
}
|
||
uni.showToast({ title: `称重成功:${numeric} 克`, icon: 'none' })
|
||
this.weighDialogVisible = false
|
||
// 复核前自动称重模式:保存成功后直接继续执行确认复核(不弹二次确认弹窗)
|
||
const shouldContinueReview = this.weighReviewMode
|
||
this.weighReviewMode = false
|
||
// 复核后称重(团购自动发货 / 散单称重模式):保存成功后切下一个未复核订单/波次
|
||
const nextReviewKey = this.pmAfterReviewReviewKey || this.weighAfterReviewKey
|
||
this.pmAfterReviewWeighWaybill = ''
|
||
this.pmAfterReviewReviewKey = ''
|
||
this.weighAfterReviewKey = ''
|
||
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.effectivePrintMode !== 'noPrint' &&
|
||
this.printFailDismissed &&
|
||
!this.printFailVisible
|
||
) {
|
||
this.printFailMessage = this.lastPrintError || '打印失败,未触发发货'
|
||
this.printFailVisible = true
|
||
return
|
||
}
|
||
// 免验自动推进(对齐 WMS_PDA handleGoodsItemClick):所有商品 need_recheck=N 或已扫满时,
|
||
// 此类订单商品明细从不变化、allScanned 不会触发,点击商品卡片时主动触发一次发货链路。
|
||
if (
|
||
!this.isDprefixedWave &&
|
||
!this.noRecheckAutoAdvanceHandled &&
|
||
this.displayOrders.length > 0 &&
|
||
this.getWaveReviewStatus(this.currentOrderHeader) !== '已复核' &&
|
||
this.displayOrders.every(
|
||
(g) => this.isRecheckExempt(g) || Number(g.scannedQty || 0) >= Number(g.quantity || 0)
|
||
)
|
||
) {
|
||
this.noRecheckAutoAdvanceHandled = true
|
||
this.autoOpenWeighAfterScan()
|
||
return
|
||
}
|
||
if (this.canNoBarcodeReview(order)) {
|
||
diagNote('no-barcode-review-open', {
|
||
item: order?.productName || order?.barcode || '',
|
||
source: 'click',
|
||
})
|
||
this.openNoBarcodeReview(order)
|
||
return
|
||
}
|
||
// 散单复核后称重待完成(先复核后称重,取消称重后):点商品行重新弹普通称重补录
|
||
if (this.scanListType === 'single' && this.weighAfterReviewKey) {
|
||
this.weighReviewMode = false
|
||
this.weighInputValue = ''
|
||
this.weighDialogVisible = true
|
||
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' })
|
||
const msg = this.isRecheckExempt(order) ? '该商品无需复核' : '该商品已复核完成'
|
||
uni.showToast({ title: msg, 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) {
|
||
const msg = this.isRecheckExempt(target) ? '该商品无需复核' : '该商品已复核完成'
|
||
uni.showToast({ title: msg, icon: 'none' })
|
||
this.closeNoBarcodeReview()
|
||
return
|
||
}
|
||
// 将该商品已扫数量置为总数(无条码复核)
|
||
target.scannedQty = total
|
||
// 同步已扫/总数统计
|
||
this.syncDetailStats(this.currentOrderHeader, this.displayOrders)
|
||
this.speakDataConsistent(target)
|
||
this.closeNoBarcodeReview()
|
||
// 商品明细全部扫完时:按“是否称重=称重”自动进入称重(复核前)
|
||
this.autoOpenWeighAfterScan()
|
||
},
|
||
togglePrinterDropdown() {
|
||
if (this.printerOpened) {
|
||
this.closePrinterDropdown()
|
||
return
|
||
}
|
||
// 打印台列表为空时,重新拉取
|
||
if (this.printerList.length === 0) {
|
||
this.loadPrinters()
|
||
}
|
||
this.printerOpened = true
|
||
},
|
||
closePrinterDropdown() {
|
||
this.printerOpened = false
|
||
},
|
||
handlePrinterOptionClick(index) {
|
||
const printer = this.printerList[index] || null
|
||
this.selectedPrinter = printer ? this.getPrinterName(printer) : ''
|
||
this.selectedPrinterId = printer ? this.getPrinterId(printer) : ''
|
||
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 || {}
|
||
},
|
||
// 读取订单/波次的推荐包材(兼容 suggested_package_material / suggestedPackageMaterial / suggestedPkg / suggested_pkg,
|
||
// 散单订单兼容 detail 包裹;无则返回 '')
|
||
resolveSuggestedPackageMaterial(item) {
|
||
if (!item || typeof item !== 'object') return ''
|
||
const keys = ['suggested_package_material', 'suggestedPackageMaterial', 'suggestedPkg', 'suggested_pkg']
|
||
const value = this.getRowValue(item, keys)
|
||
if (value !== '') return value
|
||
const src = this.getScanOrderSource(item)
|
||
if (src && src !== item) {
|
||
return this.getRowValue(src, keys)
|
||
}
|
||
return ''
|
||
},
|
||
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']) || ''
|
||
},
|
||
// 拦截状态 → 展示文案(与 interceptionLog 状态映射一致)
|
||
interceptStatusText(status) {
|
||
const s = String(status || '').trim()
|
||
if (s === '' || s === 'none') return '未拦截'
|
||
if (s === 'requested' || s === 'pending' || s === 'intercepting') return '拦截中'
|
||
if (s === 'intercepted' || s === 'intercepted_at_warehouse') return '仓库已拦截'
|
||
if (s === 'intercept_success') return '拦截成功'
|
||
if (s === 'intercept_failed') return '拦截失败'
|
||
if (s === 'cancelled') return '已取消'
|
||
return s
|
||
},
|
||
// 读取拦截订单运单号(优先 firstWaybillNo,兜底 waybillNo / waybill_code)
|
||
interceptWaybillSource(item) {
|
||
const src = this.getScanOrderSource(item)
|
||
return String(
|
||
this.getRowValue(src, [
|
||
'first_waybill_no', 'firstWaybillNo',
|
||
'waybill_no', 'waybillNo', 'waybill_code', 'waybillCode',
|
||
]) || ''
|
||
).trim()
|
||
},
|
||
// 运单号展示(对齐 ReviewDetail.interceptWaybill):
|
||
// 基础值 firstWaybillNo || waybillNo;团购模式拼 运单号-总订单数-波次索引
|
||
interceptWaybill(item, fallbackTotal = '') {
|
||
const base = this.interceptWaybillSource(item)
|
||
if (!base) return '--'
|
||
if (this.scanListType === 'group') {
|
||
const totalOrders =
|
||
this.getRowValue(item, ['totalOrders', 'total_orders']) || fallbackTotal || ''
|
||
const waveIndex = this.getRowValue(item, ['waveIndex', 'wave_index']) || ''
|
||
const parts = [base]
|
||
if (totalOrders !== '') parts.push(String(totalOrders))
|
||
if (waveIndex !== '') parts.push(String(waveIndex))
|
||
return parts.join('-')
|
||
}
|
||
return base
|
||
},
|
||
// 波次拦截单列表:优先 wave.intercepted[],兜底从 wave.orders 过滤被拦截订单
|
||
resolveWaveInterceptList(wave) {
|
||
const intercepted = Array.isArray(wave?.intercepted) ? wave.intercepted : []
|
||
if (intercepted.length > 0) {
|
||
return intercepted
|
||
}
|
||
const orders = Array.isArray(wave?.orders) ? wave.orders : []
|
||
return orders.filter((o) => this.isOrderIntercepted(o))
|
||
},
|
||
// 点击散单拦截标签:单订单形态弹窗(运单号 + 提示)
|
||
openInterceptInfo(item) {
|
||
this.interceptInfo = {
|
||
isWave: false,
|
||
waveNo: '',
|
||
waybillNo: this.interceptWaybillSource(item) || '--',
|
||
list: [],
|
||
}
|
||
this.interceptInfoVisible = true
|
||
},
|
||
// 点击团购波次拦截标签:波次形态弹窗(波次号 + 拦截单运单号列表)
|
||
openWaveInterceptInfo(wave) {
|
||
const waveNo =
|
||
this.getRowValue(wave, ['wave_no', 'waveNo']) ||
|
||
this.getRowValue(wave, ['wave_id', 'waveId']) ||
|
||
'-'
|
||
const waveTotal =
|
||
this.getRowValue(wave, ['total_orders', 'totalOrders', 'order_count', 'orderCount']) || ''
|
||
const list = this.resolveWaveInterceptList(wave).map((o) => this.interceptWaybill(o, waveTotal))
|
||
this.interceptInfo = {
|
||
isWave: true,
|
||
waveNo,
|
||
waybillNo: '',
|
||
list,
|
||
}
|
||
this.interceptInfoVisible = true
|
||
},
|
||
closeInterceptInfo() {
|
||
this.interceptInfoVisible = false
|
||
},
|
||
// 点击「拦截信息」按钮:弹窗展示当前选中订单/波次的拦截信息
|
||
handleShowInterceptInfo() {
|
||
if (!this.hasInterceptInfo) return
|
||
if (this.scanListType === 'group') {
|
||
this.openWaveInterceptInfo(this.currentOrderHeader)
|
||
} else {
|
||
this.openInterceptInfo(this.currentOrderHeader)
|
||
}
|
||
},
|
||
// 拦截中(intercept_status ∈ requested/pending/intercepting):红色"拦截"标签
|
||
isIntercepted(item) {
|
||
const status = this.getInterceptStatus(item)
|
||
return status === 'requested' || status === 'pending' || status === 'intercepting'
|
||
},
|
||
// 已拦截(intercept_status ∈ intercepted/intercepted_at_warehouse/intercept_success):灰色"已拦截"标签
|
||
isInterceptedDone(item) {
|
||
const status = this.getInterceptStatus(item)
|
||
return (
|
||
status === 'intercepted' ||
|
||
status === 'intercepted_at_warehouse' ||
|
||
status === 'intercept_success'
|
||
)
|
||
},
|
||
// 是否被拦截(对齐 WMS_PDA:interceptStatus 非空且不为 'none' 即视为拦截,
|
||
// 覆盖 requested / intercepted_at_warehouse / intercepted 及后端可能的其它非 none 取值)
|
||
isOrderIntercepted(item) {
|
||
const status = String(this.getInterceptStatus(item) || '').trim()
|
||
return status !== '' && status !== 'none'
|
||
},
|
||
// 统计团购波次下订单的拦截情况(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)
|
||
},
|
||
// 是否处于拦截/已拦截状态(不计入剩余未复核),对齐 WMS_PDA:interceptStatus 非空且不为 none
|
||
isInterceptExcluded(item) {
|
||
return this.isOrderIntercepted(item)
|
||
},
|
||
// 剩余未复核数统计:排除拦截/已拦截订单
|
||
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.spokenRecheckKeys = []
|
||
this.dprefixedAllScannedHandled = false
|
||
this.noRecheckAutoAdvanceHandled = false
|
||
this.resetSharedBarcodeState()
|
||
// 散单复核后称重待完成:切到其它订单时取消该状态(避免残留,切回后不再自动弹称重)
|
||
if (this.scanListType === 'single' && this.weighAfterReviewKey) {
|
||
const clickedKey = this.getReviewKeepKey(item)
|
||
if (clickedKey && clickedKey !== this.weighAfterReviewKey) {
|
||
this.weighAfterReviewKey = ''
|
||
}
|
||
}
|
||
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.resolveSuggestedPackageMaterial(item)
|
||
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)
|
||
// 进入详情时播报免复核商品的打包要求(need_recheck=N 且含打包要求)
|
||
this.speakNoRecheckPackRequirements(this.displayOrders)
|
||
|
||
// 选中订单含拦截信息时自动弹出拦截信息弹窗(自动/手动发货模式均弹)
|
||
if (this.isOrderIntercepted(item)) {
|
||
this.openInterceptInfo(item)
|
||
}
|
||
|
||
// D前缀波次(单品单件):商品条码定位进入时自动标记全部已扫并触发复核发货
|
||
if (this.isDprefixedWave) {
|
||
if (this.dprefixedBarcodeVerified) {
|
||
this.dprefixedBarcodeVerified = false
|
||
if (this.getWaveReviewStatus(item) !== '已复核') {
|
||
this.completeDprefixedAutoReview()
|
||
}
|
||
} else if (this.getWaveReviewStatus(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.spokenRecheckKeys = []
|
||
this.dprefixedAllScannedHandled = false
|
||
this.noRecheckAutoAdvanceHandled = false
|
||
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']) || ''
|
||
// 篮号:团购 pick_mode=1 时优先取波次 box_no(data.list[x].box_no),缺失兜底 wave_index
|
||
const wavePickMode = Number(this.getRowValue(wave, ['pick_mode', 'pickMode']))
|
||
const waveBoxNo = this.getRowValue(wave, ['box_no', 'boxNo'])
|
||
this.selectedWaveIndex =
|
||
wavePickMode === 1 && waveBoxNo !== ''
|
||
? waveBoxNo
|
||
: this.getRowValue(wave, ['wave_index', 'waveIndex'])
|
||
this.selectedItemsWeight = this.getRowValue(wave, ['items_weight', 'itemsWeight'])
|
||
const pkg = this.resolveSuggestedPackageMaterial(wave)
|
||
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)
|
||
// 进入详情时播报免复核商品的打包要求(need_recheck=N 且含打包要求)
|
||
this.speakNoRecheckPackRequirements(this.displayOrders)
|
||
// 已复核波次:商品明细统一置为全部已扫(复核后重选/取消称重重选该波次时保持已扫状态,
|
||
// 避免长按商品行误弹“无条码复核”)
|
||
if (this.getWaveReviewStatus(wave) === '已复核') {
|
||
this.markAllProductsScanned()
|
||
}
|
||
// 波次内含拦截单时自动弹出拦截信息弹窗(自动/手动发货模式均弹)
|
||
if (this.getWaveInterceptLabel(wave)) {
|
||
this.openWaveInterceptInfo(wave)
|
||
}
|
||
},
|
||
// 将当前商品明细全部置为已扫(已复核/复核后重选波次展示用)
|
||
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)
|
||
}
|
||
},
|
||
// D前缀波次单品单件:自动标记所有商品为已扫并触发复核发货;
|
||
// 若库内有相同商品(has_shared_barcode),先弹确认弹窗,确认后再自动复核发货
|
||
completeDprefixedAutoReview() {
|
||
if (!this.displayOrders.length) return
|
||
const sharedGoods = this.displayOrders.find((g) => !!g?.hasSharedBarcode)
|
||
if (sharedGoods) {
|
||
this.sharedBarcodeDprefixed = true
|
||
this.sharedBarcodeMatches = [sharedGoods]
|
||
this.sharedBarcodeCode = String(sharedGoods.barcode || '')
|
||
this.sharedBarcodeSelectedIndex = 0
|
||
this.sharedBarcodeImgError = {}
|
||
this.sharedBarcodeDrawerVisible = true
|
||
return
|
||
}
|
||
this.finishDprefixedAutoReview()
|
||
},
|
||
// 标记所有商品为已扫并触发复核发货
|
||
finishDprefixedAutoReview() {
|
||
if (!this.displayOrders.length) return
|
||
if (this.dprefixedAllScannedHandled) return
|
||
const rows = this.displayOrders.map((g) => ({
|
||
...g,
|
||
scannedQty: g.quantity,
|
||
}))
|
||
this.displayOrders = rows
|
||
this.syncDetailStats(this.currentOrderHeader, rows)
|
||
this.$nextTick(() => {
|
||
this.autoOpenWeighAfterScan()
|
||
})
|
||
},
|
||
},
|
||
mounted() {
|
||
this.loadPrinters()
|
||
this.loadSettings()
|
||
this.restoreSoftInputMode()
|
||
// 登录进入布局壳后订单页白屏兜底:订单页组件渲染晚于布局壳 onShow 的 lockLandscape,
|
||
// 这里补 setStyle 纠正 WebView 视口(立即 + 延迟重试)
|
||
this.lockLandscape()
|
||
setTimeout(() => { this.lockLandscape() }, 300)
|
||
setTimeout(() => { this.lockLandscape() }, 800)
|
||
// 扫码枪识别:真机/H5 双链路(隐藏 input + plus.key + DOM 全局监听)
|
||
this.setupScanCaptureMode()
|
||
this.attachPlusKeyboardListener()
|
||
this.attachGlobalKeyboardListener()
|
||
this.suppressSoftKeyboardBurst()
|
||
this.scheduleScanInputFocus(260)
|
||
// 页面进入即聚焦搜索框(仅桌面端;移动端/真机不自动聚焦,避免误弹软键盘)
|
||
this.$nextTick(() => {
|
||
if (!this.enableHiddenInputCapture && !this.isRealDevice()) {
|
||
this.activateSearchInput()
|
||
}
|
||
})
|
||
},
|
||
activated() {
|
||
// keep-alive 从其它页切回时:恢复扫码链路与隐藏 input 焦点
|
||
this.pageActive = true
|
||
this.restoreSoftInputMode()
|
||
this.setupScanCaptureMode()
|
||
this.attachPlusKeyboardListener()
|
||
this.attachGlobalKeyboardListener()
|
||
this.suppressSoftKeyboardBurst()
|
||
this.scheduleScanInputFocus(260)
|
||
},
|
||
deactivated() {
|
||
// keep-alive 切到其它页时:暂停扫码链路,避免隐藏 input 抢占其它页焦点
|
||
this.pageActive = false
|
||
console.log('[order-scan] deactivated -> remove listeners')
|
||
this.removePlusKeyboardListener()
|
||
this.removeGlobalKeyboardListener()
|
||
this.clearScanFocusResumeTimer()
|
||
this.clearWeighFocusTimer()
|
||
this.clearKeyboardSuppressTimers()
|
||
this.clearHiddenScanTimer()
|
||
this.clearPlusKeyTimer()
|
||
this.clearHiddenRefocusTimer()
|
||
this.scanHiddenFocused = false
|
||
this.scanInputFocus = false
|
||
},
|
||
beforeUnmount() {
|
||
this.pageActive = false
|
||
console.log('[order-scan] beforeUnmount -> remove listeners')
|
||
this.onResizeEnd()
|
||
this.removePlusKeyboardListener()
|
||
this.removeGlobalKeyboardListener()
|
||
this.clearScanFocusResumeTimer()
|
||
this.clearWeighFocusTimer()
|
||
this.clearKeyboardSuppressTimers()
|
||
this.clearHiddenScanTimer()
|
||
this.clearPlusKeyTimer()
|
||
this.clearHiddenRefocusTimer()
|
||
// 清理扫码静默防抖定时器,避免泄漏
|
||
if (this.scanTimer) {
|
||
clearTimeout(this.scanTimer)
|
||
this.scanTimer = 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;
|
||
/* 四周页边距由 25px 收窄到一半(12.5px),让面板更贴近屏幕边缘 */
|
||
padding-left: 0.125rem;
|
||
padding-right: 0.125rem;
|
||
padding-bottom: 0.125rem;
|
||
}
|
||
|
||
/* 顶栏下边距减半:20px → 7.5px,与 page-main 顶部内边距 5px 合计 12.5px,
|
||
顶部留白与左右页边距(12.5px)保持一致。
|
||
注意:uni-app H5 会把本页 <style> 强制按 scoped 处理(所有选择器补 data-v),
|
||
而 .top-nav 是 top-nav 子组件的元素(带的是子组件的 data-v),
|
||
必须用 :deep() 穿透,否则 .top-nav 会被补上本页 data-v 导致匹配不到 */
|
||
.order-review-page :deep(.top-nav) {
|
||
margin-bottom: 0.075rem !important;
|
||
}
|
||
|
||
.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.07rem;
|
||
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.1rem 0.15rem;
|
||
box-sizing: border-box;
|
||
background-color: var(--wms-card-bg);
|
||
border-radius: 0.07rem;
|
||
margin-bottom: 0.1rem;
|
||
}
|
||
|
||
.scan-qty-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
/* 左栏 380px 下这一行放不下:允许换行(必要时步进器掉到第二行),避免横向溢出 */
|
||
flex-wrap: wrap;
|
||
gap: 0.1rem;
|
||
margin-bottom: 0.1rem;
|
||
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 */
|
||
line-height: 0.36rem; /* 与高度一致:真机原生 input 无行高时文字顶部会被白底裁剪 */
|
||
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);
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.search-input {
|
||
flex: 1;
|
||
height: 0.36rem;
|
||
line-height: 0.36rem; /* 与高度一致:真机原生 input 无行高时文字顶部会被白底裁剪 */
|
||
border: 0.01rem solid #e5e5e5;
|
||
border-radius: 0.07rem;
|
||
padding: 0 0.15rem;
|
||
font-size: 0.2rem;
|
||
background-color: var(--wms-card-bg);
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.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;
|
||
border-radius: 0.07rem;
|
||
}
|
||
|
||
.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.1rem;
|
||
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-barcode-value {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.cell-barcode-extra {
|
||
color: var(--wms-primary);
|
||
}
|
||
|
||
.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;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.cell-image-wrap {
|
||
position: relative;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin: 0.05rem 0;
|
||
}
|
||
|
||
.cell-image-badge {
|
||
position: absolute;
|
||
top: -0.07rem;
|
||
right: -0.07rem;
|
||
min-width: 0.24rem;
|
||
height: 0.24rem;
|
||
line-height: 0.24rem;
|
||
padding: 0 0.05rem;
|
||
box-sizing: border-box;
|
||
font-size: 0.15rem;
|
||
color: #ffffff;
|
||
background-color: var(--wms-danger-strong);
|
||
border-radius: 0.12rem;
|
||
text-align: center;
|
||
pointer-events: none;
|
||
user-select: none;
|
||
}
|
||
|
||
.cell-image-empty {
|
||
color: var(--wms-text-placeholder);
|
||
}
|
||
|
||
.cell-pack {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.cell-pack-value {
|
||
color: var(--wms-danger-strong);
|
||
}
|
||
|
||
/* 仅文字本身带浅红底(高亮),单元格不整列浅红 */
|
||
.cell-pack-value-inner {
|
||
background-color: #fdecea;
|
||
border-radius: 0.04rem;
|
||
padding: 0.02rem 0.06rem;
|
||
}
|
||
|
||
/* 已扫行(绿底白字)也统一显示:复核要求值保持红字 */
|
||
.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);
|
||
}
|
||
|
||
/* 拦截信息弹窗:提示文案与运单号列表 */
|
||
.intercept-tip {
|
||
margin-top: 0.08rem;
|
||
font-size: 0.18rem;
|
||
color: var(--wms-danger-strong);
|
||
}
|
||
|
||
.intercept-info-scroll {
|
||
max-height: 4.8rem;
|
||
margin-top: 0.12rem;
|
||
}
|
||
|
||
.intercept-waybill-row {
|
||
padding: 0.1rem 0;
|
||
border-bottom: 0.01rem solid #eef2f8;
|
||
}
|
||
|
||
.intercept-waybill-row:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.intercept-waybill-text {
|
||
font-size: 0.2rem;
|
||
color: var(--wms-text);
|
||
word-break: break-all;
|
||
}
|
||
|
||
/* 称重/复核/批量弹窗共用遮罩
|
||
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-mask--keyboard {
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.weigh-mask--keyboard .weigh-dialog {
|
||
margin-top: 0.5rem;
|
||
}
|
||
|
||
.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;
|
||
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;
|
||
margin-left: 0.15rem;
|
||
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-prev,
|
||
.shared-img-preview-next {
|
||
position: absolute;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
width: 0.6rem;
|
||
height: 0.6rem;
|
||
line-height: 0.6rem;
|
||
text-align: center;
|
||
font-size: 0.4rem;
|
||
color: #ffffff;
|
||
background-color: rgba(0, 0, 0, 0.5);
|
||
border-radius: 50%;
|
||
z-index: 2;
|
||
user-select: none;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.shared-img-preview-prev {
|
||
left: 0.3rem;
|
||
}
|
||
|
||
.shared-img-preview-next {
|
||
right: 0.3rem;
|
||
}
|
||
|
||
.shared-img-preview-count {
|
||
position: absolute;
|
||
top: 0.3rem;
|
||
left: 50%;
|
||
transform: translateX(-50%);
|
||
padding: 0.04rem 0.16rem;
|
||
font-size: 0.22rem;
|
||
color: rgba(255, 255, 255, 0.9);
|
||
background-color: rgba(0, 0, 0, 0.4);
|
||
border-radius: 0.3rem;
|
||
z-index: 2;
|
||
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;
|
||
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;
|
||
/* 按钮间隔走 gap(真机已实测可用) */
|
||
gap: 0.2rem;
|
||
margin-left: 0.15rem;
|
||
}
|
||
|
||
.setting-seg-item {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0.05rem 0.25rem;
|
||
font-size: 0.21rem;
|
||
color: var(--wms-text-secondary);
|
||
/* 未选中态用浅灰底(而非白底):真机 rem 缩放后边框几乎不可见、白底与弹窗同色,
|
||
按钮之间会“糊成一片”看不出间隔;浅灰底让每个按钮边界清晰可见 */
|
||
background-color: var(--wms-bg-subtle);
|
||
border: 0.01rem solid var(--wms-border);
|
||
border-radius: 0.07rem;
|
||
cursor: pointer;
|
||
user-select: none;
|
||
white-space: nowrap;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.setting-seg-item--on {
|
||
background-color: var(--wms-primary);
|
||
border-color: var(--wms-primary);
|
||
color: var(--wms-white);
|
||
}
|
||
|
||
/* 复核流程:三个选项单行均分显示,不换行(间隔走 margin,老 WebView 不支持 flex gap) */
|
||
.setting-seg--nowrap {
|
||
flex-wrap: nowrap;
|
||
}
|
||
|
||
.setting-seg--nowrap .setting-seg-item {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0.05rem 0.05rem;
|
||
text-align: center;
|
||
}
|
||
|
||
.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;
|
||
line-height: 0.36rem; /* 与高度一致:真机原生 input 无行高时文字顶部会被白底裁剪 */
|
||
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);
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 输入提示(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;
|
||
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);
|
||
}
|
||
|
||
/* 弹窗底部按钮间距:不用 flex gap(老 WebView 不支持 flex 容器的 gap,真机按钮会挤在一起),
|
||
改用子项外边距;放在 .weigh-btn 等样式之后,确保覆盖其 margin:0 */
|
||
.weigh-dialog-footer > .weigh-btn {
|
||
margin-left: 0.15rem;
|
||
}
|
||
|
||
.weigh-dialog-footer > .weigh-btn:first-child {
|
||
margin-left: 0;
|
||
}
|
||
|
||
/* 无条码复核弹窗内容 */
|
||
.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;
|
||
}
|
||
|
||
/* 打印失败弹窗:具体原因(对齐 WMS_PDA print-fail-popup-msg) */
|
||
.print-fail-msg {
|
||
margin-top: 0.1rem;
|
||
padding: 0.1rem 0.12rem;
|
||
background-color: #fdf2f2;
|
||
border-radius: 0.07rem;
|
||
}
|
||
|
||
.print-fail-msg__text {
|
||
font-size: 0.18rem;
|
||
color: var(--wms-danger-strong);
|
||
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 的底色声明在 .table-row--selected 之后,
|
||
会覆盖选中高亮,这里显式提高优先级,保证首个/被点击波次选中后仍显示高亮 */
|
||
.wave-group-header.table-row--selected {
|
||
background-color: #a6c8ff;
|
||
}
|
||
|
||
.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.15rem 0.15rem 0.05rem;
|
||
background-color: var(--wms-card-bg);
|
||
border-radius: 0.07rem;
|
||
/* 不能用 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[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);
|
||
/* 行高与控件高度一致(0.36rem):line-height:1 在真机 CJK 字体的字面上下超出 1em,
|
||
配合 .tool-select 的 overflow:hidden 会把字头顶部裁掉 */
|
||
line-height: 0.36rem;
|
||
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 {
|
||
/* 纯 CSS 向下箭头:两根短斜线拼成 ⌄(对称、天然竖直居中);
|
||
inline <svg> 在真机 APP-PLUS 不渲染,这里用 ::before/::after 两条线代替 */
|
||
position: relative;
|
||
width: 0.13rem;
|
||
height: 0.07rem;
|
||
transition: transform 0.2s ease;
|
||
}
|
||
|
||
.tool-select-arrow-icon::before,
|
||
.tool-select-arrow-icon::after {
|
||
content: '';
|
||
position: absolute;
|
||
bottom: 0;
|
||
width: 0.09rem;
|
||
height: 0.02rem;
|
||
background-color: #909399;
|
||
border-radius: 0.01rem;
|
||
}
|
||
|
||
.tool-select-arrow-icon::before {
|
||
right: 50%;
|
||
transform: rotate(45deg);
|
||
transform-origin: right center;
|
||
}
|
||
|
||
.tool-select-arrow-icon::after {
|
||
left: 50%;
|
||
transform: rotate(-45deg);
|
||
transform-origin: left center;
|
||
}
|
||
|
||
.tool-select--open .tool-select-arrow-icon {
|
||
transform: rotate(180deg);
|
||
}
|
||
|
||
.tool-select-wrap {
|
||
position: relative;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tool-select-dropdown {
|
||
position: absolute;
|
||
top: calc(100% + 0.06rem);
|
||
left: 0;
|
||
min-width: 100%;
|
||
max-width: 2.6rem;
|
||
background-color: var(--wms-card-bg);
|
||
border: 0.01rem solid var(--wms-border-alt);
|
||
border-radius: 0.07rem;
|
||
box-shadow: 0 0.07rem 0.26rem rgba(0, 0, 0, 0.12);
|
||
z-index: 60;
|
||
overflow: hidden;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.tool-select-dropdown-scroll {
|
||
max-height: 2.4rem;
|
||
}
|
||
|
||
.tool-select-option {
|
||
padding: 0.12rem 0.15rem;
|
||
font-size: 0.17rem;
|
||
color: var(--wms-text);
|
||
line-height: 1.4;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.tool-select-option:active {
|
||
background-color: #f0f2f5;
|
||
}
|
||
|
||
.tool-select-option--selected {
|
||
color: var(--wms-primary);
|
||
background-color: #eaf2ff;
|
||
}
|
||
|
||
.tool-select-option--empty {
|
||
color: var(--wms-text-placeholder);
|
||
text-align: center;
|
||
}
|
||
|
||
.tool-select-mask {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 59;
|
||
}
|
||
|
||
.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;
|
||
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;
|
||
margin-left: 0.15rem;
|
||
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-tag--orange {
|
||
color: var(--wms-warning);
|
||
background-color: #fff3e6;
|
||
}
|
||
|
||
.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.1rem;
|
||
padding: 0.1rem 0.2rem;
|
||
background-color: #f6f8fc;
|
||
border: 0.01rem solid #e6ebf5;
|
||
border-radius: 0.07rem;
|
||
}
|
||
|
||
.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);
|
||
border-radius: 0.07rem;
|
||
}
|
||
|
||
.empty {
|
||
text-align: center;
|
||
color: var(--wms-text-placeholder);
|
||
font-size: 0.2rem;
|
||
padding: 0.2rem 0;
|
||
}
|
||
</style>
|