feat: 打包上报改为订单上下文key + 团单复核交互优化
- workbench.queryOrder 返回 key(服务端缓存订单上下文,展示字段不再回传) - workbench.packOrder 只接收 key(移除 delivery_order_code/wave_no/items_* 等订单入参) - 团单完全核对后,扫码恢复为运单查询(检查下一单),不再停留在验货模式 - 重复扫描正在打包的同一单(团单比波次/散单比运单号):不显示已打包、不重新复核、不重复上报,提示正在打包 - 复核完成/开始打包后移除商品行右键/长按免验事件 - 退件拆包页(returns)更新
This commit is contained in:
parent
4071acca9e
commit
1c9cf4d3de
@ -131,6 +131,8 @@ export function removeWorkbenchMember(data: {
|
||||
/**
|
||||
* 工作台条码查询订单(免登录、免鉴权,以工作台 token 鉴权)
|
||||
* - 入参 token(工作台 token)+ barcode(条码/运单号);仓库与工作台由服务端从 token 解析注入
|
||||
* - 返回 data.key:服务端缓存的订单上下文 key(开始打包时回传给 workbench.packOrder),
|
||||
* 其余返回字段仅用于展示,不再作为打包参数回传
|
||||
* - 散单 isSandan=1 附 order.intercept_flag/pack_flag;团购 isSandan=0 附 batch 波次信息
|
||||
*/
|
||||
export function queryPackOrder(token: string, barcode: string) {
|
||||
@ -143,19 +145,18 @@ export function queryPackOrder(token: string, barcode: string) {
|
||||
|
||||
/**
|
||||
* 工作台打包上报(免登录、免鉴权,以工作台 token 鉴权)
|
||||
* - 入参 token + 发货单号(必填)等;仓库与工作台由服务端从 token 解析注入
|
||||
* - 入参 token + key(workbench.queryOrder 返回的订单上下文 key,必填);
|
||||
* 仓库与工作台由服务端从 token 解析注入
|
||||
* - 订单数据由服务端按 key 从查询时缓存的上下文中解析,客户端不再回传订单信息
|
||||
* - 散单按 order_id、团购按 wave_no 去重后创建打包任务(wms_pack_task)
|
||||
*/
|
||||
export function packOrder(data: {
|
||||
token: string
|
||||
delivery_order_code: string
|
||||
wave_no?: string
|
||||
/** workbench.queryOrder 返回的订单上下文 key(服务端缓存) */
|
||||
key: string
|
||||
status?: number
|
||||
/** 打包时间(Unix 秒,后端按秒转 datetime) */
|
||||
pack_time?: number
|
||||
wave_total_orders?: number
|
||||
items_count?: number
|
||||
items_total?: number
|
||||
users?: Array<{
|
||||
wms_account_id?: number | null
|
||||
id?: number | null
|
||||
|
||||
@ -96,8 +96,8 @@
|
||||
:key="index"
|
||||
class="pack-detail-row"
|
||||
:class="{ 'pack-detail-row--scanned': isGroupOrder && isItemScanned(item) }"
|
||||
@longpress="handleLongPressProduct(item)"
|
||||
@contextmenu.prevent="handleLongPressProduct(item)"
|
||||
@longpress="!groupVerifyDone && handleLongPressProduct(item)"
|
||||
@contextmenu.prevent="!groupVerifyDone && handleLongPressProduct(item)"
|
||||
>
|
||||
<text class="pack-detail-col pack-detail-col--index">{{ index + 1 }}</text>
|
||||
<view class="pack-detail-col pack-detail-col--image">
|
||||
@ -436,7 +436,11 @@ export default {
|
||||
currentOrderCode: '',
|
||||
currentWaybillCode: '',
|
||||
currentDeliveryOrderCode: '',
|
||||
// 服务端缓存的订单上下文 key(queryOrder 返回,开始打包时回传 packOrder)
|
||||
currentOrderKey: '',
|
||||
currentOrderRaw: null,
|
||||
// 本次查询与正在打包的订单是否一致(团单比波次、散单比运单号),一致时不显示"已打包"
|
||||
sameOrderQuery: false,
|
||||
precheckPassed: false,
|
||||
packStarted: false,
|
||||
packReporting: false,
|
||||
@ -522,6 +526,14 @@ export default {
|
||||
groupVerifiedCount() {
|
||||
return this.scannedKindCount
|
||||
},
|
||||
// 团单是否已完全核对(全部商品均已核实)
|
||||
groupVerifyCompleted() {
|
||||
return this.totalKindCount > 0 && this.groupVerifiedCount >= this.totalKindCount
|
||||
},
|
||||
// 核实已完成或已开始打包:商品行右键/长按免验事件移除
|
||||
groupVerifyDone() {
|
||||
return this.groupVerifyCompleted || this.packStarted
|
||||
},
|
||||
hasPackRecord() {
|
||||
return !!(this.currentOrderRaw || this.currentOrderCode || this.detailList.length > 0)
|
||||
},
|
||||
@ -673,8 +685,14 @@ export default {
|
||||
this.scheduleScanInputFocus(150)
|
||||
return
|
||||
}
|
||||
// 已绑定:团单等待复核中,所有条码输入均作为商品条码校验(切换订单请先取消核实)
|
||||
if (this.isGroupOrder && this.precheckPassed && this.detailList.length > 0) {
|
||||
// 已绑定:团单待核实中,所有条码输入均作为商品条码校验(切换订单请先取消核实)
|
||||
// 完全核对(自动开始打包)后,扫码恢复为运单查询,用于检查下一个订单
|
||||
if (
|
||||
this.isGroupOrder &&
|
||||
this.precheckPassed &&
|
||||
this.detailList.length > 0 &&
|
||||
!this.groupVerifyCompleted
|
||||
) {
|
||||
this.matchProductBarcode(kw)
|
||||
return
|
||||
}
|
||||
@ -771,6 +789,8 @@ export default {
|
||||
this.currentWaveNo = wave?.wave_no || order?.wave_no || ''
|
||||
this.currentWaybillCode = order?.waybill_code || order?.barcode || ''
|
||||
this.currentDeliveryOrderCode = order?.delivery_order_code || ''
|
||||
this.currentOrderKey =
|
||||
order?.key || order?.order_key || order?.orderKey || wave?.key || wave?.order_key || ''
|
||||
this.waveTotalOrders = wave?.order_count ?? order?.order_count ?? ''
|
||||
this.productCount = Number(wave?.items_total) || Number(order?.items_total) || 0
|
||||
this.currentOrderCode =
|
||||
@ -813,15 +833,46 @@ export default {
|
||||
const batch = raw?.batch && typeof raw.batch === 'object' ? raw.batch : {}
|
||||
const items = Array.isArray(raw?.items) ? raw.items : []
|
||||
|
||||
// 快照:查询前正在打包的订单标识(重复查询同一单时不显示"已打包"、无需重新复核)
|
||||
const prevIsGroup = this.isGroupOrder
|
||||
const prevWaybillCode = this.currentWaybillCode
|
||||
const prevWaveNo = this.currentWaveNo
|
||||
const prevPackStarted = this.packStarted
|
||||
|
||||
// 订单类型:isSandan=1 散单、0 团单(团单需扫码商品条码核验)
|
||||
const rawSandan = this.pickInfoField(raw, {}, ['isSandan', 'is_sandan'])
|
||||
const newIsGroup = rawSandan !== '' && Number(rawSandan) === 0
|
||||
this.isSandan = rawSandan === '' ? null : Number(rawSandan)
|
||||
|
||||
// 与正在打包的订单对比:团单比波次号、散单比运单号;一致即重复查询同一单
|
||||
const newWaveNo =
|
||||
this.pickInfoField(batch, {}, ['wave_no', 'waveNo']) ||
|
||||
this.pickInfoField(order, {}, ['wave_no', 'waveNo'])
|
||||
const newWaybill =
|
||||
this.pickInfoField(raw, {}, ['waybill_code', 'waybillCode']) ||
|
||||
this.pickInfoField(raw, {}, ['barcode']) ||
|
||||
''
|
||||
this.sameOrderQuery =
|
||||
prevIsGroup === newIsGroup &&
|
||||
(newIsGroup
|
||||
? Boolean(prevWaveNo) &&
|
||||
Boolean(newWaveNo) &&
|
||||
String(prevWaveNo) === String(newWaveNo)
|
||||
: Boolean(prevWaybillCode) &&
|
||||
Boolean(newWaybill) &&
|
||||
String(prevWaybillCode) === String(newWaybill))
|
||||
|
||||
// 记录当前订单上下文(用于预检/上报)
|
||||
this.currentOrderRaw = raw
|
||||
// 订单上下文 key(服务端缓存):开始打包时回传 workbench.packOrder
|
||||
this.currentOrderKey =
|
||||
this.pickInfoField(raw, {}, ['key', 'order_key', 'orderKey']) ||
|
||||
this.pickInfoField(order, {}, ['key', 'order_key', 'orderKey']) ||
|
||||
''
|
||||
this.currentOrderCode = code || ''
|
||||
this.packStarted = false
|
||||
this.precheckPassed = false
|
||||
// 重复查询正在打包的同一单:保持打包中状态,不要求重新复核/重复上报
|
||||
this.packStarted = this.sameOrderQuery && prevPackStarted
|
||||
this.precheckPassed = this.packStarted
|
||||
|
||||
// 运单号(散单展示用:waybill_code 优先,兜底 barcode)
|
||||
this.currentWaybillCode =
|
||||
@ -871,6 +922,12 @@ export default {
|
||||
item.scannedQty = Number(item.qty) || 0
|
||||
}
|
||||
})
|
||||
// 重复查询正在打包的同一单:全部商品恢复为已核实,不要求重新复核
|
||||
if (this.sameOrderQuery && this.packStarted) {
|
||||
this.detailList.forEach((item) => {
|
||||
item.scannedQty = Number(item.qty) || 0
|
||||
})
|
||||
}
|
||||
|
||||
// ---- 预检与分流 ----
|
||||
const precheck = this.packPrecheck()
|
||||
@ -880,9 +937,15 @@ export default {
|
||||
return
|
||||
}
|
||||
this.precheckPassed = true
|
||||
// 重复查询正在打包的同一单:保持打包中,不重复上报、不重新复核
|
||||
if (this.sameOrderQuery && this.packStarted) {
|
||||
this.speak('正在打包')
|
||||
uni.showToast({ title: '正在打包', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.isGroupOrder) {
|
||||
// 团单:无商品明细 或 全部商品免验 = 无需核实,直接提交开始打包
|
||||
if (this.detailList.length === 0 || this.groupVerifiedCount >= this.totalKindCount) {
|
||||
// 团单:无商品明细 或 全部商品免验/已完全核对 = 无需核实,直接提交开始打包
|
||||
if (this.detailList.length === 0 || this.groupVerifyCompleted) {
|
||||
this.handleSubmitGroupPack()
|
||||
}
|
||||
return
|
||||
@ -922,7 +985,7 @@ export default {
|
||||
return qty > 0 && scanned >= qty
|
||||
},
|
||||
handleLongPressProduct(item) {
|
||||
if (!item || !this.isGroupOrder) {
|
||||
if (!item || !this.isGroupOrder || this.groupVerifyDone) {
|
||||
return
|
||||
}
|
||||
if (this.isItemScanned(item)) {
|
||||
@ -949,7 +1012,7 @@ export default {
|
||||
if (!this.isGroupOrder || !this.precheckPassed || this.packStarted || this.packReporting) {
|
||||
return
|
||||
}
|
||||
if (this.totalKindCount > 0 && this.groupVerifiedCount >= this.totalKindCount) {
|
||||
if (this.groupVerifyCompleted) {
|
||||
this.handleSubmitGroupPack()
|
||||
}
|
||||
},
|
||||
@ -999,7 +1062,7 @@ export default {
|
||||
}
|
||||
const packStatus =
|
||||
order?.pack_status ?? order?.packStatus ?? batch?.pack_status ?? batch?.packStatus ?? ''
|
||||
if (packStatus && String(packStatus) !== 'none') {
|
||||
if (packStatus && String(packStatus) !== 'none' && !this.sameOrderQuery) {
|
||||
return { blocked: true, reason: '订单已打包,禁止打包', speakText: '已打包' }
|
||||
}
|
||||
return { blocked: false, reason: '', speakText: '' }
|
||||
@ -1012,7 +1075,7 @@ export default {
|
||||
if (recheckStatus && !['fin', 'finished', '1'].includes(String(recheckStatus))) {
|
||||
return { blocked: true, reason: '订单未复核,禁止打包', speakText: '订单未复核,禁止打包' }
|
||||
}
|
||||
if (Number(order?.pack_flag) === 1) {
|
||||
if (Number(order?.pack_flag) === 1 && !this.sameOrderQuery) {
|
||||
return { blocked: true, reason: '订单已打包,禁止打包', speakText: '已打包' }
|
||||
}
|
||||
return { blocked: false, reason: '', speakText: '' }
|
||||
@ -1025,16 +1088,16 @@ export default {
|
||||
if (!token) {
|
||||
return Promise.reject(new Error('工作台登录已失效'))
|
||||
}
|
||||
if (!this.currentOrderKey) {
|
||||
return Promise.reject(new Error('订单上下文缺失,请重新扫码查询'))
|
||||
}
|
||||
const payload = {
|
||||
token: String(token),
|
||||
delivery_order_code:
|
||||
this.currentDeliveryOrderCode || this.currentOrderCode || this.currentWaveNo || '',
|
||||
// 订单上下文 key(queryOrder 返回,服务端按 key 解析缓存中的订单信息)
|
||||
key: this.currentOrderKey,
|
||||
status,
|
||||
// 打包时间:Unix 秒(后端按秒转 datetime,传毫秒会导致 start_time 年份溢出报错)
|
||||
pack_time: Math.floor(Date.now() / 1000),
|
||||
wave_no: this.isGroupOrder && this.currentWaveNo ? this.currentWaveNo : undefined,
|
||||
items_count: this.totalKindCount || undefined,
|
||||
items_total: this.productCount || undefined,
|
||||
// 上报当前在线操作员(workbench.packOrder 的 users 参数,支持多人)
|
||||
users:
|
||||
this.workbenchMembers.length > 0
|
||||
@ -1113,7 +1176,9 @@ export default {
|
||||
this.currentOrderCode = ''
|
||||
this.currentWaybillCode = ''
|
||||
this.currentDeliveryOrderCode = ''
|
||||
this.currentOrderKey = ''
|
||||
this.currentOrderRaw = null
|
||||
this.sameOrderQuery = false
|
||||
this.precheckPassed = false
|
||||
this.packStarted = false
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user