diff --git a/pages/work/order/groupon-picking-detail.vue b/pages/work/order/groupon-picking-detail.vue index 266e350..1e9f5ba 100644 --- a/pages/work/order/groupon-picking-detail.vue +++ b/pages/work/order/groupon-picking-detail.vue @@ -13,22 +13,23 @@ 暂无可拣货团购单 - + 波次号:{{ item.waveNo || '--' }} - 拣货员:{{ item.pickerName || '--' }} + 总订单数:{{ item.totalOrderCount }} 未复核 {{ item.pendingCount }} + {{ getStatusText(item.status) }} - + 打印面单 @@ -195,6 +196,7 @@ const rowId = source.wave_id ?? source.waveId ?? source.id ?? waveNo; const waveId = source.wave_id ?? source.waveId ?? source.id ?? ''; const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--'; + const totalOrderCount = Number(source.total_order_count ?? source.totalOrderCount ?? source.order_count ?? source.orderCount ?? source.total_count ?? source.totalCount ?? source.order_num ?? source.orderNum ?? 0); const pendingCount = Number(source.pending_count ?? source.pendingCount ?? source.unreviewed_count ?? source.unreviewedCount ?? 0); const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim(); return { @@ -202,7 +204,9 @@ waveId: typeof waveId === 'number' ? waveId : String(waveId || '').trim(), waveNo, pickerName, + totalOrderCount: Number.isFinite(totalOrderCount) ? totalOrderCount : 0, pendingCount: Number.isFinite(pendingCount) ? pendingCount : 0, + status: String(source.status || 'pending'), isMine: !!this.currentUserId && !!assigneeId && assigneeId === this.currentUserId }; }) @@ -297,6 +301,109 @@ const randomPart = Math.random().toString(36).slice(2, 10); return `PRINT_${timePart}_${randomPart}`; }, + extractPickQueryPayload(response) { + const candidates = [ + response?.data?.data, + response?.data, + response?.result, + response + ]; + for (let i = 0; i < candidates.length; i += 1) { + const current = candidates[i]; + if (current && typeof current === 'object' && !Array.isArray(current)) { + return current; + } + } + return {}; + }, + extractTaskIdFromPickQueryPayload(payload) { + const taskId = Number(payload?.task_id ?? payload?.taskId ?? 0); + return Number.isFinite(taskId) && taskId > 0 ? taskId : 0; + }, + normalizePickQueryStatus(payload) { + return String(payload?.status || '').trim().toLowerCase(); + }, + normalizePickQueryTip(payload, fallback = '') { + return String(payload?.tip || payload?.message || payload?.msg || fallback).trim(); + }, + isPickQueryConflict(payload, status) { + const conflictKeywords = ['conflict', '归属', '他人', '占用', '非当前用户', '非本人']; + const text = `${String(status || '')} ${this.normalizePickQueryTip(payload, '')}`.toLowerCase(); + return conflictKeywords.some(keyword => text.includes(keyword)); + }, + routeToPickingPage(taskId) { + this.$tools.routerTo(`/pages/work/order/picking?taskId=${encodeURIComponent(String(taskId))}`); + }, + async handleWaveItemClick(item) { + const keyword = String(item?.waveNo || '').trim(); + if (!keyword) { + uni.showToast({ + title: '波次号缺失,无法创建拣货任务', + icon: 'none' + }); + return; + } + + uni.showLoading({ + title: '查询任务中...' + }); + try { + const response = await this.$http('pick.query', { keyword }, '', false); + const payload = this.extractPickQueryPayload(response); + const status = this.normalizePickQueryStatus(payload); + const tip = this.normalizePickQueryTip(payload, '任务查询成功'); + const taskId = this.extractTaskIdFromPickQueryPayload(payload); + + if (!taskId) { + uni.showToast({ + title: tip || '未获取到拣货任务', + icon: 'none' + }); + return; + } + + if (this.isPickQueryConflict(payload, status)) { + uni.showModal({ + title: '任务归属冲突', + content: tip || '活动任务归属他人,请稍后重试', + showCancel: false + }); + return; + } + + if (status && status !== 'existing' && status !== 'created') { + uni.showToast({ + title: tip || '任务状态异常', + icon: 'none' + }); + return; + } + + if (tip) { + uni.showToast({ + title: tip, + icon: 'none' + }); + } + this.routeToPickingPage(taskId); + } catch (error) { + const tip = String(error?.data?.tip || error?.data?.message || error?.message || error?.msg || '任务查询失败').trim(); + if (this.isPickQueryConflict({ tip }, '')) { + uni.showModal({ + title: '任务归属冲突', + content: tip || '活动任务归属他人,请稍后重试', + showCancel: false + }); + return; + } + uni.showToast({ + title: tip || '任务查询失败', + icon: 'none' + }); + } finally { + uni.hideLoading(); + } + }, async requestWavePlatformPrintData() { const params = this.buildWavePlatformPrintParams(); console.log('[GrouponPickingDetail] getWavePlatformPrintData params:', params); @@ -406,11 +513,22 @@ waveId: `${index + 1}`, waveNo, pickerName: isMine ? '我' : `拣货员${(index % 3) + 1}`, + totalOrderCount: ((index % 5) + 1) * 6, pendingCount: (index % 5) + 1, + status: 'pending', isMine }; }); }, + getStatusText(status) { + const map = { + pending: '待拣货', + picking: '拣货中', + picked: '已拣货', + completed: '已完成' + }; + return map[String(status || 'pending')] || '待拣货'; + }, async showRecordDetail(item) { const target = item && typeof item === 'object' ? item : null; console.log('[GrouponPickingDetail] print button clicked:', target); diff --git a/pages/work/order/picking.vue b/pages/work/order/picking.vue index 5275ebb..ab4f3cf 100644 --- a/pages/work/order/picking.vue +++ b/pages/work/order/picking.vue @@ -21,31 +21,6 @@ - - - - - - - - - - - 搜索 - - - - - - 任务详情加载中... @@ -145,9 +120,6 @@ - - - 查询 @@ -273,25 +245,7 @@ return this.pickingView.modeName || '--'; }, filteredPickItems() { - const list = Array.isArray(this.pickingView.items) ? this.pickingView.items : []; - const key = String(this.keyword || '').trim().toLowerCase(); - if (!key) { - return list; - } - return list.filter(item => { - const fields = [ - item.itemCode, - item.itemName, - item.spaceName, - item.spaceBarcode - ] - .map(value => String(value || '').toLowerCase()); - const allocText = (Array.isArray(item.boxAllocations) ? item.boxAllocations : []) - .map(alloc => `${alloc.boxNo}`) - .join(',') - .toLowerCase(); - return fields.some(text => text.includes(key)) || allocText.includes(key); - }); + return Array.isArray(this.pickingView.items) ? this.pickingView.items : []; }, selectedPickItem() { if (!this.filteredPickItems.length) { @@ -1327,9 +1281,6 @@ this.loadingTaskDetail = false; } }, - clearSearch() { - this.keyword = ''; - }, getSelectedItemImageKey(item) { if (!item || typeof item !== 'object') { return ''; @@ -1523,13 +1474,6 @@ } } }, - handleSearch() { - const normalizedKeyword = String(this.keyword || '').trim(); - this.keyword = normalizedKeyword; - if (!this.hasActiveTask) { - this.requestPickTaskByKeyword(normalizedKeyword); - } - }, selectPickItem(index) { this.selectedIndex = Number(index || 0); }, @@ -1646,84 +1590,12 @@ min-height: 0; } - .search-filter { - background: #ffffff; - padding: 20rpx 24rpx; - border-radius: 12rpx; - border: 1rpx solid #f0f0f0; - } - - .search-box-inner { - position: relative; - } - - ::v-deep .search-box-inner .u-search { - width: 100%; - } - - ::v-deep .search-box-inner .u-search__content { - padding-right: 200rpx; - } - - ::v-deep .search-box-inner .u-search__content__close { - margin-right: 12rpx; - } - - .search-actions { - position: absolute; - right: 24rpx; - top: 50%; - transform: translateY(-50%); - height: 68rpx; - display: flex; - align-items: center; - } - - .scan-btn { - height: 68rpx; - padding: 0 8rpx 0 4rpx; - display: flex; - align-items: center; - justify-content: center; - - &:active { - opacity: 0.88; - } - } - - .search-divider { - width: 1rpx; - height: 28rpx; - background: #dcdfe6; - margin: 0 16rpx 0 10rpx; - } - - .search-btn { - height: 68rpx; - padding: 0 8rpx; - display: flex; - align-items: center; - justify-content: center; - flex-shrink: 0; - - &:active { - opacity: 0.88; - } - } - - .search-btn__text { - font-size: 30rpx; - color: #2979ff; - font-weight: 500; - line-height: 1; - } - .nav-right { padding-right: 12rpx; display: flex; align-items: center; justify-content: flex-end; - gap: 26rpx; + gap: 40rpx; flex-wrap: nowrap; min-width: 0; } @@ -1741,8 +1613,17 @@ } .nav-action-btn--bind { - background: #f0f9eb; - border-color: #d2f0c8; + background: #2979ff; + border-color: #2979ff; + border-radius: 8rpx; + height: 60rpx; + padding: 0 22rpx; + } + + .nav-action-btn--bind .nav-action-btn__text { + color: #ffffff; + font-size: 28rpx; + font-weight: 600; } .nav-action-btn__text { @@ -2039,7 +1920,6 @@ gap: 12rpx; } - .bind-cart-scan-btn, .bind-cart-query-btn { height: 68rpx; border-radius: 12rpx; @@ -2052,12 +1932,6 @@ flex-shrink: 0; } - .bind-cart-scan-btn { - width: 72rpx; - background: #f2f7ff; - border: 1rpx solid #d9e8ff; - } - .bind-cart-query-btn { min-width: 96rpx; background: #2979ff; diff --git a/pages/work/order/scatter-picking-detail.vue b/pages/work/order/scatter-picking-detail.vue index f52c54d..55418d4 100644 --- a/pages/work/order/scatter-picking-detail.vue +++ b/pages/work/order/scatter-picking-detail.vue @@ -42,8 +42,7 @@ 波次号:{{ item.waveNo || '--' }} - 拣货员:{{ item.pickerName || '--' }} - 车号:{{ item.cartNo || '--' }} + 总订单数:{{ item.totalOrderCount }} 未复核 {{ item.unreviewedCount }} @@ -244,6 +243,7 @@ const rowId = source.id ?? waveId ?? waveNo ?? `batch-${this.currentPage}-${index + 1}`; const pickerName = String(source.picker_name || source.pickerName || source.user_name || source.userName || '--').trim() || '--'; const cartNo = String(source.cart_code || source.cartCode || source.cart_no || source.cartNo || '--').trim() || '--'; + const totalOrderCount = Number(source.total_order_count ?? source.totalOrderCount ?? source.order_count ?? source.orderCount ?? source.total_count ?? source.totalCount ?? source.order_num ?? source.orderNum ?? 0); const unreviewedCount = Number(source.unreviewed_count ?? source.unreviewedCount ?? source.pending_count ?? source.pendingCount ?? 0); const assigneeId = String((source.picker_id ?? source.pickerId ?? source.user_id ?? source.userId) || '').trim(); return { @@ -252,6 +252,7 @@ waveNo, pickerName, cartNo, + totalOrderCount: Number.isFinite(totalOrderCount) ? totalOrderCount : 0, unreviewedCount: Number.isFinite(unreviewedCount) ? unreviewedCount : 0, status: String(source.status || 'pending'), waybillCode: String(source.waybill_no || source.waybillCode || source.waybill_code || ''), @@ -679,29 +680,6 @@ this.currentPage = 1; this.loadBatchWaveNoList(1); }, - buildMockOrderList(count) { - const listCount = Math.max(0, Number(count || 0)); - return Array.from({ length: listCount }).map((_, index) => { - const waveNo = `W${new Date().getFullYear()}${String(index + 1).padStart(4, '0')}`; - const orderNo = `SD${Date.now().toString().slice(-6)}${String(index + 1).padStart(2, '0')}`; - const assigneeId = this.currentUserId || `mock_user_${(index % 2) + 1}`; - const isMine = index % 2 === 0; - const pickerName = isMine ? '我' : `拣货员${(index % 3) + 1}`; - return { - id: `${orderNo}-${index + 1}`, - waveNo, - unreviewedCount: (index % 4) + 1, - pickerName, - cartNo: `A${String((index % 12) + 1).padStart(2, '0')}`, - orderNo, - waybillCode: `WB${String(index + 1).padStart(8, '0')}`, - quantity: (index % 5) + 1, - status: 'pending', - assigneeId, - isMine - }; - }); - }, getStatusText(status) { const map = { pending: '待拣货', @@ -710,19 +688,115 @@ }; return map[status] || '待拣货'; }, + extractPickQueryPayload(response) { + const candidates = [ + response?.data?.data, + response?.data, + response?.result, + response + ]; + for (let i = 0; i < candidates.length; i += 1) { + const current = candidates[i]; + if (current && typeof current === 'object' && !Array.isArray(current)) { + return current; + } + } + return {}; + }, + extractTaskIdFromPickQueryPayload(payload) { + const taskId = Number(payload?.task_id ?? payload?.taskId ?? 0); + return Number.isFinite(taskId) && taskId > 0 ? taskId : 0; + }, + normalizePickQueryStatus(payload) { + return String(payload?.status || '').trim().toLowerCase(); + }, + normalizePickQueryTip(payload, fallback = '') { + return String(payload?.tip || payload?.message || payload?.msg || fallback).trim(); + }, + isPickQueryConflict(payload, status) { + const conflictKeywords = ['conflict', '归属', '他人', '占用', '非当前用户', '非本人']; + const text = `${String(status || '')} ${this.normalizePickQueryTip(payload, '')}`.toLowerCase(); + return conflictKeywords.some(keyword => text.includes(keyword)); + }, + routeToPickingPage(taskId) { + this.$tools.routerTo(`/pages/work/order/picking?taskId=${encodeURIComponent(String(taskId))}`); + }, goPickGoodsDetail(item) { if (!item) { return; } - const params = [ - `recordId=${encodeURIComponent(String(item.id || ''))}`, - `waveNo=${encodeURIComponent(String(item.waveNo || '--'))}`, - `pickerName=${encodeURIComponent(String(item.pickerName || '--'))}`, - `cartNo=${encodeURIComponent(String(item.cartNo || '--'))}`, - `status=${encodeURIComponent(String(item.status || 'pending'))}`, - `unreviewedCount=${encodeURIComponent(String(item.unreviewedCount || 0))}` - ]; - this.$tools.routerTo(`/pages/work/order/scatter-pick-goods-detail?${params.join('&')}`); + const waveKeyword = String(item.waveNo || '').trim(); + const waybillKeyword = String(item.waybillCode || '').trim(); + const keyword = waybillKeyword || waveKeyword; + if (!keyword) { + uni.showToast({ + title: '缺少运单号或波次号', + icon: 'none' + }); + return; + } + + uni.showLoading({ + title: '查询任务中...' + }); + this.$http('pick.query', { keyword }, '', false) + .then(response => { + const payload = this.extractPickQueryPayload(response); + const status = this.normalizePickQueryStatus(payload); + const tip = this.normalizePickQueryTip(payload, '任务查询成功'); + const taskId = this.extractTaskIdFromPickQueryPayload(payload); + + if (!taskId) { + uni.showToast({ + title: tip || '未获取到拣货任务', + icon: 'none' + }); + return; + } + + if (this.isPickQueryConflict(payload, status)) { + uni.showModal({ + title: '任务归属冲突', + content: tip || '活动任务归属他人,请稍后重试', + showCancel: false + }); + return; + } + + if (status && status !== 'existing' && status !== 'created') { + uni.showToast({ + title: tip || '任务状态异常', + icon: 'none' + }); + return; + } + + if (tip) { + uni.showToast({ + title: tip, + icon: 'none' + }); + } + this.routeToPickingPage(taskId); + }) + .catch(error => { + const tip = String(error?.data?.tip || error?.data?.message || error?.message || error?.msg || '任务查询失败').trim(); + if (this.isPickQueryConflict({ tip }, '')) { + uni.showModal({ + title: '任务归属冲突', + content: tip || '活动任务归属他人,请稍后重试', + showCancel: false + }); + return; + } + uni.showToast({ + title: tip || '任务查询失败', + icon: 'none' + }); + }) + .finally(() => { + uni.hideLoading(); + }); }, async handlePrintAllUnreviewed(item) { const target = item && typeof item === 'object' ? item : null;