修改订单复核页面

This commit is contained in:
zm2000 2026-08-31 18:06:29 +08:00
parent d7638e8668
commit 2fd2cf6e8b
3 changed files with 878 additions and 49 deletions

View File

@ -171,3 +171,158 @@ export function confirmIntercept(
options
)
}
/**
* 订单复核-更新订单运单称重重量(order.updateExpressWeighingWeight)
* 支持两种模式:
* 1) 订单模式(order_id>0):订单仅一个运单时直接写入;多运单时必须传 waybill_code;
* 团购波次批量设置同一重量到波次下所有订单运单,返回拆单汇总。
* 2) 运单号模式(order_id=0):从运单号反查订单与波次,团购波次按 wave_no+business_key 批量设置。
* @param params.order_id 订单ID;正整数为订单模式,0 为运单号模式(需配合 waybill_code)
* @param params.waybill_code 运单号(多运单订单 / 运单号模式必填)
* @param params.weighing_weight 称重重量(g),必须为正整数
*/
export function updateExpressWeighingWeight(
params: {
order_id: number | string
waybill_code?: string
weighing_weight: number | string
},
options?: RequestOptions
) {
return request<ApiBody>(
'order.updateExpressWeighingWeight',
{
...workerPayload,
...params,
},
options
)
}
/**
* 面单补打-获取订单打印数据(order.print.getOrderPrintData)
* 散单/其他模式:根据订单 ID 列表获取可打印的面单数据(waveGroups)。
* @param params.order_ids 订单 ID 数组
* 响应:data.waveGroups[](打印数据分组,直接透传给 print.send)
*/
export function getOrderPrintData(
params: { order_ids: Array<number | string> },
options?: RequestOptions
) {
return request<ApiBody>(
'order.print.getOrderPrintData',
{
...workerPayload,
...params,
},
options
)
}
/**
* 面单补打-获取波次平台打印数据(order.print.getWavePlatformPrintData)
* 团购模式:按波次 ID 列表获取平台打印中间态数据,自动过滤快递未完全分配的波次,
* 返回 waveGroups(波次 -> 平台 -> 订单)结构。
* 已打印面单(打印锁占用)时 waveGroups 为空、locked_wave_groups 有值,
* 需先调用 unlockWavePlatformPrintDataByGroup 解锁后再重新获取。
* @param params.warehouse_id 仓库ID(必填,须与当前用户上下文 store_id 一致)
* @param params.wave_ids 波次ID列表(必填,支持数字或字符串,后端自动去重与归一化)
* 响应:
* summary 汇总信息
* wave_ids 通过过滤的波次ID数组
* waveGroups 主返回结构:按波次分组(波次 -> 平台 -> 订单)
* platform_groups 兼容字段:按平台分组结果(保留兼容旧客户端)
* order_list 兼容字段:逐单平台打印中间态明细(保留兼容旧客户端)
* ext 扩展字段
* 自定义区内容(后端生成,前端透传至 print.send 即可):
* - 首行在快递渠道名后追加「商品总数【n】」(n 优先订单级 items_total,其次商品明细数量累加,最后 items_count 兜底)
* - 波次 source=0 且 wave_type=1 时,商品明细行尾追加「波次总单数×该行商品数量」
* 错误码:400 / 500
*/
export function getWavePlatformPrintData(
params: {
warehouse_id: number | string
wave_ids: Array<number | string>
},
options?: RequestOptions
) {
return request<ApiBody>(
'order.print.getWavePlatformPrintData',
{
...workerPayload,
...params,
},
options
)
}
/**
* 面单补打-按分组解锁波次平台打印锁(order.print.unlockWavePlatformPrintDataByGroup)
* 按传入的 groups 条件匹配已锁定订单并将其 print_lock_status 置为 none,
* 返回解锁统计与解锁订单列表。
* @param params.warehouse_id 仓库ID(必填,正整数,须与当前用户上下文 store_id 一致)
* @param params.wave_ids 波次ID列表(必填,非空数组,支持数字或字符串,后端自动去重与归一化)
* @param params.group_type 分组类型(可选):platform | platform_express | order,默认 platform_express
* @param params.unlock_scope 解锁范围(可选):group | wave,默认 group
* @param params.groups 分组条件列表(必填,非空数组),元素字段:
* wave_id(必填)、platform(平台编码)、sys_logistics_code(系统快递编码)、order_ids(订单ID数组)
* 响应:
* summary 解锁操作的汇总统计
* wave_ids 通过过滤的波次ID数组
* unlocked_order_ids 被解锁的订单ID数组
* unlocked_orders 被解锁订单简要信息列表
* ext 扩展字段
* 错误码:400(wave_ids 非空数组 / warehouse_id 正整数且与 store_id 一致 / group_type、unlock_scope 合法取值 /
* groups 非空且匹配到有效分组条件)、500(内部错误)
*/
export function unlockWavePlatformPrintDataByGroup(
params: {
warehouse_id: number | string
wave_ids: Array<number | string>
group_type?: string
unlock_scope?: string
groups: Array<Record<string, unknown>>
},
options?: RequestOptions
) {
return request<ApiBody>(
'order.print.unlockWavePlatformPrintDataByGroup',
{
...workerPayload,
...params,
},
options
)
}
/**
* 面单补打-发送面单打印(print.send)
* 将获取到的 waveGroups 打印数据发送到指定打印台(express 路径)。
* type=express 时按 data.waveGroups -> platforms 串行处理,每个 平台+快递 组分别发送;
* 接口记录打印单并写入订单操作日志,返回摘要(flag/code/message/printId),不返回明细。
* @param params.type 打印类型(express 快递面单;customize 为自定义模板,express 场景忽略 customize 字段)
* @param params.printStationId 打印站点/工作站标识(必填,type=express)
* @param params.requestCode 请求去重/防重放 ID(必填,type=express;约定周期内不得变更)
* @param params.data.waveGroups 打印数据分组(来自 getWavePlatformPrintData 返回的 data.waveGroups)
* 响应:flag(success/failure)、code(成功200,失败1001不支持的打印类型/504打印任务发送失败)、message、printId
* 成功判定:flag !== 'failure' 且 code 不为 500/1001/504
*/
export function sendPrint(
params: {
type?: string
printStationId: number | string
requestCode: string
data: { waveGroups: unknown[] }
},
options?: RequestOptions
) {
return request<ApiBody>(
'print.send',
{
...workerPayload,
...params,
},
options
)
}

