diff --git a/env.js b/env.js
index b87b72a..c33f58a 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/work/order/order-review-comps/OrderList.vue b/pages/work/order/order-review-comps/OrderList.vue
index 970cbbf..d485d05 100644
--- a/pages/work/order/order-review-comps/OrderList.vue
+++ b/pages/work/order/order-review-comps/OrderList.vue
@@ -58,7 +58,7 @@
{{ getReviewStatusText(item) }}
0) return true;
const status = String(item?.interceptStatus || '').trim();
return INTERCEPT_STATUSES.includes(status);
},
@@ -159,7 +161,11 @@
},
isPrintDisabled(item) {
if (!item) return true;
+ // 不打印模式:列表不支持手动打印
+ if (this.printMode === 'noPrint') return true;
if (this.printMode === 'reviewFirst') return true;
+ // 拦截订单:禁止打印面单
+ if (this.isIntercepted(item)) return true;
if (this.listType === 'single') return false;
return (item.orderCount || 0) === 0 && (item.unprintedCount || 0) === 0;
},
@@ -406,6 +412,10 @@
color: #fa8c16;
}
+ .record-value--intercepted-unreviewed {
+ color: #909399;
+ }
+
.record-value--printed {
color: #f56c6c;
}
diff --git a/pages/work/order/order-review-comps/ReviewDetail.vue b/pages/work/order/order-review-comps/ReviewDetail.vue
index f5dbd3d..8bfad5c 100644
--- a/pages/work/order/order-review-comps/ReviewDetail.vue
+++ b/pages/work/order/order-review-comps/ReviewDetail.vue
@@ -28,9 +28,6 @@
货主:{{ detailInfo.storeName }}
-
- 拦截信息
-
订单数:{{ detailInfo.totalOrders || '--' }}
@@ -38,9 +35,6 @@
篮号:{{ detailInfo.waveIndex || detailInfo.boxNo || '--' }}
货主:{{ detailInfo.storeName || '--' }}
-
- 拦截信息
-
@@ -211,19 +205,26 @@
-
+
+
+
+
+
+
-
- 重置
+
+ 扫描计数:{{ scanCount }}
@@ -88,7 +88,15 @@ import voice from '@/core/utils/voice';
remarkInput: '',
result: {},
showResult: false,
- submitting: false
+ submitting: false,
+ // 扫描计数:仅在登记成功时 +1,同一快递单号重复扫描仅计数一次,进入页面从 0 开始,退出页面即清零(不持久化)
+ scanCount: 0,
+ // 已计数的快递单号集合(内存去重,不持久化,退出页面即清空)
+ countedWaybills: [],
+ // ===== 弱网处理状态 =====
+ isNetworkConnected: true,
+ pendingSubmitQueue: [],
+ isFlushingPendingQueue: false
};
},
computed: {
@@ -102,6 +110,12 @@ import voice from '@/core/utils/voice';
}
},
onLoad() {
+ // 扫描计数每次进入页面从 0 开始(含已计数字号集合清空)
+ this.scanCount = 0;
+ this.countedWaybills = [];
+ // 弱网处理:初始化网络状态并监听变化
+ this.initNetworkStatus();
+ this.bindNetworkStatusChange();
this.$store.dispatch('broadcast/setCallbacks', {
onResult: this.onScanData
});
@@ -109,11 +123,15 @@ import voice from '@/core/utils/voice';
},
onShow() {
this.$store.dispatch('broadcast/resume');
+ // 返回页面时重新检测网络并尝试补提(兜底 onNetworkStatusChange 未触发场景)
+ this.initNetworkStatus();
},
onHide() {
this.$store.dispatch('broadcast/pause');
},
onUnload() {
+ this.stopNetworkPolling();
+ this.unbindNetworkStatusChange();
this.$store.dispatch('broadcast/stop');
},
methods: {
@@ -143,64 +161,258 @@ import voice from '@/core/utils/voice';
speakVoice(text) {
voice.speak(text, { minInterval: 800 });
},
+ // ===== 弱网处理:网络状态监听 =====
+ initNetworkStatus() {
+ uni.getNetworkType({
+ success: res => {
+ const networkType = String(res && res.networkType ? res.networkType : '').toLowerCase();
+ // 仅明确的在线网络类型视为在线(none/unknown/空 均视为离线)
+ this.isNetworkConnected = ['wifi', '2g', '3g', '4g', '5g', 'ethernet'].includes(networkType);
+ if (this.isNetworkConnected) {
+ this.flushPendingSubmitQueue();
+ }
+ },
+ fail: () => {
+ // 获取失败保守视为在线,交由请求失败兜底入队
+ this.isNetworkConnected = true;
+ }
+ });
+ },
+ bindNetworkStatusChange() {
+ if (this._networkStatusChangeHandler) {
+ return;
+ }
+ this._networkStatusChangeHandler = res => {
+ const networkType = String(res && res.networkType ? res.networkType : '').toLowerCase();
+ // 以 networkType 白名单判断在线(兼容部分设备 isConnected 缺失/不准确)
+ const isConnected = ['wifi', '2g', '3g', '4g', '5g', 'ethernet'].includes(networkType);
+ this.isNetworkConnected = isConnected;
+ if (isConnected) {
+ this.flushPendingSubmitQueue();
+ }
+ };
+ uni.onNetworkStatusChange(this._networkStatusChangeHandler);
+ },
+ unbindNetworkStatusChange() {
+ if (!this._networkStatusChangeHandler) {
+ return;
+ }
+ if (typeof uni.offNetworkStatusChange === 'function') {
+ uni.offNetworkStatusChange(this._networkStatusChangeHandler);
+ }
+ this._networkStatusChangeHandler = null;
+ },
+ // 补提兜底轮询:离线入队后定时重查网络,网络恢复时自动补提(兼容 onNetworkStatusChange 未触发场景)
+ startNetworkPolling() {
+ if (this._networkPollTimer) {
+ return;
+ }
+ this._networkPollTimer = setInterval(() => {
+ if (!this.pendingSubmitQueue.length) {
+ this.stopNetworkPolling();
+ return;
+ }
+ this.initNetworkStatus();
+ }, 5000);
+ },
+ stopNetworkPolling() {
+ if (this._networkPollTimer) {
+ clearInterval(this._networkPollTimer);
+ this._networkPollTimer = null;
+ }
+ },
+
+ // ===== 弱网处理:补提队列 =====
+ enqueuePendingSubmit(waybillCode, remark = '') {
+ const normalizedCode = String(waybillCode || '').trim();
+ if (!normalizedCode) return;
+ if (this.pendingSubmitQueue.some(item => item.code === normalizedCode)) return;
+ this.pendingSubmitQueue.push({
+ code: normalizedCode,
+ remark: String(remark || '').trim()
+ });
+ },
+ dequeuePendingSubmit(waybillCode) {
+ const normalizedCode = String(waybillCode || '').trim();
+ this.pendingSubmitQueue = this.pendingSubmitQueue.filter(item => item.code !== normalizedCode);
+ },
+ // 等待提交锁空闲(150ms 轮询),避免补提与用户实时提交并发冲突
+ async waitForSubmitIdle() {
+ const maxWait = 10000;
+ const start = Date.now();
+ while (this.submitting) {
+ if (Date.now() - start > maxWait) break;
+ await this.sleep(150);
+ }
+ },
+ async flushPendingSubmitQueue() {
+ if (!this.isNetworkConnected || this.isFlushingPendingQueue || !this.pendingSubmitQueue.length) {
+ return;
+ }
+ this.isFlushingPendingQueue = true;
+ try {
+ while (this.isNetworkConnected && this.pendingSubmitQueue.length) {
+ // 等待当前提交结束后再补提,串行化避免并发竞态
+ await this.waitForSubmitIdle();
+ const head = this.pendingSubmitQueue[0];
+ if (!head) break;
+ const beforeCode = head.code;
+ try {
+ const response = await this.requestReturnRegister(head.code, head.remark, 8000);
+ this.handleReturnRegisterResponse(response, head.code, head.remark);
+ // 响应处理内部已出队,若仍在队首则手动出队
+ if (this.pendingSubmitQueue[0] && this.pendingSubmitQueue[0].code === beforeCode) {
+ this.pendingSubmitQueue.shift();
+ }
+ } catch (error) {
+ if (!this.isNetworkConnected) {
+ break;
+ }
+ // 非并发原因(如非弱网错误)且未出队,退出防止死循环
+ if (this.pendingSubmitQueue[0] && this.pendingSubmitQueue[0].code === beforeCode && !this.submitting) {
+ break;
+ }
+ }
+ }
+ } finally {
+ this.isFlushingPendingQueue = false;
+ // 队列已清空,停止补提轮询
+ if (!this.pendingSubmitQueue.length) {
+ this.stopNetworkPolling();
+ }
+ }
+ },
+
+ // ===== 弱网处理:请求超时与错误判断 =====
+ sleep(ms = 0) {
+ return new Promise(resolve => {
+ setTimeout(resolve, Number(ms) || 0);
+ });
+ },
+ createSubmitTimeoutError(timeoutMs) {
+ const error = new Error(`提交超时(${timeoutMs}ms)`);
+ error.code = 'REQUEST_TIMEOUT';
+ error.errMsg = `request:fail timeout ${timeoutMs}`;
+ return error;
+ },
+ requestReturnRegister(waybillCode, remark = '', timeoutMs = 8000) {
+ const requestPromise = this.$http('returnReceived.create', {
+ waybill_code: waybillCode,
+ remark: String(remark || '').trim()
+ }, '', false);
+ const timeoutPromise = new Promise((_, reject) => {
+ setTimeout(() => {
+ reject(this.createSubmitTimeoutError(timeoutMs));
+ }, timeoutMs);
+ });
+ return Promise.race([requestPromise, timeoutPromise]);
+ },
+ // 仅在输入框值与本次提交一致时清除,避免补提误清用户正在输入的备注
+ clearInputIfSame(waybillCode, remark = '') {
+ if (this.scanInput === waybillCode) {
+ this.scanInput = '';
+ }
+ if (this.remarkInput === String(remark || '').trim()) {
+ this.remarkInput = '';
+ }
+ },
+ // 登记响应处理:成功与业务失败均出队;重试/补提安全(服务端 30 日幂等不会重复登记)
+ handleReturnRegisterResponse(res, waybillCode, remark = '') {
+ if (res && res.flag === 'failure') {
+ this.dequeuePendingSubmit(waybillCode);
+ uni.showToast({ title: (res && (res.msg || res.message)) || '登记失败', icon: 'none' });
+ this.speakVoice('登记失败');
+ this.clearInputIfSame(waybillCode, remark);
+ return;
+ }
+ this.dequeuePendingSubmit(waybillCode);
+ // 后端返回的业务记录在 data 或 record 字段,且部分状态字段(duplicated/is_original_return/store_remark)在顶层。
+ // 将顶层与业务记录合并,保证快递号(waybill_code)等字段能正常取到
+ let payload = (res && typeof res === 'object') ? res : {};
+ const body = (res && (res.data || res.record)) || null;
+ if (body && typeof body === 'object' && !Array.isArray(body)) {
+ payload = { ...res, ...body };
+ }
+ this.result = payload || {};
+ this.showResult = true;
+ // 登记成功,扫描计数 +1;同一快递单号重复扫描仅计数一次(失败/无效单号不计入)
+ if (!this.countedWaybills.includes(waybillCode)) {
+ this.countedWaybills.push(waybillCode);
+ this.scanCount += 1;
+ }
+ this.clearInputIfSame(waybillCode, remark);
+ if (this.result.duplicated) {
+ uni.showToast({ title: '30日内已登记', icon: 'none' });
+ this.speakVoice('已登记');
+ } else if (this.result.is_original_return) {
+ uni.showToast({ title: '原单退回登记成功', icon: 'success' });
+ this.speakVoice('登记成功');
+ } else {
+ uni.showToast({ title: '退件登记成功', icon: 'success' });
+ this.speakVoice('登记成功');
+ }
+ },
/**
* 退回包裹扫码登记
* 调用 returnReceived.create 登记退回收件运单号:
* - 30日内同仓库同单号幂等(以第一次为准,duplicated=true)
* - 反查 wms_order_express 判定是否原单退回,命中则回填 order_express_id/order_id/store_id 并标记 is_back='Y'
* - warehouse_id 由服务端注入 ctx.user.store_id,前端禁止传入
+ * - 弱网:离线/请求层失败一律入队补提,网络恢复自动提交(8s 超时兜底;登录过期等登录态错误不入队)
*/
async submitReturnRegister(code) {
const waybillCode = String(code || '').trim();
- if (!waybillCode || this.submitting) return;
+ if (!waybillCode) return;
+ const remark = this.remarkInput.trim();
+ // 正在提交时不再静默丢弃,入队串行处理
+ if (this.submitting) {
+ this.enqueuePendingSubmit(waybillCode, remark);
+ uni.showToast({ title: '正在登记,已加入队列', icon: 'none' });
+ return;
+ }
+ // 离线:直接入队补提
+ if (!this.isNetworkConnected) {
+ this.enqueuePendingSubmit(waybillCode, remark);
+ uni.showToast({ title: '当前离线,已加入补提队列', icon: 'none' });
+ this.speakVoice('已加入队列');
+ this.clearInputIfSame(waybillCode, remark);
+ this.startNetworkPolling();
+ return;
+ }
this.submitting = true;
uni.showLoading({ title: '登记中...', mask: true });
try {
- const res = await this.$http('returnReceived.create', {
- waybill_code: waybillCode,
- remark: this.remarkInput.trim()
- }, '', false);
- if (res && res.flag !== 'failure') {
- const payload = (res && res.data && typeof res.data === 'object' && !Array.isArray(res.data))
- ? res.data
- : res;
- this.result = payload || {};
- this.showResult = true;
- this.scanInput = '';
- this.remarkInput = '';
- if (this.result.duplicated) {
- uni.showToast({ title: '30日内已登记', icon: 'none' });
- this.speakVoice('已登记');
- } else if (this.result.is_original_return) {
- uni.showToast({ title: '原单退回登记成功', icon: 'success' });
- this.speakVoice('登记成功');
+ try {
+ const res = await this.requestReturnRegister(waybillCode, remark, 8000);
+ this.handleReturnRegisterResponse(res, waybillCode, remark);
+ } catch (error) {
+ const authText = String((error && (error.msg || error.message || error.errMsg)) || '').toLowerCase();
+ // 登录态错误不入队,直接提示
+ if (authText.includes('登录已过期') || authText.includes('未登录') || authText.includes('401')) {
+ const msg = String((error && (error.msg || error.message)) || '登录已过期,请重新登录');
+ uni.showToast({ title: msg, icon: 'none' });
+ this.speakVoice('登记失败');
+ this.clearInputIfSame(waybillCode, remark);
} else {
- uni.showToast({ title: '退件登记成功', icon: 'success' });
- this.speakVoice('登记成功');
+ // 断网 / 弱网 / 其它请求层错误:一律入队补提,等待网络恢复自动提交。
+ // 不依赖 isNetworkConnected 与弱网关键词匹配——兼容浏览器 H5 离线时
+ // getNetworkType 误报在线(返回 4g/wifi)、错误文案不匹配弱网关键词等场景
+ this.enqueuePendingSubmit(waybillCode, remark);
+ uni.showToast({
+ title: this.isNetworkConnected ? '网络较差,已加入补提队列' : '当前离线,已加入补提队列',
+ icon: 'none'
+ });
+ this.speakVoice('已加入队列');
+ this.clearInputIfSame(waybillCode, remark);
+ this.startNetworkPolling();
}
- } else {
- uni.showToast({ title: (res && (res.msg || res.message)) || '登记失败', icon: 'none' });
- this.speakVoice('登记失败');
}
- } catch (e) {
- const msg = String((e && (e.msg || e.message)) || '网络异常');
- uni.showToast({ title: msg, icon: 'none' });
- this.speakVoice('登记失败');
} finally {
this.submitting = false;
uni.hideLoading();
+ // 兜底触发补提(flush 自身调用时 isFlushingPendingQueue=true 直接返回,无递归)
+ this.flushPendingSubmitQueue();
}
- },
- handleReset() {
- this.resetForm();
- },
- resetForm() {
- this.scanInput = '';
- this.remarkInput = '';
- this.result = {};
- this.showResult = false;
- this.submitting = false;
- this.scanFocused = true;
}
}
};
@@ -248,17 +460,22 @@ import voice from '@/core/utils/voice';
}
}
- /* ===== 重置按钮 ===== */
- .nav-reset {
- padding: 8rpx 0;
+ /* ===== 扫描计数 ===== */
+ .nav-scan-count {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 64rpx;
+ background-color: #52c41a;
+ border-radius: 8rpx;
+ padding: 0 16rpx;
+ margin-left: 16rpx;
- .nav-reset-text {
- font-size: 32rpx;
- color: #fff;
- background-color: #2979ff;
- padding: 8rpx 24rpx;
- border-radius: 8rpx;
+ .nav-scan-count-text {
+ font-size: 34rpx;
+ color: #ffffff;
white-space: nowrap;
+ line-height: 1;
}
}