From 79676c33efe67f630a36e01b6a50fde3d0b256e8 Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Sun, 20 Sep 2026 13:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=86=E6=96=99=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/request/apis.js | 6 ++ core/request/index.js | 6 +- env.js | 4 +- pages/claim/shippingLabel.vue | 129 ++++++++++++++++++++++++++++------ template.h5.html | 1 + 5 files changed, 120 insertions(+), 26 deletions(-) diff --git a/core/request/apis.js b/core/request/apis.js index 6905e24..a0e8dac 100644 --- a/core/request/apis.js +++ b/core/request/apis.js @@ -498,6 +498,12 @@ export default { method: "POST", isSystemApi: true }, + confirmPrintUnclaimedWaveCount: { + path: "order.wave.confirmPrintUnclaimedWaveCount", + auth: true, + method: "POST", + isSystemApi: true + }, wavePickTaskList: { path: "order.wave.wavePickTaskList", auth: true, diff --git a/core/request/index.js b/core/request/index.js index 6c556f2..d061256 100644 --- a/core/request/index.js +++ b/core/request/index.js @@ -11,7 +11,8 @@ export default function http( data = {}, toastBefore = '', // 请求前加载提示 toastAfter = true, // 请求后错误提示 - responseType = 'text' + responseType = 'text', + timeout = 0 // 自定义请求超时(ms),0 表示使用默认 20s;长轮询接口需传入大于服务端等待时长的值 ) { let api = getApiPath(url); console.log(api); @@ -98,7 +99,8 @@ export default function http( path: api.path, data, method: api.method, - responseType + responseType, + ...(timeout ? { timeout } : {}) }) } diff --git a/env.js b/env.js index c33f58a..b87b72a 100644 --- a/env.js +++ b/env.js @@ -1,4 +1,4 @@ -// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址 -export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址 +export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址 +// export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址 export const API_URL = `${BASE_URL}/system` //后台接口域名 export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss diff --git a/pages/claim/shippingLabel.vue b/pages/claim/shippingLabel.vue index 6509dc6..576e640 100644 --- a/pages/claim/shippingLabel.vue +++ b/pages/claim/shippingLabel.vue @@ -30,25 +30,29 @@ - - - - - 领料信息: - - + + + 确认打印未领料波次数量: + {{ unclaimedWaveCount }} + + + + + 领料信息: + + + {{ item }} - - - + + 暂无数据 - - + + @@ -76,7 +80,9 @@ scanFocused: false, totalQuantity: 0, submitting: false, - claimList: [] + claimList: [], + unclaimedWaveCount: 0, + unclaimedWavePolling: false }; }, computed: { @@ -98,12 +104,16 @@ onResult: this.onScanData }); this.$store.dispatch('broadcast/resume'); + // 启动「已打印但未领料波次数量」长轮询 + this.startUnclaimedWavePolling(); }, onHide() { this.$store.dispatch('broadcast/pause'); + this.stopUnclaimedWavePolling(); }, onUnload() { this.$store.dispatch('broadcast/stop'); + this.stopUnclaimedWavePolling(); }, methods: { // 广播扫码回调:扫码枪扫描结果 @@ -199,6 +209,51 @@ voice.speak(text, { minInterval: 800 }); } }, + // 「已打印但未领料的波次数量」长轮询(order.wave.confirmPrintUnclaimedWaveCount) + // 后端长轮询:不传 last_count 立即返回当前值;传 last_count 后最长等待 60s,变化立即返回 + startUnclaimedWavePolling() { + if (this.unclaimedWavePolling) return; + this.unclaimedWavePolling = true; + this.pollUnclaimedWaveCount(null); + }, + stopUnclaimedWavePolling() { + this.unclaimedWavePolling = false; + }, + async pollUnclaimedWaveCount(lastCount) { + if (!this.unclaimedWavePolling) return; + let nextCount = lastCount; + try { + const params = (lastCount === null || lastCount === undefined) + ? {} + : { last_count: lastCount }; + // 最后一个参数 timeout=70000:后端长轮询最长等待 60s,客户端超时需大于 60s + const res = await this.$http( + 'order.wave.confirmPrintUnclaimedWaveCount', + params, + '', + false, + 'text', + 70000 + ); + const data = (res && res.data && typeof res.data === 'object' && !Array.isArray(res.data)) + ? res.data + : {}; + const payload = { ...(res || {}), ...data }; + const count = Number(payload.count); + this.unclaimedWaveCount = Number.isFinite(count) ? count : 0; + nextCount = this.unclaimedWaveCount; + } catch (error) { + console.warn('[面单波次领料] 未领料波次数量轮询失败:', error); + // 失败后延迟 2s 重试(沿用原 last_count 基线) + await this.sleep(2000); + } + if (this.unclaimedWavePolling) { + this.pollUnclaimedWaveCount(nextCount); + } + }, + sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + }, handleCameraScan() { uni.scanCode({ success: (res) => { @@ -230,17 +285,13 @@ overflow: hidden; } - .detail-scroll { - flex: 1; - height: 0; - } - .content-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; - padding-top: 200rpx; + flex: 1; + height: 0; } .placeholder-text { @@ -249,8 +300,37 @@ color: #909399; } + /* ===== 已打印未领料波次数 ===== */ + .unclaimed-wave-count { + display: flex; + align-items: center; + justify-content: flex-start; + margin: 20rpx 24rpx 0; + padding: 24rpx; + background: #FFE7BA; + border-radius: 12rpx; + + .unclaimed-wave-count-label { + font-size: 32rpx; + font-weight: bold; + color: #D46B08; + } + + .unclaimed-wave-count-value { + margin-left: 12rpx; + font-size: 48rpx; + line-height: 32rpx; + font-weight: bold; + color: #D46B08; + } + } + /* ===== 领料信息 ===== */ .claim-info-section { + flex: 1; + height: 0; + display: flex; + flex-direction: column; background: #fff; margin: 20rpx 24rpx 0; border-radius: 12rpx; @@ -258,15 +338,20 @@ .claim-info-header { padding: 24rpx; - background-color: #ffedd5; + background-color: #D9F7BE; .claim-info-header-text { font-size: 32rpx; font-weight: bold; - color: #000; + color: #389E0D; } } + .claim-info-scroll { + flex: 1; + height: 0; + } + .claim-info-body { .info-row { display: flex; @@ -361,7 +446,7 @@ .claim-footer-total-value { font-size: 48rpx; font-weight: bold; - color: #fa8c16; + color: #389E0D; } } diff --git a/template.h5.html b/template.h5.html index 8a4e2c5..689b91b 100644 --- a/template.h5.html +++ b/template.h5.html @@ -3,6 +3,7 @@ +