From c6cd773b7c7448576e81a81fe70dabe6d4dfd316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E7=81=BF?= <2669958319@qq.com> Date: Tue, 6 Jan 2026 18:58:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0CHANGELOG.md=E3=80=81README?= =?UTF-8?q?=5Fzh.md=E3=80=81=E4=BF=AE=E6=94=B9package=E3=80=81README.md?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E3=80=81=E4=BF=AE=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +++ README.OpenSource | 11 ++++ README.en.md => README.md | 4 +- README_zh.md | 4 +- library/oh-package.json5 | 13 +++- .../src/main/resources/rawfile/vtable_util.js | 62 ++++++++++++++----- 6 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 README.OpenSource rename README.en.md => README.md (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9d1820c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +## [V 1.0.0] +### Added +- VTable core logic implemented using native ArkTS + +### Changed +- Replace the original types used in JS with custom types \ No newline at end of file diff --git a/README.OpenSource b/README.OpenSource new file mode 100644 index 0000000..d0abfdd --- /dev/null +++ b/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "name": "VTable for ArkTS", + "License": "MIT License", + "License File": "LICENSE", + "Version Number": "1.0.0", + "Owner": "", + "Upstream URl": "https://github.com/VisActor/VTable", + "Description": "VTable is a powerful and flexible data table component for ArkTS, which can be used to display and manipulate data in a variety of formats. With its intuitive interface and powerful features, VTable makes it easy to work with large datasets and analyze them quickly and efficiently.", + } +] \ No newline at end of file diff --git a/README.en.md b/README.md similarity index 96% rename from README.en.md rename to README.md index f778915..c1cc549 100644 --- a/README.en.md +++ b/README.md @@ -181,8 +181,8 @@ Verified on the following versions: ## Contributing -If you encounter any issues during use, feel free to submit an [Issue](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/issues). Of course, we also welcome [PR](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/pulls) submissions. +If you encounter any issues during use, feel free to submit an [Issue](https://gitcode.com/openharmony-tpc-incubate/ohos_VTable/issues). Of course, we also welcome [PR](https://gitcode.com/openharmony-tpc-incubate/ohos_VTable/pulls) submissions. ## Open Source License -This project follows the [BSD-2-Clause]() license. Feel free to enjoy and participate in open source. \ No newline at end of file +This project follows the [MIT]() license. Feel free to enjoy and participate in open source. \ No newline at end of file diff --git a/README_zh.md b/README_zh.md index cb1d944..edab67a 100644 --- a/README_zh.md +++ b/README_zh.md @@ -187,8 +187,8 @@ this.vTableController.setZoom(true) ## 贡献代码 -使用过程中发现任何问题都可以提交 [Issue](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/issues),当然,也非常欢迎提交 [PR](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/pulls) 。 +使用过程中发现任何问题都可以提交 [Issue](https://gitcode.com/openharmony-tpc-incubate/ohos_VTable/issues),当然,也非常欢迎提交 [PR](https://gitcode.com/openharmony-tpc-incubate/ohos_VTable/pulls) 。 ## 开源协议 -本项目遵循 [BSD-2-Clause](), 请自由的享受和参与开源。 +本项目遵循 [MIT](), 请自由的享受和参与开源。 diff --git a/library/oh-package.json5 b/library/oh-package.json5 index 83d8722..2cf5bcc 100644 --- a/library/oh-package.json5 +++ b/library/oh-package.json5 @@ -1,9 +1,16 @@ { + "types": "", + "keywords": [ + "OpenHarmony", + "HarmonyOS", + "VTable" + ], "name": "@ohos/vtable", "version": "1.0.0", - "description": "Please describe the basic information.", + "description": "本软件是参照开源库VTable适配OpenHarmony实现的表格组件", "main": "Index.ets", - "author": "", - "license": "Apache-2.0", + "author": "ohos_tpc", + "repository": "https://gitee.com/openharmony-tpc-incubate/ohos_VTable", + "license": "MIT", "dependencies": {} } diff --git a/library/src/main/resources/rawfile/vtable_util.js b/library/src/main/resources/rawfile/vtable_util.js index 1626c00..50e4656 100644 --- a/library/src/main/resources/rawfile/vtable_util.js +++ b/library/src/main/resources/rawfile/vtable_util.js @@ -163,15 +163,17 @@ var eventCallback = (type, data) => { dataPreview: JSON.stringify(filteredData).substring(0, 100) + '...' }); - if (type === 'CHANGE_CELL_VALUE'){ - let aa = window.tableInstance.getSelectedCellInfos() - // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[0][0].col)) - // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[0][0].row)) - // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[1][1].col)) - // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[1][1].row)) - window.tableInstance.unmergeCells(aa[0][0].col, aa[0][0].row, aa[aa.length-1][aa[0].length-1].col, aa[aa.length-1][aa[0].length-1].row) - window.tableInstance.mergeCells(aa[0][0].col, aa[0][0].row, aa[aa.length-1][aa[0].length-1].col, aa[aa.length-1][aa[0].length-1].row) - // renderWithRecreateCells() + if (type === 'CHANGE_CELL_VALUE') { + let aa = window.tableInstance.getSelectedCellInfos() + if (aa[0][0].col !== aa[aa.length - 1][aa[0].length - 1].col || aa[0][0].row !== aa[aa.length - 1][aa[0].length - 1].row) { + console.log("=====> getSelectedCellInfos", JSON.stringify(aa[0][0].col)) + // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[0][0].row)) + // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[1][1].col)) + // console.log("=====> getSelectedCellInfos", JSON.stringify(aa[1][1].row)) + window.tableInstance.unmergeCells(aa[0][0].col, aa[0][0].row, aa[aa.length - 1][aa[0].length - 1].col, aa[aa.length - 1][aa[0].length - 1].row) + window.tableInstance.mergeCells(aa[0][0].col, aa[0][0].row, aa[aa.length - 1][aa[0].length - 1].col, aa[aa.length - 1][aa[0].length - 1].row) + // renderWithRecreateCells() + } } } @@ -219,19 +221,37 @@ function unmergeCells(startCol, startRow, endCol, endRow) { console.error('表格实例未找到'); return; } + let hasMergeCells = false; console.log("=====> unmergeCells", JSON.stringify(window.tableInstance.editorManager.editingEditor)) - const cellnumber = window.tableInstance.getCellValue(startCol, startRow, true); + let a for (let i = startCol; i <= endCol; i++) { for (let j = startRow; j <= endRow; j++) { - if (i === startCol && j === startRow) { - window.tableInstance.changeCellValue(i, j, cellnumber); - } else { - window.tableInstance.changeCellValue(i, j, ''); + a = window.tableInstance.getCellRange(i, j) + if (a.isCustom) { + hasMergeCells = a.isCustom } + console.log("=====> unmergeCellsrange", JSON.stringify(a)) } + } + console.log("=====> unmergeCells", JSON.stringify(hasMergeCells)) + if (hasMergeCells) { + // if (startCol !== endCol || startRow !== endRow) { + const cellnumber = window.tableInstance.getCellValue(startCol, startRow, true); + console.log("=====> unmergeCells", JSON.stringify(a.start.col)) + + for (let i = a.start.col; i <= a.end.col; i++) { + for (let j = a.start.row; j <= a.end.row; j++) { + if (i === a.start.col && j === a.start.row) { + window.tableInstance.changeCellValue(i, j, cellnumber); + } else { + window.tableInstance.changeCellValue(i, j, ''); + } + } + } + window.tableInstance.unmergeCells(a.start.col, a.start.row, a.end.col, a.end.row); + // } } - window.tableInstance.unmergeCells(startCol, startRow, endCol, endRow); } // 自定义渲染 function customRender(startCol, startRow, endCol, endRow, id, style) { @@ -317,6 +337,18 @@ function initializeTable(option) { const tableInstance = new VTable.ListTable(document.getElementById('tableContainer'), option); eventList.forEach(eventName => { tableInstance.on(VTable.ListTable.EVENT_TYPE[eventName], (event) => { + if (eventName === 'CLICK_CELL') { + tableInstance.eventManager.isDraging = false; + // console.log("=====> CLICK_CELL", JSON.stringify(tableInstance.eventManager.isDraging)) + // tableInstance.stateManager.interactionState = VTable.InteractionState.default; + // console.log("=====> CLICK_CELL2", JSON.stringify(tableInstance.eventManager.isDraging)) + + // 仅执行单选(可选,确保点击只选中当前单元格) + // tableInstance.stateManager.updateSelectPosition( + // event.col, event.row, false, false, false + // ); + // console.log("=====> CLICK_CELL3", JSON.stringify(tableInstance.eventManager.isDraging)) + } eventCallback(eventName, event); }); }) -- Gitee