<script lang="ts" setup>
|
import type { MesWmSortTaskApi } from '#/api/mes/wm/sorting';
|
|
import { ref } from 'vue';
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
import { Input, message, Table } from 'ant-design-vue';
|
|
import {
|
createSortTaskFromNotice,
|
getPendingNoticeList,
|
} from '#/api/mes/wm/sorting';
|
|
defineOptions({ name: 'MesWmSortNoticeSelect' });
|
|
const emit = defineEmits<{ success: [] }>();
|
|
const noticeCode = ref('');
|
const loading = ref(false);
|
const notices = ref<MesWmSortTaskApi.PendingNotice[]>([]);
|
const selectedId = ref<number>();
|
|
const columns = [
|
{ title: '发货通知单号', dataIndex: 'noticeCode', width: 170 },
|
{ title: '销售订单号', dataIndex: 'saleOrderCode', width: 170 },
|
{ title: '收货人', dataIndex: 'recipientName', width: 110 },
|
{ title: '联系电话', dataIndex: 'recipientTelephone', width: 130 },
|
{ title: '收货地址', dataIndex: 'recipientAddress' },
|
{ title: '发货日期', dataIndex: 'deliveryDate', width: 180 },
|
];
|
|
/** 查询可生成分拣任务的发货通知单 */
|
async function loadNotices() {
|
loading.value = true;
|
try {
|
notices.value = await getPendingNoticeList(
|
noticeCode.value.trim() || undefined,
|
);
|
} finally {
|
loading.value = false;
|
}
|
}
|
|
async function handleCreate() {
|
if (!selectedId.value) {
|
message.warning('请先选择一张发货通知单');
|
return;
|
}
|
const notice = notices.value.find(
|
(item) => item.noticeId === selectedId.value,
|
);
|
await createSortTaskFromNotice(selectedId.value);
|
message.success(
|
`已按发货通知单[${notice?.noticeCode ?? ''}]生成分拣任务,可按货位指引执行分拣`,
|
);
|
emit('success');
|
await modalApi.close();
|
}
|
|
const [Modal, modalApi] = useVbenModal({
|
title: '选择发货通知单生成分拣任务',
|
confirmText: '生成分拣任务',
|
onConfirm: handleCreate,
|
async onOpenChange(isOpen: boolean) {
|
if (!isOpen) {
|
noticeCode.value = '';
|
notices.value = [];
|
selectedId.value = undefined;
|
return;
|
}
|
await loadNotices();
|
},
|
});
|
</script>
|
|
<template>
|
<Modal class="w-[1000px]">
|
<div class="mb-3 flex items-center gap-2">
|
<Input
|
v-model:value="noticeCode"
|
class="w-[240px]"
|
placeholder="按发货通知单号筛选"
|
allow-clear
|
@press-enter="loadNotices"
|
/>
|
<button class="text-blue-500" type="button" @click="loadNotices">
|
查询
|
</button>
|
<span class="ml-auto text-xs text-gray-500">
|
仅列出「待出库」且尚未生成分拣任务的发货通知单
|
</span>
|
</div>
|
<Table
|
:columns="columns"
|
:data-source="notices"
|
:loading="loading"
|
:pagination="false"
|
:row-selection="{
|
type: 'radio',
|
selectedRowKeys: selectedId ? [selectedId] : [],
|
onChange: (keys) => {
|
selectedId = Number(keys[0]);
|
},
|
}"
|
:scroll="{ y: 360 }"
|
row-key="noticeId"
|
size="small"
|
bordered
|
/>
|
</Modal>
|
</template>
|