From b3d545b1c8e598ebda5b3e6b9e0218c9b76fb590 Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Tue, 12 May 2026 17:56:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=A2=E8=B4=AD?= =?UTF-8?q?=E6=8B=A3=E8=B4=A7=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8B=A3=E8=B4=A7=E6=B5=81=E7=A8=8B=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 7 + pages/home/edit-quick-actions.vue | 5 +- pages/index/index.vue | 5 +- pages/work/order/groupon-picking-detail.vue | 229 +++++++++++++++ pages/work/order/picking.vue | 308 ++++++++++++++++++-- pages/work/product/query.vue | 11 +- 6 files changed, 544 insertions(+), 21 deletions(-) create mode 100644 pages/work/order/groupon-picking-detail.vue diff --git a/pages.json b/pages.json index dd4bb51..084f430 100644 --- a/pages.json +++ b/pages.json @@ -177,6 +177,13 @@ "titleNView": false } }, + { + "path" : "pages/work/order/groupon-picking-detail", + "style" : + { + "titleNView": false + } + }, { "path" : "pages/work/order/scatter-pick-goods-detail", "style" : diff --git a/pages/home/edit-quick-actions.vue b/pages/home/edit-quick-actions.vue index cd38048..8660fec 100644 --- a/pages/home/edit-quick-actions.vue +++ b/pages/home/edit-quick-actions.vue @@ -315,6 +315,7 @@ const isGoodsQuery = menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询')); const isOrderPicking = menuName === '订单拣货' || (menuName.includes('订单') && menuName.includes('拣货')); const isScatterWaveStrategy = menuName === '散单波次策略' || (menuName.includes('散单') && menuName.includes('波次')); + const isGrouponPickingDetail = menuName === '团购拣货详情' || (menuName.includes('团购') && menuName.includes('拣货') && menuName.includes('详情')); const rawPath = item?.component || item?.path || ''; const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : ''; const isRelocation = menuName === '移库作业' || normalizedPath === '/pages/work/storage/relocation'; @@ -330,7 +331,9 @@ ? '/pages/work/product/query' : (isOrderPicking ? '/pages/work/order/picking' - : (isScatterWaveStrategy ? '/pages/work/order/scatter-wave-strategy' : normalizedPath)); + : (isScatterWaveStrategy + ? '/pages/work/order/scatter-wave-strategy' + : (isGrouponPickingDetail ? '/pages/work/order/groupon-picking-detail' : normalizedPath))); if (!targetPath) { uni.showToast({ diff --git a/pages/index/index.vue b/pages/index/index.vue index f59b40a..f766a2d 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1150,6 +1150,7 @@ const isOrderPicking = menuName === '订单拣货' || (menuName.includes('订单') && menuName.includes('拣货')); const isScatterWaveStrategy = menuName === '散单波次策略' || (menuName.includes('散单') && menuName.includes('波次')); const isScatterPickingDetail = menuName === '散单拣货详情' || (menuName.includes('散单') && menuName.includes('拣货') && menuName.includes('详情')); + const isGrouponPickingDetail = menuName === '团购拣货详情' || (menuName.includes('团购') && menuName.includes('拣货') && menuName.includes('详情')); const rawPath = item?.component || item?.path || ''; const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : ''; const isRelocation = menuName === '移库作业' || normalizedPath === '/pages/work/storage/relocation'; @@ -1167,7 +1168,9 @@ ? '/pages/work/order/picking' : (isScatterWaveStrategy ? '/pages/work/order/scatter-wave-strategy' - : (isScatterPickingDetail ? '/pages/work/order/scatter-picking-detail' : normalizedPath))); + : (isScatterPickingDetail + ? '/pages/work/order/scatter-picking-detail' + : (isGrouponPickingDetail ? '/pages/work/order/groupon-picking-detail' : normalizedPath)))); if (!targetPath) { uni.showToast({ diff --git a/pages/work/order/groupon-picking-detail.vue b/pages/work/order/groupon-picking-detail.vue new file mode 100644 index 0000000..b4c294b --- /dev/null +++ b/pages/work/order/groupon-picking-detail.vue @@ -0,0 +1,229 @@ + + + + + \ No newline at end of file diff --git a/pages/work/order/picking.vue b/pages/work/order/picking.vue index 9e4408e..b632369 100644 --- a/pages/work/order/picking.vue +++ b/pages/work/order/picking.vue @@ -13,7 +13,7 @@ 开始拣货 - 扫描快递号或拣货单开始拣货 + 扫描快递单号或波次号开始拣货 @@ -53,8 +53,31 @@ + + + + + +{{ getSelectedImageExtraCount() }} + + + {{ selectedItemImageLoading ? '图片加载中...' : '暂无商品图片' }} - + {{ selectedPickItem.itemName || '--' }} @@ -236,6 +259,11 @@ } }, onLoad(options) { + this.$store.dispatch('broadcast/setCallbacks', { + onResult: this.handleBroadcastScan + }); + this.$store.dispatch('broadcast/start'); + const incomingTaskId = options?.taskId || options?.task_id || ''; if (incomingTaskId !== '') { this.taskId = String(incomingTaskId || '').trim(); @@ -244,7 +272,191 @@ } this.requestCurrentWavePickTask(); }, + onShow() { + this.$store.dispatch('broadcast/resume'); + }, + onHide() { + this.$store.dispatch('broadcast/stop'); + }, + onUnload() { + this.$store.dispatch('broadcast/stop'); + }, methods: { + getSelectedImageList() { + if (Array.isArray(this.selectedItemImageUrls) && this.selectedItemImageUrls.length) { + return this.selectedItemImageUrls; + } + if (this.selectedItemImageUrl) { + return [this.selectedItemImageUrl]; + } + return []; + }, + getSelectedImageThumbList() { + return this.getSelectedImageList().slice(0, 4); + }, + getSelectedImageExtraCount() { + const total = this.getSelectedImageList().length; + return total > 4 ? total - 4 : 0; + }, + normalizeScanResult(scanResult) { + if (!scanResult) { + return ''; + } + if (typeof scanResult === 'string') { + return scanResult.trim(); + } + if (typeof scanResult?.result === 'string') { + return scanResult.result.trim(); + } + if (typeof scanResult?.data === 'string') { + return scanResult.data.trim(); + } + return ''; + }, + handleScanKeywordEntry(rawKeyword) { + const scanText = this.normalizeScanResult(rawKeyword); + if (!scanText) { + uni.showToast({ + title: '未识别到有效条码', + icon: 'none' + }); + return; + } + this.keyword = scanText; + if (!this.hasActiveTask) { + this.requestPickTaskByKeyword(scanText); + return; + } + this.handleSearch(); + }, + handleBroadcastScan(payload) { + const scanText = this.normalizeScanResult(payload); + if (!this.hasActiveTask) { + this.handleScanKeywordEntry(scanText); + } + }, + extractTaskIdCandidate(rawValue) { + if (rawValue === null || rawValue === undefined || rawValue === '') { + return null; + } + const taskId = Number(rawValue); + if (!Number.isFinite(taskId) || taskId <= 0) { + return null; + } + return taskId; + }, + extractTaskIdFromPickQueryResponse(response) { + const payload = response?.data?.data || response?.data || response?.result || response || {}; + const candidates = [ + payload?.task_id, + payload?.taskId, + payload?.existing_task_id, + payload?.created_task_id, + payload?.existing?.task_id, + payload?.existing?.taskId, + payload?.created?.task_id, + payload?.created?.taskId, + payload?.task?.task_id, + payload?.task?.taskId + ]; + for (let i = 0; i < candidates.length; i += 1) { + const resolvedTaskId = this.extractTaskIdCandidate(candidates[i]); + if (resolvedTaskId) { + return resolvedTaskId; + } + } + return null; + }, + extractPickTaskConflictInfo(error) { + const responseData = error?.data || error?.response?.data || {}; + const payload = responseData?.data || responseData || {}; + const message = String( + payload?.message || + payload?.msg || + responseData?.message || + responseData?.msg || + error?.message || + '' + ).trim(); + const code = String(payload?.code || responseData?.code || error?.code || '').toLowerCase(); + const creatorName = String( + payload?.creator_name || + payload?.owner_name || + payload?.task_creator_name || + payload?.creator?.real_name || + payload?.creator?.name || + '' + ).trim(); + const taskId = this.extractTaskIdCandidate( + payload?.task_id ?? payload?.existing_task_id ?? payload?.task?.task_id ?? null + ); + const identifyText = `${code} ${message}`.toLowerCase(); + const isConflict = identifyText.includes('conflict') || identifyText.includes('owner') || identifyText.includes('创建人') || identifyText.includes('归属') || identifyText.includes('非当前用户') || identifyText.includes('非本人'); + return { + isConflict, + creatorName, + taskId, + message + }; + }, + buildPickTaskConflictMessage(conflictInfo) { + const lines = ['该拣货任务已被其他人员占用']; + if (conflictInfo?.creatorName) { + lines.push(`创建人:${conflictInfo.creatorName}`); + } + if (conflictInfo?.taskId) { + lines.push(`任务ID:${conflictInfo.taskId}`); + } + if (conflictInfo?.message) { + lines.push(conflictInfo.message); + } + return lines.join('\n'); + }, + async requestPickTaskByKeyword(keyword) { + const normalizedKeyword = String(keyword || '').trim(); + if (!normalizedKeyword) { + uni.showToast({ + title: '请输入运单号或波次号', + icon: 'none' + }); + return; + } + uni.showLoading({ + title: '正在查询任务...' + }); + try { + const response = await this.$http('pick.query', { + keyword: normalizedKeyword + }); + const taskId = this.extractTaskIdFromPickQueryResponse(response); + if (!taskId) { + uni.showToast({ + title: '未查询到可拣货任务', + icon: 'none' + }); + return; + } + this.taskId = String(taskId); + this.keyword = ''; + await this.requestWavePickTaskDetail(); + } catch (error) { + const conflictInfo = this.extractPickTaskConflictInfo(error); + if (conflictInfo.isConflict) { + uni.showModal({ + title: '任务归属冲突', + content: this.buildPickTaskConflictMessage(conflictInfo), + showCancel: false + }); + return; + } + uni.showToast({ + title: this.getApiErrorMessage(error, '任务查询失败'), + icon: 'none' + }); + } finally { + uni.hideLoading(); + } + }, openActionSheet() { if (!this.hasActiveTask) { return; @@ -364,10 +576,7 @@ this.requestWavePickTaskDetail(); return; } - uni.showToast({ - title: '请扫描面单或拣货单进入拣货流程', - icon: 'none' - }); + return; } catch (error) { uni.showToast({ title: this.getApiErrorMessage(error, '请扫描面单或拣货单进入拣货流程'), @@ -637,7 +846,11 @@ } }, handleSearch() { - this.keyword = String(this.keyword || '').trim(); + const normalizedKeyword = String(this.keyword || '').trim(); + this.keyword = normalizedKeyword; + if (!this.hasActiveTask) { + this.requestPickTaskByKeyword(normalizedKeyword); + } }, selectPickItem(index) { this.selectedIndex = Number(index || 0); @@ -652,21 +865,32 @@ const currentIndex = this.selectedItemImageUrl ? Math.max(urls.indexOf(this.selectedItemImageUrl), 0) : 0; this.$tools.previewImage(urls, currentIndex); }, + goProductQueryByCurrentBarcode() { + if (this.selectedItemBarcodeLoading) { + uni.showToast({ + title: '条码加载中,请稍后', + icon: 'none' + }); + return; + } + const barcode = String(this.selectedItemBarcode || '').trim(); + if (!barcode) { + uni.showToast({ + title: '当前商品暂无条码', + icon: 'none' + }); + return; + } + uni.navigateTo({ + url: `/pages/work/product/query?keyword=${encodeURIComponent(barcode)}` + }); + }, handleCameraScan() { uni.scanCode({ onlyFromCamera: true, scanType: ['barCode', 'qrCode'], success: res => { - const scanText = String(res?.result || '').trim(); - if (!scanText) { - uni.showToast({ - title: '未识别到有效条码', - icon: 'none' - }); - return; - } - this.keyword = scanText; - this.handleSearch(); + this.handleScanKeywordEntry(res); }, fail: () => { uni.showToast({ @@ -899,9 +1123,57 @@ min-width: 120rpx; } + .goods-image { + border-radius: 10rpx; + overflow: hidden; + background: #f5f7fa; + } + + .goods-image-grid { + width: 120rpx; + height: 120rpx; + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-content: space-between; + } + + .pick-grid-cell { + position: relative; + width: 58rpx; + height: 58rpx; + border-radius: 8rpx; + overflow: hidden; + background: #f5f7fa; + } + + .pick-grid-image { + border-radius: 8rpx; + overflow: hidden; + } + + .pick-more-mask { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.45); + display: flex; + align-items: center; + justify-content: center; + } + + .pick-more-text { + font-size: 22rpx; + color: #fff; + font-weight: 600; + } + .detail-main-right { flex: 1; min-width: 0; + cursor: pointer; } .pick-image-empty { diff --git a/pages/work/product/query.vue b/pages/work/product/query.vue index 2f9d134..8ea9c51 100644 --- a/pages/work/product/query.vue +++ b/pages/work/product/query.vue @@ -284,12 +284,21 @@ return this.pageHeaderHeight + summaryHeight + summaryGap + visualOffset; } }, - onLoad() { + onLoad(options) { this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult }); this.safeDispatchBroadcast('start'); + const routeKeyword = this.normalizeKeyword(options?.keyword || options?.barcode || options?.code || ''); + if (routeKeyword) { + this.keyword = routeKeyword; + } this.list = []; + if (routeKeyword) { + this.handleSearch({ + silentVoice: true + }); + } }, onShow() { this.safeDispatchBroadcast('setCallbacks', {