Skip to content

Commit f16c6d6

Browse files
authored
Merge pull request #3707 from VisActor/fix/gantt-updateRecord
Fix/gantt update record
2 parents fae89ff + 7751c7e commit f16c6d6

5 files changed

Lines changed: 27 additions & 22 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: updateTaskRecord api #3639\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vtable"
7+
}
8+
],
9+
"packageName": "@visactor/vtable",
10+
"email": "892739385@qq.com"
11+
}

docs/assets/guide/en/gantt/introduction.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ If there is no field data for the task date in the original data, you can create
156156
The button style can be configured via `taskBar.scheduleCreation.buttonStyle`.
157157

158158
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.
159-
**Note: Different Gantt chart instances have different capabilities to create schedules.**
160-
161-
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.
162-
163-
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.
164159

165160
**Note: Different Gantt chart instances have different capabilities to create schedules.**
166161

docs/assets/guide/zh/gantt/introduction.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ links:[
156156
按钮的样式可以通过`taskBar.scheduleCreation.buttonStyle`配置。
157157

158158
如果当前配置不能满足需求,也可以通过`taskBar.scheduleCreation.customLayout`配置项自定义创建排期的展示效果。
159-
**注意:不同的甘特图实例,创建排期能力不同。:**
160-
161-
`tasksShowMode``TasksShowMode.Tasks_Separate``TasksShowMode.Sub_Tasks_Separate`,也就是每条数据有对应的一行位置展示,但是数据中没有设置 startDate 和 endDate 的字段时,鼠标 hover 到该行会出现创建按钮,点击按钮会创建排期并展示任务条。
162-
163-
`tasksShowMode``TasksShowMode.Sub_Tasks_Inline``TasksShowMode.Sub_Tasks_Arrange``TasksShowMode.Sub_Tasks_Compact`,需要明确指明 scheduleCreatable 为`true`,才可出现创建按钮。当鼠标 hover 到空白区域即会显示创建按钮,点击按钮会触发事件`GANTT_EVENT_TYPE.CREATE_TASK_SCHEDULE`但不会真正的创建任务排期,使用者需要监听该事件根据业务需求来自行创建排期更新数据。
164159

165160
**注意:不同的甘特图实例,创建排期能力不同。:**
166161

packages/vtable-gantt/src/Gantt.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,10 @@ export class Gantt extends EventTarget {
929929
this.data.adjustOrder(source_index, source_sub_task_index, target_index, target_sub_task_index);
930930
}
931931
// 定义多个函数签名
932-
/** 更新数据信息 */
932+
/** 更新数据信息
933+
* 如果TasksShowModes是 tasks_separate 模式 则需要传入task_index即可
934+
* 如果TasksShowModes是 sub_tasks_*** 模式 则需要传入task_index和sub_task_index
935+
*/
933936
updateTaskRecord(record: any, task_index: number | number[]): void;
934937
updateTaskRecord(record: any, task_index: number, sub_task_index: number): void;
935938
updateTaskRecord(record: any, task_index: number | number[], sub_task_index?: number) {
@@ -947,17 +950,16 @@ export class Gantt extends EventTarget {
947950
this._refreshTaskBar(index, sub_index);
948951
return;
949952
}
950-
const index = task_index as number;
951-
952-
// if (this.taskListTableInstance.rowHierarchyType === 'tree' && typeof index === 'number') {
953-
// //如果是树形结构 需要获取数据源对应的索引
954-
// index = this.taskListTableInstance.getRecordIndexByCell(
955-
// 0,
956-
// index + this.taskListTableInstance.columnHeaderLevelCount
957-
// );
958-
// }
959-
this._updateRecordToListTable(record, index);
960-
this._refreshTaskBar(index, undefined);
953+
let recordIndexs: number | number[] = task_index;
954+
if (this.taskListTableInstance.rowHierarchyType === 'tree') {
955+
//如果是树形结构 需要获取数据源对应的索引
956+
recordIndexs = this.taskListTableInstance.getRecordIndexByCell(
957+
0,
958+
task_index + this.taskListTableInstance.columnHeaderLevelCount
959+
);
960+
}
961+
this._updateRecordToListTable(record, recordIndexs);
962+
this._refreshTaskBar(task_index, undefined);
961963
}
962964

963965
/**

packages/vtable-gantt/src/scenegraph/task-bar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ export class TaskBar {
161161
// clip: true
162162
});
163163
barGroupBox.name = 'task-bar';
164+
//如果TaskShowMode是tasks_separate模式 这里的task_index其实是table中的bodyIndex;如果TaskShowMode是sub_tasks_***模式 task_index也是对应父节点任务条在table中的bodyIndex(但不会渲染父节点,只是渲染子节点)
164165
barGroupBox.task_index = index;
166+
//如果TaskShowMode是tasks_separate模式,不会赋值sub_task_index;如果TaskShowMode是sub_tasks_***模式 这里的sub_task_index是父节点下子元素的index
165167
barGroupBox.sub_task_index = childIndex;
166168
barGroupBox.record = taskRecord;
167169

0 commit comments

Comments
 (0)