diff --git a/common/changes/@visactor/vtable/fix-fix-secondsUnit_2025-12-23-14-32.json b/common/changes/@visactor/vtable/fix-fix-secondsUnit_2025-12-23-14-32.json new file mode 100644 index 0000000000..fec42511a0 --- /dev/null +++ b/common/changes/@visactor/vtable/fix-fix-secondsUnit_2025-12-23-14-32.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix the issue with second-level display length\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "rem2248668357@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/vtable/fix-gantt-secondsUnit-parse_2025-12-25-08-39.json b/common/changes/@visactor/vtable/fix-gantt-secondsUnit-parse_2025-12-25-08-39.json new file mode 100644 index 0000000000..8b45c6d74c --- /dev/null +++ b/common/changes/@visactor/vtable/fix-gantt-secondsUnit-parse_2025-12-25-08-39.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "refactor: recognize millisecond for gantt taskbar\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file diff --git a/docs/assets/guide/en/edit/edit_cell.md b/docs/assets/guide/en/edit/edit_cell.md index ca8e09db90..f08d9ee571 100644 --- a/docs/assets/guide/en/edit/edit_cell.md +++ b/docs/assets/guide/en/edit/edit_cell.md @@ -188,6 +188,8 @@ In the above example, we created a custom editor named `DateEditor` and implemen ```ts export interface IEditor { + /** Prepare the edit environment, when the edit trigger is keydown in vtable, the mouse click on the cell will call this method, otherwise the first character of the Chinese input method will be treated as an English character */ + prepareEdit?: (context: PrepareEditContext) => void; /** Called when cell enters edit mode. */ onStart?: (context: EditContext) => void; /** called when cell exits edit mode. */ @@ -331,6 +333,11 @@ The basic table supports editing the display title in the header. You can enable The source data corresponding to a specific cell can be obtained through the interface `getCellOriginRecord` + +## edit trigger timing is keydown notice + +If the first pinyin is recognized as an English character under the Chinese input method, please check if there is a prepareEdit function. When the edit trigger is keydown, the mouse click on the cell will call this method to create an input box in advance, and set the input box to invisible, waiting for user input. + ## Summary Through the above steps, you can create a table with editing functions, select the appropriate editor type according to business needs, customize the editor, listen to editing events, and obtain edited data. In this way, users can easily edit the data in the table, and you can process the edited data accordingly. diff --git a/docs/assets/guide/zh/edit/edit_cell.md b/docs/assets/guide/zh/edit/edit_cell.md index 82d331cd69..2790e1acd3 100644 --- a/docs/assets/guide/zh/edit/edit_cell.md +++ b/docs/assets/guide/zh/edit/edit_cell.md @@ -193,6 +193,8 @@ VTable.register.editor('custom-date', custom_date_editor); ```ts export interface IEditor { + /** 准备编辑环境,vtable中编辑时机eeditCellTrigger为keydown时,鼠标点击单元格将调用此方法,否则中文输入法第一个字符会被当做英文字符 */ + prepareEdit?: (context: PrepareEditContext) => void; /** * 单元格进入编辑状态时调用 */ onStart: (context: EditContext) => void; /** * 单元格退出编辑状态时调用 */ @@ -332,6 +334,9 @@ interface ListTableAPI { 具体单元格对应的源数据可以通过接口`getCellOriginRecord`来获取。 +## 编辑时机为keydown时注意事项 + 中文输入法下如果出现第一个拼音被识别成了英文字符,那么请检查是否有prepareEdit 函数。在编辑时机为keydown时,鼠标点击单元格将调用此方法,提前将创建输入框,并将输入框设置为不可见,等待用户输入。 + ## 总结 通过以上步骤,你可以创建一个具有编辑功能的表格,并根据业务需求选择合适的编辑器类型、自定义编辑器、监听编辑事件以及获取编辑后的数据。这样,用户就可以方便地编辑表格中的数据,并且你可以对编辑后的数据进行相应的处理。 diff --git a/packages/vtable-gantt/src/Gantt.ts b/packages/vtable-gantt/src/Gantt.ts index 5cc41362d3..5de83ccaf0 100644 --- a/packages/vtable-gantt/src/Gantt.ts +++ b/packages/vtable-gantt/src/Gantt.ts @@ -924,9 +924,21 @@ export class Gantt extends EventTarget { startDate = createDateAtMidnight( Math.min(Math.max(this.parsedOptions._minDateTime, rawDateStartDateTime), this.parsedOptions._maxDateTime) ); + // 修复:当原始日期字符串已包含时毫秒时,不应强制设置毫秒为999 + const rawEnd = taskRecord?.[endDateField]; + // 判断:是否"提供了毫秒部分" + // 字符串:检查是否包含毫秒(秒之后的小数点,如 :SS.SSS 或 :SS.SSSSSS) + // Date/number:视为已提供时间,但无法判断是否包含毫秒,保守处理为未提供 + let hasMillisecondProvided = false; + if (typeof rawEnd === 'string') { + // 匹配秒之后的小数点格式::SS.SSS 或 :SS.SSSSSS 等 + // 也匹配 ISO 格式:T12:30:45.123Z + hasMillisecondProvided = /:\d{2}\.\d+/.test(rawEnd); + } + const shouldForceMillisecond = !hasMillisecondProvided; endDate = createDateAtLastMillisecond( Math.max(Math.min(this.parsedOptions._maxDateTime, rawDateEndDateTime), this.parsedOptions._minDateTime), - true + shouldForceMillisecond ); // const minTimeSaleIsSecond = this.parsedOptions.reverseSortedTimelineScales[0].unit === 'second'; } else {