vue甘特圖 vxe-gantt 如何將子任務顯示一行在父級中,父級行內渲染顯示子任務的用法,行內展示子任務由 task-bar-subview-config 和父級任務設置type= VxeGanttTaskType.Subview 來啓用。啓用後會將所有子任務渲染到父級任務中,可以直觀的看到任務全程進度, task-bar-subview-config.showOverview 設置是否任務總覽,當子任務被展開後自動顯示任務總覽
https://gantt.vxeui.com
當沒展開子任務時,自動將所有子任務渲染到父級中。可以直接看到任務總覽

展開子任務後,自動按每行渲染任務條

還可以通過 task-bar-config.barStyle.overviewBgColor 自定義總覽任務條顏色
<template>
<div>
<vxe-gantt v-bind="ganttOptions"></vxe-gantt>
</div>
</template>
<script setup>
import { reactive } from 'vue'
import { VxeGanttTaskType } from 'vxe-gantt'
const ganttOptions = reactive({
border: true,
height: 500,
treeConfig: {
transform: true,
rowField: 'id',
parentField: 'parentId'
},
taskBarSubviewConfig: {
showOverview: true
},
taskBarConfig: {
showContent: true,
barStyle: {
round: true,
bgColor: '#65c16f',
overviewBgColor: '#59885e'
}
},
taskViewConfig: {
tableStyle: {
width: 380
}
},
columns: [
{ field: 'title', title: '任務名稱', minWidth: 140, treeNode: true },
{ field: 'start', title: '開始時間', width: 100 },
{ field: 'end', title: '結束時間', width: 100 }
],
data: [
{ id: 10001, parentId: null, title: '項目1', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
{ id: 10002, parentId: 10001, title: '項目2', start: '2024-03-03', end: '2024-03-08', progress: 70 },
{ id: 10003, parentId: null, title: '項目3', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
{ id: 10004, parentId: 10003, title: '項目4', start: '2024-03-05', end: '2024-03-08', progress: 50 },
{ id: 10006, parentId: 10003, title: '項目5', start: '2024-03-13', end: '2024-03-21', progress: 60 },
{ id: 10008, parentId: null, title: '項目6', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
{ id: 10009, parentId: 10008, title: '項目7', start: '2024-03-11', end: '2024-03-13', progress: 50 },
{ id: 10009, parentId: 10008, title: '項目8', start: '2024-03-14', end: '2024-03-16', progress: 50 },
{ id: 10009, parentId: 10008, title: '項目9', start: '2024-03-17', end: '2024-03-20', progress: 50 }
]
})
</script>
https://gitee.com/x-extends/vxe-gantt