All checks were successful
Build and Deploy Front / deploy (push) Successful in 4m11s
地图支持全屏漫游、美国邮编港口与中国城市口岸图层;同步入出库扫码与培训手册等改动。 Co-authored-by: Cursor <cursoragent@cursor.com>
572 lines
16 KiB
Vue
572 lines
16 KiB
Vue
<template>
|
||
<div class="h5-ops">
|
||
<H5OpsPageHeader :title="t('h5Admin.ops.putaway')" @change="onWarehouseChange" />
|
||
|
||
<div class="h5-ops__scan-row">
|
||
<H5ScanInput
|
||
ref="scanRef"
|
||
v-model="scanCode"
|
||
:placeholder="t('h5Admin.ops.putaway.scanPlaceholder')"
|
||
:sheet-title="t('h5Admin.ops.cameraSheetTitle')"
|
||
:sheet-hint="t('h5Admin.ops.cameraSheetHint')"
|
||
:close-label="t('h5Admin.ops.cameraClose')"
|
||
:torch-on-label="t('h5Admin.ops.torchOn')"
|
||
:torch-off-label="t('h5Admin.ops.torchOff')"
|
||
@enter="lookup"
|
||
@detect="onDetect"
|
||
@error="onScanError"
|
||
/>
|
||
<button
|
||
type="button"
|
||
class="h5-ops__primary"
|
||
:disabled="lookingUp || submitting"
|
||
@click="lookup"
|
||
>
|
||
{{ t('h5Admin.ops.putaway.lookup') }}
|
||
</button>
|
||
</div>
|
||
|
||
<p v-if="feedbackMessage" class="h5-ops__feedback" :class="`is-${feedbackType}`">
|
||
{{ feedbackMessage }}
|
||
</p>
|
||
|
||
<section v-if="notice" class="h5-ops__panel h5-putaway__panel">
|
||
<p class="h5-ops__waybill">{{ notice.noticeNo }}</p>
|
||
<p class="h5-ops__meta">
|
||
{{ notice.customerName || notice.customerCode || '-' }}
|
||
· {{ notice.boxCount }} {{ t('warehouse.inbound.box') }}
|
||
· {{ notice.plannedQty }} pcs
|
||
</p>
|
||
|
||
<div class="h5-putaway__bulk">
|
||
<label>{{ t('h5Admin.ops.putaway.applyBin') }}</label>
|
||
<a-select
|
||
v-model="bulkBinId"
|
||
:options="binOptions"
|
||
allow-search
|
||
allow-clear
|
||
:placeholder="t('h5Admin.ops.putaway.selectBin')"
|
||
@change="applyBinToAll"
|
||
/>
|
||
</div>
|
||
|
||
<div v-for="box in boxes" :key="box.boxId" class="h5-putaway__box">
|
||
<h3>
|
||
{{ t('warehouse.inbound.box') }} {{ box.boxSeqNo || '-' }}
|
||
<span v-if="box.markBoxNo">({{ box.markBoxNo }})</span>
|
||
</h3>
|
||
<article v-for="line in box.lines" :key="line.lineId" class="h5-putaway__line">
|
||
<strong>{{ line.skuCode }}</strong>
|
||
<div class="h5-putaway__line-row">
|
||
<span>{{ t('h5Admin.ops.putaway.plannedQty') }} {{ line.plannedQty }}</span>
|
||
<label>
|
||
{{ t('h5Admin.ops.putaway.receivedQty') }}
|
||
<input
|
||
v-model.number="line.receivedQty"
|
||
type="number"
|
||
inputmode="numeric"
|
||
min="0"
|
||
/>
|
||
</label>
|
||
</div>
|
||
<label class="h5-putaway__bin">
|
||
{{ t('h5Admin.ops.putaway.bin') }}
|
||
<a-select
|
||
v-model="line.binLocationId"
|
||
:options="binOptions"
|
||
allow-search
|
||
allow-clear
|
||
:disabled="!(line.receivedQty > 0)"
|
||
:placeholder="t('h5Admin.ops.putaway.selectBin')"
|
||
/>
|
||
</label>
|
||
</article>
|
||
</div>
|
||
|
||
<button
|
||
type="button"
|
||
class="h5-ops__primary h5-putaway__submit"
|
||
:disabled="submitting || lookingUp"
|
||
@click="submit"
|
||
>
|
||
{{ t('h5Admin.ops.putaway.confirm') }}
|
||
</button>
|
||
</section>
|
||
|
||
<section class="h5-ops__recent">
|
||
<div class="h5-ops__queue-head">
|
||
<h2>{{ t('h5Admin.ops.putaway.pending') }}</h2>
|
||
<button type="button" @click="loadPending">{{ t('h5Admin.ops.refresh') }}</button>
|
||
</div>
|
||
<a-spin :loading="listLoading" style="width: 100%">
|
||
<p v-if="!listLoading && !pendingRows.length" class="h5-ops__empty">
|
||
{{ t('h5Admin.ops.putaway.emptyPending') }}
|
||
</p>
|
||
<article
|
||
v-for="row in pendingRows"
|
||
:key="row.id"
|
||
class="h5-ops__card"
|
||
:class="{ 'is-active': notice?.id === row.id }"
|
||
@click="loadById(row)"
|
||
>
|
||
<strong>{{ row.noticeNo }}</strong>
|
||
<span>{{ row.customerName || '-' }} · {{ row.boxCount }} box · {{ row.plannedQty }} pcs</span>
|
||
<em>{{ row.receiptStatus }} · {{ row.createTime }}</em>
|
||
</article>
|
||
</a-spin>
|
||
</section>
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { nextTick, onMounted, ref } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import H5ScanInput from '@/components/h5/H5ScanInput.vue';
|
||
import H5OpsPageHeader from './H5OpsPageHeader.vue';
|
||
import {
|
||
confirmWarehouseInboundReceive,
|
||
getWarehouseBinLocationList,
|
||
getWarehouseInboundDetail,
|
||
getWarehouseInboundList,
|
||
lookupWarehouseInboundByScan,
|
||
} from '@/api/warehouse';
|
||
import { useCurrentWarehouseStore } from '@/store';
|
||
import { useOperationScanFeedback } from '@/composables/useOperationScanFeedback';
|
||
import { hasPermission } from '@/utils/rbac-permission';
|
||
import { formatDateTime, normalizeListRow, pickField } from '@/utils/warehouseListMapper';
|
||
|
||
defineOptions({ name: 'H5AdminOpsPutaway' });
|
||
|
||
type PutawayLine = {
|
||
lineId: number;
|
||
skuCode: string;
|
||
plannedQty: number;
|
||
receivedQty: number;
|
||
binLocationId?: number;
|
||
};
|
||
|
||
type PutawayBox = {
|
||
boxId: number;
|
||
boxSeqNo: string;
|
||
markBoxNo: string;
|
||
lines: PutawayLine[];
|
||
};
|
||
|
||
type NoticeHead = {
|
||
id: number;
|
||
customerId: number;
|
||
warehouseId: number;
|
||
noticeNo: string;
|
||
customerName: string;
|
||
customerCode: string;
|
||
boxCount: number;
|
||
plannedQty: number;
|
||
};
|
||
|
||
type PendingRow = {
|
||
id: number;
|
||
customerId: number;
|
||
noticeNo: string;
|
||
customerName: string;
|
||
boxCount: number;
|
||
plannedQty: number;
|
||
receiptStatus: string;
|
||
createTime: string;
|
||
};
|
||
|
||
const { t } = useI18n();
|
||
const scanRef = ref<InstanceType<typeof H5ScanInput> | null>(null);
|
||
const currentWarehouseStore = useCurrentWarehouseStore();
|
||
const {
|
||
feedbackType,
|
||
feedbackMessage,
|
||
clearFeedback,
|
||
showError,
|
||
showRequestError,
|
||
showSuccess,
|
||
showWarning,
|
||
} = useOperationScanFeedback('h5Putaway');
|
||
|
||
const scanCode = ref('');
|
||
const lookingUp = ref(false);
|
||
const submitting = ref(false);
|
||
const listLoading = ref(false);
|
||
const notice = ref<NoticeHead | null>(null);
|
||
const boxes = ref<PutawayBox[]>([]);
|
||
const binOptions = ref<Array<{ label: string; value: number }>>([]);
|
||
const bulkBinId = ref<number | undefined>();
|
||
const pendingRows = ref<PendingRow[]>([]);
|
||
|
||
function canMutate() {
|
||
return (
|
||
hasPermission('Warehouse.InboundNotice.ConfirmReceive')
|
||
|| hasPermission('Warehouse.InboundNotice.Save')
|
||
);
|
||
}
|
||
|
||
function refocus() {
|
||
nextTick(() => scanRef.value?.focus());
|
||
}
|
||
|
||
function resetForm() {
|
||
notice.value = null;
|
||
boxes.value = [];
|
||
bulkBinId.value = undefined;
|
||
}
|
||
|
||
function applyDetail(raw: Record<string, unknown>) {
|
||
const row = normalizeListRow(raw);
|
||
const whId = Number(pickField(row, 'warehouseId', 'WarehouseId') || 0);
|
||
notice.value = {
|
||
id: Number(pickField(row, 'id', 'Id') || 0),
|
||
customerId: Number(pickField(row, 'customerId', 'CustomerId') || 0),
|
||
warehouseId: whId,
|
||
noticeNo: String(pickField(row, 'noticeNo', 'NoticeNo') || ''),
|
||
customerName: String(pickField(row, 'customerName', 'CustomerName') || ''),
|
||
customerCode: String(pickField(row, 'customerCode', 'CustomerCode') || ''),
|
||
boxCount: Number(pickField(row, 'boxCount', 'BoxCount') || 0),
|
||
plannedQty: Number(pickField(row, 'plannedQty', 'PlannedQty') || 0),
|
||
};
|
||
|
||
const boxesRaw = pickField(row, 'boxes', 'Boxes');
|
||
const boxList = Array.isArray(boxesRaw) ? boxesRaw : [];
|
||
boxes.value = boxList.map((boxRaw: Record<string, unknown>) => {
|
||
const box = normalizeListRow(boxRaw);
|
||
const linesRaw = pickField(box, 'lines', 'Lines');
|
||
const lines = Array.isArray(linesRaw) ? linesRaw : [];
|
||
return {
|
||
boxId: Number(pickField(box, 'id', 'Id') || 0),
|
||
boxSeqNo: String(pickField(box, 'boxSeqNo', 'BoxSeqNo') || ''),
|
||
markBoxNo: String(pickField(box, 'markBoxNo', 'MarkBoxNo') || ''),
|
||
lines: lines.map((lineRaw: Record<string, unknown>) => {
|
||
const line = normalizeListRow(lineRaw);
|
||
const planned = Number(pickField(line, 'plannedQty', 'PlannedQty') || 0);
|
||
const received = pickField<number>(line, 'receivedQty', 'ReceivedQty');
|
||
const binId = pickField<number>(line, 'binLocationId', 'BinLocationId');
|
||
return {
|
||
lineId: Number(pickField(line, 'id', 'Id') || 0),
|
||
skuCode: String(pickField(line, 'skuCode', 'SkuCode') || '-'),
|
||
plannedQty: planned,
|
||
receivedQty: received != null ? Number(received) : planned,
|
||
binLocationId: binId != null && Number(binId) > 0 ? Number(binId) : undefined,
|
||
};
|
||
}),
|
||
};
|
||
});
|
||
}
|
||
|
||
async function loadBinOptions(warehouseId?: number) {
|
||
if (!warehouseId) {
|
||
binOptions.value = [];
|
||
return;
|
||
}
|
||
try {
|
||
const { items } = await getWarehouseBinLocationList({
|
||
warehouseId,
|
||
isEnabled: true,
|
||
});
|
||
binOptions.value = (items || []).map((b: Record<string, unknown>) => {
|
||
const row = normalizeListRow(b);
|
||
const code = String(pickField(row, 'binCode', 'BinCode') || '');
|
||
const name = String(pickField(row, 'binName', 'BinName') || '');
|
||
return {
|
||
label: name ? `${code} - ${name}` : code,
|
||
value: Number(pickField(row, 'id', 'Id') || 0),
|
||
};
|
||
});
|
||
} catch {
|
||
binOptions.value = [];
|
||
}
|
||
}
|
||
|
||
function applyBinToAll(binId?: number) {
|
||
const id = binId != null ? Number(binId) : undefined;
|
||
bulkBinId.value = id && id > 0 ? id : undefined;
|
||
if (!bulkBinId.value) return;
|
||
for (const box of boxes.value) {
|
||
for (const line of box.lines) {
|
||
if (line.receivedQty > 0) {
|
||
line.binLocationId = bulkBinId.value;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
async function onDetect(code: string) {
|
||
scanCode.value = code;
|
||
await lookup();
|
||
}
|
||
|
||
function onScanError(message: string) {
|
||
showError(message);
|
||
}
|
||
|
||
async function onWarehouseChange() {
|
||
clearFeedback();
|
||
scanCode.value = '';
|
||
resetForm();
|
||
await loadBinOptions(currentWarehouseStore.warehouseId);
|
||
await loadPending();
|
||
refocus();
|
||
}
|
||
|
||
async function lookup() {
|
||
if (!canMutate()) {
|
||
showWarning(t('h5Admin.ops.noPermission'));
|
||
return;
|
||
}
|
||
const code = scanCode.value.trim();
|
||
if (!code) {
|
||
showWarning(t('h5Admin.ops.putaway.codeRequired'));
|
||
refocus();
|
||
return;
|
||
}
|
||
const warehouseId = currentWarehouseStore.warehouseId;
|
||
if (!warehouseId) {
|
||
showWarning(t('warehouse.common.noCurrentWarehouse'));
|
||
return;
|
||
}
|
||
|
||
lookingUp.value = true;
|
||
clearFeedback();
|
||
try {
|
||
const detail = (await lookupWarehouseInboundByScan({
|
||
code,
|
||
warehouseId,
|
||
})) as Record<string, unknown>;
|
||
applyDetail(detail || {});
|
||
const noticeWh = notice.value?.warehouseId;
|
||
if (noticeWh && noticeWh !== warehouseId) {
|
||
showWarning(t('h5Admin.ops.putaway.loadFailed'));
|
||
resetForm();
|
||
return;
|
||
}
|
||
await loadBinOptions(warehouseId);
|
||
scanCode.value = '';
|
||
} catch (e: any) {
|
||
resetForm();
|
||
showRequestError(e, t('h5Admin.ops.putaway.loadFailed'));
|
||
refocus();
|
||
} finally {
|
||
lookingUp.value = false;
|
||
}
|
||
}
|
||
|
||
async function loadById(row: PendingRow) {
|
||
if (!canMutate()) {
|
||
showWarning(t('h5Admin.ops.noPermission'));
|
||
return;
|
||
}
|
||
lookingUp.value = true;
|
||
clearFeedback();
|
||
try {
|
||
const detail = (await getWarehouseInboundDetail(
|
||
row.id,
|
||
row.customerId > 0 ? row.customerId : undefined,
|
||
)) as Record<string, unknown>;
|
||
applyDetail(detail || {});
|
||
await loadBinOptions(currentWarehouseStore.warehouseId || notice.value?.warehouseId);
|
||
} catch (e: any) {
|
||
showRequestError(e, t('h5Admin.ops.putaway.loadFailed'));
|
||
} finally {
|
||
lookingUp.value = false;
|
||
}
|
||
}
|
||
|
||
async function loadPending() {
|
||
const warehouseId = currentWarehouseStore.warehouseId;
|
||
if (!warehouseId) {
|
||
pendingRows.value = [];
|
||
return;
|
||
}
|
||
listLoading.value = true;
|
||
try {
|
||
const [forecasted, received] = await Promise.all([
|
||
getWarehouseInboundList({
|
||
page: 1,
|
||
pageSize: 30,
|
||
warehouseId,
|
||
receiptStatus: 'forecasted',
|
||
}),
|
||
getWarehouseInboundList({
|
||
page: 1,
|
||
pageSize: 30,
|
||
warehouseId,
|
||
receiptStatus: 'received',
|
||
}),
|
||
]);
|
||
const mapRow = (raw: Record<string, unknown>): PendingRow => {
|
||
const row = normalizeListRow(raw);
|
||
return {
|
||
id: Number(pickField(row, 'id', 'Id') || 0),
|
||
customerId: Number(pickField(row, 'customerId', 'CustomerId') || 0),
|
||
noticeNo: String(pickField(row, 'noticeNo', 'NoticeNo') || '-'),
|
||
customerName: String(pickField(row, 'customerName', 'CustomerName') || ''),
|
||
boxCount: Number(pickField(row, 'boxCount', 'BoxCount') || 0),
|
||
plannedQty: Number(pickField(row, 'plannedQty', 'PlannedQty') || 0),
|
||
receiptStatus: String(pickField(row, 'receiptStatus', 'ReceiptStatus') || ''),
|
||
createTime: formatDateTime(pickField(row, 'createTime', 'CreateTime')),
|
||
};
|
||
};
|
||
const merged = [...(forecasted.items || []), ...(received.items || [])]
|
||
.map((x) => mapRow(x as Record<string, unknown>))
|
||
.filter((x) => x.id > 0);
|
||
merged.sort((a, b) => (a.createTime < b.createTime ? 1 : -1));
|
||
pendingRows.value = merged.slice(0, 30);
|
||
} catch (e: any) {
|
||
pendingRows.value = [];
|
||
showRequestError(e, t('h5Admin.ops.putaway.loadFailed'));
|
||
} finally {
|
||
listLoading.value = false;
|
||
}
|
||
}
|
||
|
||
async function submit() {
|
||
if (!canMutate()) {
|
||
showWarning(t('h5Admin.ops.noPermission'));
|
||
return;
|
||
}
|
||
const head = notice.value;
|
||
if (!head?.id) return;
|
||
|
||
for (const box of boxes.value) {
|
||
for (const line of box.lines) {
|
||
if (line.receivedQty < 0) {
|
||
showWarning(t('h5Admin.ops.putaway.qtyInvalid'));
|
||
return;
|
||
}
|
||
if (line.receivedQty > 0 && !line.binLocationId) {
|
||
showWarning(t('h5Admin.ops.putaway.binRequired'));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
submitting.value = true;
|
||
try {
|
||
await confirmWarehouseInboundReceive({
|
||
inboundNoticeId: head.id,
|
||
customerId: head.customerId > 0 ? head.customerId : undefined,
|
||
boxes: boxes.value.map((box) => ({
|
||
boxId: box.boxId,
|
||
lines: box.lines.map((line) => ({
|
||
lineId: line.lineId,
|
||
receivedQty: Number(line.receivedQty) || 0,
|
||
binLocationId: line.receivedQty > 0 ? Number(line.binLocationId) : 0,
|
||
})),
|
||
})),
|
||
});
|
||
showSuccess(t('h5Admin.ops.putaway.success'));
|
||
resetForm();
|
||
scanCode.value = '';
|
||
await loadPending();
|
||
refocus();
|
||
} catch (e: any) {
|
||
showRequestError(e, t('h5Admin.ops.putaway.failed'));
|
||
} finally {
|
||
submitting.value = false;
|
||
}
|
||
}
|
||
|
||
onMounted(async () => {
|
||
clearFeedback();
|
||
await loadBinOptions(currentWarehouseStore.warehouseId);
|
||
await loadPending();
|
||
refocus();
|
||
});
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
@import './ops-shared.less';
|
||
|
||
.h5-putaway__panel {
|
||
display: grid;
|
||
gap: 12px;
|
||
}
|
||
|
||
.h5-putaway__bulk {
|
||
display: grid;
|
||
gap: 6px;
|
||
|
||
label {
|
||
font-size: 12px;
|
||
color: var(--h5-text-2, #4e5969);
|
||
}
|
||
}
|
||
|
||
.h5-putaway__box {
|
||
display: grid;
|
||
gap: 8px;
|
||
padding-top: 4px;
|
||
|
||
h3 {
|
||
margin: 0;
|
||
font-size: 13px;
|
||
font-weight: 650;
|
||
color: var(--h5-text, #1d2129);
|
||
|
||
span {
|
||
font-weight: 400;
|
||
color: var(--h5-text-3, #86909c);
|
||
}
|
||
}
|
||
}
|
||
|
||
.h5-putaway__line {
|
||
display: grid;
|
||
gap: 8px;
|
||
padding: 10px;
|
||
border-radius: 10px;
|
||
background: var(--h5-well-bg, #f0f3f4);
|
||
|
||
strong {
|
||
font-size: 14px;
|
||
color: var(--h5-text, #1d2129);
|
||
word-break: break-all;
|
||
}
|
||
}
|
||
|
||
.h5-putaway__line-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 10px;
|
||
font-size: 12px;
|
||
color: var(--h5-text-2, #4e5969);
|
||
|
||
label {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
|
||
input {
|
||
width: 72px;
|
||
height: 32px;
|
||
padding: 0 8px;
|
||
border: none;
|
||
border-radius: 8px;
|
||
background: #fff;
|
||
font-size: 14px;
|
||
}
|
||
}
|
||
|
||
.h5-putaway__bin {
|
||
display: grid;
|
||
gap: 6px;
|
||
font-size: 12px;
|
||
color: var(--h5-text-2, #4e5969);
|
||
}
|
||
|
||
.h5-putaway__submit {
|
||
width: 100%;
|
||
height: 44px;
|
||
margin-top: 4px;
|
||
}
|
||
|
||
.h5-ops__card {
|
||
cursor: pointer;
|
||
-webkit-tap-highlight-color: transparent;
|
||
}
|
||
</style>
|