diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..9d1820caf874e2c85c658e0d9ad56de5318a2ccd --- /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 0000000000000000000000000000000000000000..d0abfdd8171509fc8faa4c41bd790446ad8b36c4 --- /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 f778915b11b42a9368a1ce67bccbf4dbf1e40218..c1cc5497d68ddee882963987bb331ca128199ecf 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 cb1d944c572e28af877e201658851b26dcc5ef8f..edab67a204212de1e135d0219dccb0006ab1dd54 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 83d87222058e5ffa865029b18a2af58190693e71..2cf5bccf4054444295590edf9bad35af0fdbe2ff 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 22effc6113f84a07c5bac62a53330bf6d6dc39f3..8d1189fcbeb4535338918a1791cd910d45b9aa8c 100644 --- a/library/src/main/resources/rawfile/vtable_util.js +++ b/library/src/main/resources/rawfile/vtable_util.js @@ -96,15 +96,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() + } } } @@ -152,18 +154,37 @@ function unmergeCells(startCol, startRow, endCol, endRow) { console.error('表格实例未找到'); return; } - const cellnumber = window.tableInstance.getCellValue(startCol, startRow, true); + let hasMergeCells = false; + console.log("=====> unmergeCells", JSON.stringify(window.tableInstance.editorManager.editingEditor)) + 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) { @@ -249,6 +270,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); }); })