feat(mes): 添加甘特图任务列表接口,优化任务数据加载

pull/871/MERGE
YunaiV 2026-03-15 23:28:57 +08:00
parent 3860525dfd
commit 5f8a002654
3 changed files with 28 additions and 14 deletions

View File

@ -70,5 +70,10 @@ export const ProTaskApi = {
// 获得任务精简列表(下拉选项)
getTaskSimpleList: async (workOrderId?: number) => {
return await request.get({ url: `/mes/pro/task/simple-list`, params: { workOrderId } })
},
// 获得甘特图任务列表(非分页)
getGanttTaskList: async (params: any) => {
return await request.get({ url: `/mes/pro/task/gantt-list`, params })
}
}

View File

@ -114,7 +114,7 @@ const initGantt = () => {
//
gantt.config.date_format = '%Y-%m-%d %H:%i:%s'
gantt.config.duration_unit = 'hour'
gantt.config.duration_step = 8 // 1 = 8
gantt.config.duration_step = 8 // 1 = 8
gantt.config.row_height = 36
gantt.config.bar_height = 24
gantt.config.fit_tasks = true
@ -135,17 +135,25 @@ const initGantt = () => {
gantt.config.drag_progress = false
}
// >
// > 800:00 / 08:00 / 16:00
gantt.config.scales = [
{ unit: 'week', step: 1, format: '%Y年 第%W周' },
{ unit: 'day', step: 1, format: '%m/%d %D' }
{ unit: 'day', step: 1, format: '%Y-%m-%d %D' },
{
unit: 'hour',
step: 8,
format: (date: Date) => {
return String(date.getHours()).padStart(2, '0') + ':00'
}
}
]
//
gantt.config.columns = [
{ name: 'text', label: '任务名称', tree: true, width: 200, resize: true },
{ name: 'start_date', label: '开始时间', align: 'center', width: 100 },
{ name: 'duration', label: '时长(天)', align: 'center', width: 60 }
{ name: 'text', label: '任务名称', tree: true, width: 180, resize: true },
{ name: 'workstationName', label: '工作站', align: 'center', width: 100, resize: true },
{ name: 'processName', label: '工序', align: 'center', width: 100, resize: true },
{ name: 'start_date', label: '开始时间', align: 'center', width: 130 },
{ name: 'end_date', label: '结束时间', align: 'center', width: 130 }
]
// 线
@ -214,8 +222,10 @@ const convertToGanttData = (tasks: any[]) => {
id: 'task_' + t.id,
taskId: t.id,
text: t.name,
workstationName: t.workstationName || '',
processName: t.processName || '',
start_date: t.startTime ? new Date(t.startTime) : new Date(),
duration: (t.duration || 1) * 8, //
duration: (t.duration || 1) * 8, // -> end_date gantt
parent: 'wo_' + woId,
progress: t.quantity > 0 ? t.producedQuantity / t.quantity : 0,
color: t.colorCode || '#00AEF3'

View File

@ -188,6 +188,7 @@ const queryParams = reactive({
})
const queryFormRef = ref() // ref
const ganttLoading = ref(false) //
const ganttTasks = ref<any[]>([]) // ProTaskVO GanttChart
/** 查询待排产工单列表(支持父子工单树形展示) */
@ -203,14 +204,12 @@ const getWorkOrderList = async () => {
}
/** 加载甘特图预览数据(查询所有任务,供甘特图组件渲染) */
// TODO @
const loadGanttPreview = async () => {
ganttLoading.value = true
try {
const data = await ProTaskApi.getTaskPage({ pageNo: 1, pageSize: 999 })
ganttTasks.value = data.list
} catch (e) {
console.warn('加载甘特图数据失败', e)
ganttTasks.value = []
ganttTasks.value = await ProTaskApi.getGanttTaskList(queryParams)
} finally {
ganttLoading.value = false
}
}