feat: task-job主表crud基础

This commit is contained in:
2026-07-14 14:09:48 +08:00
parent d225cb8025
commit 9953367281
41 changed files with 4773 additions and 133 deletions

View File

@@ -0,0 +1,87 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace TaskTransportTaskApi {
/** 搬运任务信息 */
export interface TransportTask {
taskCode?: string; // 任务编码
taskName: string; // 任务名称
ownerService?: string; // 业务归属服务LMS/WMS用于完成取消事件一级路由
bizType: string; // 业务类型
bizId: string; // 业务侧标识
handleCode: string; // 业务回调处理器编码
taskType: string; // 任务类型
taskStatus?: string; // 任务状态
acsTaskType?: string; // ACS任务类型
agvSystemType: string; // AGV系统类型
externalTaskNo: string; // ACS外部任务号
pointCode1: string; // 取货点1
pointCode2: string; // 放货点1
pointCode3: string; // 取货点2
pointCode4: string; // 放货点2
vehicleType: string; // 载具类型
vehicleQty?: number; // 载具数量
vehicleCode: string; // 载具编码
vehicleCode2: string; // 载具编码2
carNo: string; // 车号
priority?: string; // 优先级
productArea: string; // 生产区域
isAutoIssue?: string; // 是否自动下发
taskGroupId: number; // 任务组标识
sortSeq?: number; // 任务组顺序号
finishedType: string; // 任务完成类型
callbackStatus: string; // 业务回调状态PENDING/SUCCESS/FAILED
callbackRetryCount?: number; // 业务回调重试次数
callbackErrorMsg: string; // 业务回调失败原因
createMode?: string; // 生成方式
requestParam: string; // 创建任务请求参数
dispatchParam: string; // 下发ACS的AcsTaskDto扩展报文
resultParam: string; // ACS反馈参数
remark: string; // 备注
}
}
/** 查询搬运任务分页 */
export function getTransportTaskPage(params: PageParam) {
return requestClient.get<PageResult<TaskTransportTaskApi.TransportTask>>(
'/task/transport-task/page',
{ params },
);
}
/** 查询搬运任务详情 */
export function getTransportTask(id: number) {
return requestClient.get<TaskTransportTaskApi.TransportTask>(
`/task/transport-task/get?id=${id}`,
);
}
/** 新增搬运任务 */
export function createTransportTask(data: TaskTransportTaskApi.TransportTask) {
return requestClient.post('/task/transport-task/create', data);
}
/** 修改搬运任务 */
export function updateTransportTask(data: TaskTransportTaskApi.TransportTask) {
return requestClient.put('/task/transport-task/update', data);
}
/** 删除搬运任务 */
export function deleteTransportTask(id: number) {
return requestClient.delete(`/task/transport-task/delete?id=${id}`);
}
/** 批量删除搬运任务 */
export function deleteTransportTaskList(ids: number[]) {
return requestClient.delete(
`/task/transport-task/delete-list?ids=${ids.join(',')}`,
);
}
/** 导出搬运任务 */
export function exportTransportTask(params: any) {
return requestClient.download('/task/transport-task/export-excel', { params });
}

View File

