feat: optimize warehouse return scan flow

This commit is contained in:
wushumin
2026-06-06 16:56:40 +08:00
parent 22b18e2dac
commit d13db60618
2 changed files with 76 additions and 66 deletions

View File

@@ -24,7 +24,6 @@ const scanValue = ref("");
const matchedInboundNo = ref("");
const internalTagNo = ref("");
const inboundAttachments = ref<AdminFileAsset[]>([]);
const materialQr = ref("");
const expressCompany = ref("");
const returnTrackingNo = ref("");
const context = ref<AdminWarehouseWorkbenchContext | null>(null);
@@ -57,10 +56,11 @@ const returnFlowEnded = computed(() =>
Boolean(context.value?.transfer_flow?.return_shipped_at),
);
const canReturnShip = computed(() => Boolean(context.value?.transfer_flow?.return_confirmed_at) && !returnFlowEnded.value);
const isPendingReturnOrder = computed(() => context.value?.order_info.order_status === "report_published");
const outboundActionText = computed(() => {
if (actionLoading.value) return "提交中";
if (returnFlowEnded.value && !context.value?.next_action) return "寄回已完成";
if (canReturnShip.value && !context.value?.next_action) return "填写回寄信息";
if ((canReturnShip.value || isPendingReturnOrder.value) && !context.value?.next_action) return "填写回寄信息";
return "确认操作";
});
@@ -74,7 +74,6 @@ function chooseMode(next: WarehouseMode) {
matchedInboundNo.value = "";
internalTagNo.value = "";
inboundAttachments.value = [];
materialQr.value = "";
expressCompany.value = "";
returnTrackingNo.value = "";
context.value = null;
@@ -95,7 +94,6 @@ function applyReturnShippedPayload(payload: ReturnShippedPayload | AdminWarehous
if (nextContext) {
context.value = nextContext;
}
materialQr.value = "";
expressCompany.value = "";
returnTrackingNo.value = "";
}
@@ -306,14 +304,26 @@ function closeInboundVideo() {
async function lookupOutbound() {
loading.value = true;
try {
let zhongjianContext: AdminWarehouseWorkbenchContext | null = null;
try {
context.value = await adminApi.lookupZhongjianWarehouseTransfer(scanValue.value.trim());
zhongjianContext = await adminApi.lookupZhongjianWarehouseTransfer(scanValue.value.trim());
} catch {
zhongjianContext = null;
}
if (zhongjianContext) {
context.value = zhongjianContext;
if (isPendingReturnOrder.value && !context.value.next_action) {
await enterReturnShippingFlow();
return;
}
showInfoToast("已识别中检流转");
return;
} catch (zhongjianError) {
context.value = await adminApi.lookupWarehouseReturn(scanValue.value.trim());
showInfoToast("已打开寄回流程");
}
context.value = await adminApi.lookupWarehouseReturn(scanValue.value.trim());
showInfoToast("已打开寄回流程");
await enterReturnShippingFlow();
} catch (error) {
context.value = null;
showErrorToast(error, "出库查询失败");
@@ -322,17 +332,41 @@ async function lookupOutbound() {
}
}
function openReturnReportReview() {
const reportId = Number(context.value?.report_info?.id || context.value?.return_verification?.report_id || 0);
function openReturnShipping(tagNo: string) {
uni.navigateTo({ url: `/pages/return-shipping/index?internal_tag_no=${encodeURIComponent(tagNo)}` });
}
async function enterReturnShippingFlow() {
const tagNo = scanValue.value.trim();
if (!reportId || !tagNo) {
showInfoToast("未找到可核对的报告");
const reportId = Number(context.value?.report_info?.id || 0);
if (!tagNo) {
showInfoToast("请先扫描内部流转挂牌编号");
return;
}
if (returnFlowEnded.value) {
showInfoToast("寄回流程已完成");
return;
}
if (canReturnShip.value) {
openReturnShipping(tagNo);
return;
}
if (!isPendingReturnOrder.value) {
showInfoToast("当前订单不处于待寄回状态");
return;
}
if (!reportId) {
showInfoToast("未找到已发布报告");
return;
}
uni.navigateTo({
url: `/pages/report/detail?id=${reportId}&return_internal_tag_no=${encodeURIComponent(tagNo)}`,
context.value = await adminApi.confirmWarehouseReturnReport({
internal_tag_no: tagNo,
report_id: reportId,
});
showInfoToast("已确认回寄,请填写运单");
openReturnShipping(tagNo);
}
async function submitOutboundAction() {
@@ -356,24 +390,7 @@ async function submitOutboundAction() {
showInfoToast("寄回流程已完成");
return;
}
if (context.value.order_info.service_provider === "zhongjian") {
openReturnReportReview();
return;
}
if (!canReturnShip.value) {
if (!materialQr.value.trim()) {
showInfoToast("请扫描验真吊牌");
return;
}
context.value = await adminApi.verifyWarehouseReturnMaterialTag({
internal_tag_no: scanValue.value.trim(),
qr_input: materialQr.value.trim(),
});
showInfoToast("验真吊牌匹配通过,请核对报告");
openReturnReportReview();
return;
}
uni.navigateTo({ url: `/pages/return-shipping/index?internal_tag_no=${encodeURIComponent(scanValue.value.trim())}` });
await enterReturnShippingFlow();
} catch (error) {
showErrorToast(error, "出库操作失败");
} finally {
@@ -421,16 +438,6 @@ function scanInternalTagInput() {
});
}
function scanMaterialQr() {
uni.scanCode({
scanType: ["barCode", "qrCode"],
success: (result) => {
materialQr.value = String(result.result || "").trim();
},
fail: () => showInfoToast("当前环境暂不支持扫码,可手动输入"),
});
}
onLoad(() => {
uni.$on("warehouse-return-shipped", handleReturnShipped);
});
@@ -516,14 +523,10 @@ onUnload(() => {
<view v-if="mode === 'outbound' && context" class="card">
<view class="card-title">出库动作</view>
<view class="card-desc">
{{ context.next_action_text || (context.order_info.service_provider === 'zhongjian' ? '确认中检报告后回寄' : '确认验真吊牌后回寄') }}
{{ returnFlowEnded && !context.next_action ? '寄回流程已完成' : !context.next_action && (canReturnShip || isPendingReturnOrder) ? '待寄回订单可直接填写回寄物流' : context.next_action_text || '暂无可执行出库动作' }}
</view>
<view v-if="context.order_info.service_provider !== 'zhongjian' && !canReturnShip && !returnFlowEnded && !context.next_action" class="scan-control">
<input v-model="materialQr" class="field scan-input" placeholder="验真吊牌二维码" />
<button class="btn scan-button" @click="scanMaterialQr">扫码</button>
</view>
<view v-if="canReturnShip && !context.next_action" class="ship-fields">
<view class="card-desc">报告已确认可进入回寄信息页填写快递单号并上传打包装箱附件</view>
<view v-if="(canReturnShip || isPendingReturnOrder) && !returnFlowEnded && !context.next_action" class="ship-fields">
<view class="card-desc">可进入回寄信息页填写快递单号并上传打包装箱附件</view>
</view>
<view v-if="returnFlowEnded && !context.next_action" class="ship-fields">
<view class="card-desc">寄回流程已完成无需重复填写回寄信息</view>