From 5af5a00819004ed97770a32cb1f50b0a9e9f0d5f Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Mon, 7 Apr 2025 19:34:21 +0800 Subject: [PATCH 1/2] fix: updateTaskRecord api #3639 --- docs/assets/guide/en/gantt/introduction.md | 5 ---- docs/assets/guide/zh/gantt/introduction.md | 5 ---- packages/vtable-gantt/src/Gantt.ts | 26 ++++++++++--------- .../vtable-gantt/src/scenegraph/task-bar.ts | 2 ++ 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/docs/assets/guide/en/gantt/introduction.md b/docs/assets/guide/en/gantt/introduction.md index e7eb24a496..725f1caab2 100644 --- a/docs/assets/guide/en/gantt/introduction.md +++ b/docs/assets/guide/en/gantt/introduction.md @@ -156,11 +156,6 @@ If there is no field data for the task date in the original data, you can create The button style can be configured via `taskBar.scheduleCreation.buttonStyle`. If the current configuration does not meet your needs, you can also customize the display effect of the creation schedule through the `taskBar.scheduleCreation.customLayout` configuration item. -**Note: Different Gantt chart instances have different capabilities to create schedules.** - -When `tasksShowMode` is `TasksShowMode.Tasks_Separate` or `TasksShowMode.Sub_Tasks_Separate`, each piece of data has a corresponding row position display, but when there is no `startDate` and `endDate` field set in the data, a create button will appear when the mouse hovers over the row, and clicking the button will create a schedule and display the task bar. - -When `tasksShowMode` is `TasksShowMode.Sub_Tasks_Inline`, `TasksShowMode.Sub_Tasks_Arrange`, or `TasksShowMode.Sub_Tasks_Compact`, a create button will be displayed when the mouse hovers over the blank area, and clicking the button will trigger the event `GANTT_EVENT_TYPE.CREATE_TASK_SCHEDULE`, but it will not actually create a task schedule. The user needs to listen for this event and create a schedule update data according to business needs. **Note: Different Gantt chart instances have different capabilities to create schedules.** diff --git a/docs/assets/guide/zh/gantt/introduction.md b/docs/assets/guide/zh/gantt/introduction.md index 521f6ea387..6f1555c939 100644 --- a/docs/assets/guide/zh/gantt/introduction.md +++ b/docs/assets/guide/zh/gantt/introduction.md @@ -156,11 +156,6 @@ links:[ 按钮的样式可以通过`taskBar.scheduleCreation.buttonStyle`配置。 如果当前配置不能满足需求,也可以通过`taskBar.scheduleCreation.customLayout`配置项自定义创建排期的展示效果。 -**注意:不同的甘特图实例,创建排期能力不同。:** - -当`tasksShowMode`为`TasksShowMode.Tasks_Separate`或`TasksShowMode.Sub_Tasks_Separate`,也就是每条数据有对应的一行位置展示,但是数据中没有设置 startDate 和 endDate 的字段时,鼠标 hover 到该行会出现创建按钮,点击按钮会创建排期并展示任务条。 - -当`tasksShowMode`为`TasksShowMode.Sub_Tasks_Inline`或`TasksShowMode.Sub_Tasks_Arrange`或`TasksShowMode.Sub_Tasks_Compact`,需要明确指明 scheduleCreatable 为`true`,才可出现创建按钮。当鼠标 hover 到空白区域即会显示创建按钮,点击按钮会触发事件`GANTT_EVENT_TYPE.CREATE_TASK_SCHEDULE`但不会真正的创建任务排期,使用者需要监听该事件根据业务需求来自行创建排期更新数据。 **注意:不同的甘特图实例,创建排期能力不同。:** diff --git a/packages/vtable-gantt/src/Gantt.ts b/packages/vtable-gantt/src/Gantt.ts index 4abe2c78f2..955141ec80 100644 --- a/packages/vtable-gantt/src/Gantt.ts +++ b/packages/vtable-gantt/src/Gantt.ts @@ -929,7 +929,10 @@ export class Gantt extends EventTarget { this.data.adjustOrder(source_index, source_sub_task_index, target_index, target_sub_task_index); } // 定义多个函数签名 - /** 更新数据信息 */ + /** 更新数据信息 + * 如果TasksShowModes是 tasks_separate 模式 则需要传入task_index即可 + * 如果TasksShowModes是 sub_tasks_*** 模式 则需要传入task_index和sub_task_index + */ updateTaskRecord(record: any, task_index: number | number[]): void; updateTaskRecord(record: any, task_index: number, sub_task_index: number): void; updateTaskRecord(record: any, task_index: number | number[], sub_task_index?: number) { @@ -947,17 +950,16 @@ export class Gantt extends EventTarget { this._refreshTaskBar(index, sub_index); return; } - const index = task_index as number; - - // if (this.taskListTableInstance.rowHierarchyType === 'tree' && typeof index === 'number') { - // //如果是树形结构 需要获取数据源对应的索引 - // index = this.taskListTableInstance.getRecordIndexByCell( - // 0, - // index + this.taskListTableInstance.columnHeaderLevelCount - // ); - // } - this._updateRecordToListTable(record, index); - this._refreshTaskBar(index, undefined); + let recordIndexs: number | number[] = task_index; + if (this.taskListTableInstance.rowHierarchyType === 'tree') { + //如果是树形结构 需要获取数据源对应的索引 + recordIndexs = this.taskListTableInstance.getRecordIndexByCell( + 0, + task_index + this.taskListTableInstance.columnHeaderLevelCount + ); + } + this._updateRecordToListTable(record, recordIndexs); + this._refreshTaskBar(task_index, undefined); } /** diff --git a/packages/vtable-gantt/src/scenegraph/task-bar.ts b/packages/vtable-gantt/src/scenegraph/task-bar.ts index 6630ba8f3a..ac7107a831 100644 --- a/packages/vtable-gantt/src/scenegraph/task-bar.ts +++ b/packages/vtable-gantt/src/scenegraph/task-bar.ts @@ -161,7 +161,9 @@ export class TaskBar { // clip: true }); barGroupBox.name = 'task-bar'; + //如果TaskShowMode是tasks_separate模式 这里的task_index其实是table中的bodyIndex;如果TaskShowMode是sub_tasks_***模式 task_index也是对应父节点任务条在table中的bodyIndex(但不会渲染父节点,只是渲染子节点) barGroupBox.task_index = index; + //如果TaskShowMode是tasks_separate模式,不会赋值sub_task_index;如果TaskShowMode是sub_tasks_***模式 这里的sub_task_index是父节点下子元素的index barGroupBox.sub_task_index = childIndex; barGroupBox.record = taskRecord; From 7751c7ef603c438cbfcc228a0dbcf388c15848f0 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Mon, 7 Apr 2025 19:35:01 +0800 Subject: [PATCH 2/2] docs: update changlog of rush --- .../fix-gantt-updateRecord_2025-04-07-11-35.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vtable/fix-gantt-updateRecord_2025-04-07-11-35.json diff --git a/common/changes/@visactor/vtable/fix-gantt-updateRecord_2025-04-07-11-35.json b/common/changes/@visactor/vtable/fix-gantt-updateRecord_2025-04-07-11-35.json new file mode 100644 index 0000000000..65b05c424b --- /dev/null +++ b/common/changes/@visactor/vtable/fix-gantt-updateRecord_2025-04-07-11-35.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: updateTaskRecord api #3639\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file