@@ -0,0 +1,707 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { TaskTransportTaskApi } from '#/api/task/transporttask';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'taskId',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'taskCode',
label: '任务编码',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入任务编码',
},
},
{
fieldName: 'taskName',
label: '任务名称',
component: 'Input',
componentProps: {
placeholder: '请输入任务名称',
},
},
{
fieldName: 'ownerService',
label: '业务归属服务',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入业务归属服务LMS/WMS',
},
},
{
fieldName: 'bizType',
label: '业务类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择业务类型',
},
},
{
fieldName: 'bizId',
label: '业务侧标识',
component: 'Input',
componentProps: {
placeholder: '请输入业务侧标识',
},
},
{
fieldName: 'handleCode',
label: '业务回调处理器编码',
component: 'Input',
componentProps: {
placeholder: '请输入业务回调处理器编码',
},
},
{
fieldName: 'taskType',
label: '任务类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择任务类型',
},
},
{
fieldName: 'taskStatus',
label: '任务状态',
rules: 'required',
component: 'RadioGroup',
componentProps: {
options: [],
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'acsTaskType',
label: 'ACS任务类型',
rules: 'required',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择ACS任务类型',
},
},
{
fieldName: 'agvSystemType',
label: 'AGV系统类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择AGV系统类型',
},
},
{
fieldName: 'externalTaskNo',
label: 'ACS外部任务号',
component: 'Input',
componentProps: {
placeholder: '请输入ACS外部任务号',
},
},
{
fieldName: 'pointCode1',
label: '取货点1',
component: 'Input',
componentProps: {
placeholder: '请输入取货点1',
},
},
{
fieldName: 'pointCode2',
label: '放货点1',
component: 'Input',
componentProps: {
placeholder: '请输入放货点1',
},
},
{
fieldName: 'pointCode3',
label: '取货点2',
component: 'Input',
componentProps: {
placeholder: '请输入取货点2',
},
},
{
fieldName: 'pointCode4',
label: '放货点2',
component: 'Input',
componentProps: {
placeholder: '请输入放货点2',
},
},
{
fieldName: 'vehicleType',
label: '载具类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择载具类型',
},
},
{
fieldName: 'vehicleQty',
label: '载具数量',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入载具数量',
},
},
{
fieldName: 'vehicleCode',
label: '载具编码',
component: 'Input',
componentProps: {
placeholder: '请输入载具编码',
},
},
{
fieldName: 'vehicleCode2',
label: '载具编码2',
component: 'Input',
componentProps: {
placeholder: '请输入载具编码2',
},
},
{
fieldName: 'carNo',
label: '车号',
component: 'Input',
componentProps: {
placeholder: '请输入车号',
},
},
{
fieldName: 'priority',
label: '优先级',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入优先级',
},
},
{
fieldName: 'productArea',
label: '生产区域',
component: 'Input',
componentProps: {
placeholder: '请输入生产区域',
},
},
{
fieldName: 'isAutoIssue',
label: '是否自动下发',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入是否自动下发',
},
},
{
fieldName: 'taskGroupId',
label: '任务组标识',
component: 'Input',
componentProps: {
placeholder: '请输入任务组标识',
},
},
{
fieldName: 'sortSeq',
label: '任务组顺序号',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入任务组顺序号',
},
},
{
fieldName: 'finishedType',
label: '任务完成类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择任务完成类型',
},
},
{
fieldName: 'callbackStatus',
label: '业务回调状态PENDING/SUCCESS/FAILED',
component: 'RadioGroup',
componentProps: {
options: [],
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'callbackRetryCount',
label: '业务回调重试次数',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入业务回调重试次数',
},
},
{
fieldName: 'callbackErrorMsg',
label: '业务回调失败原因',
component: 'Input',
componentProps: {
placeholder: '请输入业务回调失败原因',
},
},
{
fieldName: 'createMode',
label: '生成方式',
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.USER_TYPE, 'string'),
placeholder: '请选择生成方式',
},
},
{
fieldName: 'requestParam',
label: '创建任务请求参数',
component: 'Input',
componentProps: {
placeholder: '请输入创建任务请求参数',
},
},
{
fieldName: 'dispatchParam',
label: '下发ACS的AcsTaskDto扩展报文',
component: 'Input',
componentProps: {
placeholder: '请输入下发ACS的AcsTaskDto扩展报文',
},
},
{
fieldName: 'resultParam',
label: 'ACS反馈参数',
component: 'Input',
componentProps: {
placeholder: '请输入ACS反馈参数',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
placeholder: '请输入备注',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'taskCode',
label: '任务编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入任务编码',
},
},
{
fieldName: 'taskName',
label: '任务名称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入任务名称',
},
},
{
fieldName: 'ownerService',
label: '业务归属服务',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.TASK_OWNER_SERVICE),
placeholder: '请输入业务归属服务',
},
},
{
fieldName: 'bizType',
label: '业务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择业务类型',
},
},
{
fieldName: 'handleCode',
label: '处理器编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入业务回调处理器编码',
},
},
{
fieldName: 'taskType',
label: '任务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择任务类型',
},
},
{
fieldName: 'taskStatus',
label: '任务状态',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择任务状态',
},
},
{
fieldName: 'acsTaskType',
label: 'ACS任务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择ACS任务类型',
},
},
{
fieldName: 'pointCode1',
label: '取货点1',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入取货点1',
},
},
{
fieldName: 'pointCode2',
label: '放货点1',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入放货点1',
},
},
{
fieldName: 'pointCode3',
label: '取货点2',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入取货点2',
},
},
{
fieldName: 'pointCode4',
label: '放货点2',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入放货点2',
},
},
{
fieldName: 'vehicleType',
label: '载具类型',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择载具类型',
},
},
{
fieldName: 'vehicleCode',
label: '载具编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入载具编码',
},
},
{
fieldName: 'vehicleCode2',
label: '载具编码2',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入载具编码2',
},
},
{
fieldName: 'carNo',
label: '车号',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入车号',
},
},
{
fieldName: 'productArea',
label: '生产区域',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入生产区域',
},
},
{
fieldName: 'taskGroupId',
label: '任务组标识',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入任务组标识',
},
},
{
fieldName: 'createMode',
label: '生成方式',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.USER_TYPE, 'string'),
placeholder: '请选择生成方式',
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<TaskTransportTaskApi.TransportTask>['columns'] {
return [
{ type: 'checkbox', width: 40 },
{
field: 'taskId',
title: '任务标识',
minWidth: 120,
},
{
field: 'taskCode',
title: '任务编码',
minWidth: 120,
},
{
field: 'taskName',
title: '任务名称',
minWidth: 120,
},
{
field: 'ownerService',
title: '业务归属服务',
minWidth: 120,
},
{
field: 'bizType',
title: '业务类型',
minWidth: 120,
},
{
field: 'bizId',
title: '业务侧标识',
minWidth: 120,
},
{
field: 'handleCode',
title: '业务回调处理器编码',
minWidth: 120,
},
{
field: 'taskType',
title: '任务类型',
minWidth: 120,
},
{
field: 'taskStatus',
title: '任务状态',
minWidth: 120,
},
{
field: 'acsTaskType',
title: 'ACS任务类型',
minWidth: 120,
},
{
field: 'agvSystemType',
title: 'AGV系统类型',
minWidth: 120,
},
{
field: 'externalTaskNo',
title: 'ACS外部任务号',
minWidth: 120,
},
{
field: 'pointCode1',
title: '取货点1',
minWidth: 120,
},
{
field: 'pointCode2',
title: '放货点1',
minWidth: 120,
},
{
field: 'pointCode3',
title: '取货点2',
minWidth: 120,
},
{
field: 'pointCode4',
title: '放货点2',
minWidth: 120,
},
{
field: 'vehicleType',
title: '载具类型',
minWidth: 120,
},
{
field: 'vehicleQty',
title: '载具数量',
minWidth: 120,
},
{
field: 'vehicleCode',
title: '载具编码',
minWidth: 120,
},
{
field: 'vehicleCode2',
title: '载具编码2',
minWidth: 120,
},
{
field: 'carNo',
title: '车号',
minWidth: 120,
},
{
field: 'priority',
title: '优先级',
minWidth: 120,
},
{
field: 'productArea',
title: '生产区域',
minWidth: 120,
},
{
field: 'isAutoIssue',
title: '是否自动下发',
minWidth: 120,
},
{
field: 'taskGroupId',
title: '任务组标识',
minWidth: 120,
},
{
field: 'sortSeq',
title: '任务组顺序号',
minWidth: 120,
},
{
field: 'finishedType',
title: '任务完成类型',
minWidth: 120,
},
{
field: 'callbackStatus',
title: '业务回调状态PENDING/SUCCESS/FAILED',
minWidth: 120,
},
{
field: 'callbackRetryCount',
title: '业务回调重试次数',
minWidth: 120,
},
{
field: 'callbackErrorMsg',
title: '业务回调失败原因',
minWidth: 120,
},
{
field: 'createMode',
title: '生成方式',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.USER_TYPE },
},
},
{
field: 'requestParam',
title: '创建任务请求参数',
minWidth: 120,
},
{
field: 'dispatchParam',
title: '下发ACS的AcsTaskDto扩展报文',
minWidth: 120,
},
{
field: 'resultParam',
title: 'ACS反馈参数',
minWidth: 120,
},
{
field: 'remark',
title: '备注',
minWidth: 120,
},
{
field: 'createTime',
title: '创建时间',
minWidth: 120,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 200,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,179 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { TaskTransportTaskApi } from '#/api/task/transporttask';
import { ref } from 'vue';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'antdv-next';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteTransportTask,
deleteTransportTaskList,
exportTransportTask,
getTransportTaskPage,
} from '#/api/task/transporttask';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 创建搬运任务 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑搬运任务 */
function handleEdit(row: TaskTransportTaskApi.TransportTask) {
formModalApi.setData(row).open();
}
/** 删除搬运任务 */
async function handleDelete(row: TaskTransportTaskApi.TransportTask) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.id]),
duration: 0,
});
try {
await deleteTransportTask(row.id!);
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
handleRefresh();
} finally {
hideLoading();
}
}
/** 批量删除搬运任务 */
async function handleDeleteBatch() {
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = message.loading({
content: $t('ui.actionMessage.deletingBatch'),
duration: 0,
});
try {
await deleteTransportTaskList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: TaskTransportTaskApi.TransportTask[];
}) {
checkedIds.value = records.map((item) => item.id!);
}
/** 导出表格 */
async function handleExport() {
const data = await exportTransportTask(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '搬运任务.xls', source: data });
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getTransportTaskPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<TaskTransportTaskApi.TransportTask>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
});
</script>
<template>
<Page auto-content-height>
<FormModal @success="handleRefresh" />
<Grid table-title="搬运任务列表">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['task:transport-task:export'],
onClick: handleExport,
},
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['task:transport-task:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['task:transport-task:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['task:transport-task:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.taskCode]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,82 @@
<script lang="ts" setup>
import type { TaskTransportTaskApi } from '#/api/task/transporttask';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { createTransportTask, getTransportTask, updateTransportTask } from '#/api/task/transporttask';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<TaskTransportTaskApi.TransportTask>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['搬运任务'])
: $t('ui.actionTitle.create', ['搬运任务']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 80,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as TaskTransportTaskApi.TransportTask;
try {
await (formData.value?.id ? updateTransportTask(data) : createTransportTask(data));
// 关闭并提示
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<TaskTransportTaskApi.TransportTask>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getTransportTask(data.id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -280,6 +280,11 @@ const WMS_DICT = {
WMS_SHIPMENT_ORDER_TYPE: 'wms_shipment_order_type', // WMS 出库单类型
} as const;
/** ========== TASK - 任务管理模块 ========== */
const TASK_DICT = {
TASK_OWNER_SERVICE: 'task_owner_service', // TASK 任务回调服务提供类型
} as const;
/** 字典类型枚举 - 统一导出 */
const DICT_TYPE = {
...AI_DICT,
@@ -297,6 +302,7 @@ const DICT_TYPE = {
...MALL_DICT,
...SYSTEM_DICT,
...COMMON_DICT,
...TASK_DICT,
} as const;
export { DICT_TYPE };