From a81eea91ca770a86da95f132f8c6e8a5db3dc5a8 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 24 Nov 2023 11:38:23 +0800 Subject: [PATCH] =?UTF-8?q?gantt=E5=9B=BE=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GanttComponent.vue | 30 +++++++++++++++--- src/views/pm/mtask2.vue | 51 ++++++++++++------------------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/components/GanttComponent.vue b/src/components/GanttComponent.vue index 8162fb21..0d26a515 100644 --- a/src/components/GanttComponent.vue +++ b/src/components/GanttComponent.vue @@ -28,25 +28,43 @@ }, }, mounted: function () { - gantt.i18n.setLocale('cn'); + gantt.clearAll();// 清空之前的配置 + gantt.i18n.setLocale('cn'); // 设置中文 gantt.config.date_format = "%Y-%m-%d"; gantt.config.date_grid = "%Y/%m/%d"; - gantt.config.readonly = true; - gantt.config.autosize = true; + gantt.config.readonly = true; // 设置中文 + gantt.config.autosize = true;//自适应尺寸 gantt.plugins({tooltip: true}); + gantt.config.bar_height = 20; //task高度 // gantt.config.start_date = new Date(2023, 9, 1); // gantt.config.end_date = new Date(2023, 9, 10); + //更改父项图标 + // gantt.templates.grid_folder = (item) => { + // return "" + // } + //更改子项图标 + // gantt.templates.grid_file = (item) => { + // return "" + // } gantt.config.columns = [ {name: 'number',label: '任务编号',tree: true,width: '*',align: 'left'}, {name: 'cate',label: '规格型号', width: '70',align: 'center'}, {name: 'count',label: '完成量',width: '50', align: 'center'} ]; gantt.attachEvent('onGanttReady', function () { - // var tooltips = gantt.ext.tooltips; gantt.templates.tooltip_text = function (start, end, task) { - return task.number + '
计划产量:' + task.count + '
当日产量:' + task.count + '
完成产量:' + task.count + '
开工时间:' + gantt.templates.tooltip_date_format(start) + '
完工时间:' + gantt.templates.tooltip_date_format(end); + return task.number + + '
计划产量:' + task.count + + '
当日产量:' + task.count_real + + '
完成产量:' + task.count_ok + + '
开工时间:' + gantt.templates.tooltip_date_format(start) + + '
完工时间:' + gantt.templates.tooltip_date_format(start); }; }); + //自适应甘特图的尺寸大小, 使得在不出现滚动条的情况下, 显示全部任务 + // gantt.config.autosize = true; + // gantt.config.open_split_tasks = true; + // gantt.config.scale_unit = "day"; // gantt.config.step = 1; // gantt.config.date_scale = " %Y/%m/%d"; @@ -61,6 +79,8 @@ { unit: 'year', step: 1, format: " %Y年", css: yearScaleCss }, { unit: 'day', step: 1, format: " %m月%d日", css: monthScaleCss } ]; + gantt.config.duration_step = 1; + // 初始化甘特图 gantt.init(this.$refs.ganttContainer); gantt.parse(this.$props.tasks); } diff --git a/src/views/pm/mtask2.vue b/src/views/pm/mtask2.vue index c423b0f4..b47b8ce0 100644 --- a/src/views/pm/mtask2.vue +++ b/src/views/pm/mtask2.vue @@ -25,7 +25,7 @@