WMS_PDA/pages/packing/packMode.vue

1793 lines
55 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="pack-mode-page">
<!-- 顶部栏 -->
<view class="top-bar">
<view class="status-bar"></view>
<view class="header">
<view class="header-left" @click="handleBack">
<u-icon name="arrow-left" size="36rpx" color="#303133"></u-icon>
<text class="header-left__text">退出</text>
</view>
<view class="header-center">
<text class="header-title">打包模式</text>
<text v-if="bound && workbenchName" class="header-subtitle">{{ workbenchName }}</text>
</view>
<view class="header-right">
<view class="user-info-btn" :class="{ 'user-info-btn--bound': boundOperator.memberId }" @click="handleUserInfo">
<u-icon name="account-fill" size="34rpx" color="#ffffff"></u-icon>
<text class="user-info-btn__text">{{ boundOperator.memberId ? (boundOperator.userName || '已绑定') : '未绑定' }}</text>
</view>
</view>
</view>
</view>
<view class="content">
<!-- ============ 已绑定态 ============ -->
<template v-if="bound">
<!-- 订单查询 -->
<view class="order-query-card">
<view class="order-query__scan-row">
<input
class="order-query__input"
v-model="orderBarcode"
:focus="orderInputFocus"
placeholder="扫描/输入运单号查询"
placeholder-style="color:#c0c4cc;font-size:34rpx"
@confirm="handleOrderQueryConfirm"
/>
<view class="camera-btn" @click="handleOrderCameraScan">
<u-icon name="scan" size="36rpx" color="#2979ff"></u-icon>
</view>
</view>
<!-- 查询中 -->
<view v-if="orderQueryState === 'loading'" class="order-query__loading">
<u-loading-icon text="查询中..." color="#2979ff"></u-loading-icon>
</view>
<!-- 查询失败 -->
<view v-else-if="orderQueryState === 'error'" class="order-query__error">
<text class="order-query__error-text">{{ orderQueryError || '查询失败,请重试' }}</text>
</view>
<!-- 查询成功 -->
<template v-else-if="orderQueryState === 'success' && orderQueryResult">
<!-- 头部:运单号 + 类型 -->
<view class="order-query__head">
<text class="order-result-waybill">{{ orderQueryResult.waybill_code || orderQueryResult.barcode || '--' }}</text>
<text class="order-result-tag" :class="orderQueryIsSandan ? 'order-result-tag--sandan' : 'order-result-tag--tuangou'">{{ orderQueryIsSandan ? '散单' : '团购' }}</text>
</view>
<!-- 精简概要:波次 共x单 / 包材名称 商品总数量 -->
<view class="order-summary">
<view class="order-summary__row">
<text class="order-summary__label">波次</text>
<text class="order-summary__value order-summary__value--strong">{{ orderWaveNo }}</text>
<text class="order-summary__extra">共 <text class="order-summary__num">{{ orderWaveTotal }}</text> 单</text>
</view>
<view v-if="orderQueryResult.store_remark" class="order-summary__row">
<text class="order-summary__label">货主</text>
<text class="order-summary__value">{{ orderQueryResult.store_remark }}</text>
</view>
<view class="order-summary__row">
<text class="order-summary__label">包材名称</text>
<text class="order-summary__value">{{ packageMaterialName || '--' }}</text>
<text class="order-summary__extra">商品总数 <text class="order-summary__num">{{ orderItemsTotal }}</text></text>
</view>
</view>
<!-- 团购核实:进度 + 全部核实后提交开始打包 -->
<view v-if="!orderQueryIsSandan" class="group-verify">
<view class="group-verify__head">
<text class="group-verify__progress">{{ groupVerifiedCount }}/{{ groupItems.length }}</text>
<u-button
v-if="groupVerifyingActive"
text="取消核实"
type="error"
@click="handleCancelGroupVerify"
></u-button>
</view>
</view>
<!-- 商品明细:数量 + 图片 + 名称 + 条码 -->
<view class="order-block">
<text class="order-block__title">商品明细</text>
<template v-if="orderQueryResult.items && orderQueryResult.items.length">
<view
v-for="(item, idx) in orderQueryResult.items"
:key="item.id || idx"
class="order-item"
:class="{ 'order-item--verified': !orderQueryIsSandan && isItemVerified(item, idx) }"
@longpress="handleGroupItemLongPress(item, idx)"
>
<image
v-if="orderItemImg(item)"
class="order-item__img"
:src="orderItemImg(item)"
mode="aspectFill"
></image>
<view v-else class="order-item__img order-item__img--placeholder">
<u-icon name="photo" size="40rpx" color="#c0c4cc"></u-icon>
</view>
<view class="order-item__info">
<text class="order-item__name">{{ item.item_name || '--' }}</text>
<text class="order-item__barcode">{{ orderItemBarcode(item) || item.item_code || '--' }}</text>
</view>
<view class="order-item__right">
<text class="order-item__qty">x{{ item.plan_qty }}</text>
<text
v-if="!orderQueryIsSandan"
class="order-item__state"
:class="isItemVerified(item, idx) ? 'order-item__state--done' : ''"
>{{ itemVerifyText(item, idx) }}</text>
</view>
</view>
</template>
<view v-else class="order-empty">无商品明细</view>
</view>
</template>
</view>
</template>
<!-- ============ 未绑定态:提示返回登录页 ============ -->
<template v-else>
<view class="state-card">
<view class="state-badge">
<u-icon name="info-circle" size="36rpx" color="#909399"></u-icon>
<text class="state-badge__text">未绑定工作台</text>
</view>
<view class="info-block">
<view class="info-row">
<text class="info-label">提示</text>
<text class="info-value">当前未绑定工作台,请返回登录页使用工作台登录码(wblc 开头)登录后进入打包模式。</text>
</view>
</view>
</view>
<view class="action-area action-area--col">
<u-button text="返回登录页" plain @click="handleBack"></u-button>
</view>
</template>
</view>
<!-- 操作员弹窗 -->
<u-popup
:show="userDrawerOpen"
mode="center"
round="16"
bgColor="#ffffff"
:closeable="true"
:z-index="10090"
@close="handleCloseUserDrawer"
>
<view class="user-drawer">
<view class="user-drawer__header">
<text class="user-drawer__title">操作员</text>
</view>
<view class="user-drawer__body">
<!-- 已绑定操作员:姓名 + 绑定状态 + 移除 -->
<template v-if="boundOperator.memberId">
<view class="operator-line">
<text class="operator-line__name">{{ boundOperator.userName || '--' }}</text>
<view class="operator-line__status operator-line__status--bound">
<text class="operator-line__status-text">已绑定</text>
</view>
<view class="operator-line__remove" @click="handleRemoveOperator">
<u-icon name="trash" size="30rpx" color="#f56c6c"></u-icon>
<text class="operator-line__remove-text">移除</text>
</view>
</view>
</template>
<!-- 未绑定:扫码识别工牌 → 绑定 -->
<template v-else>
<view class="scan-section">
<view class="scan-row">
<input
class="scan-input"
v-model="opScanCode"
:focus="opInputFocus"
placeholder="输入/扫描工牌绑定工作台"
placeholder-style="color:#c0c4cc;font-size:34rpx"
@confirm="handleOpInputConfirm"
/>
<view class="camera-btn" @click="handleOpCameraScan">
<u-icon name="scan" size="36rpx" color="#2979ff"></u-icon>
</view>
</view>
</view>
<view v-if="opQueryState === 'loading'" class="query-state query-state--loading">
<u-loading-icon text="识别中..." color="#2979ff"></u-loading-icon>
</view>
<view v-else-if="opQueryState === 'identified' && opQueryResult" class="operator-ident-card">
<u-button
text="绑定"
type="primary"
:loading="opBinding"
@click="handleBindOperator"
></u-button>
</view>
<view v-else-if="opQueryState === 'error'" class="query-state query-state--error">
<text class="query-state__error-text">{{ opQueryError || '识别失败,请重试' }}</text>
</view>
</template>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
// 当前绑定
bound: false,
workbenchId: '',
workbenchName: '',
workbenchToken: '',
warehouseId: '',
workbenchStatus: '',
workbenchType: '',
infoRefreshing: false, // 进入后刷新工作台信息请求防重入锁
// 当前操作员(工作台成员,本地保存 bindMember 返回的成员行 id)
boundOperator: {
memberId: '', // wms_workbench_member.id
workbenchId: '', // 记录归属工作台,重新进入时按此匹配
userId: '', // wms_account.id(非系统账号用户为空)
userName: '' // 姓名快照
},
opScanCode: '', // 操作员扫码输入框内容(ye4s 登录临时码)
opInputFocus: false,
opQueryState: '', // '' | loading | identified | error(识别待绑定状态)
opQueryResult: null, // 识别出的待绑定操作员 { scanToken, name, wmsAccountId }
opQueryError: '',
opBinding: false, // bindMember 请求中
opRemoving: false, // removeMember 请求中
// 操作员弹窗
userDrawerOpen: false,
// 订单查询(workbench.queryOrder)
orderBarcode: '',
orderInputFocus: false,
orderQuerying: false,
orderQueryState: '', // '' | loading | success | error
orderQueryResult: null,
orderQueryError: '',
packReporting: false, // packOrder 上报请求防重入锁
finishPacking: false, // finishPack 完成打包请求防重入锁
hasActivePack: false, // 该工作台是否存在未结束打包任务(status<2):退出/解绑前自动上报打包完成
// 团购核实:商品行已扫计数(key=商品行id/序号 → 已扫次数),达 plan_qty 视为已核实
groupVerified: {},
groupSubmitting: false, // 团购提交开始打包防重入
groupAutoSubmitted: false // 团购全部核实后是否已自动提交开始打包
}
},
// 团购:全部商品核实完成后自动提交开始打包(每次查询仅自动提交一次)
watch: {
groupAllVerified(verified) {
if (verified && !this.orderQueryIsSandan && this.orderQueryResult && !this.groupAutoSubmitted) {
this.groupAutoSubmitted = true;
this.handleSubmitGroupPack();
}
}
},
computed: {
maskedToken() {
const token = String(this.workbenchToken || '');
if (!token) return '';
if (token.length <= 12) return token;
return `${token.substring(0, 6)}...${token.substring(token.length - 4)}`;
},
statusText() {
if (this.workbenchStatus === 0 || this.workbenchStatus === '0') return '禁用';
if (this.workbenchStatus === 1 || this.workbenchStatus === '1') return '启用';
return this.workbenchStatus === '' || this.workbenchStatus === null || typeof this.workbenchStatus === 'undefined' ? '--' : String(this.workbenchStatus);
},
typeText() {
if (this.workbenchType === 'personal') return '个人工作台';
if (this.workbenchType === 'group') return '团体工作台';
return this.workbenchType ? this.workbenchType : '--';
},
// 查询结果是否为散单
orderQueryIsSandan() {
const r = this.orderQueryResult;
return !!(r && Number(r.isSandan) === 1);
},
// 精简概要:包材名称(express/order 的 package_material_name)
packageMaterialName() {
const r = this.orderQueryResult;
const raw = (r?.order && (r.order.package_material_name ?? r.order.packageMaterialName)) ?? (r?.express && (r.express.package_material_name ?? r.express.packageMaterialName));
return String(raw || '').trim();
},
// 波次号(batch.wave_no 优先,兜底 order.wave_no)
orderWaveNo() {
const r = this.orderQueryResult;
const batchNo = r?.batch && r.batch.wave_no ? String(r.batch.wave_no) : '';
const orderNo = r?.order && r.order.wave_no ? String(r.order.wave_no) : '';
return batchNo || orderNo || '--';
},
// 波次总单数(团购 batch.total_orders;兜底 items_count)
orderWaveTotal() {
const r = this.orderQueryResult;
const batchTotal = r?.batch && (r.batch.total_orders !== undefined && r.batch.total_orders !== null) ? r.batch.total_orders : null;
const itemCount = r?.order && (r.order.items_count !== undefined && r.order.items_count !== null) ? r.order.items_count : 0;
return batchTotal !== null ? batchTotal : itemCount;
},
// 商品总数量(order.items_total,缺省按 items 求和)
orderItemsTotal() {
const r = this.orderQueryResult;
const total = r?.order && (r.order.items_total !== undefined && r.order.items_total !== null) ? r.order.items_total : null;
if (total !== null) return total;
if (Array.isArray(r?.items)) {
return r.items.reduce((sum, it) => sum + (Number(it.plan_qty) || 0), 0);
}
return 0;
},
// 团购订单商品明细(查询结果 items)
groupItems() {
const r = this.orderQueryResult;
return (r && Array.isArray(r.items)) ? r.items : [];
},
// 团购已核实商品数
groupVerifiedCount() {
const items = this.groupItems;
let count = 0;
for (let i = 0; i < items.length; i++) {
if (this.isItemVerified(items[i], i)) count++;
}
return count;
},
// 团购商品是否全部核实(无明细视为无需核实)
groupAllVerified() {
if (this.orderQueryIsSandan) return false;
const items = this.groupItems;
if (!items.length) return true;
return this.groupVerifiedCount >= items.length;
},
// 团购核实扫描激活中:存在未核实的可扫商品(此时扫码=核实商品条码)
groupVerifyingActive() {
if (this.orderQueryIsSandan) return false;
const items = this.groupItems;
return !!this.orderQueryResult && items.length > 0 && this.groupVerifiedCount < items.length;
},
// 输入框占位:团购核实时提示扫商品条码
groupScanPlaceholder() {
return this.groupVerifyingActive ? '扫描商品条码核实' : '扫描/输入运单号查询';
}
},
onLoad(options) {
this.loadBound(options);
// 读取本地保存的已绑定操作员(bindMember 返回的成员行 id,按 workbenchId 匹配)
this.loadBoundOperator();
// 进入打包模式:重新拉取工作台信息(同时校验本地工作台 token 是否仍有效)
if (this.bound) {
this.fetchWorkbenchInfo();
}
// 注册广播扫码回调(操作员弹窗内枪扫工牌识别绑定用)
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('start');
},
onShow() {
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
},
onHide() {
this.safeDispatchBroadcast('pause');
},
onUnload() {
this.safeDispatchBroadcast('stop');
},
methods: {
// 语音播报($tools.speakText 封装,自动 catch)
speakText(text = '') {
try {
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') return;
const task = tools.speakText(String(text).trim(), {});
if (task && typeof task.catch === 'function') {
task.catch(error => console.warn('[packMode] 语音播报失败:', error));
}
} catch (error) {
console.warn('[packMode] 语音播报异常:', error);
}
},
// 主界面扫码统一入口:无成员不可查询;团购核实时 → 扫商品条码核实;否则 → 按运单查询
handleBarcodeInput(code) {
const c = String(code || '').trim();
if (!c) return;
if (!String(this.boundOperator?.memberId || '').trim()) {
uni.showToast({ title: '请先绑定操作员再查询', icon: 'none' });
return;
}
this.orderBarcode = c;
this.orderInputFocus = false;
if (this.groupVerifyingActive) {
this.handleGroupVerifyScan(c);
return;
}
this.queryOrder(c);
},
// ===== 团购商品核实 =====
groupItemKey(item, idx) {
return (item && item.id !== undefined && item.id !== null) ? ('id_' + item.id) : ('idx_' + idx);
},
// 商品可扫条码列表(barcodes[].barcode / barcode / item_code)
groupItemCodes(item) {
if (!item) return [];
const out = [];
const codes = item.barcodes ?? item.barcode;
if (Array.isArray(codes)) {
codes.forEach((c) => {
if (!c) return;
if (typeof c === 'object') {
if (c.barcode) out.push(String(c.barcode));
else if (c.code) out.push(String(c.code));
} else {
out.push(String(c));
}
});
} else if (codes && typeof codes === 'object') {
if (codes.barcode) out.push(String(codes.barcode));
else if (codes.code) out.push(String(codes.code));
} else if (codes) {
out.push(String(codes));
}
if (item.item_code) out.push(String(item.item_code));
return out.map(s => String(s).trim()).filter(Boolean);
},
groupItemScannable(item) {
return this.groupItemCodes(item).length > 0;
},
isItemVerified(item, idx) {
const qty = Math.max(1, Number(item && item.plan_qty) || 1);
const key = this.groupItemKey(item, idx);
return (this.groupVerified[key] || 0) >= qty;
},
// 长按复核:整件标记已核实(视为数量全部扫满)
markItemVerified(item, idx) {
const key = this.groupItemKey(item, idx);
if (this.isItemVerified(item, idx)) return;
const qty = Math.max(1, Number(item && item.plan_qty) || 1);
this.groupVerified = Object.assign({}, this.groupVerified, { [key]: qty });
},
// 扫描计数 +1:扫中商品条码一次记一次,返回是否刚好扫满(该商品已核实)
incrementVerified(item, idx) {
const key = this.groupItemKey(item, idx);
const qty = Math.max(1, Number(item && item.plan_qty) || 1);
const current = this.groupVerified[key] || 0;
if (current >= qty) return false;
const next = current + 1;
this.groupVerified = Object.assign({}, this.groupVerified, { [key]: next });
return next >= qty;
},
// 商品行核实状态文案:已核实 / 已扫x/y
itemVerifyText(item, idx) {
if (this.orderQueryIsSandan) return '';
// 已核实:绿底即完成状态,不再显示文字标签;未核实显示已扫 x/y
if (this.isItemVerified(item, idx)) return '';
const current = this.groupVerified[this.groupItemKey(item, idx)] || 0;
const qty = Math.max(1, Number(item && item.plan_qty) || 1);
return `${current}/${qty}`;
},
// 扫描条码与订单信息条码比对:命中且该商品未扫满 → 计数+1;达到数量即标记已完成
handleGroupVerifyScan(barcode) {
const code = String(barcode || '').trim();
if (!code) return;
if (this.orderQueryIsSandan || !this.orderQueryResult) return;
const items = this.groupItems;
for (let i = 0; i < items.length; i++) {
const item = items[i];
if (this.isItemVerified(item, i)) continue;
if (this.groupItemCodes(item).indexOf(code) !== -1) {
const name = String(item.item_name || '商品').trim();
const done = this.incrementVerified(item, i);
const key = this.groupItemKey(item, i);
const current = this.groupVerified[key] || 0;
const qty = Math.max(1, Number(item.plan_qty) || 1);
if (done) {
this.speakText(`${name},已核实`);
uni.showToast({ title: `${name} 已核实`, icon: 'none' });
} else {
// 数量未扫满:提示进度
uni.showToast({ title: `${name} ${current}/${qty}`, icon: 'none' });
}
return;
}
}
this.speakText('条码不匹配');
uni.showToast({ title: '条码与待核实商品不匹配', icon: 'none' });
},
// 长按复核:团单任意未核实商品可通过“无条码复核”人工标记已核实
handleGroupItemLongPress(item, idx) {
if (this.orderQueryIsSandan) return;
if (this.isItemVerified(item, idx)) return;
const name = String(item.item_name || '该商品').trim();
uni.showModal({
title: '无条码复核',
content: `确认已核实「${name}」?(无条码复核,人工确认)`,
confirmText: '确认',
cancelText: '取消',
success: (res) => {
if (!res.confirm) return;
this.markItemVerified(item, idx);
this.speakText(`${name},已核实`);
}
});
},
// 取消团购核实:放弃本次核实且不开始打包,回到查询态
handleCancelGroupVerify() {
uni.showModal({
title: '取消核实',
content: '确认取消本次核实?将放弃当前订单的商品核实,且不会开始打包。',
confirmText: '取消核实',
cancelText: '继续核实',
success: (res) => {
if (!res.confirm) return;
// 清除核实与当前订单结果,回到可扫描其它运单状态
this.groupVerified = {};
this.groupAutoSubmitted = false;
this.orderQueryState = '';
this.orderQueryResult = null;
this.orderQueryError = '';
this.orderBarcode = '';
uni.showToast({ title: '已取消核实', icon: 'none' });
}
});
},
// 团购全部商品核实后:提交开始打包(packOrder status=1)并语音
async handleSubmitGroupPack() {
if (this.groupSubmitting || !this.groupAllVerified) return;
this.groupSubmitting = true;
try {
const ok = await this.reportPackOrder();
if (ok) {
this.speakText('开始打包');
}
} finally {
this.groupSubmitting = false;
}
},
// 打开操作员弹窗:已绑定态展示操作员信息;未绑定态准备枪扫/输入工牌绑定
handleUserInfo() {
this.userDrawerOpen = true;
// 确保广播监听(从其它页面返回时可能已 pause),未绑定时扫码即识别绑定
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
if (!this.boundOperator.memberId) {
// 重置识别待绑定态并聚焦输入框,便于扫码枪/键盘输入
this.opScanCode = '';
this.opQueryState = '';
this.opQueryResult = null;
this.opQueryError = '';
this.$nextTick(() => {
setTimeout(() => {
this.opInputFocus = true;
}, 300);
});
} else {
this.opInputFocus = false;
}
},
// 关闭操作员弹窗
handleCloseUserDrawer() {
this.userDrawerOpen = false;
this.opInputFocus = false;
},
// 广播扫码结果:操作员弹窗打开且未绑定 → 识别操作员;主界面(已绑定)→ 查询订单
handleBroadcastResult(result) {
const scanText = this.normalizeScanResult(result);
console.log('[packMode] handleBroadcastResult 扫描结果:', scanText);
if (!scanText) return;
if (this.userDrawerOpen && !this.boundOperator.memberId) {
this.opScanCode = scanText;
this.opInputFocus = false;
this.queryOperatorUser(scanText);
return;
}
if (this.bound) {
this.handleBarcodeInput(scanText);
}
},
// 订单查询输入框回车确认
handleOrderQueryConfirm() {
const code = String(this.orderBarcode || '').trim();
if (!code) {
uni.showToast({ title: '请输入/扫描运单号', icon: 'none' });
return;
}
this.handleBarcodeInput(code);
},
// 订单查询相机扫码
handleOrderCameraScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
success: (res) => {
const code = String(res?.result || '').trim();
if (!code) return;
this.handleBarcodeInput(code);
},
fail: () => {}
});
},
// 按运单号条码查询订单(workbench.queryOrder)
async queryOrder(barcode) {
const code = String(barcode || '').trim();
if (!code) return;
// 无成员(未绑定操作员)时不允许查询订单
if (!String(this.boundOperator?.memberId || '').trim()) {
uni.showToast({ title: '请先绑定操作员再查询订单', icon: 'none' });
return;
}
const token = String(this.workbenchToken || '').trim();
if (!token) {
uni.showToast({ title: '工作台 token 缺失', icon: 'none' });
return;
}
if (this.orderQuerying) return;
this.orderQuerying = true;
this.orderQueryState = 'loading';
this.orderQueryResult = null;
this.orderQueryError = '';
uni.showLoading({ title: '查询中...', mask: true });
try {
// toastAfter=false:失败提示由本方法自行控制,避免拦截器重复弹 toast
const res = await this.$http('workbench.queryOrder', { token, barcode: code }, '', false);
const invalid = res?.flag === 'failure' || [0, 401, 403].indexOf(Number(res?.code)) !== -1;
if (invalid) {
this.orderQueryState = 'error';
this.orderQueryError = res?.message || '查询失败,请重试';
return;
}
const data = (res && typeof res === 'object' && res.data && typeof res.data === 'object') ? res.data : res;
if (!data || typeof data !== 'object') {
this.orderQueryState = 'error';
this.orderQueryError = '查询结果无效';
return;
}
this.orderQueryResult = data;
this.orderQueryState = 'success';
// 查询成功:清空输入框,方便连续扫描下一单
this.orderBarcode = '';
// 团购:初始化商品核实状态(不自动上报,全部核实后将自动提交开始打包)
this.groupVerified = {};
this.groupAutoSubmitted = false;
// 兜底:无商品明细的团购单视为无需核实,直接自动提交开始打包
if (!this.orderQueryIsSandan && this.groupAllVerified && !this.groupAutoSubmitted) {
this.groupAutoSubmitted = true;
this.handleSubmitGroupPack();
}
if (this.orderQueryIsSandan) {
// 散单:扫描面单立即上报开始打包(等查询 loading 关闭后再发起)
setTimeout(() => {
this.reportPackOrder().then((ok) => {
if (ok) this.speakText('开始打包');
});
}, 0);
}
} catch (error) {
console.error('[packMode] 查询订单失败:', error);
this.orderQueryState = 'error';
this.orderQueryError = error?.message || '查询失败,请重试';
} finally {
uni.hideLoading();
this.orderQuerying = false;
}
},
// 商品明细首张图片(image_url 为数组或字符串时取首个非空)
orderItemImg(item) {
if (!item) return '';
const url = item.image_url ?? item.imageUrl;
if (Array.isArray(url)) {
const first = url.find(u => u);
return String(first || '');
}
return String(url || '');
},
// 商品明细条码(barcodes 数组取首项 barcode,或字符串直接返回)
orderItemBarcode(item) {
if (!item) return '';
const codes = item.barcodes ?? item.barcode;
if (Array.isArray(codes)) {
const first = codes.find(c => c);
if (first && typeof first === 'object') return String(first.barcode || first.code || '');
return String(first || '');
}
if (codes && typeof codes === 'object') return String(codes.barcode || codes.code || '');
return String(codes || '');
},
// 打包预检(上报 packOrder 前):散单拦截 → 未复核 → 已打包;命中则文字+语音提示并禁止打包
packPrecheck() {
const r = this.orderQueryResult;
const order = r && r.order;
if (!order) return true;
// 1. 拦截:仅散单判断(团购不做拦截)
if (this.orderQueryIsSandan && Number(order.intercept_flag) === 1) {
this.speakText('订单已拦截,禁止打包');
uni.showToast({ title: '订单已拦截,禁止打包', icon: 'none' });
return false;
}
// 2. 未复核(recheck_status 非完成视为未复核,团散都判)
const recheck = String(order.recheck_status ?? '').trim().toLowerCase();
const recheckDone = recheck === 'fin' || recheck === 'finished' || recheck === '1';
if (!recheckDone) {
this.speakText('订单未复核,禁止打包');
uni.showToast({ title: '订单未复核,禁止打包', icon: 'none' });
return false;
}
// 3. 已打包:散单看 pack_flag=1;团购无 pack_flag 用 pack_status 非空/非 none
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) {
this.speakText('已打包');
uni.showToast({ title: '已打包', icon: 'none' });
return false;
}
return true;
},
// 工作台打包上报(workbench.packOrder):基于最近一次查询结果,状态=1 打包中;成功返回 true
async reportPackOrder() {
const r = this.orderQueryResult;
if (!r) return false;
// 打包预检:订单未复核/拦截/已打包时提示并禁止开始打包
if (!this.packPrecheck()) return false;
const token = String(this.workbenchToken || '').trim();
if (!token) return false;
if (this.packReporting) return false;
const deliveryOrderCode = String(r?.order?.delivery_order_code || '').trim();
if (!deliveryOrderCode) {
uni.showToast({ title: '缺少发货单号,无法上报打包', icon: 'none' });
return false;
}
// 打包人员:当前已绑定操作员
const operator = this.boundOperator;
if (!operator || !String(operator.memberId || '').trim() || !String(operator.userName || '').trim()) {
uni.showToast({ title: '请先绑定操作员再上报打包', icon: 'none' });
return false;
}
this.packReporting = true;
uni.showLoading({ title: '打包上报中...', mask: true });
try {
const payload = {
token,
delivery_order_code: deliveryOrderCode,
status: 1, // 打包中
wave_total_orders: (r?.batch && r.batch.total_orders !== undefined && r.batch.total_orders !== null)
? Number(r.batch.total_orders)
: 1,
users: [{
wms_account_id: (operator.userId !== '' && operator.userId !== null && operator.userId !== undefined) ? Number(operator.userId) : null,
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:失败提示由本方法自行控制
const res = await this.$http('workbench.packOrder', payload, '', false);
const invalid = res?.flag === 'failure' || [0, 400, 401, 403].indexOf(Number(res?.code)) !== -1;
if (invalid) {
uni.showToast({ title: res?.message || '打包上报失败', icon: 'none' });
return false;
}
console.log('[packMode] 打包上报成功:', res?.data || res);
// 记录存在未结束打包任务:退出工作台/解绑操作员前将自动上报打包完成
this.hasActivePack = true;
uni.showToast({ title: '已开始打包', icon: 'success' });
return true;
} catch (error) {
console.error('[packMode] 打包上报失败:', error);
uni.showToast({ title: error?.message || '打包上报失败', icon: 'none' });
return false;
} finally {
uni.hideLoading();
this.packReporting = false;
}
},
// 工作台打包完成请求(workbench.finishPack):结束该工作台最后一个未结束打包任务
async requestFinishPack() {
const token = String(this.workbenchToken || '').trim();
if (!token) return { ok: false, error: '工作台 token 缺失' };
if (this.finishPacking) return { ok: false, busy: true };
this.finishPacking = true;
try {
// toastAfter=false:失败提示由调用方自行控制
const res = await this.$http('workbench.finishPack', { token }, '', false);
const invalid = res?.flag === 'failure' || [401, 403].indexOf(Number(res?.code)) !== -1;
if (invalid) {
return { ok: false, error: res?.message || '完成打包失败' };
}
const data = (res && typeof res === 'object' && res.data && typeof res.data === 'object') ? res.data : res;
const finished = !!(data && (data.finished === true || data.finished === 'true' || data.finished === 1));
if (finished) {
this.hasActivePack = false;
}
return {
ok: true,
finished,
error: finished ? '' : (data?.message || '当前无进行中的打包任务')
};
} catch (error) {
console.error('[packMode] 完成打包失败:', error);
return { ok: false, error: error?.message || '完成打包失败' };
} finally {
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 未初始化/禁用时静默失败)
safeDispatchBroadcast(action, payload) {
try {
const task = this.$store.dispatch(`broadcast/${action}`, payload);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn(`[packMode] broadcast/${action} 调用失败:`, error);
});
}
} catch (error) {
console.warn(`[packMode] broadcast/${action} 调用异常:`, error);
}
},
// 归一化广播扫描结果文本
normalizeScanResult(scanResult) {
if (!scanResult) return '';
if (typeof scanResult === 'string') return String(scanResult).trim();
if (typeof scanResult.result === 'string') return String(scanResult.result).trim();
if (Array.isArray(scanResult.result)) {
const firstResult = scanResult.result.find(item => item);
if (typeof firstResult === 'string') return String(firstResult).trim();
if (firstResult && typeof firstResult.data === 'string') return String(firstResult.data).trim();
}
if (typeof scanResult.data === 'string') return String(scanResult.data).trim();
return '';
},
// 读取本地保存的已绑定操作员(bindMember 返回的成员行 id,按 workbenchId 匹配)
loadBoundOperator() {
let saved = null
try {
saved = uni.getStorageSync('workbenchOperator')
} catch (e) {}
if (!saved || typeof saved !== 'object') saved = {}
const sameWorkbench = String(saved?.workbenchId || '') === String(this.workbenchId || '')
this.boundOperator = sameWorkbench
? {
memberId: String(saved?.memberId || ''),
workbenchId: String(saved?.workbenchId || ''),
userId: (saved?.userId === null || saved?.userId === undefined || saved?.userId === '') ? '' : String(saved?.userId),
userName: String(saved?.userName || '')
}
: { memberId: '', workbenchId: String(this.workbenchId || ''), userId: '', userName: '' }
},
// 操作员扫码输入框回车确认
handleOpInputConfirm() {
const code = String(this.opScanCode || '').trim();
if (!code) return;
// 识别成功后输入框回显的是姓名(非工牌码),避免把姓名当码再次查询
if (this.opQueryState === 'identified' && this.opQueryResult && code === this.opQueryResult.name) {
return;
}
this.queryOperatorUser(code);
},
// 操作员相机扫码
handleOpCameraScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
success: (res) => {
const code = String(res?.result || '').trim();
if (!code) return;
this.opScanCode = code;
this.opInputFocus = false;
this.queryOperatorUser(code);
},
fail: () => {}
});
},
// 按 ye4s 登录临时码识别操作员(index.queryUserByToken),成功后进入待绑定态
async queryOperatorUser(token) {
const t = String(token || '').trim();
if (!t) return;
if (this.opQueryState === 'loading' || this.opBinding) return;
this.opQueryState = 'loading';
this.opQueryResult = null;
this.opQueryError = '';
uni.showLoading({ title: '识别中...', mask: true });
try {
// toastAfter=false:失败提示由本方法自行控制,避免拦截器重复弹 toast
const res = await this.$http('index.queryUserByToken', { token: t }, '', false);
if (res?.flag === 'success' || Number(res?.code) === 200) {
const data = (res && typeof res === 'object' && res.data && typeof res.data === 'object') ? res.data : res;
const name = String(data?.real_name ?? data?.realName ?? '').trim();
if (!name) {
this.opQueryState = 'error';
this.opQueryError = '未识别到操作员姓名';
return;
}
const rawWmsId = data?.wms_account_id ?? data?.wmsAccountId;
this.opQueryResult = {
scanToken: t,
name,
wmsAccountId: (rawWmsId === null || rawWmsId === undefined || rawWmsId === '') ? null : Number(rawWmsId)
};
this.opQueryState = 'identified';
// 扫描/输入成功且识别到姓名:输入框直接回显姓名
this.opScanCode = name;
this.opInputFocus = false;
} else {
const code = Number(res?.code);
const msg = String(res?.message || res?.msg || '');
if (code === 404) {
this.opQueryError = '未找到对应用户';
} else if (code === 400) {
this.opQueryError = 'token 不能为空';
} else {
this.opQueryError = msg || '识别失败,请重试';
}
this.opQueryState = 'error';
}
} catch (error) {
console.error('[packMode] 识别操作员失败:', error);
this.opQueryState = 'error';
this.opQueryError = error?.message || '识别失败,请重试';
} finally {
uni.hideLoading();
}
},
// 绑定操作员到本工作台(workbench.bindMember)
async handleBindOperator() {
const ident = this.opQueryResult;
if (!ident) return;
const token = String(this.workbenchToken || '').trim();
if (!token) {
uni.showToast({ title: '工作台 token 缺失', icon: 'none' });
return;
}
if (this.opBinding) return;
this.opBinding = true;
uni.showLoading({ title: '绑定中...', mask: true });
try {
const res = await this.$http('workbench.bindMember', {
userId: ident.wmsAccountId !== null && ident.wmsAccountId !== undefined ? ident.wmsAccountId : null,
userName: ident.name,
token
});
const invalid = res?.flag === 'failure' || Number(res?.code) === 400 || Number(res?.code) === 403;
if (invalid) {
throw new Error(res?.message || '绑定操作员失败');
}
const data = (res && typeof res === 'object' && res.data && typeof res.data === 'object') ? res.data : res;
const memberId = data?.id ?? data?.member_id ?? data?.memberId;
if (memberId === null || memberId === undefined || memberId === '') {
throw new Error('绑定成功但未返回成员ID');
}
// bindMember 返回后本地保存成员行 id(供 removeMember 使用),并展示为当前操作员
this.boundOperator = {
memberId: String(memberId),
workbenchId: String(this.workbenchId || ''),
userId: ident.wmsAccountId !== null && ident.wmsAccountId !== undefined ? String(ident.wmsAccountId) : '',
userName: String(ident.name)
};
uni.setStorageSync('workbenchOperator', this.boundOperator);
// 重置识别待绑定态并关闭弹窗(顶部按钮自动变为“已绑定”)
this.opScanCode = '';
this.opQueryState = '';
this.opQueryResult = null;
this.opQueryError = '';
this.userDrawerOpen = false;
this.opInputFocus = false;
uni.showToast({ title: '操作员绑定成功', icon: 'success' });
} catch (error) {
console.error('[packMode] 绑定操作员失败:', error);
uni.showToast({ title: error?.message || '绑定操作员失败', icon: 'none' });
} finally {
uni.hideLoading();
this.opBinding = false;
}
},
// 移除操作员(workbench.removeMember):按本地保存的成员行 id 直接移除
handleRemoveOperator() {
const memberId = String(this.boundOperator?.memberId || '').trim();
if (!memberId) return;
this.doRemoveOperator(memberId);
},
// 执行移除成员请求
async doRemoveOperator(memberId) {
if (this.opRemoving) return;
const token = String(this.workbenchToken || '').trim();
if (!token) {
uni.showToast({ title: '工作台 token 缺失', icon: 'none' });
return;
}
this.opRemoving = true;
uni.showLoading({ title: '移除中...', mask: true });
try {
// 成员解绑/登出前:若存在进行中的打包任务先上报打包完成(失败不阻断解绑)
await this.ensurePackFinishedBeforeLeave();
const res = await this.$http('workbench.removeMember', {
ids: Number(memberId),
token
});
const invalid = res?.flag === 'failure' || [400, 403, 404].indexOf(Number(res?.code)) !== -1;
if (invalid) {
throw new Error(res?.message || '移除操作员失败');
}
// 清除本地记录,回到可重新绑定态
this.boundOperator = { memberId: '', workbenchId: String(this.workbenchId || ''), userId: '', userName: '' };
uni.setStorageSync('workbenchOperator', this.boundOperator);
this.opScanCode = '';
this.opQueryState = '';
this.opQueryResult = null;
this.opQueryError = '';
// 操作员已移除:清空查询订单/团购核实列表数据,避免残留给下一位操作员
this.orderBarcode = '';
this.orderQueryState = '';
this.orderQueryResult = null;
this.orderQueryError = '';
this.groupVerified = {};
this.groupAutoSubmitted = false;
uni.showToast({ title: '操作员已移除', icon: 'success' });
} catch (error) {
console.error('[packMode] 移除操作员失败:', error);
uni.showToast({ title: error?.message || '移除操作员失败', icon: 'none' });
} finally {
uni.hideLoading();
this.opRemoving = false;
}
},
// 读取本地已绑定信息(wblc 免登录 / 绑定成功均写入 storage)
loadBound(options) {
const cached = uni.getStorageSync('workbenchInfo') || {};
// 优先使用 storage 中的原始信息(UTF-8),避免真机上 URL 中文参数乱码
this.workbenchId = String(cached?.id || options?.workbenchId || '');
this.workbenchName = String(cached?.name || options?.workbenchName || '');
this.workbenchToken = String(cached?.token || uni.getStorageSync('workbenchToken') || '');
this.warehouseId = String(cached?.warehouse_id ?? cached?.warehouseId ?? '');
this.workbenchStatus = cached?.status ?? '';
this.workbenchType = String(cached?.type || '');
this.bound = !!this.workbenchToken;
},
// 重新拉取工作台信息:进入打包模式时校验本地工作台 token 并刷新工作台信息
async fetchWorkbenchInfo() {
const token = String(this.workbenchToken || '').trim();
if (!token) return;
if (this.infoRefreshing) return;
this.infoRefreshing = true;
try {
const res = await this.$http('workbench.getWorkbenchInfo', { token });
const invalid = res?.flag === 'failure' || Number(res?.code) === 400 || Number(res?.code) === 403;
if (invalid) {
console.warn('[packMode] 工作台 token 已失效,退出工作台模式:', res?.message || res?.code);
await this.exitWorkbench(true);
return;
}
const data = (res && typeof res === 'object' && res.data && typeof res.data === 'object')
? res.data
: res;
if (!data || typeof data !== 'object') {
await this.exitWorkbench(true);
return;
}
const detail = {
id: data?.workbench_id ?? data?.workbenchId ?? data?.id ?? this.workbenchId,
name: String(data?.name || this.workbenchName),
warehouse_id: data?.warehouse_id ?? data?.warehouseId ?? '',
status: data?.status ?? '',
type: String(data?.type || ''),
remark: String(data?.remark || ''),
token
};
// 刷新页面展示与本地缓存
this.workbenchId = String(detail.id);
this.workbenchName = detail.name;
this.warehouseId = String(detail.warehouse_id ?? '');
this.workbenchStatus = detail.status ?? '';
this.workbenchType = detail.type;
uni.setStorageSync('workbenchInfo', detail);
console.log('[packMode] 工作台信息刷新成功:', detail);
} catch (error) {
// 网络/其它异常:保留本地缓存信息继续使用,仅提示,不清除会话
console.warn('[packMode] 工作台信息刷新失败,沿用本地缓存:', error);
uni.showToast({ title: '工作台信息刷新失败', icon: 'none' });
} finally {
this.infoRefreshing = false;
}
},
// 退出工作台模式(用户主动):确认后清除工作台 token 并返回登录页
handleBack() {
uni.showModal({
title: '退出工作台模式',
content: '退出后将清除本地工作台登录记录,需要重新扫码(wblc 开头登录码)才能进入打包模式。',
confirmText: '退出',
cancelText: '取消',
success: async (res) => {
if (!res.confirm) return;
// 退出工作台前:若存在进行中的打包任务先上报打包完成
await this.ensurePackFinishedBeforeLeave();
await this.exitWorkbench(false);
}
});
},
// 清除工作台 token 并返回登录页:工作台会话(主 token 即工作台 token)时一并清除主登录态
async exitWorkbench(withToast = false) {
const wbToken = String(uni.getStorageSync('workbenchToken') || '').trim();
const mainToken = String(uni.getStorageSync('token') || '').trim();
uni.removeStorageSync('workbenchToken');
uni.removeStorageSync('workbenchInfo');
if (withToast) {
uni.showToast({ title: '工作台登录已失效,请重新登录', icon: 'none' });
}
if (wbToken && mainToken === wbToken) {
try {
// logout 内部 clearSession(store) 会清除主 token / isLogin / userInfo 等并跳回登录页
await this.$store.dispatch('logout');
return;
} catch (error) {
console.warn('[packMode] 退出工作台模式失败,兜底跳转登录页:', error);
}
}
uni.reLaunch({ url: '/pages/login/index' });
}
}
}
</script>
<style lang="scss" scoped>
.pack-mode-page {
width: 100vw;
min-height: 100vh;
background: #f5f6f7;
box-sizing: border-box;
}
.status-bar {
height: var(--status-bar-height, 0px);
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 144rpx;
padding: 16rpx 24rpx;
box-sizing: border-box;
background: #ffffff;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.header-left {
display: flex;
align-items: center;
width: 260rpx;
}
.header-left__text {
margin-left: 8rpx;
font-size: 34rpx;
color: #606266;
}
.header-title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
line-height: 1.15;
}
.header-center {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
min-width: 0;
}
.header-subtitle {
margin-top: 4rpx;
font-size: 34rpx;
color: #303133;
line-height: 1.25;
text-align: center;
word-break: break-all;
max-width: 100%;
}
.header-right {
width: 260rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.user-info-btn {
display: flex;
align-items: center;
gap: 6rpx;
padding: 8rpx 16rpx;
border-radius: 8rpx;
background: #2979ff;
max-width: 248rpx;
}
.user-info-btn--bound {
background: #18b566;
}
.user-info-btn__text {
font-size: 34rpx;
color: #ffffff;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.content {
padding: 0 24rpx 24rpx;
box-sizing: border-box;
}
/* 已绑定态顶部工作台卡并入 header,以下旧样式不再使用 */
.state-card {
background: #ffffff;
border-radius: 20rpx;
padding: 32rpx 28rpx;
box-sizing: border-box;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.state-badge {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 24rpx;
}
.state-badge__text {
font-size: 36rpx;
font-weight: 600;
color: #303133;
}
.info-block {
display: flex;
flex-direction: column;
gap: 20rpx;
border-top: 1rpx solid #f0f0f0;
padding-top: 24rpx;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20rpx;
}
.info-label {
font-size: 26rpx;
color: #909399;
flex-shrink: 0;
}
.info-value {
font-size: 26rpx;
color: #303133;
text-align: right;
word-break: break-all;
}
.info-value--mono {
font-family: monospace;
font-size: 24rpx;
}
/* ===== 查询订单 ===== */
.order-query-card {
margin-top: 24rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx;
box-sizing: border-box;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.order-query__scan-row {
display: flex;
align-items: center;
gap: 8rpx;
background: #f5f6f7;
border: 2rpx solid #e4e7ed;
border-radius: 12rpx;
padding: 0 8rpx 0 20rpx;
box-sizing: border-box;
}
.order-query__input {
flex: 1;
height: 88rpx;
font-size: 34rpx;
color: #303133;
}
.order-query__loading {
margin-top: 24rpx;
padding: 24rpx 0;
display: flex;
justify-content: center;
align-items: center;
}
.order-query__error {
margin-top: 24rpx;
background: #fef0f0;
border-radius: 16rpx;
padding: 24rpx 20rpx;
box-sizing: border-box;
}
.order-query__error-text {
font-size: 34rpx;
color: #f56c6c;
text-align: center;
line-height: 1.5;
}
.order-query__head {
margin-top: 24rpx;
display: flex;
align-items: center;
gap: 16rpx;
border-bottom: 1rpx solid #f0f0f0;
padding-bottom: 16rpx;
}
.order-result-waybill {
flex: 1;
font-size: 34rpx;
font-weight: 600;
color: #303133;
word-break: break-all;
}
.order-result-tag {
flex-shrink: 0;
padding: 6rpx 18rpx;
border-radius: 999rpx;
font-size: 28rpx;
}
.order-result-tag--sandan {
background: #e8f8ef;
color: #18b566;
}
.order-result-tag--tuangou {
background: #e8f0fe;
color: #2979ff;
}
.order-summary {
margin-top: 20rpx;
background: #f8f9fb;
border-radius: 16rpx;
padding: 16rpx 20rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 8rpx;
}
.order-summary__row {
display: flex;
align-items: center;
gap: 16rpx;
}
.order-summary__label {
font-size: 30rpx;
color: #909399;
flex-shrink: 0;
}
.order-summary__value {
flex: 1;
font-size: 34rpx;
font-weight: 600;
color: #303133;
word-break: break-all;
min-width: 0;
}
.order-summary__extra {
flex-shrink: 0;
font-size: 30rpx;
color: #2979ff;
}
.order-summary__num {
font-size: 36rpx;
font-weight: 600;
color: #2979ff;
}
.order-block {
margin-top: 20rpx;
background: #f8f9fb;
border-radius: 16rpx;
padding: 20rpx;
box-sizing: border-box;
}
.order-block__title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
margin-bottom: 12rpx;
}
.order-item {
display: flex;
align-items: center;
gap: 16rpx;
background: #ffffff;
border-radius: 12rpx;
padding: 16rpx;
margin-top: 12rpx;
}
.order-item__img {
width: 96rpx;
height: 96rpx;
border-radius: 12rpx;
background: #f0f1f4;
flex-shrink: 0;
}
.order-item__img--placeholder {
display: flex;
align-items: center;
justify-content: center;
}
.order-item__info {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.order-item__name {
font-size: 34rpx;
font-weight: 600;
color: #303133;
word-break: break-all;
}
.order-item__barcode {
font-size: 34rpx;
color: #909399;
word-break: break-all;
}
.order-item__qty {
flex-shrink: 0;
font-size: 36rpx;
font-weight: 600;
color: #2979ff;
}
.order-empty {
padding: 24rpx 0;
font-size: 30rpx;
color: #909399;
text-align: center;
}
/* 团购商品核实区 */
.group-verify {
margin-top: 20rpx;
background: #fffbea;
border-radius: 16rpx;
padding: 16rpx 20rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.group-verify__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.group-verify__head ::v-deep .u-button {
width: 128rpx !important;
height: 76rpx !important;
padding: 0 !important;
margin: 0 !important;
border-radius: 10rpx;
}
.group-verify__head ::v-deep .u-button__text {
font-size: 26rpx !important;
}
.group-verify__progress {
font-size: 30rpx;
font-weight: 600;
color: #2979ff;
}
/* 商品行右侧:数量 + 核实状态 */
.order-item__right {
flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 6rpx;
}
.order-item__state {
font-size: 26rpx;
color: #c0c4cc;
}
.order-item__state--done {
color: #18b566;
}
.order-item--verified {
background: #43a047;
}
.order-item--verified .order-item__name,
.order-item--verified .order-item__barcode,
.order-item--verified .order-item__qty,
.order-item--verified .order-item__state {
color: #ffffff;
}
.order-item--verified .order-item__img {
background: rgba(255, 255, 255, 0.2);
}
.order-item--verified .order-item__state {
font-weight: 600;
}
.action-area {
margin-top: 48rpx;
display: flex;
flex-direction: column;
gap: 20rpx;
}
.operator-line {
display: flex;
align-items: center;
gap: 14rpx;
}
.operator-line__name {
font-size: 34rpx;
font-weight: 600;
color: #303133;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.operator-line__status {
flex-shrink: 0;
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 34rpx;
}
.operator-line__status--bound {
background: #e8f8ef;
color: #18b566;
}
.operator-line__remove {
display: flex;
align-items: center;
gap: 6rpx;
flex-shrink: 0;
padding: 10rpx 20rpx;
border-radius: 8rpx;
background: #fef0f0;
}
.operator-line__remove-text {
font-size: 34rpx;
color: #f56c6c;
}
.operator-ident-card {
margin-top: 24rpx;
background: #f0f7ff;
border-radius: 16rpx;
padding: 20rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: stretch;
gap: 20rpx;
}
/* ===== 操作员弹窗 ===== */
.user-drawer {
width: 560rpx;
box-sizing: border-box;
background: #ffffff;
border-radius: 16rpx;
display: flex;
flex-direction: column;
max-height: 75vh;
overflow: hidden;
}
.user-drawer__header {
padding: 48rpx 28rpx 16rpx;
flex-shrink: 0;
}
.user-drawer__title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
text-align: center;
}
.user-drawer__body {
flex: 1;
min-height: 0;
padding: 20rpx 28rpx 40rpx;
box-sizing: border-box;
overflow-y: auto;
}
.scan-section {
background: #f5f6f7;
border-radius: 16rpx;
padding: 20rpx;
box-sizing: border-box;
}
.scan-row {
display: flex;
align-items: center;
gap: 8rpx;
background: #ffffff;
border: 2rpx solid #e4e7ed;
border-radius: 12rpx;
padding: 0 8rpx 0 20rpx;
box-sizing: border-box;
}
.scan-input {
flex: 1;
height: 88rpx;
font-size: 34rpx;
color: #303133;
}
.camera-btn {
width: 76rpx;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
}
.scan-tip {
display: flex;
align-items: center;
gap: 8rpx;
margin-top: 16rpx;
}
.scan-tip__text {
font-size: 24rpx;
color: #909399;
}
.query-state {
margin-top: 32rpx;
padding: 48rpx 24rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
}
.query-state--loading {
min-height: 200rpx;
justify-content: center;
}
.query-state--error {
background: #fef0f0;
border-radius: 16rpx;
}
.query-state__error-text {
font-size: 34rpx;
color: #f56c6c;
text-align: center;
line-height: 1.5;
}
.result-card {
margin-top: 32rpx;
background: #f0f7ff;
border-radius: 16rpx;
padding: 12rpx 24rpx;
box-sizing: border-box;
}
.result-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 22rpx 0;
gap: 20rpx;
}
.result-label {
font-size: 28rpx;
color: #909399;
flex-shrink: 0;
}
.result-value {
font-size: 28rpx;
font-weight: 600;
color: #303133;
word-break: break-all;
text-align: right;
}
.result-divider {
height: 1rpx;
background: #e4e7ed;
}
</style>