View File

@ -148,10 +148,28 @@ export default {
})
}
},
persistUserContext(user) {
if (!user || typeof user !== 'object') {
return
}
const storeId =
user?.store_id ?? user?.storeId ?? user?.store?.id ?? user?.store?.store_id
const warehouseId =
user?.warehouse_id ?? user?.warehouseId ?? user?.warehouse?.id ?? user?.warehouse?.warehouse_id
if (storeId !== undefined && storeId !== null && storeId !== '') {
uni.setStorageSync('store_id', storeId)
}
if (warehouseId !== undefined && warehouseId !== null && warehouseId !== '') {
uni.setStorageSync('warehouse_id', warehouseId)
}
},
loadCurrentUserInfo() {
fetchUserInfo()
.then((body) => {
this.currentUser = body?.data || body?.result || body || null
const user = body?.data || body?.result || body || null
this.currentUser = user
// 持久化用户上下文 store_id / warehouse_id(面单补打团单模式按接口约定 warehouse_id 须与 store_id 一致)
this.persistUserContext(user)
this.ensureActiveMenuValid()
if (!this.activeMenuPath && this.topMenus.length) {

View File

@ -37,7 +37,7 @@
<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' : '']"
:class="['table-row', 'scan-row', index % 2 === 1 ? 'table-row--alt' : '', selectedPendingOrderKey === getScanOrderKey(item) ? 'table-row--selected' : '', 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>
@ -45,6 +45,7 @@
<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>
@ -58,12 +59,16 @@
<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' : '']"
:class="['table-row', 'wave-group-header', wIndex % 2 === 1 ? 'table-row--alt' : '', selectedWaveKey === getWaveKey(wave) ? 'table-row--selected' : '', 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>
@ -86,12 +91,16 @@
<view class="panel-right">
<!-- 顶部操作区:按钮 / 下拉框 / 提示信息 -->
<view class="review-toolbar">
<button :class="['tool-btn', interceptMode ? 'tool-btn--intercept' : 'tool-btn--confirm']" @click="handleConfirmReview">{{ interceptMode ? '确认拦截' : '确认复核' }}</button>
<button
:class="['tool-btn', interceptMode ? 'tool-btn--intercept' : 'tool-btn--confirm']"
:disabled="!hasSelection || interceptLocked"
@click="handleConfirmReview"
>{{ interceptMode ? '确认拦截' : '确认复核' }}</button>
<button class="tool-btn" @click="handleClear">清空</button>
<button class="tool-btn tool-btn--blue-outline" @click="handleBatchQuickReview">批量快捷复核</button>
<button class="tool-btn tool-btn--blue-outline" @click="handleSingleReviewList">散单复核列表</button>
<button class="tool-btn tool-btn--orange" @click="handleRePrintLabel">面单补打</button>
<button class="tool-btn tool-btn--gray" @click="handleWeigh">称重</button>
<button class="tool-btn tool-btn--orange" :disabled="!hasSelection" @click="handleRePrintLabel">面单补打</button>
<button class="tool-btn tool-btn--gray" :disabled="!hasSelection" @click="handleWeigh">称重</button>
<picker
:range="printerOptions"
@change="handlePrinterChange"
@ -210,6 +219,41 @@
</view>
</view>
<!-- 称重弹窗 -->
<view v-if="weighDialogVisible" class="weigh-mask" @click.self="closeWeighDialog">
<view class="weigh-dialog">
<view class="weigh-dialog-header">
<text class="weigh-dialog-title">称重</text>
<text class="weigh-dialog-close" @click="closeWeighDialog">✕</text>
</view>
<view class="weigh-dialog-body">
<view class="weigh-stepper">
<view class="weigh-label-inline">
<text class="weigh-required">*</text>
<text class="weigh-input-label">重量(g)</text>
</view>
<view class="weigh-step-btn" @click="handleWeighMinus">−</view>
<input
class="weigh-input"
v-model="weighInputValue"
type="digit"
:adjust-position="false"
focus
placeholder="请输入重量(g)"
placeholder-class="weigh-input-placeholder"
confirm-type="done"
@confirm="confirmWeigh"
/>
<view class="weigh-step-btn" @click="handleWeighPlus">+</view>
</view>
</view>
<view class="weigh-dialog-footer">
<button class="weigh-btn weigh-btn--cancel" @click="closeWeighDialog">取消</button>
<button class="weigh-btn weigh-btn--confirm" @click="confirmWeigh">保存</button>
</view>
</view>
</view>
<!-- 真机扫码捕获:保持隐藏 input 聚焦,WebView 才会持续派发按键 -->
<input
v-if="enableHiddenInputCapture"
@ -228,13 +272,26 @@
<script>
import TopNav from '@/components/top-nav.vue'
import { scanReviewOrder, scanReviewTask, fetchPrintList, confirmIntercept } from '@/api/order'
import {
scanReviewOrder,
scanReviewTask,
fetchPrintList,
confirmIntercept,
updateExpressWeighingWeight,
getOrderPrintData,
getWavePlatformPrintData,
unlockWavePlatformPrintDataByGroup,
sendPrint,
} from '@/api/order'
// 扫码枪识别参数
// 无回车结束符时:停止输入超过该毫秒数视为一次完整扫码,自动提交
const SCAN_IDLE_TIMEOUT = 300
// 自动提交所需的最短内容长度,避免正常输入过程中的短暂停顿触发误识别
const SCAN_MIN_LENGTH = 2
// 手动输入识别:相邻按键间隔超过该毫秒数视为手动输入,不自动提交,需按回车后才查询
// 扫码枪连续按键间隔通常 <30ms,手动键盘输入间隔通常 >100ms
const SCAN_BURST_MAX_GAP = 100
export default {
name: 'OrderReviewOnePage',
@ -259,6 +316,8 @@ export default {
// 扫码枪无结束符自动识别:静默计时器与最后按键时间
scanTimer: null,
lastScanKeyTime: 0,
// 手动输入识别:是否为扫码枪快速输入(相邻按键间隔均小于阈值),仅扫码枪允许静默自动提交
scanBurstConfirmed: false,
// ---- 扫码枪真机兼容(移植自 login.vue)----
// 页面激活状态:keep-alive 切换 / 页面隐藏时暂停扫码聚焦抢占
pageActive: true,
@ -309,14 +368,23 @@ export default {
selectedPrinterId: '',
printerOpened: false,
printerList: [],
// 面单补打
warehouseId: '',
printRequestCode: '',
printSending: false,
selectedReviewProcess: '',
reviewProcessOpened: false,
selectedWeigh: '不称重',
weighOpened: false,
reviewProcessOptions: ['先打印后复核', '先复核后打印'],
weighOptions: ['不称重', '称重'],
// 称重弹窗
weighDialogVisible: false,
weighInputValue: '',
// 拦截确认模式(点击左侧"拦截"后,确认按钮变为"确认拦截")
interceptMode: false,
// 已拦截锁定:选中行为已拦截订单时,确认拦截按钮置为禁用
interceptLocked: false,
interceptTarget: null,
// 顶部提示信息
pickerName: '',
@ -405,6 +473,8 @@ export default {
})
},
handleConfirm() {
// 提交后重置扫码快速输入标记,下一轮输入重新识别手动/扫码
this.scanBurstConfirmed = false
// 已选中列表项时,回车走商品条码匹配流程;否则走关键词查询
if (this.hasSelection) {
this.handleBarcodeMatch()
@ -481,7 +551,16 @@ export default {
},
/** 刷新扫码静默计时:记录最后按键时间并重置防抖定时器 */
touchScanInput() {
this.lastScanKeyTime = Date.now()
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)
}
@ -492,7 +571,8 @@ export default {
this.scanTimer = null
const elapsed = Date.now() - this.lastScanKeyTime
const buffer = (this.keyword || '').trim()
if (elapsed >= SCAN_IDLE_TIMEOUT && buffer.length >= SCAN_MIN_LENGTH) {
// 仅扫码枪快速输入(scanBurstConfirmed)允许静默自动提交;手动输入需按回车后才查询
if (this.scanBurstConfirmed && elapsed >= SCAN_IDLE_TIMEOUT && buffer.length >= SCAN_MIN_LENGTH) {
this.handleConfirm()
}
},
@ -942,17 +1022,20 @@ export default {
this.scanListType = payload?.list_type || ''
this.scanOrderList = list
this.pickerName = this.getRowValue(payload, ['picker_name', 'pickerName']) || ''
// 汇总数据:优先取接口顶层字段;缺失时按列表逐项累加(团购模式为波次列表)
const topTotal = this.getRowValue(payload, ['total_orders'])
const topUnreviewed = this.getRowValue(payload, ['unreviewed_count'])
if (topTotal !== '' || topUnreviewed !== '') {
this.waveTotalOrders = topTotal
this.waveUnreviewedCount = topUnreviewed
} else {
this.waveTotalOrders = list.reduce((sum, row) => sum + (Number(row?.total_orders) || 0), 0)
this.waveUnreviewedCount = list.reduce((sum, row) => sum + (Number(row?.unreviewed_count) || 0), 0)
// 记录仓库ID(团购面单补打需要)
const scanWarehouseId = this.getRowValue(payload, ['warehouse_id', 'warehouseId'])
if (scanWarehouseId !== '') {
this.warehouseId = scanWarehouseId
}
// 汇总数据:波次总单数优先取接口顶层字段,缺失时按列表累加(团购模式为波次列表)
const topTotal = this.getRowValue(payload, ['total_orders'])
this.waveTotalOrders =
topTotal !== ''
? topTotal
: list.reduce((sum, row) => sum + (Number(row?.total_orders) || 0), 0)
// 剩余未复核数:前端统计并排除拦截/已拦截订单
this.waveUnreviewedCount = this.countUnreviewedExcludingIntercepted(list)
this.clearSelection()
// 记录拣货任务 ID,供刷新按钮按 task_id 调用 scanTask
@ -960,6 +1043,7 @@ export default {
},
clearSelection() {
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
this.selectedPendingOrderKey = ''
this.selectedWaveKey = ''
@ -1008,6 +1092,11 @@ export default {
this.storeRemark = this.getRowValue(source, ['store_remark', 'storeRemark']) || ''
},
handleConfirmReview() {
// 已拦截订单:确认拦截按钮已禁用,此处兜底拦截重复操作
if (this.interceptLocked) {
uni.showToast({ title: '该订单已拦截,无需重复操作', icon: 'none' })
return
}
// 拦截确认模式下,弹窗确认后执行拦截;否则执行确认复核
if (this.interceptMode) {
const orderNo = this.interceptTarget?.orderNo || this.selectedOrderNo || ''
@ -1064,7 +1153,18 @@ export default {
// 拦截完成,退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
// 同步刷新左侧列表:本地即时将该行标记为已拦截,并从服务端刷新列表
if (successCount > 0) {
const successIds = successList
.map((s) => s?.order_id ?? s?.orderId ?? s?.id ?? '')
.filter((id) => id !== '')
const ids = successIds.length > 0 ? successIds : [orderId]
ids.forEach((id) => this.markRowIntercepted(id))
this.handleRefresh(false)
}
} catch (error) {
// 接口调用失败:保留拦截确认模式,便于重试
uni.showToast({ title: '拦截失败,请重试', icon: 'none' })
@ -1077,7 +1177,13 @@ export default {
this.clearSelection()
uni.showToast({ title: '已清空', icon: 'none' })
},
handleRefresh() {
// 刷新左侧列表;showToast=false 时静默刷新(拦截成功后自动同步,不弹提示打扰)
handleRefresh(showToast = true) {
const notify = (title) => {
if (showToast) {
uni.showToast({ title, icon: 'none' })
}
}
// 优先按拣货任务 ID 拉取复核扫描视图;无任务 ID 时回退到关键词查询
const taskId = this.currentTaskId
if (taskId !== null && taskId !== undefined && taskId !== '') {
@ -1085,42 +1191,27 @@ export default {
.then((body) => {
const payload = body?.data || body?.result || body || {}
this.applyScanResult(payload)
uni.showToast({
title: '刷新成功',
icon: 'none',
})
notify('刷新成功')
})
.catch(() => {
uni.showToast({
title: '刷新失败',
icon: 'none',
})
notify('刷新失败')
})
return
}
const query = (this.activeKeyword || this.keyword).trim()
if (!query) {
uni.showToast({
title: '请输入关键词',
icon: 'none',
})
notify('请输入关键词')
return
}
scanReviewOrder({ keyword: query })
.then((body) => {
const payload = body?.data || body?.result || body || {}
this.applyScanResult(payload)
uni.showToast({
title: '刷新成功',
icon: 'none',
})
notify('刷新成功')
})
.catch(() => {
uni.showToast({
title: '刷新失败',
icon: 'none',
})
notify('刷新失败')
})
},
handleBatchQuickReview() {
@ -1129,11 +1220,264 @@ export default {
handleSingleReviewList() {
uni.showToast({ title: '散单复核列表', icon: 'none' })
},
handleRePrintLabel() {
uni.showToast({ title: '面单补打', icon: 'none' })
// 面单补打:先取打印数据(团购/散单模式区分),再发送到所选打印台
async handleRePrintLabel() {
// 未选中订单时提示
if (!this.hasSelection) {
uni.showToast({ title: '请先在左侧选择订单', icon: 'none' })
return
}
// 未选择打印台时提示
if (!this.selectedPrinterId) {
uni.showToast({ title: '未选择打印台,无法补打', icon: 'none' })
return
}
// 防止重复点击
if (this.printSending) {
return
}
this.printSending = true
uni.showLoading({ title: '补打处理中...' })
try {
// 1. 获取打印数据(团购:打印锁占用时先解锁再重新获取)
let waveGroups = []
if (this.scanListType === 'group') {
waveGroups = await this.fetchGroupWavePrintData(this.currentOrderHeader)
} else {
const orderId = this.getScanOrderId(this.currentOrderHeader)
if (orderId === '') {
throw new Error('未找到订单ID,无法补打')
}
const body = await getOrderPrintData({ order_ids: [Number(orderId)] })
const payload = this.extractPrintPayload(body)
waveGroups = this.normalizeWaveGroups(payload)
}
if (!waveGroups.length) {
throw new Error('未获取到可打印数据')
}
// 2. 发送打印
this.printRequestCode = this.buildPrintRequestCode()
const response = await sendPrint({
type: 'express',
printStationId: this.selectedPrinterId,
requestCode: this.printRequestCode,
data: { waveGroups },
})
// 成功判定(后端约定):flag=success 且 code=200;失败码 1001(不支持的打印类型)/504(打印任务发送失败)
const success =
response?.flag !== 'failure' &&
response?.code !== '500' &&
response?.code !== 500 &&
response?.code !== 1001 &&
response?.code !== 504
if (!success) {
throw new Error(response?.message || response?.msg || '打印发送失败')
}
uni.hideLoading()
uni.showToast({ title: '面单补打已发送', icon: 'success' })
// 静默刷新左侧列表,同步服务端打印状态
this.handleRefresh(false)
} catch (error) {
uni.hideLoading()
const message = String(error?.message || error?.msg || error?.errMsg || '补打失败')
uni.showToast({ title: message, icon: 'none' })
} finally {
this.printSending = false
this.scheduleScanInputFocus(150)
}
},
// 生成打印请求码(唯一)
buildPrintRequestCode() {
const timePart = Date.now().toString(36)
const randomPart = Math.random().toString(36).slice(2, 10)
return `PRINT_${timePart}_${randomPart}`
},
// 解析仓库ID:面单补打团单模式按接口约定 warehouse_id 须与用户上下文 store_id 一致。
// 优先取扫码结果记录值(本次会话上下文),兜底读本地存储(含 user.info 持久化的 store_id/warehouse_id)
resolveWarehouseId() {
const candidates = [
this.warehouseId,
uni.getStorageSync('warehouse_id'),
uni.getStorageSync('warehouseId'),
uni.getStorageSync('store_id'),
uni.getStorageSync('storeId'),
]
for (const value of candidates) {
const numeric = Number(value)
if (Number.isFinite(numeric) && numeric > 0) {
return numeric
}
}
return 0
},
// 从打印接口响应中提取数据体(兼容多层包裹结构)
extractPrintPayload(response) {
const candidates = [response?.data?.data, response?.data, response?.result, response]
for (const current of candidates) {
if (current && typeof current === 'object') {
return current
}
}
return {}
},
// 提取可打印的 waveGroups
normalizeWaveGroups(payload) {
const groups = Array.isArray(payload?.waveGroups) ? payload.waveGroups : []
return groups
.map((group) => (group && typeof group === 'object' ? group : null))
.filter((group) => !!group)
},
// 提取被打印锁占用的分组(已打印面单的数据)
extractLockedWaveGroups(payload) {
const groups = Array.isArray(payload?.locked_wave_groups) ? payload.locked_wave_groups : []
return groups
.map((group) => (group && typeof group === 'object' ? group : null))
.filter((group) => !!group)
},
// 将 locked_wave_groups 转换为解锁分组条件(波次+平台+系统快递编码 组合为一个分组)
buildUnlockGroups(lockedWaveGroups) {
const groups = []
;(Array.isArray(lockedWaveGroups) ? lockedWaveGroups : []).forEach((waveGroup) => {
const waveId = waveGroup?.wave_id ?? waveGroup?.waveId ?? waveGroup?.id ?? ''
const platforms = Array.isArray(waveGroup?.platforms) ? waveGroup.platforms : []
if (platforms.length) {
platforms.forEach((platform) => {
groups.push({
wave_id: waveId,
platform: platform?.platform ?? platform?.platform_code ?? '',
sys_logistics_code:
platform?.sys_logistics_code ??
platform?.sysLogisticsCode ??
platform?.logistics_code ??
'',
order_ids: Array.isArray(platform?.order_ids) ? platform.order_ids : [],
})
})
} else if (waveId !== '' && waveId != null) {
// 无平台嵌套时按波次兜底
groups.push({ wave_id: waveId, platform: '', sys_logistics_code: '', order_ids: [] })
}
})
return groups.filter((group) => group.wave_id !== '' && group.wave_id != null)
},
// 团购模式:按分组解锁波次平台打印锁
async unlockGroupWavePrintLock(lockedWaveGroups) {
const warehouseId = this.resolveWarehouseId()
if (!warehouseId) {
throw new Error('缺少仓库ID')
}
const groups = this.buildUnlockGroups(lockedWaveGroups)
if (!groups.length) {
throw new Error('缺少可解锁的分组条件')
}
const waveIds = Array.from(
new Set(groups.map((g) => g.wave_id).filter((id) => id !== '' && id != null))
)
return unlockWavePlatformPrintDataByGroup({
warehouse_id: warehouseId,
wave_ids: waveIds,
group_type: 'platform_express',
unlock_scope: 'group',
groups,
})
},
// 团购模式获取波次平台可打印数据;打印锁占用时先解锁再重新获取
async fetchGroupWavePrintData(item) {
const warehouseId = this.resolveWarehouseId()
if (!warehouseId) {
throw new Error('缺少仓库ID')
}
const waveId = String(this.getRowValue(item, ['wave_id', 'waveId', 'id']) || '').trim()
if (!waveId) {
throw new Error('未找到波次ID')
}
const requestData = async () => {
const body = await getWavePlatformPrintData({
warehouse_id: warehouseId,
wave_ids: [waveId],
})
return this.extractPrintPayload(body)
}
let payload = await requestData()
let waveGroups = this.normalizeWaveGroups(payload)
const lockedWaveGroups = this.extractLockedWaveGroups(payload)
// 打印锁占用:waveGroups 为空 + locked_wave_groups 有值 → 先解锁再重新获取
if (!waveGroups.length && lockedWaveGroups.length) {
try {
await this.unlockGroupWavePrintLock(lockedWaveGroups)
} catch (error) {
throw new Error(
`解锁打印锁失败:${String(error?.message || error?.msg || error?.errMsg || '请稍后重试')}`
)
}
payload = await requestData()
waveGroups = this.normalizeWaveGroups(payload)
}
return waveGroups
},
handleWeigh() {
uni.showToast({ title: '称重', icon: 'none' })
// 未选中订单时提示先选择
if (!this.hasSelection) {
uni.showToast({ title: '请先在左侧选择订单', icon: 'none' })
return
}
this.weighInputValue = ''
this.weighDialogVisible = true
},
closeWeighDialog() {
this.weighDialogVisible = false
this.scheduleScanInputFocus(150)
},
handleWeighPlus() {
this.weighInputValue = String((Number(this.weighInputValue) || 0) + 1)
},
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' })
return
}
const numeric = Number(weight)
if (!Number.isInteger(numeric) || numeric <= 0) {
uni.showToast({ title: '重量必须为正整数(g)', icon: 'none' })
return
}
// 团购模式按运单号提交(order_id=0);其余按订单 ID 提交
let params
if (this.scanListType === 'group') {
const waybillCode = this.getWaveRepresentWaybill(this.currentOrderHeader)
if (!waybillCode) {
uni.showToast({ title: '未找到波次运单号,无法称重', icon: 'none' })
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' })
return
}
params = {
order_id: orderId,
weighing_weight: numeric,
}
}
try {
await updateExpressWeighingWeight(params)
uni.showToast({ title: `保存成功:${numeric} g`, icon: 'none' })
this.weighDialogVisible = false
this.scheduleScanInputFocus(150)
} catch (error) {
uni.showToast({ title: '保存失败,请重试', icon: 'none' })
}
},
handlePrinterSelectStart() {
// 打印台列表为空时,重新拉取
@ -1276,14 +1620,120 @@ export default {
}
return this.getRowValue(wave, ['review_status', 'reviewStatus', 'wave_status', 'waveStatus']) || '-'
},
// 获取订单拦截状态(requested=已申请拦截 / intercepted_at_warehouse=仓库已拦截 / none=无)
getInterceptStatus(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['intercept_status', 'interceptStatus']) || ''
},
// 是否有拦截(intercept_status === 'requested')
isIntercepted(item) {
const src = this.getScanOrderSource(item)
return this.getRowValue(src, ['intercept_status', 'interceptStatus']) === 'requested'
return this.getInterceptStatus(item) === 'requested'
},
// 是否已拦截(intercept_status === 'intercepted_at_warehouse')
isInterceptedDone(item) {
const status = this.getInterceptStatus(item)
return status === 'intercepted_at_warehouse' || status === 'intercepted'
},
// 统计团购波次下订单的拦截情况(wave.orders[] 携带 intercept_status)
getWaveInterceptCount(wave) {
const orders = Array.isArray(wave?.orders) ? wave.orders : []
let intercept = 0
let intercepted = 0
for (const order of orders) {
if (this.isIntercepted(order)) {
intercept += 1
} else if (this.isInterceptedDone(order)) {
intercepted += 1
}
}
return { intercept, intercepted }
},
// 团购波次拦截标志文案('' 表示无拦截);有已拦截订单优先显示"已拦截"
getWaveInterceptLabel(wave) {
const { intercept, intercepted } = this.getWaveInterceptCount(wave)
if (intercepted > 0) return '已拦截'
if (intercept > 0) return '拦截'
return ''
},
// 获取团购波次的代表运单号(优先 first_waybill_no 波次首张快递单号,兜底 scanOrder 返回的 waybill_no),供称重接口运单号模式使用
getWaveRepresentWaybill(wave) {
if (!wave || typeof wave !== 'object') {
return ''
}
// 优先:波次首张快递单号
const first = this.getRowValue(wave, ['first_waybill_no', 'firstWaybillNo'])
if (first !== '') {
return first
}
// 兜底:scanOrder 返回的 waybill_no
return this.getScanOrderNo(wave)
},
// 拦截成功后:本地将左侧列表对应订单行状态更新为已拦截
markRowIntercepted(orderId) {
if (orderId === '' || orderId === null || orderId === undefined) {
return
}
const target = String(orderId)
const mark = (row) => {
const rowId = this.getScanOrderId(row)
if (rowId !== '' && String(rowId) === target) {
const src = this.getScanOrderSource(row)
if (src && typeof src === 'object') {
src.intercept_status = 'intercepted_at_warehouse'
}
return true
}
return false
}
for (const row of this.scanOrderList) {
if (mark(row)) {
return
}
// 团购模式:波次下订单也可能携带拦截状态
if (row && Array.isArray(row.orders)) {
for (const order of row.orders) {
if (mark(order)) {
return
}
}
}
}
},
// 是否处于拦截/已拦截状态(不计入剩余未复核)
isInterceptExcluded(item) {
const status = this.getInterceptStatus(item)
return status === 'requested' || status === 'intercepted_at_warehouse' || status === 'intercepted'
},
// 剩余未复核数统计:排除拦截/已拦截订单
countUnreviewedExcludingIntercepted(list) {
const rows = Array.isArray(list) ? list : []
let count = 0
for (const row of rows) {
// 团购波次:波次下订单列表(orders[] 可识别订单级拦截状态)
const subOrders = Array.isArray(row?.orders) ? row.orders : []
if (subOrders.length > 0) {
const rowUnreviewed = Number(this.getRowValue(row, ['unreviewed_count', 'unreviewedCount'])) || 0
// 波次内被拦截(含已拦截)且未复核的订单数
const interceptedUnreviewed = subOrders.filter(
(o) => this.isInterceptExcluded(o) && this.getWaveReviewStatus(o) === '未复核'
).length
count += Math.max(0, rowUnreviewed - interceptedUnreviewed)
continue
}
// 散单订单:被拦截(含已拦截)的不计入未复核
if (this.isInterceptExcluded(row)) {
continue
}
if (this.getWaveReviewStatus(row) === '未复核') {
count += 1
}
}
return count
},
handleScanOrderClick(item) {
// 切换选中订单时退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
const src = this.getScanOrderSource(item)
this.selectedPendingOrderKey = this.getScanOrderKey(item)
@ -1315,11 +1765,24 @@ export default {
if (this.isIntercepted(item)) {
const orderNo = this.getScanOrderNo(item) || this.getRowValue(src, ['order_id', 'orderId'])
this.interceptMode = true
this.interceptLocked = false
this.interceptTarget = {
orderNo,
orderId: this.getScanOrderId(item),
}
uni.showToast({ title: `已进入拦截确认:${orderNo}`, icon: 'none' })
return
}
// 已拦截订单:进入拦截锁定态,确认拦截按钮禁用,不可再次拦截
if (this.isInterceptedDone(item)) {
const orderNo = this.getScanOrderNo(item) || this.getRowValue(src, ['order_id', 'orderId'])
this.interceptMode = true
this.interceptLocked = true
this.interceptTarget = {
orderNo,
orderId: this.getScanOrderId(item),
}
uni.showToast({ title: `订单「${orderNo}」已拦截`, icon: 'none' })
}
},
getWaveKey(wave) {
@ -1339,6 +1802,7 @@ export default {
handleWaveClick(wave) {
// 团购模式:点击波次在右侧展示该波次的商品明细(stocks);切换时退出拦截确认模式
this.interceptMode = false
this.interceptLocked = false
this.interceptTarget = null
this.selectedWaveKey = this.getWaveKey(wave)
this.selectedPendingOrderKey = ''
@ -1919,9 +2383,16 @@ export default {
margin-right: 8rpx;
}
/* 运单号为弹性列:默认单行完整显示(不省略、不换行,整体直观);有拦截标志的行才换行显示完整 */
.scan-row .cell-wave-no {
padding-left: 0;
min-width: 260rpx;
min-width: 140rpx;
white-space: nowrap;
overflow: visible;
}
/* 有拦截标志的行(散单订单/团购波次):运单号列被拦截标签挤压,长号换行显示完整 */
.scan-row--intercept .cell-wave-no {
white-space: normal;
overflow: visible;
text-overflow: clip;
@ -1936,10 +2407,8 @@ export default {
flex: 1;
min-width: 0;
padding-left: 4rpx;
white-space: normal;
white-space: nowrap;
overflow: visible;
text-overflow: clip;
word-break: break-all;
}
.cell-print-status {
@ -1966,6 +2435,185 @@ export default {
user-select: none;
}
/* 已拦截状态(intercept_status=intercepted_at_warehouse):灰色标签,区别于待确认的红色拦截 */
.cell-intercept--done {
background-color: #909399;
}
/* 称重弹窗 */
.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: 1000;
}
.weigh-dialog {
width: 670rpx;
max-width: 92%;
background-color: #fff;
border-radius: 16rpx;
box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.18);
overflow: hidden;
display: flex;
flex-direction: column;
}
.weigh-dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 32rpx 20rpx;
border-bottom: 1rpx solid #eef2f8;
}
.weigh-dialog-title {
font-size: 32rpx;
font-weight: 700;
color: #333;
}
.weigh-dialog-close {
font-size: 30rpx;
color: #999;
padding: 8rpx;
cursor: pointer;
user-select: none;
}
.weigh-dialog-body {
padding: 24rpx 32rpx;
}
.weigh-info-row {
display: flex;
align-items: center;
gap: 16rpx;
padding: 10rpx 0;
}
.weigh-info-label {
width: 140rpx;
flex-shrink: 0;
font-size: 26rpx;
color: #909399;
}
.weigh-info-value {
flex: 1;
min-width: 0;
font-size: 28rpx;
color: #333;
word-break: break-all;
}
.weigh-label-inline {
display: flex;
align-items: center;
gap: 6rpx;
flex-shrink: 0;
margin-right: 8rpx;
}
.weigh-required {
color: #e64340;
font-size: 30rpx;
line-height: 1;
}
.weigh-input-label {
font-size: 28rpx;
color: #333;
}
.weigh-stepper {
display: flex;
align-items: center;
gap: 8rpx;
}
.weigh-step-btn {
flex-shrink: 0;
width: 72rpx;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
border: 1rpx solid #d9dde8;
border-radius: 8rpx;
background-color: #fff;
color: #333;
font-size: 36rpx;
user-select: none;
}
.weigh-step-btn:active {
background-color: #f0f2f5;
}
.weigh-input {
flex: 1;
min-width: 0;
height: 72rpx;
text-align: center;
border: 1rpx solid #d9dde8;
border-radius: 8rpx;
font-size: 40rpx;
color: #333;
background-color: #fff;
}
/* 输入提示(placeholder)保持小字号浅色,不随输入值放大(uni-app placeholder-class 生效于各端) */
.weigh-input-placeholder {
font-size: 28rpx;
color: #999;
}
.weigh-input-unit {
flex-shrink: 0;
font-size: 26rpx;
color: #909399;
}
.weigh-dialog-footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 20rpx;
padding: 20rpx 32rpx 28rpx;
border-top: 1rpx solid #eef2f8;
}
.weigh-btn {
height: 64rpx;
line-height: 64rpx;
padding: 0 36rpx;
margin: 0;
font-size: 28rpx;
border-radius: 8rpx;
}
.weigh-btn::after {
border: none;
}
.weigh-btn--cancel {
background-color: #fff;
color: #666;
border: 1rpx solid #d9dde8;
}
.weigh-btn--confirm {
background-color: #2f7dff;
color: #fff;
}
/* 左侧订单/波次列表:整行内容完整显示不省略;需换行时优先对运单号/波次号列换行 */
.table-wrap--current-wave .table-cell:not(.cell-wave-no) {
white-space: nowrap;
@ -2040,6 +2688,14 @@ export default {
color: #fff;
}
/* 确认拦截按钮禁用态(已拦截订单):深灰字体 + 浅灰底,明确不可点击 */
.tool-btn[disabled] {
color: #666;
background-color: #f2f2f2;
border-color: #d9dde8;
cursor: not-allowed;
}
.tool-select {
display: flex;
align-items: center;