<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { MesWmSortTaskApi } from '#/api/mes/wm/sorting';
|
|
import { ref } from 'vue';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
import { Button, message } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
cancelSortTask,
|
deleteSortTask,
|
getSortTaskPage,
|
} from '#/api/mes/wm/sorting';
|
import { $t } from '#/locales';
|
|
import { SORT_TASK_STATUS, useGridColumns, useGridFormSchema } from './data';
|
import NoticeSelect from './modules/notice-select.vue';
|
import Print from './modules/print.vue';
|
import SortModal from './modules/sort-modal.vue';
|
|
/** 分拣配送(需求 5.3):按发货通知单生成分拣任务,依据货位指引扫码分拣,完成后触发配送 */
|
defineOptions({ name: 'MesWmSortTask' });
|
|
const [NoticeModal, noticeModalApi] = useVbenModal({
|
connectedComponent: NoticeSelect,
|
destroyOnClose: true,
|
});
|
|
const [SortTaskModal, sortTaskModalApi] = useVbenModal({
|
connectedComponent: SortModal,
|
destroyOnClose: true,
|
});
|
|
/** 打印组件 */
|
const printRef = ref<InstanceType<typeof Print>>();
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 生成分拣任务:从待出库的发货通知单中选择 */
|
function handleCreate() {
|
noticeModalApi.open();
|
}
|
|
/** 订单分拣 */
|
function handleSort(row: MesWmSortTaskApi.SortTask) {
|
sortTaskModalApi.setData({ id: row.id }).open();
|
}
|
|
/** 打印分拣单据 */
|
function handlePrint(row: MesWmSortTaskApi.SortTask) {
|
printRef.value?.print(row.id!);
|
}
|
|
/** 取消分拣任务 */
|
async function handleCancel(row: MesWmSortTaskApi.SortTask) {
|
await cancelSortTask(row.id!);
|
message.success('分拣任务已取消');
|
handleRefresh();
|
}
|
|
/** 删除分拣任务 */
|
async function handleDelete(row: MesWmSortTaskApi.SortTask) {
|
const hideLoading = message.loading({
|
content: $t('ui.actionMessage.deleting', [row.code]),
|
duration: 0,
|
});
|
try {
|
await deleteSortTask(row.id!);
|
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) => {
|
return await getSortTaskPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
});
|
},
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
custom: true,
|
},
|
} as VxeTableGridOptions<MesWmSortTaskApi.SortTask>,
|
});
|
|
const StatusEnum = SORT_TASK_STATUS;
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<NoticeModal @success="handleRefresh" />
|
<SortTaskModal @success="handleRefresh" />
|
<Print ref="printRef" />
|
|
<Grid table-title="分拣任务列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: '生成分拣任务',
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['mes:wm-sort-task:create'],
|
onClick: handleCreate,
|
},
|
]"
|
/>
|
</template>
|
<template #code="{ row }">
|
<Button type="link" @click="handleSort(row)">
|
{{ row.code }}
|
</Button>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '订单分拣',
|
type: 'link',
|
auth: ['mes:wm-sort-task:update'],
|
ifShow:
|
row.status === StatusEnum.PENDING ||
|
row.status === StatusEnum.SORTING,
|
onClick: handleSort.bind(null, row),
|
},
|
{
|
label: '打印单据',
|
type: 'link',
|
icon: 'lucide:printer',
|
auth: ['mes:wm-sort-task:query'],
|
onClick: handlePrint.bind(null, row),
|
},
|
{
|
label: '取消',
|
type: 'link',
|
danger: true,
|
auth: ['mes:wm-sort-task:update'],
|
ifShow:
|
row.status === StatusEnum.PENDING ||
|
row.status === StatusEnum.SORTING,
|
popConfirm: {
|
title: `确认取消分拣任务[${row.code}]?取消后可重新按发货通知单生成。`,
|
confirm: handleCancel.bind(null, row),
|
},
|
},
|
{
|
label: $t('common.delete'),
|
type: 'link',
|
danger: true,
|
icon: ACTION_ICON.DELETE,
|
auth: ['mes:wm-sort-task:delete'],
|
ifShow:
|
row.status === StatusEnum.PENDING ||
|
row.status === StatusEnum.CANCELED,
|
popConfirm: {
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
confirm: handleDelete.bind(null, row),
|
},
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|