All checks were successful
Build and Deploy Front / deploy (push) Successful in 7m27s
Co-authored-by: Cursor <cursoragent@cursor.com>
176 lines
5.2 KiB
Vue
176 lines
5.2 KiB
Vue
<template>
|
|
<div class="h5-ops">
|
|
<H5OpsPageHeader :title="t('h5Admin.ops.parcelArrival')" @change="onWarehouseChange" />
|
|
|
|
<div class="h5-ops__scan-row">
|
|
<H5ScanInput
|
|
ref="scanRef"
|
|
v-model="trackingNo"
|
|
:placeholder="t('warehouse.parcelArrival.form.placeholder.scanOrInput')"
|
|
: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="submit"
|
|
@detect="onDetect"
|
|
@error="onScanError"
|
|
/>
|
|
<button type="button" class="h5-ops__primary" :disabled="submitting" @click="submit">
|
|
{{ t('warehouse.parcelArrival.actions.arrive') }}
|
|
</button>
|
|
</div>
|
|
|
|
<p v-if="feedbackMessage" class="h5-ops__feedback" :class="`is-${feedbackType}`">
|
|
{{ feedbackMessage }}
|
|
</p>
|
|
|
|
<section class="h5-ops__recent">
|
|
<h2>{{ t('warehouse.parcelArrival.recent.title') }}</h2>
|
|
<a-spin :loading="listLoading" style="width: 100%">
|
|
<p v-if="!listLoading && !rows.length" class="h5-ops__empty">
|
|
{{ t('h5Admin.ops.emptyRecent') }}
|
|
</p>
|
|
<article v-for="row in rows" :key="row.id" class="h5-ops__card">
|
|
<strong>{{ row.trackingNo }}</strong>
|
|
<span>{{ row.warehouseName }}</span>
|
|
<em>{{ row.operateTime }}</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 {
|
|
createWarehouseParcelArrival,
|
|
getWarehouseParcelArrivalList,
|
|
} 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: 'H5AdminOpsParcelArrival' });
|
|
|
|
const { t } = useI18n();
|
|
const scanRef = ref<InstanceType<typeof H5ScanInput> | null>(null);
|
|
const currentWarehouseStore = useCurrentWarehouseStore();
|
|
const {
|
|
feedbackType,
|
|
feedbackMessage,
|
|
clearFeedback,
|
|
showError,
|
|
showSuccess,
|
|
showWarning,
|
|
} = useOperationScanFeedback('h5ParcelArrival');
|
|
|
|
const trackingNo = ref('');
|
|
const submitting = ref(false);
|
|
const listLoading = ref(false);
|
|
const rows = ref<
|
|
Array<{ id: number; trackingNo: string; warehouseName: string; operateTime: string }>
|
|
>([]);
|
|
|
|
function refocus() {
|
|
nextTick(() => scanRef.value?.focus());
|
|
}
|
|
|
|
function onWarehouseChange() {
|
|
clearFeedback();
|
|
trackingNo.value = '';
|
|
void loadList();
|
|
refocus();
|
|
}
|
|
|
|
async function onDetect(code: string) {
|
|
trackingNo.value = code;
|
|
await submit();
|
|
}
|
|
|
|
function onScanError(message: string) {
|
|
showError(message);
|
|
}
|
|
|
|
async function loadList() {
|
|
listLoading.value = true;
|
|
try {
|
|
const { items } = await getWarehouseParcelArrivalList({
|
|
page: 1,
|
|
pageSize: 30,
|
|
warehouseId: currentWarehouseStore.warehouseId,
|
|
});
|
|
rows.value = (items || []).map((raw: Record<string, unknown>) => {
|
|
const row = normalizeListRow(raw);
|
|
return {
|
|
id: Number(pickField(row, 'id', 'Id') || 0),
|
|
trackingNo: String(pickField(row, 'trackingNo', 'TrackingNo') || '-'),
|
|
warehouseName: String(pickField(row, 'warehouseName', 'WarehouseName') || '-'),
|
|
operateTime: formatDateTime(pickField(row, 'createTime', 'CreateTime')),
|
|
};
|
|
});
|
|
} catch (e: any) {
|
|
showError(e?.message || t('warehouse.parcelArrival.message.loadFailed'));
|
|
rows.value = [];
|
|
} finally {
|
|
listLoading.value = false;
|
|
}
|
|
}
|
|
|
|
async function submit() {
|
|
if (!hasPermission('Operation.ParcelArrival.Save')) {
|
|
showWarning(t('h5Admin.ops.noPermission'));
|
|
return;
|
|
}
|
|
const no = trackingNo.value.trim();
|
|
if (!no) {
|
|
showWarning(t('warehouse.parcelArrival.message.trackingRequired'));
|
|
refocus();
|
|
return;
|
|
}
|
|
const warehouseId = currentWarehouseStore.warehouseId;
|
|
if (!warehouseId) {
|
|
showWarning(t('warehouse.common.noCurrentWarehouse'));
|
|
return;
|
|
}
|
|
submitting.value = true;
|
|
try {
|
|
const result = await createWarehouseParcelArrival({ warehouseId, trackingNo: no });
|
|
const linked = (result as any)?.linkedOrders || (result as any)?.LinkedOrders || [];
|
|
const serviceNos = linked
|
|
.map((o: any) => o.serviceNo || o.ServiceNo)
|
|
.filter(Boolean)
|
|
.join('、');
|
|
if (serviceNos) {
|
|
showSuccess(
|
|
t('warehouse.parcelArrival.message.arriveSuccessWithOrders', { orders: serviceNos }),
|
|
);
|
|
} else {
|
|
showSuccess(t('warehouse.parcelArrival.message.arriveSuccess'));
|
|
}
|
|
trackingNo.value = '';
|
|
await loadList();
|
|
refocus();
|
|
} catch (e: any) {
|
|
showError(e?.message || t('warehouse.parcelArrival.message.arriveFailed'));
|
|
refocus();
|
|
} finally {
|
|
submitting.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
clearFeedback();
|
|
void loadList();
|
|
refocus();
|
|
});
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
@import './ops-shared.less';
|
|
</style>
|