diff --git a/README.md b/README.md index 81d5f06254..a0c0fc569d 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ * [x] ~~v1.0 基于 vue2.6,支持所有主流的浏览器,实现表格的一切实用的功能~~ * [x] ~~v2.0 基于 vue2.6,支持所有主流的浏览器,同时兼具功能与性能~~ * [x] ~~v3.0 基于 vue2.6+,支持现代浏览器并保留兼容 IE11~~ - * [x] v3.9+ 基于 vue2.6+,内部重构,只支持现代浏览器,不支持 IE + * [x] v3.9+ 基于 vue2.6+,内部重构,拆分 Table 库和 UI 库,只支持现代浏览器,不支持 IE * [x] ~~v4.0 基于 vue3.2+,只支持现代浏览器,不支持 IE~~ - * [x] v4.7+ 基于 vue3.2+,内部重构,只支持现代浏览器,不支持 IE + * [x] v4.7+ 基于 vue3.2+,内部重构,拆分 Table 库和 UI 库,只支持现代浏览器,不支持 IE * [ ] 下一阶段:sticky 渲染模式、将虚拟滚动提升到极致、虚拟表单、数据图表可视化 ## 浏览器支持 diff --git a/package.json b/package.json index d30d62e6a1..e919828ef7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "4.9.19", + "version": "4.9.20", "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...", "scripts": { "update": "npm install --legacy-peer-deps", @@ -28,7 +28,7 @@ "style": "lib/style.css", "typings": "types/index.d.ts", "dependencies": { - "vxe-pc-ui": "^4.3.22" + "vxe-pc-ui": "^4.3.24" }, "devDependencies": { "@types/resize-observer-browser": "^0.1.11", diff --git a/packages/locale/lang/ar-EG.ts b/packages/locale/lang/ar-EG.ts index c26f8efc43..d3b67e2310 100644 --- a/packages/locale/lang/ar-EG.ts +++ b/packages/locale/lang/ar-EG.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/de-DE.ts b/packages/locale/lang/de-DE.ts index c425e675a3..dd70fa9eba 100644 --- a/packages/locale/lang/de-DE.ts +++ b/packages/locale/lang/de-DE.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/es-ES.ts b/packages/locale/lang/es-ES.ts index 858231969e..18175f0e21 100644 --- a/packages/locale/lang/es-ES.ts +++ b/packages/locale/lang/es-ES.ts @@ -47,8 +47,8 @@ export default { notExp: 'El navegador no es compatible con la importación / exportación.', impFields: 'Error de importación, por favor revise que el nombre del campo y el formato de datos sean correctos.', treeNotImp: 'La tabla de árbol no soporta importación.', - treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeCrossDrag: 'Only the first level of data can be dragged', + treeDragChild: 'Parent data cannot be dragged into its own child', reqPlugin: 'Optional extension "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/fr-FR.ts b/packages/locale/lang/fr-FR.ts index f22f95ac5b..2a301cdc4e 100644 --- a/packages/locale/lang/fr-FR.ts +++ b/packages/locale/lang/fr-FR.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/hu-HU.ts b/packages/locale/lang/hu-HU.ts index 32f8fb68ba..3a56768beb 100644 --- a/packages/locale/lang/hu-HU.ts +++ b/packages/locale/lang/hu-HU.ts @@ -48,7 +48,7 @@ export default { impFields: 'Az importálás nem sikerült, ellenőrizze, hogy a mezőnév és az adatformátum helyes-e', treeNotImp: 'A fatáblák nem támogatják az importálást', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/hy-AM.ts b/packages/locale/lang/hy-AM.ts index 566e82a00e..9dc89b521b 100644 --- a/packages/locale/lang/hy-AM.ts +++ b/packages/locale/lang/hy-AM.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/ja-JP.ts b/packages/locale/lang/ja-JP.ts index 9871e6dcce..1a941c6bf5 100644 --- a/packages/locale/lang/ja-JP.ts +++ b/packages/locale/lang/ja-JP.ts @@ -48,7 +48,7 @@ export default { impFields: 'インポートに失敗しました。フィールド名とデータ形式を確認してください', treeNotImp: 'ツリーテーブルはインポートをサポートしていません', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/ko-KR.ts b/packages/locale/lang/ko-KR.ts index d6c26255bd..69d3fabeb2 100644 --- a/packages/locale/lang/ko-KR.ts +++ b/packages/locale/lang/ko-KR.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/nb-NO.ts b/packages/locale/lang/nb-NO.ts index 9cfe62fc20..6b942226af 100644 --- a/packages/locale/lang/nb-NO.ts +++ b/packages/locale/lang/nb-NO.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/pt-BR.ts b/packages/locale/lang/pt-BR.ts index dec4a2548f..83ad76c267 100644 --- a/packages/locale/lang/pt-BR.ts +++ b/packages/locale/lang/pt-BR.ts @@ -48,7 +48,7 @@ export default { impFields: 'Falha na importação, verifique se o nome do campo e o formato dos dados estão corretos.', treeNotImp: 'A tabela de árvore não suporta importação.', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/ru-RU.ts b/packages/locale/lang/ru-RU.ts index aeaf0ef307..bddffe89bc 100644 --- a/packages/locale/lang/ru-RU.ts +++ b/packages/locale/lang/ru-RU.ts @@ -48,7 +48,7 @@ export default { impFields: 'Не удалось выполнить импорт. Проверьте правильность имени поля и формата данных.', treeNotImp: 'Древовидные таблицы не поддерживают импорт.', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/ug-CN.ts b/packages/locale/lang/ug-CN.ts index b032e3891b..c557dd28b0 100644 --- a/packages/locale/lang/ug-CN.ts +++ b/packages/locale/lang/ug-CN.ts @@ -48,7 +48,7 @@ export default { impFields: 'ئەكىرىشى مەغلۇپ بولدى،سۆز ھەم ئۇچۇر فورماتىنى تەكشۈرۈڭ', treeNotImp: 'دەرەخ شەكىللىك جەدىۋەلنى ئەكىرىشنى قوللىمايدۇ', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/uk-UA.ts b/packages/locale/lang/uk-UA.ts index f378b005ce..249c173eb0 100644 --- a/packages/locale/lang/uk-UA.ts +++ b/packages/locale/lang/uk-UA.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/vi-VN.ts b/packages/locale/lang/vi-VN.ts index f378b005ce..249c173eb0 100644 --- a/packages/locale/lang/vi-VN.ts +++ b/packages/locale/lang/vi-VN.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/zh-CHT.ts b/packages/locale/lang/zh-CHT.ts index 8cc0f0610c..3ca28054d8 100644 --- a/packages/locale/lang/zh-CHT.ts +++ b/packages/locale/lang/zh-CHT.ts @@ -48,7 +48,7 @@ export default { impFields: '匯入失敗,請檢查欄位名稱和資料格式是否正確', treeNotImp: '樹表格不支援導入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可選擴展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/locale/lang/zh-CN.ts b/packages/locale/lang/zh-CN.ts index 566e82a00e..9dc89b521b 100644 --- a/packages/locale/lang/zh-CN.ts +++ b/packages/locale/lang/zh-CN.ts @@ -48,7 +48,7 @@ export default { impFields: '导入失败,请检查字段名和数据格式是否正确', treeNotImp: '树表格不支持导入', treeCrossDrag: '只能拖拽第一层级的数据', - treeDragChild: '父级数据不能拖拽到子级中', + treeDragChild: '父级数据不能拖拽到自己的子级中', reqPlugin: '可选扩展插件 "{1}" https://vxeui.com/other{0}/#/{1}/install' }, table: { diff --git a/packages/table/render/index.ts b/packages/table/render/index.ts index 6e4bbe0f99..e168db1579 100644 --- a/packages/table/render/index.ts +++ b/packages/table/render/index.ts @@ -606,17 +606,36 @@ renderer.mixin({ renderTableCell (renderOpts, params) { const { props = {} } = renderOpts const { row, column } = params - const digits = props.digits || getConfig().numberInput?.digits || 2 + const { type } = props let cellValue = XEUtils.get(row, column.field) if (cellValue) { - switch (props.type) { - case 'float': - cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits) - break + if (type === 'float') { + const digits = props.digits || getConfig().numberInput.digits || 1 + cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits) + } else if (type === 'amount') { + const digits = props.digits || getConfig().numberInput.digits || 2 + cellValue = XEUtils.commafy(XEUtils.toNumber(cellValue), { digits }) } } return getCellLabelVNs(renderOpts, params, cellValue) }, + renderTableFooter (renderOpts, params) { + const { props = {} } = renderOpts + const { row, column, _columnIndex } = params + const { type } = props + // 兼容老模式 + const cellValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field) + if (XEUtils.isNumber(cellValue)) { + if (type === 'float') { + const digits = props.digits || getConfig().numberInput.digits || 1 + return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits) + } else if (type === 'amount') { + const digits = props.digits || getConfig().numberInput.digits || 2 + return XEUtils.commafy(XEUtils.toNumber(cellValue), { digits }) + } + } + return getFuncText(cellValue, 1) + }, renderTableDefault: defaultEditRender, renderTableFilter: defaultFilterRender, tableFilterDefaultMethod: handleInputFilterMethod diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index a143c9c37d..6fdb66b665 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -6215,6 +6215,9 @@ export default defineComponent({ cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent, level, height: 0 } } if (isSource) { + cacheItem.row = row + cacheItem.items = items + cacheItem.parent = parent cacheItem.level = level cacheItem.index = treeConfig && parent ? -1 : index fullDataRowIdMaps[rowid] = cacheItem @@ -6995,8 +6998,8 @@ export default defineComponent({ } }, triggerCurrentColumnEvent (evnt, params) { - const columnOpts = computeColumnOpts - const { currentMethod } = columnOpts.value + const columnOpts = computeColumnOpts.value + const { currentMethod } = columnOpts const { column } = params if (!currentMethod || currentMethod({ column })) { tableMethods.setCurrentColumn(column) @@ -7004,8 +7007,8 @@ export default defineComponent({ }, triggerCurrentRowEvent (evnt, params) { const { currentRow: oldValue } = reactData - const rowOpts = computeRowOpts - const { currentMethod } = rowOpts.value + const rowOpts = computeRowOpts.value + const { currentMethod } = rowOpts const { row: newValue } = params const isChange = oldValue !== newValue if (!currentMethod || currentMethod({ row: newValue })) {