修改打包模式页面

This commit is contained in:
zm2000 2026-09-21 18:20:27 +08:00
parent 79676c33ef
commit 3f2b7fa5d0
2 changed files with 526 additions and 104 deletions

View File

@ -162,6 +162,7 @@ export async function handleTokenExpired(store) {
uni.removeStorageSync('workbenchToken') uni.removeStorageSync('workbenchToken')
uni.removeStorageSync('workbenchInfo') uni.removeStorageSync('workbenchInfo')
uni.removeStorageSync('workbenchOperator') uni.removeStorageSync('workbenchOperator')
uni.removeStorageSync('workbenchOperators')
} catch (e) {} } catch (e) {}
const currentRoute = getCurrentRoute() const currentRoute = getCurrentRoute()
if (!isLoginRoute(currentRoute)) { if (!isLoginRoute(currentRoute)) {

View File

@ -13,9 +13,9 @@
<text v-if="bound && workbenchName" class="header-subtitle">{{ workbenchName }}</text> <text v-if="bound && workbenchName" class="header-subtitle">{{ workbenchName }}</text>
</view> </view>
<view class="header-right"> <view class="header-right">
<view class="user-info-btn" :class="{ 'user-info-btn--bound': boundOperator.memberId }" @click="handleUserInfo"> <view class="user-info-btn" :class="{ 'user-info-btn--bound': boundOperators.length }" @click="handleUserInfo">
<u-icon name="account-fill" size="34rpx" color="#ffffff"></u-icon> <u-icon name="account-fill" size="34rpx" color="#ffffff"></u-icon>
<text class="user-info-btn__text">{{ boundOperator.memberId ? (boundOperator.userName || '已绑定') : '未绑定' }}</text> <text class="user-info-btn__text">{{ boundOperatorText }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -71,7 +71,7 @@
<!-- 精简概要:波次(散单显示运单) 共x单 / 包材名称 商品总数量 --> <!-- 精简概要:波次(散单显示运单) 共x单 / 包材名称 商品总数量 -->
<view class="order-summary"> <view class="order-summary">
<view class="order-summary__row"> <view class="order-summary__row" :class="{ 'order-summary__row--blocked': orderBlocked }">
<text class="order-summary__label">{{ orderQueryIsSandan ? '运单' : '波次' }}</text> <text class="order-summary__label">{{ orderQueryIsSandan ? '运单' : '波次' }}</text>
<text class="order-summary__value order-summary__value--strong">{{ orderQueryIsSandan ? orderWaybillNo : orderWaveNo }}</text> <text class="order-summary__value order-summary__value--strong">{{ orderQueryIsSandan ? orderWaybillNo : orderWaveNo }}</text>
<text v-if="orderQueryIsSandan" class="order-result-tag order-result-tag--sandan order-summary__tag">散单</text> <text v-if="orderQueryIsSandan" class="order-result-tag order-result-tag--sandan order-summary__tag">散单</text>
@ -88,8 +88,11 @@
</view> </view>
</view> </view>
<!-- 商品明细:数量 + 图片 + 名称 + 条码(拦截/未复核/已打包时不显示) --> <!-- 商品明细:数量 + 图片 + 名称 + 条码(拦截/未复核/已打包时显示禁止打包提示) -->
<view v-if="!orderBlocked" class="order-block"> <view v-if="orderBlocked" class="order-block order-block--blocked">
<view class="order-block__hint">{{ orderBlockedHint }}</view>
</view>
<view v-else class="order-block">
<template v-if="orderQueryResult.items && orderQueryResult.items.length"> <template v-if="orderQueryResult.items && orderQueryResult.items.length">
<view <view
v-for="(item, idx) in orderQueryResult.items" v-for="(item, idx) in orderQueryResult.items"
@ -286,7 +289,23 @@
<view class="remove-operator-popup"> <view class="remove-operator-popup">
<view class="remove-operator-popup__title">移除操作员</view> <view class="remove-operator-popup__title">移除操作员</view>
<view class="remove-operator-popup__body"> <view class="remove-operator-popup__body">
<text class="remove-operator-popup__text">确认移除操作员「{{ boundOperator.userName || '--' }}」?移除后需重新扫码绑定。</text> <text class="remove-operator-popup__text">{{ removeOperatorHint }}</text>
<view class="remove-operator-list">
<view
v-for="op in boundOperators"
:key="op.memberId"
class="remove-operator-item"
:class="{ 'remove-operator-item--checked': isOperatorSelected(op) }"
@click="toggleOperatorSelected(op)"
>
<text class="remove-operator-item__name">{{ op.userName || '--' }}</text>
<u-icon
:name="isOperatorSelected(op) ? 'checkmark-circle-fill' : 'checkmark-circle'"
:color="isOperatorSelected(op) ? '#2979ff' : '#c0c4cc'"
size="22"
></u-icon>
</view>
</view>
</view> </view>
<view class="remove-operator-popup__actions"> <view class="remove-operator-popup__actions">
<view class="remove-operator-popup__btn remove-operator-popup__btn--cancel" @click="handleCloseRemoveOperatorPopup">取消</view> <view class="remove-operator-popup__btn remove-operator-popup__btn--cancel" @click="handleCloseRemoveOperatorPopup">取消</view>
@ -298,6 +317,9 @@
</template> </template>
<script> <script>
// 工作台在线成员列表本地缓存 key(服务端 getWorkbenchInfo 返回 members[] 时同步并缓存,重进时据此恢复)
const MEMBER_STORAGE_KEY = 'workbenchMembers'
export default { export default {
data() { data() {
return { return {
@ -311,13 +333,11 @@ export default {
workbenchType: '', workbenchType: '',
infoRefreshing: false, // 进入后刷新工作台信息请求防重入锁 infoRefreshing: false, // 进入后刷新工作台信息请求防重入锁
bcastHealTimer: null, // 广播监听自愈定时器(onShow 延迟重新注册用) bcastHealTimer: null, // 广播监听自愈定时器(onShow 延迟重新注册用)
// 当前操作员(工作台成员,本地保存 bindMember 返回的成员行 id) // 当前操作员列表(工作台成员,本地保存 bindMember 返回的成员行 id,支持多人)
boundOperator: { boundOperators: [],
memberId: '', // wms_workbench_member.id // 工作台在线成员列表(以服务端 getWorkbenchInfo 返回的 members[] 为权威,绑定/下线后静默重拉同步)
workbenchId: '', // 记录归属工作台,重新进入时按此匹配 workbenchMembers: [],
userId: '', // wms_account.id(非系统账号用户为空) infoRefreshingSilent: false, // 静默刷新工作台信息防重入锁
userName: '' // 姓名快照
},
opScanCode: '', // 操作员扫码输入框内容(ye4s 登录临时码) opScanCode: '', // 操作员扫码输入框内容(ye4s 登录临时码)
opInputFocus: false, opInputFocus: false,
opQueryState: '', // '' | loading | identified | error(识别待绑定状态) opQueryState: '', // '' | loading | identified | error(识别待绑定状态)
@ -334,9 +354,12 @@ export default {
orderQueryState: '', // '' | loading | success | error orderQueryState: '', // '' | loading | success | error
orderQueryResult: null, orderQueryResult: null,
orderQueryError: '', orderQueryError: '',
packContextKey: '', // 查单返回的打包上下文 key(20 分钟有效,packOrder 凭此打包)
packReporting: false, // packOrder 上报请求防重入锁 packReporting: false, // packOrder 上报请求防重入锁
finishPacking: false, // finishPack 完成打包请求防重入锁 finishPacking: false, // finishPack 完成打包请求防重入锁
hasActivePack: false, // 该工作台是否存在未结束打包任务(status<2):退出/解绑前自动上报打包完成 hasActivePack: false, // 该工作台是否存在未结束打包任务(status<2):退出/解绑前自动上报打包完成
activePackIdentity: '', // 当前「打包中」订单唯一标识:团单为 wave_no,散单为 waybill_code(重复查单去重用)
packRestored: false, // 重进后从服务端恢复的「打包中」态(跳过拦截/已打包/预检,直接展示进行中任务)
// 团购核实:商品行已扫计数(key=商品行id/序号 → 已扫次数),达 plan_qty 视为已核实 // 团购核实:商品行已扫计数(key=商品行id/序号 → 已扫次数),达 plan_qty 视为已核实
groupVerified: {}, groupVerified: {},
groupSubmitting: false, // 团购提交开始打包防重入 groupSubmitting: false, // 团购提交开始打包防重入
@ -349,7 +372,9 @@ export default {
// 退出工作台弹窗 // 退出工作台弹窗
exitPopupOpen: false, exitPopupOpen: false,
// 移除操作员二次确认弹窗 // 移除操作员二次确认弹窗
removeOperatorPopupOpen: false removeOperatorPopupOpen: false,
// 移除弹窗中已勾选的操作员成员行 id(多选)
removeSelectedIds: []
} }
}, },
// 团购:全部商品核实完成后自动提交开始打包(每次查询仅自动提交一次) // 团购:全部商品核实完成后自动提交开始打包(每次查询仅自动提交一次)
@ -378,6 +403,20 @@ export default {
if (this.workbenchType === 'group') return '团体工作台'; if (this.workbenchType === 'group') return '团体工作台';
return this.workbenchType ? this.workbenchType : '--'; return this.workbenchType ? this.workbenchType : '--';
}, },
// 顶部操作员按钮文案:单人显示姓名,多人显示「姓名 等N人」
boundOperatorText() {
const list = this.boundOperators;
if (!list.length) return '未绑定';
const name = String(list[0] && list[0].userName || '').trim() || '已绑定';
return list.length > 1 ? `${name} 等${list.length}人` : name;
},
// 移除操作员二次确认弹窗文案(默认「已选 0 名」,与勾选后文案结构一致,避免页面跳动)
removeOperatorHint() {
const list = this.boundOperators;
if (!list.length) return '当前没有已绑定的操作员';
const count = this.removeSelectedIds.length;
return `已选 ${count} 名操作员,移除后需重新扫码绑定。`;
},
// 查询结果是否为散单 // 查询结果是否为散单
orderQueryIsSandan() { orderQueryIsSandan() {
const r = this.orderQueryResult; const r = this.orderQueryResult;
@ -385,6 +424,8 @@ export default {
}, },
// 订单是否被禁止打包(拦截/未复核/已打包),命中时不显示商品明细 // 订单是否被禁止打包(拦截/未复核/已打包),命中时不显示商品明细
orderBlocked() { orderBlocked() {
// 重进恢复的进行中任务:跳过拦截/未复核/已打包判断,直接展示打包中状态
if (this.packRestored) return false;
const r = this.orderQueryResult; const r = this.orderQueryResult;
const order = r && r.order; const order = r && r.order;
if (!order) return false; if (!order) return false;
@ -408,6 +449,31 @@ export default {
} }
return packed; return packed;
}, },
// 禁止打包提示文案:与 orderBlocked 判定顺序一致(拦截 → 未复核 → 已打包)
orderBlockedHint() {
if (!this.orderBlocked) return '';
const r = this.orderQueryResult;
const order = r && r.order;
if (this.orderQueryIsSandan && order && Number(order.intercept_flag) === 1) {
return '订单已拦截,禁止打包';
}
if (order) {
const recheck = String(order.recheck_status ?? '').trim().toLowerCase();
const recheckDone = recheck === 'fin' || recheck === 'finished' || recheck === '1';
if (!recheckDone) {
return '订单未复核,禁止打包';
}
let packed = false;
if (this.orderQueryIsSandan) {
packed = Number(order.pack_flag) === 1 || order.pack_flag === true;
} else {
const ps = String(order.pack_status ?? '').trim().toLowerCase();
packed = ps !== '' && ps !== 'none';
}
if (packed) return '订单已打包,禁止打包';
}
return '订单禁止打包';
},
// 精简概要:包材名称(express/order 的 package_material_name) // 精简概要:包材名称(express/order 的 package_material_name)
packageMaterialName() { packageMaterialName() {
const r = this.orderQueryResult; const r = this.orderQueryResult;
@ -492,8 +558,10 @@ export default {
}, },
onLoad(options) { onLoad(options) {
this.loadBound(options); this.loadBound(options);
// 读取本地保存的已绑定操作员(bindMember 返回的成员行 id,按 workbenchId 匹配) // 读取本地保存的已绑定操作员列表(bindMember 返回的成员行 id,按 workbenchId 匹配)
this.loadBoundOperator(); this.loadBoundOperators();
// 恢复本地缓存的工作台成员列表(离线优先,随后 fetchWorkbenchInfo 以服务端 members 覆盖)
this.restoreWorkbenchMembers();
// 进入打包模式:重新拉取工作台信息(同时校验本地工作台 token 是否仍有效) // 进入打包模式:重新拉取工作台信息(同时校验本地工作台 token 是否仍有效)
if (this.bound) { if (this.bound) {
this.fetchWorkbenchInfo(); this.fetchWorkbenchInfo();
@ -564,7 +632,7 @@ export default {
handleBarcodeInput(code) { handleBarcodeInput(code) {
const c = String(code || '').replace(/\s+/g, ''); const c = String(code || '').replace(/\s+/g, '');
if (!c) return; if (!c) return;
if (!String(this.boundOperator?.memberId || '').trim()) { if (!this.boundOperators.length) {
// 未绑定操作员:输入/扫描值走绑定操作员流程(识别工牌 → 自动绑定,识别失败由 queryOperatorUser 提示) // 未绑定操作员:输入/扫描值走绑定操作员流程(识别工牌 → 自动绑定,识别失败由 queryOperatorUser 提示)
this.opScanCode = c; this.opScanCode = c;
this.opInputFocus = false; this.opInputFocus = false;
@ -618,7 +686,14 @@ export default {
groupItemScannable(item) { groupItemScannable(item) {
return this.groupItemCodes(item).length > 0; return this.groupItemCodes(item).length > 0;
}, },
// 商品是否需要复核:need_recheck 为 'N' 视为免验(无需复核),其余(含缺省)按需要复核(Y)
isItemNeedRecheck(item) {
const v = String((item && item.need_recheck) || 'Y').trim().toUpperCase();
return v !== 'N';
},
isItemVerified(item, idx) { isItemVerified(item, idx) {
// 免验商品(need_recheck=N)无需扫码复核,直接视为已核实
if (!this.isItemNeedRecheck(item)) return true;
const qty = Math.max(1, Number(item && item.plan_qty) || 1); const qty = Math.max(1, Number(item && item.plan_qty) || 1);
const key = this.groupItemKey(item, idx); const key = this.groupItemKey(item, idx);
return (this.groupVerified[key] || 0) >= qty; return (this.groupVerified[key] || 0) >= qty;
@ -682,10 +757,12 @@ export default {
resetOrderQuery() { resetOrderQuery() {
this.groupVerified = {}; this.groupVerified = {};
this.groupAutoSubmitted = false; this.groupAutoSubmitted = false;
this.packRestored = false;
this.orderQueryState = ''; this.orderQueryState = '';
this.orderQueryResult = null; this.orderQueryResult = null;
this.orderQueryError = ''; this.orderQueryError = '';
this.orderBarcode = ''; this.orderBarcode = '';
this.packContextKey = '';
}, },
// 长按复核:团单任意未核实商品可通过“无条码复核”人工标记已核实 // 长按复核:团单任意未核实商品可通过“无条码复核”人工标记已核实
handleGroupItemLongPress(item, idx) { handleGroupItemLongPress(item, idx) {
@ -727,10 +804,12 @@ export default {
// 清除核实与当前订单结果,回到可扫描其它运单状态 // 清除核实与当前订单结果,回到可扫描其它运单状态
this.groupVerified = {}; this.groupVerified = {};
this.groupAutoSubmitted = false; this.groupAutoSubmitted = false;
this.packRestored = false;
this.orderQueryState = ''; this.orderQueryState = '';
this.orderQueryResult = null; this.orderQueryResult = null;
this.orderQueryError = ''; this.orderQueryError = '';
this.orderBarcode = ''; this.orderBarcode = '';
this.packContextKey = '';
uni.showToast({ title: '已取消核实', icon: 'none' }); uni.showToast({ title: '已取消核实', icon: 'none' });
this.speakText('已取消核实'); this.speakText('已取消核实');
}, },
@ -754,7 +833,7 @@ export default {
// 顶部操作员姓名按钮:已绑定态直接弹移除二次确认;未绑定态打开操作员弹窗准备枪扫/输入工牌绑定 // 顶部操作员姓名按钮:已绑定态直接弹移除二次确认;未绑定态打开操作员弹窗准备枪扫/输入工牌绑定
handleUserInfo() { handleUserInfo() {
// 已绑定:简化操作,直接弹移除操作员二次确认弹窗 // 已绑定:简化操作,直接弹移除操作员二次确认弹窗
if (this.boundOperator.memberId) { if (this.boundOperators.length) {
this.handleRemoveOperator(); this.handleRemoveOperator();
return; return;
} }
@ -788,7 +867,7 @@ export default {
const scanText = this.normalizeScanResult(result); const scanText = this.normalizeScanResult(result);
console.log('[packMode] handleBroadcastResult 扫描结果:', scanText); console.log('[packMode] handleBroadcastResult 扫描结果:', scanText);
if (!scanText) return; if (!scanText) return;
if (this.bound && !this.boundOperator.memberId) { if (this.bound && !this.boundOperators.length) {
this.opScanCode = scanText; this.opScanCode = scanText;
this.opInputFocus = false; this.opInputFocus = false;
this.queryOperatorUser(scanText); this.queryOperatorUser(scanText);
@ -820,12 +899,28 @@ export default {
fail: () => {} fail: () => {}
}); });
}, },
// 订单唯一标识:散单比 waybill_code(barcode 兜底),团单比 wave_no(batch.wave_no 优先,order.wave_no 兜底)
orderIdentity(result) {
if (!result || typeof result !== 'object') return '';
if (Number(result.isSandan) === 1) {
return String(result.waybill_code || result.barcode || '').trim();
}
const batchNo = result.batch && result.batch.wave_no ? String(result.batch.wave_no) : '';
const orderNo = result.order && result.order.wave_no ? String(result.order.wave_no) : '';
return String(batchNo || orderNo || '').trim();
},
// 重复查单判断:本次查询结果与当前「打包中」订单相同(团单比 wave_no,散单比 waybill_code)
sameOrderQuery(result) {
if (!this.hasActivePack || !this.activePackIdentity) return false;
const identity = this.orderIdentity(result);
return !!identity && identity === this.activePackIdentity;
},
// 按运单号条码查询订单(workbench.queryOrder) // 按运单号条码查询订单(workbench.queryOrder)
async queryOrder(barcode) { async queryOrder(barcode) {
const code = String(barcode || '').trim(); const code = String(barcode || '').trim();
if (!code) return; if (!code) return;
// 无成员(未绑定操作员)时不允许查询订单 // 无成员(未绑定操作员)时不允许查询订单
if (!String(this.boundOperator?.memberId || '').trim()) { if (!this.boundOperators.length) {
this.speakText('未绑定操作员'); this.speakText('未绑定操作员');
uni.showToast({ title: '请先绑定操作员再查询订单', icon: 'none', duration: 4000 }); uni.showToast({ title: '请先绑定操作员再查询订单', icon: 'none', duration: 4000 });
return; return;
@ -836,6 +931,8 @@ export default {
return; return;
} }
if (this.orderQuerying) return; if (this.orderQuerying) return;
// 记录上一次查询结果:重复查同一「打包中」订单时据此保持显示、不重复上报
const prevResult = this.orderQueryResult;
this.orderQuerying = true; this.orderQuerying = true;
this.orderQueryState = 'loading'; this.orderQueryState = 'loading';
this.orderQueryResult = null; this.orderQueryResult = null;
@ -859,8 +956,23 @@ export default {
this.orderQueryError = '查询结果无效'; this.orderQueryError = '查询结果无效';
return; return;
} }
// 重复查单:本次查询与当前「打包中」订单相同(团单比 wave_no,散单比 waybill_code),
// 保持「打包中」状态展示,不重复上报开始打包
if (this.sameOrderQuery(data)) {
this.orderQueryResult = prevResult;
this.orderQueryState = 'success';
this.orderQueryError = '';
this.orderBarcode = '';
this.speakText('订单打包中');
uni.showToast({ title: '订单打包中,请勿重复上报', icon: 'none' });
return;
}
this.orderQueryResult = data; this.orderQueryResult = data;
this.orderQueryState = 'success'; this.orderQueryState = 'success';
// 新查询正常进入,清除恢复态
this.packRestored = false;
// 打包上下文 key:packOrder 凭 key 由服务端解析订单信息,前端不回传订单数据
this.packContextKey = String(data?.key || '').trim();
// 查询成功:清空输入框,方便连续扫描下一单 // 查询成功:清空输入框,方便连续扫描下一单
this.orderBarcode = ''; this.orderBarcode = '';
// 团购:初始化商品核实状态(不自动上报,全部核实后将自动提交开始打包) // 团购:初始化商品核实状态(不自动上报,全部核实后将自动提交开始打包)
@ -985,14 +1097,15 @@ export default {
if (!token) return false; if (!token) return false;
if (this.packReporting) return false; if (this.packReporting) return false;
const deliveryOrderCode = String(r?.order?.delivery_order_code || '').trim(); // 打包上下文 key:来自 workbench.queryOrder 响应(20 分钟有效),订单信息由服务端从 key 解析,前端不回传订单信息
if (!deliveryOrderCode) { const packKey = String(this.packContextKey || '').trim();
uni.showToast({ title: '缺少发货单号,无法上报打包', icon: 'none' }); if (!packKey) {
uni.showToast({ title: '缺少打包上下文,请重新扫码查询', icon: 'none' });
return false; return false;
} }
// 打包人员:当前已绑定操作员 // 打包人员:当前已绑定操作员(可多人)
const operator = this.boundOperator; const operators = this.boundOperators;
if (!operator || !String(operator.memberId || '').trim() || !String(operator.userName || '').trim()) { if (!operators || !operators.length || !operators.some(op => String(op && op.userName || '').trim())) {
uni.showToast({ title: '请先绑定操作员再上报打包', icon: 'none' }); uni.showToast({ title: '请先绑定操作员再上报打包', icon: 'none' });
return false; return false;
} }
@ -1002,22 +1115,15 @@ export default {
try { try {
const payload = { const payload = {
token, token,
delivery_order_code: deliveryOrderCode, key: packKey,
status: 1, // 打包中 status: 1, // 打包中
wave_total_orders: (r?.batch && r.batch.total_orders !== undefined && r.batch.total_orders !== null) // pack_time 必须为 Unix 秒(毫秒会导致 start_time 年份溢出)
? Number(r.batch.total_orders) pack_time: Math.floor(Date.now() / 1000),
: 1, users: operators.map(op => ({
users: [{ wms_account_id: (op.userId !== '' && op.userId !== null && op.userId !== undefined) ? Number(op.userId) : null,
wms_account_id: (operator.userId !== '' && operator.userId !== null && operator.userId !== undefined) ? Number(operator.userId) : null, real_name: op.userName
real_name: operator.userName }))
}]
}; };
const waveNo = (r?.batch && r.batch.wave_no) ? String(r.batch.wave_no) : (r?.order && r.order.wave_no ? String(r.order.wave_no) : '');
if (waveNo) payload.wave_no = waveNo;
const itemsCount = r?.order && r.order.items_count !== undefined && r.order.items_count !== null ? Number(r.order.items_count) : null;
if (itemsCount !== null) payload.items_count = itemsCount;
const itemsTotal = r?.order && r.order.items_total !== undefined && r.order.items_total !== null ? Number(r.order.items_total) : null;
if (itemsTotal !== null) payload.items_total = itemsTotal;
// toastAfter=false:失败提示由本方法自行控制 // toastAfter=false:失败提示由本方法自行控制
const res = await this.$http('workbench.packOrder', payload, '', false); const res = await this.$http('workbench.packOrder', payload, '', false);
@ -1025,12 +1131,19 @@ export default {
if (invalid) { if (invalid) {
// 401:工作台 token 失效,退出工作台模式并清除 token 回登录页 // 401:工作台 token 失效,退出工作台模式并清除 token 回登录页
if (this.handleWorkbenchAuthExpired(res?.code)) return false; if (this.handleWorkbenchAuthExpired(res?.code)) return false;
// 400:打包上下文 key 缺失或过期(跨仓库/跨工作台消费他人 key 为 403),提示重新扫码
if (Number(res?.code) === 400) {
uni.showToast({ title: res?.message || '打包上下文已失效,请重新扫码查询', icon: 'none' });
return false;
}
uni.showToast({ title: res?.message || '打包上报失败', icon: 'none' }); uni.showToast({ title: res?.message || '打包上报失败', icon: 'none' });
return false; return false;
} }
console.log('[packMode] 打包上报成功:', res?.data || res); console.log('[packMode] 打包上报成功:', res?.data || res);
// 记录存在未结束打包任务:退出工作台/解绑操作员前将自动上报打包完成 // 记录存在未结束打包任务:退出工作台/解绑操作员前将自动上报打包完成
this.hasActivePack = true; this.hasActivePack = true;
// 记录当前「打包中」订单标识,重复扫描同一订单时保持打包中、不重复上报
this.activePackIdentity = this.orderIdentity(this.orderQueryResult);
uni.showToast({ title: '已开始打包', icon: 'success' }); uni.showToast({ title: '已开始打包', icon: 'success' });
return true; return true;
} catch (error) { } catch (error) {
@ -1063,6 +1176,7 @@ export default {
const finished = !!(data && (data.finished === true || data.finished === 'true' || data.finished === 1)); const finished = !!(data && (data.finished === true || data.finished === 'true' || data.finished === 1));
if (finished) { if (finished) {
this.hasActivePack = false; this.hasActivePack = false;
this.activePackIdentity = '';
} }
return { return {
ok: true, ok: true,
@ -1076,16 +1190,6 @@ export default {
this.finishPacking = false; this.finishPacking = false;
} }
}, },
// 退出/解绑前上报打包完成:存在进行中任务时先结束;失败不阻断后续
async ensurePackFinishedBeforeLeave() {
if (!this.hasActivePack) return true;
const r = await this.requestFinishPack();
if (!r.ok || !r.finished) {
console.warn('[packMode] 离开前上报打包完成未成功:', r);
return false;
}
return true;
},
// 广播调用兜底(广播 store 未初始化/禁用时静默失败) // 广播调用兜底(广播 store 未初始化/禁用时静默失败)
safeDispatchBroadcast(action, payload) { safeDispatchBroadcast(action, payload) {
try { try {
@ -1113,22 +1217,96 @@ export default {
if (typeof scanResult.data === 'string') return clean(scanResult.data); if (typeof scanResult.data === 'string') return clean(scanResult.data);
return ''; return '';
}, },
// 读取本地保存的已绑定操作员(bindMember 返回的成员行 id,按 workbenchId 匹配) // 读取本地保存的已绑定操作员列表(bindMember 返回的成员行 id,按 workbenchId 匹配;兼容旧版单操作员缓存)
loadBoundOperator() { loadBoundOperators() {
let saved = null let list = null
try { try {
saved = uni.getStorageSync('workbenchOperator') list = uni.getStorageSync('workbenchOperators')
} catch (e) {} } catch (e) {}
if (!saved || typeof saved !== 'object') saved = {} if (!Array.isArray(list)) {
const sameWorkbench = String(saved?.workbenchId || '') === String(this.workbenchId || '') // 兼容旧版单操作员缓存(workbenchOperator 对象)
this.boundOperator = sameWorkbench let saved = null
? { try {
memberId: String(saved?.memberId || ''), saved = uni.getStorageSync('workbenchOperator')
workbenchId: String(saved?.workbenchId || ''), } catch (e) {}
userId: (saved?.userId === null || saved?.userId === undefined || saved?.userId === '') ? '' : String(saved?.userId), if (saved && typeof saved === 'object' && String(saved?.memberId || '')) {
userName: String(saved?.userName || '') list = [saved]
} else {
list = []
} }
: { memberId: '', workbenchId: String(this.workbenchId || ''), userId: '', userName: '' } }
const wbId = String(this.workbenchId || '')
this.boundOperators = list
.filter(op => op && String(op?.memberId || ''))
.filter(op => !op.workbenchId || String(op.workbenchId) === wbId)
.map(op => ({
memberId: String(op.memberId),
workbenchId: String(op.workbenchId || wbId),
userId: (op.userId === null || op.userId === undefined || op.userId === '') ? '' : String(op.userId),
userName: String(op.userName || '')
}))
},
// 归一化服务端 members[] 为统一结构 { id, workbench_id, user_id, user_name }
normalizeWorkbenchMembers(members, workbenchId) {
const wbId = workbenchId === null || workbenchId === undefined ? '' : workbenchId;
return (Array.isArray(members) ? members : [])
.filter((m) => m && (m.id || m.member_id || m.memberId || m.user_name || m.userName || m.real_name || m.name))
.map((m) => ({
id: (m.id || m.member_id || m.memberId || ''),
workbench_id: (m.workbench_id ?? m.workbenchId ?? wbId ?? ''),
user_id: (m.user_id ?? m.userId ?? m.wms_account_id ?? m.wmsAccountId ?? null),
user_name: String(m.user_name ?? m.userName ?? m.real_name ?? m.realName ?? m.name ?? '')
}))
.filter((m) => m.id || m.user_name);
},
// 应用成员列表:写入 workbenchMembers + 本地缓存,并同步 boundOperators(现有业务依赖)
// 同一 user_id 只保留一个(服务端重复绑定会产生多行成员,显示/上报需去重)
applyWorkbenchMembers(members) {
const seen = new Set();
const list = (Array.isArray(members) ? members : []).filter((m) => {
if (!m || (!m.id && !m.user_name)) return false;
const uid = m.user_id;
const key = (uid !== null && uid !== undefined && uid !== '') ? ('uid_' + uid) : ('id_' + m.id);
if (seen.has(key)) return false;
seen.add(key);
return true;
});
this.workbenchMembers = list;
try {
uni.setStorageSync(MEMBER_STORAGE_KEY, list);
} catch (e) {}
const wbId = String(this.workbenchId || '');
this.boundOperators = list
.map((m) => ({
memberId: m.id === null || m.id === undefined ? '' : String(m.id),
workbenchId: String(m.workbench_id || wbId),
userId: (m.user_id === null || m.user_id === undefined || m.user_id === '') ? '' : String(m.user_id),
userName: String(m.user_name || '')
}))
.filter((op) => op.memberId);
try {
uni.setStorageSync('workbenchOperators', this.boundOperators);
} catch (e) {}
},
// 恢复本地缓存的工作台成员列表(服务端 members 缓存;缺失时用 boundOperators 兜底保持一致)
restoreWorkbenchMembers() {
let cached = null;
try {
cached = uni.getStorageSync(MEMBER_STORAGE_KEY);
} catch (e) {}
if (Array.isArray(cached) && cached.length) {
this.applyWorkbenchMembers(cached.filter((m) => m && (m.id || m.user_name)));
return;
}
// 无新缓存:用 boundOperators 兜底映射,保持 workbenchMembers 与 boundOperators 一致
const list = (Array.isArray(this.boundOperators) ? this.boundOperators : [])
.filter((op) => op && op.memberId);
this.workbenchMembers = list.map((op) => ({
id: String(op.memberId),
workbench_id: String(op.workbenchId || this.workbenchId || ''),
user_id: (op.userId === null || op.userId === undefined || op.userId === '') ? null : op.userId,
user_name: String(op.userName || '')
}));
}, },
// 操作员扫码输入框回车确认 // 操作员扫码输入框回车确认
handleOpInputConfirm() { handleOpInputConfirm() {
@ -1251,14 +1429,23 @@ export default {
if (memberId === null || memberId === undefined || memberId === '') { if (memberId === null || memberId === undefined || memberId === '') {
throw new Error('绑定成功但未返回成员ID'); throw new Error('绑定成功但未返回成员ID');
} }
// bindMember 返回后本地保存成员行 id(供 removeMember 使用),并展示为当前操作员 // bindMember 返回后本地保存成员行 id(供 removeMember 使用),追加到当前操作员列表
this.boundOperator = { const mid = String(memberId);
memberId: String(memberId), const member = {
workbenchId: String(this.workbenchId || ''), id: mid,
userId: ident.wmsAccountId !== null && ident.wmsAccountId !== undefined ? String(ident.wmsAccountId) : '', workbench_id: String(this.workbenchId || ''),
userName: String(ident.name) user_id: ident.wmsAccountId !== null && ident.wmsAccountId !== undefined ? String(ident.wmsAccountId) : null,
user_name: String(ident.name)
}; };
uni.setStorageSync('workbenchOperator', this.boundOperator); const wmList = Array.isArray(this.workbenchMembers) ? this.workbenchMembers.slice() : [];
const wmIdx = wmList.findIndex((m) => String(m && m.id) === mid);
if (wmIdx >= 0) {
wmList[wmIdx] = member;
} else {
wmList.push(member);
}
this.applyWorkbenchMembers(wmList);
uni.removeStorageSync('workbenchOperator'); // 清理旧版单操作员缓存
// 重置识别待绑定态并关闭弹窗(顶部按钮自动变为“已绑定”) // 重置识别待绑定态并关闭弹窗(顶部按钮自动变为“已绑定”)
this.opScanCode = ''; this.opScanCode = '';
this.opQueryState = ''; this.opQueryState = '';
@ -1268,6 +1455,8 @@ export default {
this.opInputFocus = false; this.opInputFocus = false;
uni.showToast({ title: '操作员绑定成功', icon: 'success' }); uni.showToast({ title: '操作员绑定成功', icon: 'success' });
this.speakText('绑定成功'); this.speakText('绑定成功');
// 绑定后静默重拉工作台信息,成员列表以服务端为准
this.fetchWorkbenchInfo({ silent: true });
} catch (error) { } catch (error) {
console.error('[packMode] 绑定操作员失败:', error); console.error('[packMode] 绑定操作员失败:', error);
// 绑定失败:进入待绑定态,保留识别结果,展示「绑定」按钮供手动重试 // 绑定失败:进入待绑定态,保留识别结果,展示「绑定」按钮供手动重试
@ -1279,26 +1468,53 @@ export default {
this.opBinding = false; this.opBinding = false;
} }
}, },
// 移除操作员(workbench.removeMember):先弹二次确认,确认后按本地保存的成员行 id 移除 // 移除操作员(workbench.removeMember):打开多选列表,默认不选中任何操作员
handleRemoveOperator() { handleRemoveOperator() {
const memberId = String(this.boundOperator?.memberId || '').trim(); if (!this.boundOperators.length) return;
if (!memberId) return; this.removeSelectedIds = [];
this.removeOperatorPopupOpen = true; this.removeOperatorPopupOpen = true;
}, },
// 关闭移除操作员二次确认弹窗 // 关闭移除操作员二次确认弹窗
handleCloseRemoveOperatorPopup() { handleCloseRemoveOperatorPopup() {
this.removeOperatorPopupOpen = false; this.removeOperatorPopupOpen = false;
}, },
// 确认移除操作员 // 某操作员是否被勾选
isOperatorSelected(op) {
const id = String(op && op.memberId || '');
return this.removeSelectedIds.indexOf(id) !== -1;
},
// 勾选/取消勾选某操作员
toggleOperatorSelected(op) {
const id = String(op && op.memberId || '');
if (!id) return;
const idx = this.removeSelectedIds.indexOf(id);
if (idx === -1) {
this.removeSelectedIds = this.removeSelectedIds.concat([id]);
} else {
this.removeSelectedIds = this.removeSelectedIds.filter(v => v !== id);
}
},
// 确认移除操作员:按勾选的成员行 id 批量移除
async confirmRemoveOperator() { async confirmRemoveOperator() {
const memberId = String(this.boundOperator?.memberId || '').trim(); const ids = this.removeSelectedIds.map(v => String(v || '').trim()).filter(Boolean);
this.removeOperatorPopupOpen = false; this.removeOperatorPopupOpen = false;
if (!memberId) return; if (!ids.length) {
await this.doRemoveOperator(memberId); uni.showToast({ title: '请先选择要移除的操作员', icon: 'none' });
return;
}
await this.doRemoveOperators(ids);
}, },
// 执行移除成员请求(silent=true 时为退出工作台前的静默解绑:不弹 loading/toast/语音) // 执行移除成员请求(silent=true 时为退出工作台前的静默解绑:不弹 loading/toast/语音)
async doRemoveOperator(memberId, opts = {}) { // 支持一次移除多个操作员(ids 传数组);全员下线(移除后无成员)时先 finishPack 再 clearPackState() 清空订单数据
async doRemoveOperators(ids, opts = {}) {
const silent = !!opts.silent; const silent = !!opts.silent;
const idList = (Array.isArray(ids) ? ids : [ids])
.map(v => String(v == null ? '' : v).trim())
.filter(Boolean);
if (!idList.length) {
if (!silent) uni.showToast({ title: '成员行ID不能为空', icon: 'none' });
return { ok: false, error: '成员行ID不能为空' };
}
if (this.opRemoving) return { ok: false, busy: true }; if (this.opRemoving) return { ok: false, busy: true };
const token = String(this.workbenchToken || '').trim(); const token = String(this.workbenchToken || '').trim();
if (!token) { if (!token) {
@ -1308,35 +1524,47 @@ export default {
this.opRemoving = true; this.opRemoving = true;
if (!silent) uni.showLoading({ title: '移除中...', mask: true }); if (!silent) uni.showLoading({ title: '移除中...', mask: true });
try { try {
// 成员解绑/登出前:若存在进行中的打包任务先上报打包完成(失败不阻断解绑)
await this.ensurePackFinishedBeforeLeave();
const res = await this.$http('workbench.removeMember', { const res = await this.$http('workbench.removeMember', {
ids: Number(memberId), ids: idList.map(Number),
token token
}); });
const invalid = res?.flag === 'failure' || [400, 403, 404].indexOf(Number(res?.code)) !== -1; const bizCode = Number(res?.code);
// 404:成员行已不存在(已被其它设备移除/下线),视为已移除,继续走本地清理流程
const missing = bizCode === 404;
const invalid = !missing && (res?.flag === 'failure' || [400, 403].indexOf(bizCode) !== -1);
if (invalid) { if (invalid) {
// 401:工作台 token 失效,退出工作台模式并清除 token 回登录页 // 401:工作台 token 失效,退出工作台模式并清除 token 回登录页
if (this.handleWorkbenchAuthExpired(res?.code)) return { ok: false, expired: true }; if (this.handleWorkbenchAuthExpired(bizCode)) return { ok: false, expired: true };
throw new Error(res?.message || '移除操作员失败'); throw new Error(res?.message || '移除操作员失败');
} }
// 清除本地记录,回到可重新绑定态 // 从本地列表移除已移除的成员行(同步 workbenchMembers 与 boundOperators)
this.boundOperator = { memberId: '', workbenchId: String(this.workbenchId || ''), userId: '', userName: '' }; const removedSet = new Set(idList);
uni.setStorageSync('workbenchOperator', this.boundOperator); const wmList = (Array.isArray(this.workbenchMembers) ? this.workbenchMembers : [])
.filter(m => !removedSet.has(String(m && m.id || '')));
if (wmList.length) {
this.applyWorkbenchMembers(wmList);
} else {
// 全员下线:清空成员列表与本地缓存
this.workbenchMembers = [];
uni.removeStorageSync(MEMBER_STORAGE_KEY);
this.boundOperators = [];
uni.removeStorageSync('workbenchOperators');
}
this.opScanCode = ''; this.opScanCode = '';
this.opQueryState = ''; this.opQueryState = '';
this.opQueryResult = null; this.opQueryResult = null;
this.opQueryError = ''; this.opQueryError = '';
// 操作员已移除:清空查询订单/团购核实列表数据,避免残留给下一位操作员 // 全员下线(移除后工作台已无任何成员):先 finishPack 再 clearPackState() 清空订单数据
this.orderBarcode = ''; if (!this.boundOperators.length) {
this.orderQueryState = ''; const fr = await this.requestFinishPack();
this.orderQueryResult = null; if (fr && fr.expired) return { ok: false, expired: true };
this.orderQueryError = ''; this.clearPackState();
this.groupVerified = {}; }
this.groupAutoSubmitted = false;
if (!silent) { if (!silent) {
uni.showToast({ title: '操作员已移除', icon: 'success' }); uni.showToast({ title: '操作员已移除', icon: 'success' });
this.speakText('移除成功'); this.speakText('移除成功');
// 下线后静默重拉工作台信息,成员列表以服务端为准(退出流程 silent 不重拉)
this.fetchWorkbenchInfo({ silent: true });
} }
return { ok: true }; return { ok: true };
} catch (error) { } catch (error) {
@ -1351,6 +1579,19 @@ export default {
this.opRemoving = false; this.opRemoving = false;
} }
}, },
// 清空订单打包状态与查询/核实数据(全员下线、退出工作台时调用)
clearPackState() {
this.orderBarcode = '';
this.orderQueryState = '';
this.orderQueryResult = null;
this.orderQueryError = '';
this.packContextKey = '';
this.groupVerified = {};
this.groupAutoSubmitted = false;
this.hasActivePack = false;
this.activePackIdentity = '';
this.packRestored = false;
},
// 读取本地已绑定信息(wblc 免登录 / 绑定成功均写入 storage) // 读取本地已绑定信息(wblc 免登录 / 绑定成功均写入 storage)
loadBound(options) { loadBound(options) {
const cached = uni.getStorageSync('workbenchInfo') || {}; const cached = uni.getStorageSync('workbenchInfo') || {};
@ -1363,12 +1604,117 @@ export default {
this.workbenchType = String(cached?.type || ''); this.workbenchType = String(cached?.type || '');
this.bound = !!this.workbenchToken; this.bound = !!this.workbenchToken;
}, },
// 从 getWorkbenchInfo 响应恢复「进行中的打包任务」:服务端是唯一事实来源,
// 把服务端记录的未结束任务画回界面(商品明细全部视为已核实、显示打包中、跳过拦截/已打包/预检)
restoreCurrentPackTask(raw) {
const src = raw && typeof raw === 'object' ? raw : {};
const wave = src.current_wave ?? src.currentWave;
const orders = src.current_orders ?? src.currentOrders ?? src.current_order ?? src.currentOrder;
// 无进行中任务则不恢复
if (!wave && !orders) return;
const hasWave = !!(wave && typeof wave === 'object' && Object.keys(wave).length);
const isSandan = hasWave ? 0 : 1;
// 汇总进行中任务的订单商品明细
const orderList = Array.isArray(orders) ? orders : (orders ? [orders] : []);
let items = [];
orderList.forEach((od) => {
if (Array.isArray(od && od.items)) items = items.concat(od.items);
});
const waveNo = String(
(wave && (wave.wave_no ?? wave.waveNo)) ||
(orderList[0] && (orderList[0].wave_no ?? orderList[0].waveNo)) || ''
).trim();
// 散单恢复运单号:waybill_code(运单号)优先,express.waybill_code 次之,delivery_order_code(发货单号)最后兜底;
// 用 || 跳过空字符串;团购为波次,无单一运单号,置空
const firstOrder = orderList[0] || {};
const express = firstOrder.express || {};
const waybill = hasWave
? ''
: String(
firstOrder.waybill_code ||
express.waybill_code ||
firstOrder.delivery_order_code ||
firstOrder.waybillCode ||
firstOrder.barcode ||
''
).trim();
// 波次总单数:current_wave.order_count 优先,兜底 current_orders 数量
const rawTotal = wave && (wave.order_count ?? wave.total_orders ?? wave.totalOrders);
const totalOrders = (rawTotal !== undefined && rawTotal !== null) ? rawTotal : orderList.length;
const mappedItems = items.map((it, i) => {
const o = it || {};
// 实际字段:item_id(wms_item id)为主;item.id 可能为 0(无效),不能用于核实 key
const rawId = o.item_id ?? o.itemId ?? o.sku_id ?? o.id;
const hasValidId = rawId !== undefined && rawId !== null && rawId !== 0 && rawId !== '';
return {
id: hasValidId ? rawId : i,
plan_qty: Number((o.plan_qty ?? o.qty ?? o.num) || 1) || 1,
item_name: String((o.item_name ?? o.itemName ?? o.name ?? o.sku_name) || '').trim(),
item_code: String((o.item_code ?? o.itemCode ?? o.sku_code) || '').trim(),
barcodes: o.barcodes ?? o.barcode,
image_url: o.image_url ?? o.imageUrl ?? o.image,
need_recheck: o.need_recheck
};
});
this.orderQueryResult = {
isSandan,
waybill_code: waybill,
barcode: waybill,
key: '', // 恢复态无需再发起 packOrder,不携带打包上下文 key
store_remark: String((orderList[0] && (orderList[0].store_remark ?? orderList[0].storeRemark)) || ''),
// 散单恢复运单信息(包材名称/物流公司/称重重量);团购 express 为 null,置 undefined
express: hasWave ? undefined : {
waybill_code: express.waybill_code,
logistics_name: express.logistics_name,
weighing_weight: express.weighing_weight,
package_material_name: express.package_material_name
},
batch: hasWave ? { wave_no: waveNo, total_orders: totalOrders } : undefined,
order: {
wave_no: waveNo,
recheck_status: 'fin', // 恢复态跳过未复核判断
pack_status: 'packing', // 恢复态跳过已打包判断(packRestored 兜底)
items_count: mappedItems.length,
items_total: mappedItems.reduce((s, it) => s + (Number(it.plan_qty) || 0), 0)
},
items: mappedItems
};
// 恢复「打包中」状态:全部商品视为已核实
const verified = {};
mappedItems.forEach((it, i) => {
verified[this.groupItemKey(it, i)] = Math.max(1, Number(it.plan_qty) || 1);
});
// 先置 groupAutoSubmitted 再写 groupVerified,避免 groupAllVerified 变化触发重复提交打包
this.groupAutoSubmitted = true;
this.groupVerified = verified;
this.orderQueryState = 'success';
this.orderQueryError = '';
this.orderBarcode = '';
this.packContextKey = '';
this.hasActivePack = true;
this.activePackIdentity = this.orderIdentity(this.orderQueryResult);
this.packRestored = true; // 跳过拦截/已打包/预检,展示进行中任务
console.log('[packMode] 恢复进行中打包任务:', { isSandan, waveNo, waybill, items: mappedItems.length });
},
// 重新拉取工作台信息:进入打包模式时校验本地工作台 token 并刷新工作台信息 // 重新拉取工作台信息:进入打包模式时校验本地工作台 token 并刷新工作台信息
async fetchWorkbenchInfo() { // silent=true:静默刷新(绑定/下线成功后重拉同步成员),失败不弹 toast
async fetchWorkbenchInfo(options = {}) {
const silent = !!options.silent;
const token = String(this.workbenchToken || '').trim(); const token = String(this.workbenchToken || '').trim();
if (!token) return; if (!token) return;
if (this.infoRefreshing) return; if (silent) {
this.infoRefreshing = true; if (this.infoRefreshingSilent) return;
this.infoRefreshingSilent = true;
} else {
if (this.infoRefreshing) return;
this.infoRefreshing = true;
}
try { try {
const res = await this.$http('workbench.getWorkbenchInfo', { token }); const res = await this.$http('workbench.getWorkbenchInfo', { token });
const invalid = res?.flag === 'failure' || Number(res?.code) === 400 || Number(res?.code) === 403; const invalid = res?.flag === 'failure' || Number(res?.code) === 400 || Number(res?.code) === 403;
@ -1400,13 +1746,25 @@ export default {
this.workbenchStatus = detail.status ?? ''; this.workbenchStatus = detail.status ?? '';
this.workbenchType = detail.type; this.workbenchType = detail.type;
uni.setStorageSync('workbenchInfo', detail); uni.setStorageSync('workbenchInfo', detail);
// 同步工作台在线成员列表(服务端 members 为权威,含绑定/下线后的最新状态)
if (Array.isArray(data?.members)) {
this.applyWorkbenchMembers(this.normalizeWorkbenchMembers(data.members, detail.id));
}
// 恢复进行中的打包任务(服务端是唯一事实来源:current_wave / current_orders)
this.restoreCurrentPackTask(data);
console.log('[packMode] 工作台信息刷新成功:', detail); console.log('[packMode] 工作台信息刷新成功:', detail);
} catch (error) { } catch (error) {
// 网络/其它异常:保留本地缓存信息继续使用,仅提示,不清除会话 // 网络/其它异常:保留本地缓存信息继续使用,仅提示,不清除会话
console.warn('[packMode] 工作台信息刷新失败,沿用本地缓存:', error); console.warn('[packMode] 工作台信息刷新失败,沿用本地缓存:', error);
uni.showToast({ title: '工作台信息刷新失败', icon: 'none' }); if (!silent) {
uni.showToast({ title: '工作台信息刷新失败', icon: 'none' });
}
} finally { } finally {
this.infoRefreshing = false; if (silent) {
this.infoRefreshingSilent = false;
} else {
this.infoRefreshing = false;
}
} }
}, },
// 退出工作台模式(用户主动):打开退出确认弹窗 // 退出工作台模式(用户主动):打开退出确认弹窗
@ -1416,12 +1774,10 @@ export default {
// 确认退出工作台 // 确认退出工作台
async confirmExit() { async confirmExit() {
this.exitPopupOpen = false; this.exitPopupOpen = false;
// 退出工作台前:若存在进行中的打包任务先上报打包完成 // 退出工作台 = 同时解绑操作员:操作员已绑定时先静默批量解绑(不弹提示,随后统一退出)
await this.ensurePackFinishedBeforeLeave(); const ids = this.boundOperators.map(op => String(op && op.memberId || '').trim()).filter(Boolean);
// 退出工作台 = 同时解绑操作员:操作员已绑定时先静默解绑(不弹提示,随后统一退出) if (ids.length && String(this.workbenchToken || '').trim()) {
const memberId = String(this.boundOperator?.memberId || '').trim(); const unbind = await this.doRemoveOperators(ids, { silent: true });
if (memberId && String(this.workbenchToken || '').trim()) {
const unbind = await this.doRemoveOperator(memberId, { silent: true });
// 401 已由 handleWorkbenchAuthExpired 处理退出并回登录页,无需重复退出 // 401 已由 handleWorkbenchAuthExpired 处理退出并回登录页,无需重复退出
if (unbind && unbind.expired) return; if (unbind && unbind.expired) return;
} }
@ -1439,6 +1795,10 @@ export default {
uni.removeStorageSync('workbenchInfo'); uni.removeStorageSync('workbenchInfo');
// 退出工作台同时清除本地操作员绑定记录,避免下次进入误恢复旧操作员 // 退出工作台同时清除本地操作员绑定记录,避免下次进入误恢复旧操作员
uni.removeStorageSync('workbenchOperator'); uni.removeStorageSync('workbenchOperator');
uni.removeStorageSync('workbenchOperators');
uni.removeStorageSync(MEMBER_STORAGE_KEY);
this.workbenchMembers = [];
this.boundOperators = [];
if (withToast) { if (withToast) {
uni.showToast({ title: '工作台登录已失效,请重新登录', icon: 'none' }); uni.showToast({ title: '工作台登录已失效,请重新登录', icon: 'none' });
} }
@ -1796,6 +2156,21 @@ export default {
color: #2979ff; color: #2979ff;
} }
/* 禁止打包:运单/波次行红底 */
.order-summary__row--blocked {
background: #e64340;
border-radius: 8rpx;
padding: 8rpx 12rpx;
}
.order-summary__row--blocked .order-summary__label,
.order-summary__row--blocked .order-summary__value,
.order-summary__row--blocked .order-summary__extra,
.order-summary__row--blocked .order-summary__num,
.order-summary__row--blocked .order-result-tag {
color: #ffffff;
}
.order-block { .order-block {
margin-top: 12rpx; margin-top: 12rpx;
background: #f8f9fb; background: #f8f9fb;
@ -1814,6 +2189,20 @@ export default {
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.order-block--blocked {
display: flex;
align-items: center;
justify-content: center;
}
.order-block__hint {
font-size: 36rpx;
font-weight: 600;
color: #e64340;
text-align: center;
line-height: 1.6;
}
.order-item { .order-item {
background: #ffffff; background: #ffffff;
border: 1rpx solid #000000; border: 1rpx solid #000000;
@ -2366,6 +2755,38 @@ export default {
line-height: 1.6; line-height: 1.6;
} }
.remove-operator-list {
margin-top: 24rpx;
display: flex;
flex-direction: column;
gap: 16rpx;
max-height: 360rpx;
overflow-y: auto;
}
.remove-operator-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
padding: 20rpx 24rpx;
border: 2rpx solid #e4e7ed;
border-radius: 12rpx;
background: #f8f9fb;
}
.remove-operator-item--checked {
border-color: #2979ff;
background: #f0f7ff;
}
.remove-operator-item__name {
flex: 1;
font-size: 34rpx;
color: #303133;
word-break: break-all;
}
.remove-operator-popup__actions { .remove-operator-popup__actions {
display: flex; display: flex;
align-items: center; align-items: center;