+
+
+
+ |
{{ rowIndex + 1 }} |
{{ colOption.fieldType === 'date' ? (rowItem[colOption.field] | i18nDate: 'short':false) : rowItem[colOption.field] }}
diff --git a/devui/data-table/demo/mutil-styles/mutil-styles.component.ts b/devui/data-table/demo/mutil-styles/mutil-styles.component.ts
index 7bb11740..6a1c1a61 100644
--- a/devui/data-table/demo/mutil-styles/mutil-styles.component.ts
+++ b/devui/data-table/demo/mutil-styles/mutil-styles.component.ts
@@ -84,6 +84,10 @@ export class MutilStylesComponent implements OnInit {
};
tableWidthConfig: TableWidthConfig[] = [
+ {
+ field: 'checkbox',
+ width: '50px'
+ },
{
field: '#',
width: '50px'
@@ -114,6 +118,10 @@ export class MutilStylesComponent implements OnInit {
this.tableWidthConfig = [];
} else {
this.tableWidthConfig = [
+ {
+ field: 'checkbox',
+ width: '50px'
+ },
{
field: '#',
width: '50px'
diff --git a/devui/data-table/doc/api-cn.md b/devui/data-table/doc/api-cn.md
index 712befa2..f3e2f2d4 100644
--- a/devui/data-table/doc/api-cn.md
+++ b/devui/data-table/doc/api-cn.md
@@ -22,6 +22,7 @@ import { DataTableModule } from 'ng-devui/data-table';
| scrollable | `boolean` | -- | 可选,表格在超出容器时,是否可以通过滚动查看表格内容 | [表格交互](demo#table-interaction) |
| maxWidth | `string px` | -- | 可选,限制表格最大宽度,默认撑满父容器 |
| maxHeight | `string px` | -- | 可选,限制最大高度,默认 | [表头固定](demo#table-fixing) |
+| minHeight | `string px` | -- | 可选,限制最小高度 | -- |
| size | `'sm'\|'md'\|'lg'` | 'sm' | 可选,表格大小,分别对应行高40px,48px,56px |[表格样式](demo#mutil-styles) |
| rowHoveredHighlight | `boolean` | true | 可选,鼠标悬浮行时是否高亮,默认高亮认 |
| generalRowHoveredData | `boolean` | false | 可选,使用配置column方式实现table,鼠标悬浮行时$hovered是否记录到rowItem中,默认不记录 |
@@ -31,11 +32,11 @@ import { DataTableModule } from 'ng-devui/data-table';
| containFixHeaderHeight | `boolean` | false | 可选,固定表头指定的高度是否包含表头高度,`tableHeight`设置的高度默认是表格body的高度 | [固定表头虚拟滚动](demo#fixed-virtual-scroll) |
| fixHeader | `boolean` | false | 可选,表头是否固定 | [固定表头虚拟滚动](demo#fixed-virtual-scroll) |
| checkableRelation | [`CheckableRelation`](#checkablerelation) | -- | 可选,配置树形表格的父子选中是否互相关联 | [树形表格](demo#tree-form) |
-| loadChildrenTable | `Promise` | -- | 可选,展开子表格的回调,用于异步加载子表格 | [树形表格](demo#tree-form) |
-| loadAllChildrenTable | `Promise` | -- | 可选,表头展开所有子表格的回调,用于异步加载所有子表格 | [树形表格](demo#tree-form) |
+| loadChildrenTable | `(rowItem: any) => Promise` | -- | 可选,展开子表格的回调,用于异步加载子表格 | [树形表格](demo#tree-form) |
+| loadAllChildrenTable | `() => Promise` | -- | 可选,表头展开所有子表格的回调,用于异步加载所有子表格 | [树形表格](demo#tree-form) |
| colDraggable | `boolean` | false | 可选,表格列是否可拖动排序 | [列拖拽](demo#column-dragging) |
| colDropFreezeTo | `number` | 0 | 可选,表格列可拖动排序时配置前n列不可拖动 | [列拖拽](demo#column-dragging) |
-| virtualScroll | `boolean` | false | 可选,是否开启虚拟滚动 | [虚拟滚动](demo#virtual-scroll) |
+| virtualScroll | `boolean` | false | 可选,是否开启虚拟滚动,虚拟滚动参数对树形表格不生效 | [虚拟滚动](demo#virtual-scroll) |
| virtualItemSize | `number` | 40 | 可选,虚拟滚动时每一行的高度,默认为表格默认行高40`px` | [虚拟滚动](demo#virtual-scroll) |
| virtualMinBufferPx | `number` | 80 | 可选,虚拟滚动时缓冲区最小像素高度,低于该值时将加载新结构 | [虚拟滚动](demo#virtual-scroll) |
| virtualMaxBufferPx | `number` | 200 | 可选,虚拟滚动时缓冲区最大像素高度 | [虚拟滚动](demo#virtual-scroll) |
@@ -51,11 +52,11 @@ import { DataTableModule } from 'ng-devui/data-table';
| hideColumn | `string[]` | -- | 可选,用于隐藏列,传入对应的field字段 |
| pageAllChecked | `boolean` | -- | 可选,选中当前页所有row |
| onlyOneColumnSort | `boolean` | -- | 可选,是否限制多列排序的输出限制为一项 | [表格交互](demo#table-interaction) |
-| multiSort | [`SortEventArg[]`](#sorteventarg) | [] | 可选,多列选择数组,用来指导那几列会被排序 | [表格交互](demo#table-interaction) |
+| multiSort | [`SortEventArg[]`](#sorteventarg) | [] | 可选,多列选择数组,用来指导那几列会被排序,仅column模式下有效 | [表格交互](demo#table-interaction) |
| resizeable | `boolean` | -- | 可选,是否可以拖拽调整列宽 | [表格交互](demo#table-interaction) |
| timeout | `number` | 300 | 可选,同时绑定单击、双击事件时,用于区分点击的时间间隔, 默认300`ms`,两个事件不同时使用可以指定为0 |
| headerExpandConfig | [`TableExpandConfig`](#tableexpandconfig) | -- | 可选,配置header下的额外内容 | [扩展行](demo#expand-row) |
-| beforeCellEdit | `Promise` | -- | 可选,单元格编辑前的拦截方法, resolve(extraOptions)将更新该列的extraOptions | [编辑单元格](demo#edit-cell) |
+| beforeCellEdit | `(rowItem: any, column: any) => Promise` | -- | 可选,单元格编辑前的拦截方法, resolve(extraOptions)将更新该列的extraOptions | [编辑单元格](demo#edit-cell) |
| headerBg | `boolean` | false | 可选,表头是否显示背景色 | [表格样式](demo#mutil-styles) |
| tableLayout | `'fixed'\|'auto'` | 'fixed' | 可选,表格布局 | [表格样式](demo#mutil-styles) |
| borderType | `''\|'bordered'\|'borderless'` | '' | 可选,表格边框类型,默认有行边框,bordered:全边框,borderless:无边框 | [表格样式](demo#mutil-styles) |
@@ -70,7 +71,7 @@ import { DataTableModule } from 'ng-devui/data-table';
| resize | `EventEmitter` | 列宽变化事件,返回单元格信息 | [表格交互](demo#table-interaction) |
| childrenTableClose | `EventEmitter` | 子列表关闭事件,返回列表行信息 |
| allChildrenTableClose | `EventEmitter` | 全部子列表关闭事件 |
-| multiSortChange | `EventEmitter` | 多列选择Change事件,用来更新多列选择数组,返回单元格信息 | [表格交互](demo#table-interaction) |
+| multiSortChange | `EventEmitter` | 多列选择Change事件,用来更新多列选择数组,返回单元格信息, 仅column模式下生效 | [表格交互](demo#table-interaction) |
| cellClick | `EventEmitter` | 表格单元格点击事件,返回单元格信息 | [表格交互](demo#table-interaction) |
| cellDBClick | `EventEmitter` | 表格单元格双击事件,返回单元格信息 | [表格交互](demo#table-interaction) |
| rowClick | `EventEmitter` | 表格行点击事件,返回行信息 | [表格交互](demo#table-interaction) |
@@ -80,6 +81,7 @@ import { DataTableModule } from 'ng-devui/data-table';
| cellEditEnd | `EventEmitter` | 表格单元格结束编辑事件,返回单元格信息 | [编辑单元格](demo#edit-cell) |
| tableScrollEvent | `EventEmitter` | 表格内部滚动事件 | |
| columnDragEnd | `EventEmitter<{form: index, to: index}>` | 列拖拽结束事件 | [列拖拽](demo#column-dragging) |
+| loadMore | `EventEmitter<{any}>` | 延迟懒加载完成事件 | [懒加载](demo#lazy-loading-of-list-data) |
### d-data-table 公共方法
@@ -121,7 +123,7 @@ import { DataTableModule } from 'ng-devui/data-table';
| resizeEnabled | `boolean` | -- | 可选,该列宽度是否可调整 | [表格交互](demo#table-interaction) |
| maxWidth | `string` | -- | 可选,拖动调整宽度时的最大宽度,单位`px` |
| minWidth | `string` | -- | 可选,拖动调整宽度时的最小宽度,单位`px` |
-| filterable | `boolean` | -- | 可选,该列宽度是否可过滤 | [表格交互](demo#table-interaction) |
+| filterable | `boolean` | -- | 可选,该列是否可过滤 | [表格交互](demo#table-interaction) |
| closeFilterWhenScroll | `boolean` | -- | 可选,表格或者body滚动时是否关闭过滤框 | [表格交互](demo#table-interaction) |
| customFilterTemplate | `TemplateRef` | -- | 可选,过滤弹出框的自定义模板 | [表格交互](demo#table-interaction) |
| extraFilterTemplate | `TemplateRef` | -- | 可选,过滤弹出框扩展区域自定义模板 | [表格交互](demo#table-interaction) |
@@ -130,12 +132,12 @@ import { DataTableModule } from 'ng-devui/data-table';
| filterMultiple | `boolean` | -- | 可选,设置该列为多选或单选, true为多选,false为单选 | [表格交互](demo#table-interaction) |
| filterBoxWidth | `string` | -- | 过滤弹出框的宽度,如:‘300px’ |
| filterBoxHeight | `string` | -- | 过滤弹出框的高度,如:‘400px’ |
-| beforeFilter | `function\|Promise\|Observable` | -- | 可选,表格过滤弹出框弹出前的回调函数,返回false可阻止弹框弹出 | [表格交互](demo#table-interaction) |
+| beforeFilter | `(value) => boolean \| Promise \| Observable` | -- | 可选,表格过滤弹出框弹出前的回调函数,返回false可阻止弹框弹出 | [表格交互](demo#table-interaction) |
| sortable | `boolean` | -- | 可选,该列是否可排序 | [表格交互](demo#table-interaction) |
| sortDirection | `SortDirection` | -- | 可选,设置该列的已排序状态 | [表格交互](demo#table-interaction) |
| nestedColumn | `boolean` | -- | 可选,是否展示树形表格的表头展开\折叠图标 | [树形表格](demo#tree-form) |
-| iconFoldTable | `DOMString` | -- | 可选,自定义树形表格的折叠图标 | [树形表格](demo#tree-form) |
-| iconUnFoldTable | `DOMString` | -- | 可选,自定义树形表格的展开图标 | [树形表格](demo#tree-form) |
+| iconFoldTable | `DOMString` | -- | 可选,自定义树形表格的折叠图标,传入自定义html字符串 | [树形表格](demo#tree-form) |
+| iconUnFoldTable | `DOMString` | -- | 可选,自定义树形表格的展开图标,传入自定义html字符串 | [树形表格](demo#tree-form) |
| fixedLeft | `string` | -- | 可选,该列固定到左侧的距离,如:‘100px’ | [固定列](demo#fixed-column) |
| fixedRight | `string` | -- | 可选,该列固定到右侧的距离,如:‘100px’ | [固定列](demo#fixed-column) |
| showSortIcon | `boolean` | fasle | 可选,是否显示排序未激活图标,默认不显示 | [表格交互](demo#table-interaction) |
@@ -145,12 +147,13 @@ import { DataTableModule } from 'ng-devui/data-table';
| 事件 | 类型 | 描述 | 跳转 Demo |
| :----------------------: | :-----------------: | :-------------------------------------------------: | :------------------------------------------------------- |
-| filterChange | `FilterConfig[]` | 确认筛选回调事件,返回选中的筛选数组 | [表格交互](demo#table-interaction) |
-| sortChange | `SortEventArg` | 排序回调事件,返回该列排序信息 | [表格交互](demo#table-interaction) |
-| resizeStartEvent | `MouseEvent` | 该列宽度调整开始时的事件 |
-| resizingEvent | `{ width: string }` | 该列宽度调整进行中的事件 |
-| resizeEndEvent | `{ width: string }` | 该列宽度调整结束时的事件 | [表格交互](demo#table-interaction) |
-| toggleChildrenTableEvent | `boolean` | 所有子表格展开收起事件,true表示展开,false表示收起 |
+| filterChange | `EventEmitter` | 确认筛选回调事件,返回选中的筛选数组 | [表格交互](demo#table-interaction) |
+| sortChange | `EventEmitter` | 排序回调事件,返回该列排序信息 | [表格交互](demo#table-interaction) |
+| resizeStartEvent | `EventEmitter` | 该列宽度调整开始时的事件 |
+| resizingEvent | `EventEmitter<{ width: string }>` | 该列宽度调整进行中的事件 |
+| resizeEndEvent | `EventEmitter<{ width: string }>` | 该列宽度调整结束时的事件 | [表格交互](demo#table-interaction) |
+| toggleChildrenTableEvent | `EventEmitter` | 所有子表格展开收起事件,true表示展开,false表示收起 | |
+| sortDirectionChange | `EventEmitter` | 排序顺序方向变化事件 |
# dTableCell
@@ -177,8 +180,8 @@ import { DataTableModule } from 'ng-devui/data-table';
| 事件 | 类型 | 描述 | 跳转 Demo |
| :-------------------: | :-------: | :-----------------------------------------------------: | :------------------------------------------------- |
-| editStatusEvent | `boolean` | 单元格编辑状态事件 | [编辑单元格](demo#edit-cell) |
-| toggleChildTableEvent | `boolean` | 当前行的子表格展开收起事件,true表示展开,false表示收起 | [树形表格](demo#tree-form) |
+| editStatusEvent | `EventEmitter` | 单元格编辑状态事件 | [编辑单元格](demo#edit-cell) |
+| toggleChildTableEvent | `EventEmitter` | 当前行的子表格展开收起事件,true表示展开,false表示收起 | [树形表格](demo#tree-form) |
#### 使用自定义模板方式时配置dTableBody的行模板
@@ -340,15 +343,17 @@ export enum SortDirection {
| closeFilterWhenScroll | `boolean` | -- | 可选,表格或者body滚动时是否关闭过滤框 | [表格交互](demo#table-interaction) |
| filterList | `array` | -- | 传入需要操作的筛选列表,当filterable为true时必选 | [表格交互](demo#table-interaction) |
| filterMultiple | `boolean` | true | 可选,选择筛选列表为多选或单选, true为多选,false为单选 | [表格交互](demo#table-interaction) |
+| filterIconActive | `boolean` | false | 可选,主动设置filter 图标是否激活 | [表格交互](demo#table-interaction) |
| customFilterTemplate | `TemplateRef` | -- | 可选,表格过滤弹出框的自定义模板,参考DOC下‘自定义过滤弹出框’使用 | [表格交互](demo#table-interaction) |
| extraFilterTemplate | `TemplateRef` | -- | 可选,表格过滤弹出框扩展区域自定义模板 | [表格交互](demo#table-interaction) |
-| beforeFilter | `function、Promise、Observable` | -- | 可选,表格过滤弹出框弹出前的回调函数,返回false可阻止弹框弹出 | [表格交互](demo#table-interaction) |
+| beforeFilter | `(value) => boolean \| Promise \| Observable` | -- | 可选,表格过滤弹出框弹出前的回调函数,返回false可阻止弹框弹出 | [表格交互](demo#table-interaction) |
| cellClass | `string` | -- | 该列单元格自定义class |
| fixedLeft | `string` | -- | 该列固定到左侧的距离,如:‘100px’ | [固定列](demo#fixed-column) |
| fixedRight | `string` | -- | 该列固定到右侧的距离,如:‘100px’ | [固定列](demo#fixed-column) |
| filterBoxWidth | `any` | -- | 过滤弹出框的宽度,如:‘300px’ |
| filterBoxHeight | `any` | -- | 过滤弹出框的高度,如:‘400px’ |
| nestedColumnIndent | `number` | 16 | 单元格中子表格的缩进距离,单位px | [树形表格](demo#tree-form) |
+| advancedHeader | `advancedHeader` | -- | column类型的表格中实现表头单元格合并 | [树形表格](demo#tree-form) |
## d-column 事件
@@ -446,4 +451,4 @@ advancedHeader: Array < {
}
```
-注意: 空单元格也需要表示,并根据内容把rowspan/colspan置为0,如果同时使用列宽拖拽和多行表头,请为列内容附上宽度width,如果第一行的列宽度不正确,请手动为advancedHeader[rowNumber]增加一个属性$width
\ No newline at end of file
+注意: 空单元格也需要表示,并根据内容把rowspan/colspan置为0,如果同时使用列宽拖拽和多行表头,请为列内容附上宽度width,如果第一行的列宽度不正确,请手动为advancedHeader[rowNumber]增加一个属性$width
diff --git a/devui/data-table/doc/api-en.md b/devui/data-table/doc/api-en.md
index 318eca60..76ac9a5f 100644
--- a/devui/data-table/doc/api-en.md
+++ b/devui/data-table/doc/api-en.md
@@ -22,6 +22,7 @@ On the page:
| scrollable | `boolean` | -- | Optional. Whether the table content can be viewed by scrolling when the table exceeds the container. | [Table interaction](demo#table-interaction) |
| maxWidth | `string px` | -- | Optional. Limit the maximum table width. By default, the parent container is full. |
| maxHeight | `string px` | -- | Optional. The maximum height is limited. The default value is | [fixed table header](demo#table-fixing) |
+| minHeight | `string px` | -- | Optional, limit the minimum height | -- |
| size | `'sm'\|'md'\|'lg'`| 'sm' | Optional. Specifies the table size, which corresponds to 40 px, 48 px, and 56 px respectively | [Table style](demo#mutil-styles) |
| rowHoveredHighlight | `boolean` | true | Optional. Indicating whether to highlight a line when the cursor is hovering. The default value is highlighted. |
| generalRowHoveredData | `boolean` | false | Optional. It is used to configure columns to implement the table. When the cursor is moved to a row, $hovered is recorded to the row item. By default, $hovered is not recorded. |
@@ -31,11 +32,11 @@ On the page:
| containFixHeaderHeight | `boolean` | false | Optional. whether the height specified by the fixed header includes the height of the header, the height set by tableHeight is the height of the table body by default | [Fixed table header virtual scrolling](demo#fixed-virtual-scroll) |
| fixHeader | `boolean` | false | Optional. Whether the table header is fixed | [Fixed table header virtual scrolling](demo#fixed-virtual-scroll) |
| checkableRelation | [`CheckableRelation`](#checkablerelation) | -- | Optional. This parameter specifies whether the parent and child selections in the tree table are associated. | [Tree table](demo#tree-form) |
-| loadChildrenTable | `Promise` | -- | Optional. It is the callback of subtable expansion, which is used to asynchronously load subtables. | [Tree table](demo#tree-form) |
-| loadAllChildrenTable | `Promise` | -- | Optional. It is the callback for expanding all subtables in the table header. It is used to asynchronously load all subtables. | [Tree table](demo#tree-form) |
+| loadChildrenTable | ``(rowItem: any) => Promise` | -- | Optional. It is the callback of subtable expansion, which is used to asynchronously load subtables. | [Tree table](demo#tree-form) |
+| loadAllChildrenTable | `() => Promise` | -- | Optional. It is the callback for expanding all subtables in the table header. It is used to asynchronously load all subtables. | [Tree table](demo#tree-form) |
| colDraggable | `boolean` | false | Optional. Whether columns can be dragged or sorted | [Column dragging](demo#column-dragging) |
| colDropFreezeTo | `number` | 0 | Optional. The first n columns cannot be dragged when the table columns can be sorted. | [Column dragging](demo#column-dragging) |
-| virtualScroll | `boolean` | false | Optional. Specifies whether to enable virtual scrolling. | [Virtual scrolling](demo#virtual-scroll) |
+| virtualScroll | `boolean` | false | Optional. Specifies whether to enable virtual scrolling. Virtual scrolling parameters do not take effect for tree tables. | [Virtual scrolling](demo#virtual-scroll) |
| virtualItemSize | `number` | 40 | Optional. Height of each row during virtual scrolling. The default value is 40`px`. | [Virtual scrolling](demo#virtual-scroll) |
| virtualMinBufferPx | `number` | 80 | Optional. Minimum pixel height of the buffer during virtual scrolling. If the pixel height is less than this value, the new structure is loaded. | [Virtual scrolling](demo#virtual-scroll) |
| virtualMaxBufferPx | `number` | 200 | Optional. Maximum pixel height of the buffer during virtual scrolling | [virtual scrolling](demo#virtual-scroll) |
@@ -51,11 +52,11 @@ On the page:
| hideColumn | `string[]` | -- | Optional. Used to hide columns, Transfer the corresponding field. |
| pageAllChecked | `boolean` | -- | Optional. Select all rows on the current page. |
| onlyOneColumnSort | `boolean` | -- | Optional. Whether to restrict the output of multi-column sorting to one item | [Table interaction](demo#table-interaction) |
-| multiSort | [`SortEventArg[]`](#sorteventarg) | [] | Optional. It is a multi-column selection array, which is used to guide the columns to be sorted. | [Table interaction](demo#table-interaction) |
+| multiSort | [`SortEventArg[]`](#sorteventarg) | [] | Optional. It is a multi-column selection array, which is used to guide the columns to be sorted.This parameter is valid only in column mode. | [Table interaction](demo#table-interaction) |
| resizeable | `boolean` | -- | Optional. Whether the column width can be adjusted by dragging. | [Table interaction](demo#table-interaction) |
| timeout | `number` | 300 | Optional. This parameter is used to distinguish the click interval when the click and double-click events are bound at the same time. The default value is 300`ms`. You can set this parameter to 0 when the two events are used at the same time. |
| headerExpandConfig | [`TableExpandConfig`](#tableexpandconfig) | -- | Optional. Extra content under the header | [Extended line](demo#expand-row) |
-| beforeCellEdit | `Promise` | -- | Optional. Interception method before cell editing. resolve(extraOptions) updates extraOptions of the column. | [edit cell](demo#edit-cell) |
+| beforeCellEdit | `(rowItem: any, column: any) => Promise` | -- | Optional. Interception method before cell editing. resolve(extraOptions) updates extraOptions of the column. | [edit cell](demo#edit-cell) |
| headerBg | `boolean` | false | Optional. Indicating whether to display the background color in the table header | [Table style](demo#mutil-styles) |
| tableLayout | `'fixed'\|'auto'` | 'fixed' | Optional. Table layout | [Table style](demo#mutil-styles) |
| borderType | `''\|'bordered'\|'borderless'` | '' | Optional. Table border type. The default value is row border. The options are bordered (full border) and borderless (no border). | [Table style](demo#mutil-styles) |
@@ -70,7 +71,7 @@ On the page:
| resize | `EventEmitter` | Column Width Change Event, Returning Cell Information | [Table Interaction](demo#table-interaction) |
| childrenTableClose | `EventEmitter` | Event for closing a sublist. The list row information is returned. |
| allChildrenTableClose | `EventEmitter` | All Sublist Close Event |
-| multiSortChange | `EventEmitter` | Change event, which is used to update the multi-column selection array and return cell information. | [Table interaction](demo#table-interaction) |
+| multiSortChange | `EventEmitter` | Change event, which is used to update the multi-column selection array and return cell information.This parameter is valid only in column mode. | [Table interaction](demo#table-interaction) |
| cellClick | `EventEmitter` | Cell Click Event, Returning Cell Information | [Table Interaction](demo#table-interaction) |
| cellDBClick | `EventEmitter` | Cell Double-click Event, Returning Cell Information | [Table Interaction](demo#table-interaction) |
| rowClick | `EventEmitter` | Table row click event, which returns row information | [Table interaction](demo#table-interaction) |
@@ -80,6 +81,7 @@ On the page:
| cellEditEnd | `EventEmitter` | Table cell editing end event. Cell information is returned. | [Edit cell](demo#edit-cell) |
| tableScrollEvent | `EventEmitter` | Table Internal Rolling Event | |
| columnDragEnd | `EventEmitter<{form: index, to: index}>` | Column Drag End Event | [Column dragging](demo#column-dragging) |
+| loadMore | `EventEmitter<{any}>` | Lazy Loading Completion Event|[Lazy Loading](demo#lazy-loading-of-list-data) |
## d-data-table public method
@@ -129,7 +131,7 @@ On the page:
| filterMultiple | `boolean` | -- | Optional. Sets the column to be selected. true indicates that multiple choices are selected, and false indicates that only one choice is selected. | [Table interaction](demo#table-interaction) |
| filterBoxWidth | `string` | -- | Optional. Width of the filter dialog box, for example, 300px. |
| filterBoxHeight | `string` | -- | Optional. Height of the filter dialog box, for example, 400px. |
-| beforeFilter | `function\|Promise\|Observable` | -- | Optional. Callback function before the table filtering dialog box is displayed. If false is returned, the dialog box is blocked. | [Table interaction](demo#table-interaction) |
+| beforeFilter | `(value) => boolean \| Promise \| Observable` | -- | Optional. Callback function before the table filtering dialog box is displayed. If false is returned, the dialog box is blocked. | [Table interaction](demo#table-interaction) |
| sortable | `boolean` | -- | Optional. Whether the column can be sorted | [Table interaction](demo#table-interaction) |
| sortDirection | `SortDirection` | -- | Optional. Sets the sorting status of the column. | [Table interaction](demo#table-interaction) |
| nestedColumn | `boolean` | -- | Optional. Indicates whether to display the expand or collapse icon of the table header in the tree table. | [Tree table](demo#tree-form) |
@@ -144,19 +146,20 @@ On the page:
| Event | Type | Description | Jump to Demo |
| :----------------------: | :-----------------: | :-------------------------------------------------: | :------------------------------------------------------- |
-| filterChange | `FilterConfig[]` | Callback event for confirming the filtering and returning the selected filtering array. | [Table interaction](demo#table-interaction) |
-| sortChange | `SortEventArg` | Sorting callback event, which returns the sorting information of the column. | [Table interaction](demo#table-interaction) |
-| resizeStartEvent | `MouseEvent` | Event when the column width adjustment starts |
-| resizingEvent | `{width: string}` | Event that the column width is being adjusted |
-| resizeEndEvent | `{width: string}` | Event when the column width adjustment ends | [Table interaction](demo#table-interaction) |
-| toggleChildrenTableEvent | `boolean` | Event for expanding and collapsing all subtables. The value true indicates expanding, and the value false indicates collapse. |
+| filterChange | `EventEmitter` | Callback event for confirming the filtering and returning the selected filtering array. | [Table interaction](demo#table-interaction) |
+| sortChange | `EventEmitter` | Sorting callback event, which returns the sorting information of the column. | [Table interaction](demo#table-interaction) |
+| resizeStartEvent | `EventEmitter` | Event when the column width adjustment starts |
+| resizingEvent | `EventEmitter<{ width: string }>` | Event that the column width is being adjusted |
+| resizeEndEvent | `EventEmitter<{ width: string }>` | Event when the column width adjustment ends | [Table interaction](demo#table-interaction) |
+| toggleChildrenTableEvent | `EventEmitter` | Event for expanding and collapsing all subtables. The value true indicates expanding, and the value false indicates collapse. |
+| sortDirectionChange | `EventEmitter` | Sort Order Direction Change Event|
# dTableCell
## dTableCell Parameter
-| Parameter name | Type | Default value | Description | Jump to Demo |Global Config|
-| :-------------: | :-----------------------------: | :----- | :------------------------------------------------------------: | :------------------------------------------------- |
+| Parameter name | Type | Default value | Description | Jump to Demo |
+| :-------------: | :-----------------------------: | :-----: | :------------------------------------------------: | :----------------------: |
| editable | `boolean` | -- | Optional. Whether a cell can be edited | [edit cell](demo#edit-cell) |
| editableTip | `'hover'\|'btn'` | -- | Optional. This parameter indicates the editing prompt. The background color of the hover changes. The edit button is displayed in the btn. | [edit cell](demo#edit-cell) |
| nestedColumn | `boolean` | -- | Optional. Display the expansion and collapse icons when the row in the tree table contains subtables. | [Tree table](demo#tree-form) |
@@ -176,8 +179,8 @@ On the page:
| Event | Type | Description | Jump to Demo |
| :-------------------: | :-------: | :-----------------------------------------------------: | :------------------------------------------------- |
-| editStatusEvent | `boolean` | Cell editing status event | [edit cell](demo#edit-cell) |
-| toggleChildTableEvent | `boolean` | Event for expanding and collapsing the subtable in the current row. The options are true and false. | [Tree table](demo#tree-form) |
+| editStatusEvent | `EventEmitter` | Cell editing status event | [edit cell](demo#edit-cell) |
+| toggleChildTableEvent | `EventEmitter` | Event for expanding and collapsing the subtable in the current row. The options are true and false. | [Tree table](demo#tree-form) |
#### Configure the row template of the dTableBody when the user-defined template is used.
@@ -432,249 +435,3 @@ colspan: number;
}
```
Note: Empty cells also need to be indicated. Set rowspan/colspan to 0 based on the content. If column width dragging and multi-row headers are used at the same time, attach the width to the column content. If the column width of the first row is incorrect, manually add the $width attribute for advancedHeader[rowNumber].
-
-#### Tree table with a large amount of data
-
-## virtual-scroll-tree-table parameter
-| Parameter name | Type | Default value | Description | Jump to Demo |
-| :---------------: | :-----------------: | :----- | :-------------------------------------------------------------------------------------------------------: |:-----------------: |
-| dataSource | `any[]` | -- | Required. It is a data source used to render table data. |[Tree table with a large amount of data](demo#virtual-scroll-tree-table)|
-| editOption | `any[]` | -- | Optional. Used to configure the resource of the drop-down list box during modification. |[Tree table with a large amount of data](demo#virtual-scroll-tree-table)|
-| showRowIndex | `number` | 10 | Optional. Used to configure the initial number of rows to be displayed in a table. |[Tree table with a large amount of data](demo#virtual-scroll-tree-table)|
-| dataTableProperties | [`DataTableProperiesInterface`](#DataTableProperiesInterface) | -- | Optional. Support for original parameters of dataTable, Parameters defined in DataTableProperiesInterface can be supported. |[Tree table with a large amount of data](demo#virtual-scroll-tree-table)|
-
-## virtual-scroll-tree-table event
-| Event | Type | Description | Jump to Demo |
-| :-------------------: | :------------------------------------: | :------------------------------------------------------: | :------------------------------------------------------: |
-| save | `EventEmitter` | Returns the data after the operation is changed. | [Tree table with a large amount of data](demo#virtual-scroll-tree-table) |
-
-## Customizing Templates and Operation Columns in d-column Mode
-
-``` xml
-
-
-
- {{ rowItem.category }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-```
-
-## Expanding or collapsing a tree table with a large amount of data
-
-Use @ViewChild to invoke the expand/collapse all function
-
-``` xml
-
-Expand All
-Fold All
-```
-
-``` javascript
-@ViewChild('VirtualTableTree') VirtualTableTree: VirtualScrollTreeTableComponent;
-
-toggleAllNodesExpand(e) {
- this.VirtualTableTree.toggleAllNodesExpand(e);
- this.isOpenAll = e;
-}
-
-// Use @ViewChild to call toggleAllNodesExpand method in VirtualScrollTreeTableComponent
-```
-
-## Tree table search for a large amount of data
-
-Use @ViewChild to invoke the search function
-
-``` xml
-
-
-
-
-```
-
-``` javascript
-@ViewChild('VirtualTableTree') VirtualTableTree: VirtualScrollTreeTableComponent;
-
-searchSelectChange() {
- this.BigTableTree.searchAttr = this.searchAttr;
- this.BigTableTree.searchSelectChange();
-}
-
-search(event) {
- this.VirtualTableTree.search(event);
- if(event) {
- this.isSearch = true;
- } else {
- this.isSearch = false;
- }
-}
-
-// Call the searchSelectChange and search methods in VirtualScrollTreeTableComponent using @ViewChild
-```
-
-## Adding a large amount of data to a tree table
-
-Use @ViewChild to invoke the add function
-
-``` xml
-// Global Add
-Add Node
-Add Folder
-
-// Add Operation Column
-
-
-
-
-```
-
-``` javascript
-@ViewChild('VirtualTableTree') VirtualTableTree: VirtualScrollTreeTableComponent;
-
-// Users can customize data templates.
-addTemplate: any = {
- "property": "addPro",
- "description": "addDes",
- "category": "Dynamic"
-}
-
-// Global Add
-addGolbal(status) {
- this.isAddGolbalData = true;
- this.VirtualTableTree.addGolbal(status, this.addTemplate);
- this.isAddGolbalData = false;
-}
-
-// Call the addGolbal method in VirtualScrollTreeTableComponent using @ViewChild
-
-// Add Operation Column
-addOperation(rowItem, status) {
- this.VirtualTableTree.addOperation(rowItem, status, this.addTemplate);
-}
-
-// Call the addOperation method in VirtualScrollTreeTableComponent using @ViewChild
-```
-
-## Copying and Pasting Tree Tables with a Large Amount of Data
-
-Use @ViewChild to invoke the copying and pasting function
-
-``` xml
-
-
-
-
-```
-
-``` javascript
-@ViewChild('VirtualTableTree') VirtualTableTree: VirtualScrollTreeTableComponent;
-
-copyAndCut(rowItem, status) {
- this.saveCopyClickNode = rowItem.node_id;
- if(status === 'cut') {
- this.isCut = true;
- }
- this.VirtualTableTree.copyAndCut(rowItem, status);
-}
-
-paste(rowItem, status) {
- this.VirtualTableTree.paste(rowItem, status);
- if(this.isCut) {
- this.saveCopyClickNode = "";
- this.isCut = false;
- }
-}
-
-// Use @ViewChild to call copyAndCut and paste methods in VirtualScrollTreeTableComponent
-```
-
-## Removing a large amount of data from a tree table
-
-Use @ViewChild to invoke the delete function
-``` xml
-
-```
-
-``` javascript
-@ViewChild('VirtualTableTree') VirtualTableTree: VirtualScrollTreeTableComponent;
-
-delete(rowItem) {
- this.VirtualTableTree.delete(rowItem);
-}
-
-// Call the delete method in VirtualScrollTreeTableComponent using @ViewChild
-```
-
-## DataTableProperiesInterface
-
-```ts
-export interface DataTableProperiesInterface {
- maxWidth?: string;
- maxHeight?: string;
- size?: string;
- rowHoveredHighlight?: boolean;
- generalRowHoveredData?: boolean;
- cssClass?: string;
- tableWidth?: string;
- fixHeader?: boolean;
- colDraggable?: boolean;
- colDropFreezeTo?: number;
- tableWidthConfig?: TableWidthConfig[];
- showSortIcon?: boolean;
- showFilterIcon?: boolean;
- showOperationArea?: boolean;
- hideColumn?: string[];
- pageAllChecked?: boolean;
- onlyOneColumnSort?: boolean;
- multiSort?: any;
- resizeable?: boolean;
- timeout?: number;
- beforeCellEdit?: any;
- headerBg?: boolean;
- tableLayout?: string;
- borderType?: string;
- striped?: boolean;
-}
-```
\ No newline at end of file
diff --git a/devui/data-table/public-api.ts b/devui/data-table/public-api.ts
index 5b4fc8a7..ee70c1de 100755
--- a/devui/data-table/public-api.ts
+++ b/devui/data-table/public-api.ts
@@ -2,10 +2,11 @@ export * from './data-table-body.component';
export * from './data-table-cell.component';
export * from './data-table-head.component';
export * from './data-table-row.component';
+export * from './data-table-row.token';
export * from './data-table.component';
export * from './data-table.model';
export * from './data-table.module';
-export * from './dataTableProperties.interface';
+export * from './data-table.token';
export * from './display-cell-value.pipe';
export * from './editor-host.directive';
export * from './table/body/tbody.component';
@@ -21,5 +22,4 @@ export * from './tmpl/data-table-cell-tmpl.component';
export * from './tmpl/data-table-cell-view-tmpl.component';
export * from './tmpl/data-table-column-tmpl.component';
export * from './tmpl/data-table-head-cell-tmpl.component';
-export * from './virtualScrollTreeTable.component';
-
+export * from './utils/utils';
diff --git a/devui/data-table/table/body/td/td.component.ts b/devui/data-table/table/body/td/td.component.ts
index 80a381de..d1b0915e 100644
--- a/devui/data-table/table/body/td/td.component.ts
+++ b/devui/data-table/table/body/td/td.component.ts
@@ -34,8 +34,11 @@ export class TableTdComponent implements OnInit, OnChanges, OnDestroy {
@Input() beforeEditEnd: (rowItem, field) => boolean | Promise | Observable;
@Output() toggleChildTableEvent = new EventEmitter();
@Input() editing: boolean;
- @Output() editingChange = new EventEmitter();
@Output() editStatusEvent = new EventEmitter();
+ /**
+ * 编辑状态调整 @deprecated
+ */
+ @Output() editingChange = new EventEmitter();
private documentClickSubscription: Subscription;
private tdMousedownSubscription: Subscription;
diff --git a/devui/data-table/table/head/th/filter/filter.component.html b/devui/data-table/table/head/th/filter/filter.component.html
index dd563217..24c51c52 100644
--- a/devui/data-table/table/head/th/filter/filter.component.html
+++ b/devui/data-table/table/head/th/filter/filter.component.html
@@ -38,7 +38,6 @@
[ngStyle]="{ 'min-height': filterBoxHeight ? filterBoxHeight : '60px' }"
>
item.checked);
this.setFilterIconActive(checkedList);
this.filterChange.emit(checkedList);
@@ -190,10 +191,18 @@ export class FilterComponent implements OnInit, OnChanges, OnDestroy {
filterCheckAll($event) {
this.filterHalfChecked = false;
- this.filterListDisplay.forEach(item => {
- item.checked = $event;
- this.checkedListForFilter.push(item);
- });
+ // 全选时只针对当前面板操作,全不选时针对所有数据
+ if ($event) {
+ this.filterListDisplay.forEach(item => {
+ item.checked = $event;
+ this.checkedListForFilter.push(item);
+ });
+ } else {
+ this.filterList.forEach(item => {
+ item.checked = $event;
+ this.checkedListForFilter.push(item);
+ });
+ }
}
setHalfChecked() {
diff --git a/devui/data-table/table/head/th/th.component.ts b/devui/data-table/table/head/th/th.component.ts
index 23d2f402..987eb325 100644
--- a/devui/data-table/table/head/th/th.component.ts
+++ b/devui/data-table/table/head/th/th.component.ts
@@ -1,6 +1,7 @@
import { DOCUMENT } from '@angular/common';
import {
- ChangeDetectorRef, Component, ElementRef, EventEmitter, HostBinding, HostListener, Inject, Input,
+ ChangeDetectorRef, Component, ElementRef, EventEmitter,
+ forwardRef, HostBinding, HostListener, Inject, Input,
NgZone, OnChanges, OnDestroy, Output, Renderer2, SimpleChanges, TemplateRef
} from '@angular/core';
import { fromEvent, Observable, Subscription } from 'rxjs';
@@ -11,9 +12,10 @@ import { TABLE_TH } from './th.token';
/* eslint-disable-next-line @angular-eslint/component-selector*/
selector: '[dHeadCell]',
templateUrl: './th.component.html',
- providers: [
- {provide: TABLE_TH, useExisting: TableThComponent}
- ],
+ providers: [{
+ provide: TABLE_TH,
+ useExisting: forwardRef(() => TableThComponent)
+ }],
})
export class TableThComponent implements OnChanges, OnDestroy {
@HostBinding('class.resizeable') resizeEnabledClass = false;
@@ -52,7 +54,6 @@ export class TableThComponent implements OnChanges, OnDestroy {
@Input() iconFoldTable: string;
@Input() iconUnFoldTable: string;
- resizeBarRefElement: HTMLElement;
@Input() tableViewRefElement: ElementRef;
@Output() resizeEndEvent: EventEmitter = new EventEmitter();
@@ -64,6 +65,8 @@ export class TableThComponent implements OnChanges, OnDestroy {
@Input() fixedLeft: string;
@Input() fixedRight: string;
+
+ resizeBarRefElement: HTMLElement;
element: HTMLElement;
subscription: Subscription;
resizing = false;
@@ -75,10 +78,11 @@ export class TableThComponent implements OnChanges, OnDestroy {
mouseDownScreenX: number;
resizeHandleElement: HTMLElement;
tableElement: HTMLElement;
+
+ // 以下为内部传递参数,不对外暴露
@Input() childrenTableOpen: boolean;
@Output() toggleChildrenTableEvent = new EventEmitter();
@Output() tapEvent = new EventEmitter();
-
@Input() column: any; // 为配置column方式兼容自定义过滤模板context
document: Document;
@@ -249,9 +253,8 @@ export class TableThComponent implements OnChanges, OnDestroy {
if (this.tableElement) {
this.renderer2.removeChild(this.tableElement, this.resizeBarRefElement);
}
- // this.width = finalWidth + 'px';
- this.resizeEndEvent.emit({ width: finalWidth });
+ this.resizeEndEvent.emit({ width: finalWidth, beforeWidth: this.initialWidth });
});
if (this.subscription && !this.subscription.closed) {
this._destroySubscription();
diff --git a/devui/data-table/tmpl/data-table-column-tmpl.component.ts b/devui/data-table/tmpl/data-table-column-tmpl.component.ts
index f81d1806..7f2384b1 100755
--- a/devui/data-table/tmpl/data-table-column-tmpl.component.ts
+++ b/devui/data-table/tmpl/data-table-column-tmpl.component.ts
@@ -27,7 +27,6 @@ export class DataTableColumnTmplComponent implements OnChanges, OnDestroy, OnIni
@Input() header: string;
@Input() sortable: boolean;
@Input() editable: boolean;
- @Input() unresizable: boolean;
@Input() filterable: boolean;
@Input() closeFilterWhenScroll: boolean;
@Input() cellClass: string;
diff --git a/devui/data-table/utils/utils.ts b/devui/data-table/utils/utils.ts
index eefa58c4..dea12693 100644
--- a/devui/data-table/utils/utils.ts
+++ b/devui/data-table/utils/utils.ts
@@ -63,7 +63,7 @@ export const highPerformanceExpandObjectInArray = (oldObj, attr) => {
if(attr) {
const newObj=[];
for(let i=0;i {
}
return res;
};
+
+export const flatTreeData = (dataSource: any[]) => {
+ const flatData = [];
+
+ const travelObj = (arr, parentId) => {
+ arr.forEach(item => {
+ if (item.children) {
+ const obj = {
+ id: generateId(),
+ node_id: generateId(),
+ node_type: 1,
+ parent_node_id: parentId,
+ ...item
+ };
+ const children = obj.children;
+ delete obj.children;
+ flatData.push(obj);
+ travelObj(children, obj.node_id);
+ } else {
+ const obj = {
+ id: generateId(),
+ node_id: generateId(),
+ node_type: 0,
+ parent_node_id: parentId,
+ ...item
+ };
+ flatData.push(obj);
+ }
+ });
+ };
+
+ travelObj(dataSource, null);
+
+ return flatData;
+};
diff --git a/devui/data-table/utils/virtualScrollTreeTable.factory.ts b/devui/data-table/utils/virtualScrollTreeTable.factory.ts
deleted file mode 100644
index e4873e49..00000000
--- a/devui/data-table/utils/virtualScrollTreeTable.factory.ts
+++ /dev/null
@@ -1,720 +0,0 @@
-import {
- distinct, FindChild, generateId, getNodeIndex, highPerformanceExpandObjectInArray, highPerformanceFilter, simDeepClone
-} from './utils';
-
-
-// 删除
-export class VirtualScrollTreeTableDelete {
- findChild: any;
-
- delete(rowItem, treeTableArray, spliceArr) {
- this.findChild = new FindChild();
- const allChildCol = this.findChild.getAllChildrenOfItem(rowItem, treeTableArray);
- const allChild = distinct(allChildCol, []);
- this.deleteChooseData(allChild, treeTableArray);
- this.deleteAllRecord(allChild, spliceArr);
- return {treeTableArray: treeTableArray, spliceArr: spliceArr};
- }
-
- deleteChooseData(allChild, treeTableArray) {
- for(let i=0; i v.node_id === node_id);
- if(pos !== -1) {
- treeTableArray.splice(pos, 1);
- }
- }
- }
-
- deleteAllRecord(allChild, spliceArr) {
- spliceArr.expandArr = this.deleteRecordArrData(allChild, spliceArr.expandArr);
- spliceArr.toggledArr = this.deleteRecordArrData(allChild, spliceArr.toggledArr);
- spliceArr.expandClickArr = this.deleteRecordArrData(allChild, spliceArr.expandClickArr);
- spliceArr.toggledClickArr = this.deleteRecordArrData(allChild, spliceArr.toggledClickArr);
- spliceArr.searchRes = this.deleteRecordArrData(allChild, spliceArr.searchRes);
- spliceArr.searchArr = this.deleteRecordArrData(allChild, spliceArr.searchArr);
- }
-
- deleteRecordArrData(allChild, arr) {
- if(arr.length > 0) {
- const allChildNodeId = allChild.map(item => item.node_id);
- let node_id;
- for(let i=0; i -1) {
- arr[i].node_id = "";
- }
- }
- arr = highPerformanceFilter(arr, item => item.node_id !== "");
- }
- return arr;
- }
-}
-
-
-// 新增
-export class VirtualScrollTreeTableAdd {
- findChild: any;
-
- addGolbal(status, treeTableArray, addTemplate?) {
- if(addTemplate) {
- treeTableArray = this.addData(status, treeTableArray, addTemplate);
- } else {
- treeTableArray = this.addData(status, treeTableArray);
- }
- return treeTableArray;
- }
-
- addOperation(rowItem, status, treeTableArray, addTemplate?) {
- let dataObj: any;
- if(addTemplate) {
- dataObj = this.addData(status, treeTableArray, addTemplate);
- } else {
- dataObj = this.addData(status, treeTableArray);
- }
- const lastDataObj = this.getoperationAddData(status, rowItem, dataObj);
- this.changeOperationAdd(lastDataObj, treeTableArray);
- return treeTableArray;
- }
-
- addData(type, treeTableArray, addTemplate?) {
- const newType = (type==='node' || type==='addDataNode' || type==='insertDataNode') ? "node" : "folder";
- const properties = this.getAddDataProperties(newType, treeTableArray);
- let obj: any = {};
- if(addTemplate) {
- obj = {...properties, ...addTemplate};
- } else {
- obj = {
- "id": properties.id,
- "type": properties.type,
- "name": properties.name,
- "property": "",
- "description": "",
- "locked": 0,
- "create_user": "张三",
- "create_time": "2021-08-31T00:00:00.000+00:00",
- "update_user": "李四",
- "update_time": "2021-08-31T00:00:00.000+00:00",
- "node_type": properties.node_type,
- "node_id": properties.node_id,
- "by_order": properties.by_order,
- "category": "Static",
- "update_time_string": "2021-08-31 00:00:00",
- "create_time_string": "2021-08-31 00:00:00"
- };
- }
- if(type === 'node' || type === 'folder') {
- treeTableArray.push(obj);
- return treeTableArray;
- } else {
- return obj;
- }
- }
-
- getAddDataProperties(type, treeTableArray) {
- return {
- id: generateId(),
- node_id: generateId(),
- node_type: type === 'node' ? 0 : 1,
- type: type === 'node'? 'String' : '',
- name: this.getAddName(type, treeTableArray),
- by_order: treeTableArray.length + 1
- };
- }
-
- getAddName(type, treeTableArray) {
- let name = "";
- const namePrefix = type === 'node'? 'New_Variable_' : 'New_Folder_';
- const arr = treeTableArray;
- const newDataArr = highPerformanceFilter(arr, item => {
- if(item.name.includes(namePrefix)) {return item;}
- });
- if(newDataArr.length > 0) {
- const newDataNumArr = [];
- newDataArr.forEach(item => {
- newDataNumArr.push(Number(item.name.split('_')[2]));
- });
- newDataNumArr.sort((a, b) => {
- return a - b;
- });
- name = namePrefix + (newDataNumArr[newDataNumArr.length - 1] + 1).toString();
- } else {
- name = namePrefix + "1";
- }
- return name;
- }
-
- getoperationAddData(type, rowItem, dataObj) {
- const parent_node_id = this.getAddParentId(type, rowItem);
- if(parent_node_id) {
- dataObj.parent_node_id = parent_node_id;
- } else {
- dataObj.posId = rowItem.node_id;
- }
- dataObj.by_order = 0;
- return dataObj;
- }
-
- getAddParentId(type, rowItem) {
- let parent_node_id = "";
- if(type === 'addDataNode' || type === 'addDataFolder') {
- parent_node_id = rowItem.node_id;
- } else {
- if(rowItem.parent_node_id) {
- parent_node_id = rowItem.parent_node_id;
- }
- }
- return parent_node_id;
- }
-
- changeOperationAdd(data, treeTableArray) {
- const parent_node_id = data.parent_node_id;
- let pos;
- if(parent_node_id) {
- pos = treeTableArray.findIndex((v) => v.node_id === parent_node_id);
- } else {
- const posId = data.posId;
- pos = treeTableArray.findIndex((v) => v.node_id === posId);
- }
- this.insertData(data, pos, treeTableArray);
- }
-
- insertData(data, pos, treeTableArray) {
- if(pos !== -1) {
- this.findChild = new FindChild();
- const allChildCol = this.findChild.getAllChildrenOfItem(treeTableArray[pos], treeTableArray);
- const childData = distinct(allChildCol, []);
- if(childData.length > 0) {
- const realPos = pos + childData.length;
- if(Array.isArray(data)) {
- for(let i=0; i 0) {
- copyStatus = 'cut';
- } else {
- copyStatus = 'copy';
- }
- this.saveCopyNode.push(this.changeCopyNodeName(this.saveCopyClickNode[0], copyStatus));
- this.saveCopyNode = this.saveCopyNode.flat(Infinity);
- }
-
- changeCopyNodeName(rowItem, status) {
- const copyRowItem = simDeepClone(rowItem);
- if(copyRowItem.node_type) {
- let copyRows;
- if(this.isAgainCopy) {
- copyRows = this.getCopyRows(copyRowItem);
- this.saveCopyRowChild = copyRows;
- } else {
- copyRows = this.saveCopyRowChild;
- }
- if(status === 'copy') {
- const newRows = this.changeCopyDataParent(copyRows);
- return newRows;
- } else {
- copyRows.forEach(arr => {
- arr.by_order = 0;
- });
- return copyRows;
- }
- } else {
- if(status === 'copy') {
- this.changeCopyData(copyRowItem);
- } else {
- copyRowItem["by_order"] = 0;
- }
- return copyRowItem;
- }
- }
-
- getCopyRows(copyRowItem) {
- this.findChild = new FindChild();
- const allChildCol = this.findChild.getAllChildrenOfItem(copyRowItem, this.treeTableArray);
- const allChildLen = distinct(allChildCol, []).length;
- const slicePos = (this.treeTableArray.findIndex((v) => v.node_id === copyRowItem.node_id));
- const copyRows = simDeepClone(this.treeTableArray.slice(slicePos, slicePos + allChildLen));
- return copyRows;
- }
-
-
- changeCopyDataParent(copyRows) {
- const newRows = simDeepClone(copyRows);
- for(let i=0; i {
- if(item.parent_node_id === copyRows[i].node_id) {
- newRows[index].parent_node_id = newRows[i].node_id;
- }
- });
- }
- return newRows;
- }
-
- changeCopyData(rowData) {
- rowData["id"] = generateId();
- rowData["name"] = this.getCopyName(rowData['name']);
- rowData["node_id"] = generateId();
- rowData["by_order"] = 0;
- }
-
- getCopyName(name) {
- let newName = name + '_';
- const newDataArr = highPerformanceFilter(this.treeTableArray, item => {
- if(item.name.includes(newName)) {return item;}
- });
- if(newDataArr.length > 0) {
- const newDataNumArr = [];
- newDataArr.forEach(arr => {
- const numArr = arr.name.split('_');
- let num = Number(numArr[numArr.length - 1]);
- if(!num) {
- num = 0;
- }
- newDataNumArr.push(num);
- });
- newDataNumArr.sort((a, b) => {
- return a - b;
- });
- newName = newName + (newDataNumArr[newDataNumArr.length - 1] + 1).toString();
- } else {
- newName = newName + '1';
- }
- return newName;
- }
-
- pastData(rowItem, status) {
- if(this.saveCutNode.length > 0) {
- const cutPos = this.treeTableArray.findIndex((v) => v.node_id === this.saveCutNode[0].node_id);
- this.findChild = new FindChild();
- const allChildCol = this.findChild.getAllChildrenOfItem(this.treeTableArray[cutPos], this.treeTableArray);
- const childData = distinct(allChildCol, []);
- for(let i=0; i v.node_id === childData[i].node_id);
- if(pos !== -1) {
- this.treeTableArray.splice(pos, 1);
- }
- }
- this.spliceArr = this.deleteAllRecord(childData, this.spliceArr);
-
- this.pastPublicOperation(rowItem, status);
- this.saveCopyClickNode = [];
- this.copyRowNodeId = "";
- } else {
- this.pastPublicOperation(rowItem, status);
- }
- }
-
- pastPublicOperation(rowItem, status) {
- if(status === 'paste') {
- this.pastChangeCopyData(rowItem);
- } else {
- this.pastToRootChangeCopyData();
- }
- }
-
- pastChangeCopyData(rowItem) {
- this.saveCopyNode[0].parent_node_id = rowItem.node_id;
- const pos = this.treeTableArray.findIndex((v) => v.node_id === rowItem.node_id);
- this.insertData(this.saveCopyNode, pos);
- }
-
- insertData(data, pos) {
- if(pos !== -1) {
- this.findChild = new FindChild();
- const allChildCol = this.findChild.getAllChildrenOfItem(this.treeTableArray[pos], this.treeTableArray);
- const childData = distinct(allChildCol, []);
- if(childData.length > 0) {
- const realPos = pos + childData.length;
- if(Array.isArray(data)) {
- for(let i=0; i 0) {
- const allChildNodeId = allChild.map(item => item.node_id);
- let node_id;
- for(let i=0; i -1) {
- arr[i].node_id = "";
- }
- }
- arr = highPerformanceFilter(arr, item => item.node_id !== "");
- }
- return arr;
- }
-}
-
-// 拖拽
-export class VirtualScrollTreeTableDrop {
- findChild: any;
-
- visibleNodes: any;
- itemCount: any;
- expandArr: any;
- treeTableArray: any;
-
- onDrop(e: any, visibleNodes, itemCount, treeTableArray, expandArr) {
- this.visibleNodes = visibleNodes;
- this.itemCount = itemCount;
- this.expandArr = expandArr;
- this.treeTableArray = treeTableArray;
-
- const dragFromIndex = e.dragFromIndex;
- let dropIndex = e.dropIndex; let realToIndex;
-
- if(dropIndex < 0) {
- dropIndex = 0;
- } else if(dropIndex > itemCount) {
- dropIndex = itemCount;
- }
-
- if (dropIndex < dragFromIndex) {
- dropIndex++;
- }
-
- const realFromIndex = getNodeIndex(e.dragData.node_id, this.treeTableArray);
- realToIndex = dropIndex < this.itemCount ?
- getNodeIndex(this.visibleNodes[dropIndex].node_id, this.treeTableArray)
- : getNodeIndex(this.visibleNodes[dropIndex - 1].node_id, this.treeTableArray);
- if (realToIndex > realFromIndex && dropIndex < dragFromIndex) {
- realToIndex--;
- }
- if (realToIndex < realFromIndex && dropIndex > dragFromIndex) {
- realToIndex++;
- }
- const newDropParentNode = this.visibleNodes[dropIndex - 1];
- this.changeNodeInfoByDrop(newDropParentNode, realFromIndex);
-
- const moveCount = dragFromIndex === dropIndex ? 0
- : !this.visibleNodes[dropIndex] || realToIndex > realFromIndex ? 1
- : getNodeIndex(this.visibleNodes[dropIndex].node_id, this.treeTableArray)
- - getNodeIndex(this.visibleNodes[dropIndex - 1].node_id, this.treeTableArray);
- const targetIndex = dropIndex < this.itemCount ? realToIndex - moveCount : realToIndex;
- this.treeTableArray.splice(
- targetIndex,
- 0,
- realFromIndex === -1 ? e.dragData : this.treeTableArray.splice(realFromIndex, 1)[0]
- );
-
- return {expandArr: this.expandArr, treeTableArray: this.treeTableArray};
- }
-
- changeNodeInfoByDrop(newDropParentNode, realFromIndex) {
- const findIndex = this.expandArr.findIndex(value => value.node_id === this.treeTableArray[realFromIndex].node_id);
- if (!newDropParentNode || !newDropParentNode.parent_node_id) {
- this.dropToRoot(findIndex, realFromIndex, newDropParentNode);
- } else if (newDropParentNode.parent_node_id) {
- this.dropToChild(findIndex, realFromIndex, newDropParentNode);
- }
- }
-
- dropToRoot(findIndex, realFromIndex, newDropParentNode) {
- if (newDropParentNode?.node_type === 1 && newDropParentNode?.expand) {
- this.treeTableArray[realFromIndex].parent_node_id = newDropParentNode.node_id;
- findIndex > -1 ?
- this.expandArr[findIndex].parent_node_id = newDropParentNode.node_id
- :
- this.expandArr.push(this.treeTableArray[realFromIndex]);
- } else {
- if (this.treeTableArray[realFromIndex].parent_node_id) {
- delete this.treeTableArray[realFromIndex].parent_node_id;
- if (findIndex > -1) {
- this.expandArr.splice(findIndex, 1);
- }
- }
- }
- }
-
- dropToChild(findIndex, realFromIndex, newDropParentNode) {
- if (newDropParentNode.node_type === 1 && newDropParentNode.expand) {
- this.treeTableArray[realFromIndex].parent_node_id = newDropParentNode.node_id;
- findIndex > -1 ?
- this.expandArr[findIndex].parent_node_id = newDropParentNode.node_id
- :
- this.expandArr.push(this.treeTableArray[realFromIndex]);
- } else {
- this.treeTableArray[realFromIndex].parent_node_id = newDropParentNode.parent_node_id;
- if (findIndex > -1) {
- this.expandArr[findIndex].parent_node_id = newDropParentNode.parent_node_id;
- }
- }
- }
-}
-
-// 搜索
-export class VirtualScrollTreeTableSearch {
- beforeSearchTarget: any;
- searchRes: Array = [];
- searchArr: Array = [];
- isSearch = false;
- searchKeyArr: Array = [];
- parentData: Array = [];
- searchAttr: any = {};
- treeTableArray: any;
-
- search(searchTarget, searchAttr, treeTableArray) {
- this.searchAttr = searchAttr;
- this.treeTableArray = treeTableArray;
-
- this.beforeSearchTarget = searchTarget;
- this.searchRes = [];
- this.searchArr = [];
- if (searchTarget) {
- this.isSearch = true;
- const attr = this.searchAttr.value;
- if (this.treeTableArray.length < 100) {
- this.getSearchDataLittle(this.treeTableArray, searchTarget, attr);
- } else {
- this.getSearchData(this.treeTableArray, this.treeTableArray.length, searchTarget, attr);
- }
- this.searchKeyArr = [];
- } else {
- this.isSearch = false;
- }
-
- return {beforeSearchTarget: this.beforeSearchTarget, searchRes: this.searchRes, searchArr: this.searchArr, isSearch: this.isSearch};
- }
-
- getSearchDataLittle(data, searchTarget, attr) {
- const lowSearchTarget = searchTarget.toLowerCase();
- if(attr === 'all') {
- for(let i=0; i= loopNum) {
- i += loopNum;
- } else {
- i = len;
- }
- }
- }
-
- sliceToGroupData(data, groupNum, len, num, attr, lowSearchTarget) {
- let sliceNum = groupNum;
- if (len - num < groupNum) {
- sliceNum = 0;
- }
- const preparationData = this.batchFilterData(data, num, sliceNum, attr, lowSearchTarget);
- return preparationData;
- }
-
- batchFilterData(data, num, sliceNum, attr, lowSearchTarget) {
- const rtnData = [];
- let everySearchData;
- if (sliceNum > 0) {
- everySearchData = data.slice(num, num + sliceNum);
- } else {
- everySearchData = data.slice(num);
- }
- let everySearchDataAttr;
- if(attr === 'all') {
- everySearchDataAttr = everySearchData.filter(
- item => highPerformanceExpandObjectInArray(item, ['name', 'property', 'category', 'description']).join("丅")
- );
- } else {
- everySearchDataAttr = everySearchData.filter(item => highPerformanceExpandObjectInArray(item, [attr]).join("丅"));
- }
- const inArr = (JSON.stringify(everySearchDataAttr).toLowerCase()).includes(lowSearchTarget);
- rtnData.push(everySearchData, inArr);
- return rtnData;
- }
-
- getLastSearchData(lastSearchData, attr, searchTarget, lowSearchTarget) {
- let searchRes = [];
- if(attr === 'all') {
- for (let m = 0; m < lastSearchData.length; m++) {
- const searchProper = highPerformanceExpandObjectInArray(
- lastSearchData[m], ['name', 'property', 'category', 'description']
- ).join("丅");
- const searchScope = JSON.stringify(searchProper).toLowerCase().includes(lowSearchTarget);
- searchRes = this.searchResData(searchTarget, searchScope, lastSearchData[m], searchRes);
- }
- } else {
- for (let m = 0; m < lastSearchData.length; m++) {
- const searchProper = highPerformanceExpandObjectInArray(lastSearchData[m], [attr]).join("丅");
- const searchScope = JSON.stringify(searchProper).toLowerCase().includes(lowSearchTarget);
- searchRes = this.searchResData(searchTarget, searchScope, lastSearchData[m], searchRes);
- }
- }
- return searchRes;
- }
-
- searchResData(searchTarget, searchScope, data, searchRes?) {
- if (searchTarget && searchScope) {
- this.getLastSearchParentData(data);
- if (this.parentData.length > 0) {
- if(searchRes) {
- searchRes = [...searchRes, ...this.parentData];
- } else {
- this.searchRes = [...this.searchRes, ...this.parentData];
- }
- this.parentData = [];
- }
- if (this.searchKeyArr.indexOf(data.node_id) === -1) {
- if(searchRes) {
- searchRes.push(data);
- } else {
- this.searchRes.push(data);
- }
- this.searchKeyArr.push(data.node_id);
- }
- }
- if(searchRes) {
- return searchRes;
- }
- }
-
- getLastSearchParentData(data) {
- const parent_node_id = data.parent_node_id;
- if (parent_node_id) {
- const getData = highPerformanceFilter(this.treeTableArray, item => item.node_id === parent_node_id);
- if (this.searchKeyArr.indexOf(getData[0].node_id) === -1) {
- this.parentData.push(getData[0]);
- this.searchKeyArr.push(getData[0].node_id);
- }
- if (getData[0].parent_node_id) {
- this.getLastSearchParentData(getData[0]);
- } else {
- this.parentData.reverse();
- }
- }
- }
-
- calculationDataNum(len) {
- const lenStr = len.toString();
- const countNum = lenStr.substr(0, 1);
- const remainderNum = lenStr.substr(1, lenStr.length - 1);
- let loopNum = '1';
- if (Number(remainderNum) === 0 && Number(countNum) === 1) {
- for (let i = 0; i < remainderNum.length - 1; i++) {
- loopNum += '0';
- }
- } else {
- for (let i = 0; i < remainderNum.length; i++) {
- loopNum += '0';
- }
- }
- return Number(loopNum);
- }
-}
diff --git a/devui/data-table/virtualScrollTreeTable.component.html b/devui/data-table/virtualScrollTreeTable.component.html
deleted file mode 100644
index c2f2f3cb..00000000
--- a/devui/data-table/virtualScrollTreeTable.component.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/devui/data-table/virtualScrollTreeTable.component.scss b/devui/data-table/virtualScrollTreeTable.component.scss
deleted file mode 100644
index 169fc1b3..00000000
--- a/devui/data-table/virtualScrollTreeTable.component.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-.devui-cdk-scroll-container {
- position: relative;
-
- #data-table-virtual-tree-scroll {
- width: calc(100% - 3px);
- }
-
- #data-table-virtual-tree {
- position: absolute;
- z-index: 1;
- left: 0;
- top: 0;
- right: 5px;
- bottom: 0;
- width: calc(100% - 8px);
- }
-}
diff --git a/devui/data-table/virtualScrollTreeTable.component.ts b/devui/data-table/virtualScrollTreeTable.component.ts
deleted file mode 100644
index f87aef83..00000000
--- a/devui/data-table/virtualScrollTreeTable.component.ts
+++ /dev/null
@@ -1,779 +0,0 @@
-import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
-import {
- AfterContentInit, ChangeDetectorRef, Component, ContentChildren,
- EventEmitter, Input, OnChanges, OnInit, Output, QueryList, ViewChild
-} from '@angular/core';
-import { DataTableComponent } from './data-table.component';
-import { DataTableProperiesInterface } from './dataTableProperties.interface';
-import { DataTableColumnTmplComponent } from './tmpl/data-table-column-tmpl.component';
-import {
- distinct, FindChild, highPerformanceFilter, highPerformanceMap, simDeepClone
-} from './utils/utils';
-import {
- VirtualScrollTreeTableAdd, VirtualScrollTreeTableCopy,
- VirtualScrollTreeTableDelete, VirtualScrollTreeTableDrop, VirtualScrollTreeTableSearch
-} from './utils/virtualScrollTreeTable.factory';
-
-export interface TreeNodeInterface {
- key: string;
- title: string;
- level: number;
- parentKey?: string;
- expand?: boolean;
- isLeaf: boolean;
- isDelete?: boolean;
- isMatch?: boolean;
- _children?: string[];
- [prop: string]: any;
-}
-
-@Component({
- selector: 'd-virtual-scroll-tree-table',
- templateUrl: './virtualScrollTreeTable.component.html',
- styleUrls: ['./virtualScrollTreeTable.component.scss']
-})
-export class VirtualScrollTreeTableComponent implements OnInit, AfterContentInit, OnChanges {
- @ContentChildren(DataTableColumnTmplComponent) columns: QueryList;
- @ViewChild('dataTable', { static: true }) dataTable: DataTableComponent;
-
- @Input() dataSource: any;
- @Input() editOption: any;
- @Input() showRowIndex = 10;
- @Input() dataTableProperties: DataTableProperiesInterface;
-
- @Output() save = new EventEmitter();
-
- virtualScrollTreeTableDelete: any;
- virtualScrollTreeTableAdd: any;
- virtualScrollTreeTableCopy: any;
- virtualScrollTreeTableDrop: any;
- virtualScrollTreeTableSearch: any;
-
- findChild: any;
- itemSize = 40;
- itemCount = 10;
- virtualScrollPadding = '';
-
- get initData() {
- return highPerformanceFilter(this.treeTableArray, item => !item.parent_node_id);
- }
- get allTableData() {
- return highPerformanceFilter(this.treeTableArray, item => item);
- }
- get copySearchRes() {
- return highPerformanceFilter(this.searchRes, item => item);
- }
- get dataTableEvent() {
- return this.dataTable;
- }
- isOpenAll = false;
- treeTableMap: { [key: string]: TreeNodeInterface } = {};
- treeTableArray: TreeNodeInterface[] = [];
- visibleNodes: TreeNodeInterface[] = [];
- iconParentOpen: string;
- iconParentClose: string;
- basicDataSource: any = [];
- expandArr: Array = [];
- expandClickArr: Array = [];
- expandItemKeys: Array = [];
- toggledArr: Array = [];
- toggledClickArr: Array = [];
- toggledItemKeys: Array = [];
- countNum: any = 0;
- totleItem: Number = 0;
- scrollArray: Array = [];
- @ViewChild(CdkVirtualScrollViewport) viewPort: CdkVirtualScrollViewport;
-
- isSearch = false;
- searchRes: Array = [];
- searchAttr: any = {
- name: '全部',
- value: 'all'
- };
- beforeSearchTarget: any;
- parentData: Array = [];
- searchKeyArr: Array = [];
- searchArr: Array = [];
-
- itemLevel: any = 1;
- peersNum = 0;
-
- allChildCol: Array = [];
-
- saveCopyClickNode: any = [];
- saveCopyNode: any = [];
- copyRowNodeId = '';
- saveCutNode: any = [];
- saveCopyRowChild: any = [];
-
- isAgainCopy = false;
-
- isDragMove = false;
- dragLine: any;
- dragMouseTipWidth: any;
-
- constructor(private ref: ChangeDetectorRef) { }
-
- ngAfterContentInit() {
- this.dataTable.columns = this.columns;
- this.dataTable.updateColumns();
- setTimeout(() => {
- const dataTableHead = this.dataTable.fixHeaderContainerRefElement.nativeElement.clientHeight;
- this.virtualScrollPadding = dataTableHead + 'px';
- });
- }
-
- ngOnChanges(changes): void {
- if(this.dataSource) {
- new Promise((resolve, reject) => {
- try {
- this.basicDataSource = this.dataSource;
- this.basicDataSource = simDeepClone(this.basicDataSource);
- this.treeTableArray = this.basicDataSource;
- this.totleItem = this.treeTableArray.length;
- this.countNum = this.initData.length;
- this.scrollArray = Array.from(this.initData.keys());
- this.itemCount = this.showRowIndex;
- resolve(true);
- } catch (error) {
- reject(error);
- }
- }).then(() => {
- this.visibleNodes = simDeepClone(this.initData.slice(0, this.itemCount));
- this.visibleNodes.forEach(arr => {
- arr.expand = false;
- });
- this.getVisibleDataOrder(this.visibleNodes);
- this.getVisibleDataLevel(this.visibleNodes);
- });
- } else {
- this.treeTableArray = [];
- this.visibleNodes = [];
- }
-
- if (
- (changes['dataTableProperties'])
- ) {
- const params = changes['dataTableProperties']['currentValue'];
- this.copyAttribute(this.dataTable, params);
- }
- }
-
- ngOnInit() {
- this.virtualScrollTreeTableDelete = new VirtualScrollTreeTableDelete();
- this.virtualScrollTreeTableAdd = new VirtualScrollTreeTableAdd();
- this.virtualScrollTreeTableCopy = new VirtualScrollTreeTableCopy();
- this.virtualScrollTreeTableDrop = new VirtualScrollTreeTableDrop();
- this.virtualScrollTreeTableSearch = new VirtualScrollTreeTableSearch();
- this.findChild = new FindChild();
- }
-
- copyAttribute(target, updateParams) {
- if(!target) {return;}
- const updateKeys = Object.keys(updateParams);
- if(updateKeys.length) {
- updateKeys.forEach(key => {
- if(key === 'size') {
- if(updateParams[key] === 'md') {
- this.itemSize = 48;
- } else if(updateParams[key] === 'lg') {
- this.itemSize = 56;
- } else {
- this.itemSize = 40;
- }
- }
- target[key] = updateParams[key];
- });
- }
- }
-
- batchUpdateTable(key, val) {
- const saveArr = this.treeTableArray;
- if(saveArr.length) {
- highPerformanceMap(saveArr, obj => {
- obj[key] = val;
- });
- }
- this.getVisiableNodes();
- }
-
- updateRowData(id, key, val) {
- for (let i = 0; i < this.visibleNodes.length; i++) {
- if(this.visibleNodes[i].node_id === id) {
- this.visibleNodes[i][key] = val;
- }
- }
-
- const pos = this.treeTableArray.findIndex((v) => v.node_id === id);
- if(pos !== -1) {
- this.treeTableArray[pos][key] = val;
- }
- }
-
- removeAll() {
- this.expandArr = [];
- this.toggledArr = [];
- this.expandClickArr = [];
- this.toggledClickArr = [];
- this.searchRes = [];
- this.searchArr = [];
- }
-
- setScrollLength(countNum) {
- this.countNum = countNum;
- this.scrollArray = Array.from(new Array(this.countNum).keys());
- }
- setVisibleNodes(data, flag) {
- this.visibleNodes = simDeepClone(data);
- for (let i = 0; i < this.visibleNodes.length; i++) {
- this.visibleNodes[i].expand = flag;
- }
- }
- getVisiableNodes() {
- const scrollOffset = this.viewPort.measureScrollOffset();
- const firstVisibleIndex = Math.ceil(scrollOffset / this.itemSize);
- const originalDataLength = this.treeTableArray.length;
- if (this.isSearch) {
- if (this.searchArr.length > 0) {
- this.setScrollLength(this.searchRes.length - this.searchArr.length);
- const newSearchRes = this.assemblyToggledData(this.copySearchRes, this.searchArr);
- this.setVisibleNodes(newSearchRes.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount), true);
- this.singleExpend(this.searchArr, 'search');
- } else {
- this.setScrollLength(this.searchRes.length);
- this.setVisibleNodes(this.searchRes.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount), true);
- }
- } else {
- if (this.isOpenAll) {
- this.expandArr = [];
- this.expandClickArr = [];
- if (this.toggledClickArr.length > 0) {
- const newTreeTableArray = this.assemblyToggledData(this.allTableData, this.toggledArr);
- this.setScrollLength(originalDataLength - this.toggledArr.length);
- this.setVisibleNodes(newTreeTableArray.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount), true);
- this.singleExpend(this.toggledClickArr, 'away');
- } else {
- this.setScrollLength(this.treeTableArray.length);
- this.setVisibleNodes(this.treeTableArray.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount), true);
- }
- } else {
- this.toggledArr = [];
- this.toggledClickArr = [];
- if (this.expandClickArr.length > 0) {
- const newInitData = this.assemblyExpandData(this.initData, this.expandArr);
- this.setScrollLength(this.initData.length + this.expandArr.length);
- this.visibleNodes = simDeepClone(newInitData.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount));
- this.singleToggled();
- } else {
- this.setScrollLength(this.initData.length);
- this.setVisibleNodes(this.initData.slice(firstVisibleIndex, firstVisibleIndex + this.itemCount), false);
- }
- }
- }
-
- this.getVisibleDataOrder(this.visibleNodes);
- this.getVisibleDataLevel(this.visibleNodes);
- this.dataTable.cancelEditingStatus();
- }
-
- getVisibleDataOrder(visibleNodes) {
- for (let i = 0; i < visibleNodes.length; i++) {
- const index = this.treeTableArray.findIndex((v) => v.node_id === visibleNodes[i].node_id);
- visibleNodes[i].by_order = index + 1;
- }
- }
-
- getVisibleDataLevel(visibleNodes) {
- visibleNodes.forEach(arr => {
- this.itemLevel = 1;
- if (arr.parent_node_id) {
- this.getParentNodeLevel(arr.parent_node_id, 1);
- arr.level = this.itemLevel;
- } else {
- arr.level = 1;
- }
- });
- }
-
- getParentNodeLevel(parent_node_id, level) {
- this.itemLevel = level + 1;
- const data: any = highPerformanceFilter(this.treeTableArray, item => item.node_id === parent_node_id);
- if (data.length > 0) {
- this.getParentNodeLevel(data[0].parent_node_id, this.itemLevel);
- }
- }
-
- singleExpend(recordArr, status) {
- const keyArr = [];
- for (let i = 0; i < recordArr.length; i++) {
- if (status === 'search') {
- keyArr.push(recordArr[i].parent_node_id);
- } else {
- keyArr.push(recordArr[i].node_id);
- }
- }
- for (let i = 0; i < this.visibleNodes.length; i++) {
- if (keyArr.includes(this.visibleNodes[i].node_id)) { this.visibleNodes[i].expand = false; }
- }
- }
-
- singleToggled() {
- const visibleNodesKeys = this.visibleNodes.map(item => item.node_id);
- let node_id;
- for (let i = 0; i < this.expandClickArr.length; i++) {
- node_id = this.expandClickArr[i].node_id;
- if (node_id && visibleNodesKeys.indexOf(node_id) > -1) {
- this.visibleNodes.filter(o => o.node_id === node_id)[0].expand = true;
- }
- }
- }
-
- assemblyExpandData(InitData, expandArr) {
- const newExpandArr = [];
- let parent_node_id;
- for (let i = 0; i < expandArr.length; i++) {
- parent_node_id = expandArr[i].parent_node_id;
- const pos = InitData.findIndex((v) => v.node_id === parent_node_id);
- if (pos !== -1) {
- this.getPeersDataNum(InitData, pos, parent_node_id);
- const realDataPos = this.treeTableArray.findIndex((v) => v.node_id === expandArr[i].node_id);
- if (realDataPos !== -1) {
- const realExpandData = this.treeTableArray[realDataPos];
- InitData.splice(pos + 1 + this.peersNum, 0, realExpandData);
- this.peersNum = 0;
- }
- } else {
- newExpandArr.push(expandArr[i]);
- }
- }
- if (newExpandArr.length > 0) {
- this.assemblyExpandData(InitData, newExpandArr);
- } else {
- return InitData;
- }
- }
-
- getPeersDataNum(InitData, pos, parent_node_id) {
- const checkDataPos = pos + 1;
- if (InitData[checkDataPos]) {
- const checkDataParent = InitData[checkDataPos].parent_node_id;
- if (checkDataParent === parent_node_id) {
- this.peersNum++;
- this.getPeersDataNum(InitData, checkDataPos, parent_node_id);
- } else {
- return;
- }
- } else {
- return;
- }
- }
-
- assemblyToggledData(arrayData, toggledArr) {
- let node_id;
- for (let i = 0; i < toggledArr.length; i++) {
- node_id = toggledArr[i].node_id;
- const pos = arrayData.findIndex((v) => v.node_id === node_id);
- if (pos !== -1) {
- arrayData.splice(pos, 1);
- }
- }
- return arrayData;
- }
-
- scroll(e) {
- e.preventDefault();
- const event = e;
- const wheelDelta = event.wheelDelta;
- const step = (wheelDelta === 0 ? 0 : wheelDelta / Math.abs(wheelDelta)) * (-this.itemSize);
- document.getElementById('data-table-virtual-tree-scroll').scrollBy(0, step);
- }
- onBodyScroll() {
- this.getVisiableNodes();
- }
- toggleAllNodesExpand(e) {
- this.isOpenAll = e;
- this.getVisiableNodes();
- }
-
-
- toggleNodeExpand(node: TreeNodeInterface, $event: boolean, isRefresh = true): void {
- if (this.isSearch) {
- this.operationSearchArr(node, $event ? 'add' : 'del');
- } else {
- this.isOpenAll ? this.operationToggledArr(node, $event ? 'add' : 'del') : this.operationExpandArr(node, $event ? 'add' : 'del');
- }
- isRefresh && this.getVisiableNodes();
-
- if (!node.expand && node.node_id === this.visibleNodes[this.visibleNodes.length - 1].node_id) {
- this.scrollToLastItem();
- }
- }
-
- scrollToLastItem() {
- document.getElementById('data-table-virtual-tree-scroll').scrollBy(0, this.itemSize * (this.itemCount - 1));
- }
-
- operationSearchArr(node, status) {
- if (status === 'add') {
- this.publicSingleRecordAdd(node, this.searchArr);
- } else {
- this.publicSingleRecordDel(node, 'search');
- }
- }
-
- operationExpandArr(node, status) {
- if (status === 'add') {
- const showNodes = this.findChild.getChildrenOfItem(node, this.treeTableArray);
- this.expandArr = distinct(this.expandArr, showNodes);
- this.expandClickArr = distinct(this.expandClickArr, [node]);
- } else {
- const inNodeData = [];
- inNodeData.push(node);
- this.spliceExpandArrData(inNodeData);
- const allChild = this.getAllChildArr(node);
- let node_id;
- for (let i = 0; i < allChild.length; i++) {
- node_id = allChild[i].node_id;
- const pos = this.expandClickArr.findIndex((v) => v.node_id === node_id);
- if (pos !== -1) {
- this.expandClickArr.splice(pos, 1);
- }
- }
- }
- }
-
- spliceExpandArrData(inNodeData) {
- let nodeChildData = [];
- for (let i = 0; i < inNodeData.length; i++) {
- const selectData = this.expandArr.filter(item => {
- if (item.parent_node_id === inNodeData[i].node_id) {
- return item;
- }
- });
- nodeChildData = [...nodeChildData, ...selectData];
- }
- if (nodeChildData.length > 0) {
- for (let i = 0; i < nodeChildData.length; i++) {
- const node_id = nodeChildData[i].node_id;
- const index = this.expandArr.findIndex((v) => v.node_id === node_id);
- this.expandArr.splice(index, 1);
- }
- this.spliceExpandArrData(nodeChildData);
- } else {
- return;
- }
- }
-
- operationToggledArr(node, status) {
- if (status === 'add') {
- this.publicSingleRecordAdd(node, this.toggledArr);
- for (let i = 0; i < this.toggledClickArr.length; i++) {
- if (node.node_id === this.toggledClickArr[i].node_id) {
- this.toggledClickArr.splice(i, 1);
- }
- }
- } else {
- this.publicSingleRecordDel(node, 'away');
- const allChild = this.getAllChildArr(node);
- this.toggledClickArr = distinct(this.toggledClickArr, allChild);
- }
- }
-
- getAllChildArr(node) {
- const allChildCol = this.findChild.getAllChildrenOfItem(node, this.treeTableArray);
- let allChild = distinct(allChildCol, []);
- allChild = allChild.filter(item => item.node_type === 1);
- return allChild;
- }
-
- publicSingleRecordAdd(node, recordArr) {
- const showNodes = this.findChild.getChildrenOfItem(node, this.treeTableArray);
- const toggledArrKey = recordArr.map(item => item.node_id);
- let node_id;
- for (let i = 0; i < showNodes.length; i++) {
- node_id = showNodes[i].node_id;
- if (node_id && toggledArrKey.indexOf(node_id) > -1) {
- const index = recordArr.findIndex((v) => v.node_id === node_id);
- recordArr.splice(index, 1);
- }
- }
- }
-
- publicSingleRecordDel(node, status) {
- const inNodeData = [];
- inNodeData.push(node);
- this.spliceToggledArrData(inNodeData, status);
- }
-
- spliceToggledArrData(inNodeData, status) {
- let nodeChild = [];
- for (let i = 0; i < inNodeData.length; i++) {
- const inNodeDataChild = this.findChild.getChildrenOfItem(inNodeData[i], this.treeTableArray);
- if (status === 'away') {
- nodeChild = this.toggledArrChange(inNodeDataChild, nodeChild);
- } else {
- nodeChild = this.searchArrChange(inNodeDataChild, nodeChild);
- }
- }
-
- if (nodeChild.length > 0) {
- this.spliceToggledArrData(nodeChild, status);
- } else {
- return;
- }
- }
-
- toggledArrChange(inNodeDataChild, nodeChild) {
- this.toggledArr = distinct(this.toggledArr, inNodeDataChild);
- nodeChild = this.getNodeChild(inNodeDataChild, nodeChild);
- return nodeChild;
- }
-
- searchArrChange(inNodeDataChild, nodeChild) {
- const searchNode = [];
- for (let k = 0; k < inNodeDataChild.length; k++) {
- const node_id = inNodeDataChild[k].node_id;
- const pos = this.searchRes.findIndex((v) => v.node_id === node_id);
- if (pos !== -1) {
- searchNode.push(inNodeDataChild[k]);
- }
- }
- this.searchArr = distinct(this.searchArr, searchNode);
- nodeChild = this.getNodeChild(searchNode, nodeChild);
- return nodeChild;
- }
-
- getNodeChild(childData, nodeChild) {
- for (let k = 0; k < childData.length; k++) {
- if (childData[k].node_type) {
- nodeChild.push(childData[k]);
- }
- }
- return nodeChild;
- }
-
- beforeEditStart = (rowItem, field) => {
- return true;
- };
-
- beforeEditEnd = (rowItem, field) => {
- return rowItem && rowItem[field].length >= 3;
- };
-
- onEditEnd(rowItem, field) {
- const cloneRow = simDeepClone(rowItem);
-
- const editSelectField = [];
- Object.keys(this.editOption).forEach(arr => {
- editSelectField.push(arr + 'Edit');
- });
-
- if (editSelectField.includes(field)) {
- this.dataTable.cancelEditingStatus();
- }
-
- const treeTablePos = this.treeTableArray.findIndex((v) => v.node_id === cloneRow.node_id);
- this.treeTableArray.splice(treeTablePos, 1, cloneRow);
- }
-
- searchSelectChange() {
- this.search(this.beforeSearchTarget);
- }
-
- search(searchTarget) {
- const res = this.virtualScrollTreeTableSearch.search(searchTarget, this.searchAttr, this.treeTableArray);
- this.beforeSearchTarget = res.beforeSearchTarget;
- this.searchRes = res.searchRes;
- this.searchArr = res.searchArr;
- this.isSearch = res.isSearch;
- this.getVisiableNodes();
- }
-
- addGolbal(status, addTemplate?) {
- event.stopPropagation();
- if(addTemplate) {
- this.treeTableArray = this.virtualScrollTreeTableAdd.addGolbal(status, this.treeTableArray, addTemplate);
- } else {
- this.treeTableArray = this.virtualScrollTreeTableAdd.addGolbal(status, this.treeTableArray);
- }
- this.getVisiableNodes();
- setTimeout(() => {
- this.addAutoScroll();
- });
- }
-
- addOperation(rowItem, status, addTemplate?) {
- if(addTemplate) {
- this.treeTableArray = this.virtualScrollTreeTableAdd.addOperation(rowItem, status, this.treeTableArray, addTemplate);
- } else {
- this.treeTableArray = this.virtualScrollTreeTableAdd.addOperation(rowItem, status, this.treeTableArray);
- }
- this.getVisiableNodes();
-
- if (!this.isOpenAll) {
- const changeStatus = (status === 'addDataFolder' || status === 'addDataNode') ? 'add' : 'insert';
- this.againExpandNode(changeStatus, rowItem);
- }
- }
-
- againExpandNode(changeStatus, rowItem) {
- let recordExpNode = [];
- if (changeStatus === 'add') {
- recordExpNode = this.recordExpandChild(rowItem);
- this.changeSingleExpand(rowItem);
- } else {
- const parent_node_id = rowItem.parent_node_id;
- if (parent_node_id) {
- const pos = this.treeTableArray.findIndex((v) => v.node_id === parent_node_id);
- recordExpNode = this.recordExpandChild(this.treeTableArray[pos]);
- this.changeSingleExpand(this.treeTableArray[pos]);
- }
- }
-
- for (let i = 0; i < recordExpNode.length; i++) {
- this.toggleNodeExpand(recordExpNode[i], true);
- }
- }
-
- changeSingleExpand(row) {
- this.toggleNodeExpand(row, false);
- this.toggleNodeExpand(row, true);
- }
-
- recordExpandChild(row) {
- const recordExpNode = [];
- const allChildCol = this.findChild.getAllChildrenOfItem(row, this.treeTableArray);
- const allChild = highPerformanceFilter(distinct(allChildCol, []), item => (item.node_id !== row.node_id && item.node_type));
- const allChildNodeId = allChild.map(item => item.node_id);
- for (let i = 0; i < this.expandClickArr.length; i++) {
- const node_id = this.expandClickArr[i].node_id;
- if (node_id && allChildNodeId.indexOf(node_id) > -1) {
- recordExpNode.push(this.expandClickArr[i]);
- }
- }
- return recordExpNode;
- }
-
- addAutoScroll() {
- document.getElementById('data-table-virtual-tree-scroll').scrollTo(0, (this.itemSize * this.scrollArray.length));
- }
-
- copyAndCut(rowItem, status) {
- this.saveCopyClickNode = [];
- this.saveCutNode = [];
- const res = this.virtualScrollTreeTableCopy.copyAndCut(rowItem, status);
- this.saveCopyClickNode = res.saveCopyClickNode;
- this.saveCutNode = res.saveCutNode;
- this.copyRowNodeId = res.copyRowNodeId;
- }
-
- paste(rowItem, status) {
- const spliceArr = {
- expandArr: this.expandArr,
- toggledArr: this.toggledArr,
- expandClickArr: this.expandClickArr,
- toggledClickArr: this.toggledClickArr,
- searchRes: this.searchRes,
- searchArr: this.searchArr
- };
-
- const res = this.virtualScrollTreeTableCopy.paste(rowItem, status, this.treeTableArray, spliceArr);
- this.saveCopyClickNode = res.saveCopyClickNode;
- this.copyRowNodeId = res.copyRowNodeId;
- this.treeTableArray = res.treeTableArray;
-
- if (this.saveCutNode.length > 0) {
- this.expandArr = res.spliceArr.expandArr;
- this.toggledArr = res.spliceArr.toggledArr;
- this.expandClickArr = res.spliceArr.expandClickArr;
- this.toggledClickArr = res.spliceArr.toggledClickArr;
- this.searchRes = res.spliceArr.searchRes;
- this.searchArr = res.spliceArr.searchArr;
- }
-
- this.getVisiableNodes();
- if (status === 'paste') {
- this.changeSingleExpand(rowItem);
- } else {
- setTimeout(() => {
- this.addAutoScroll();
- });
- }
- }
-
- delete(rowItem) {
- const spliceArr = {
- expandArr: this.expandArr,
- toggledArr: this.toggledArr,
- expandClickArr: this.expandClickArr,
- toggledClickArr: this.toggledClickArr,
- searchRes: this.searchRes,
- searchArr: this.searchArr
- };
- const res = this.virtualScrollTreeTableDelete.delete(rowItem, this.treeTableArray, spliceArr);
- this.treeTableArray = res.treeTableArray;
- this.expandArr = res.spliceArr.expandArr;
- this.toggledArr = res.spliceArr.toggledArr;
- this.expandClickArr = res.spliceArr.expandClickArr;
- this.toggledClickArr = res.spliceArr.toggledClickArr;
- this.searchRes = res.spliceArr.searchRes;
- this.searchArr = res.spliceArr.searchArr;
- this.getVisiableNodes();
- }
-
- onDragOver(e: any) {
- const scrollBoxY = document.getElementById('data-table-virtual-tree-scroll').getBoundingClientRect().y;
- if (scrollBoxY - e.y > 0) {
- document.getElementById('data-table-virtual-tree-scroll').scrollBy(0, -this.itemSize);
- }
- if (e.y - scrollBoxY > this.itemSize * (this.itemCount - 1) - 10) {
- document.getElementById('data-table-virtual-tree-scroll').scrollBy(0, this.itemSize);
- }
- }
-
- onDrop(e: any) {
- const res = this.virtualScrollTreeTableDrop.onDrop(e, this.visibleNodes, this.itemCount, this.treeTableArray, this.expandArr);
- this.expandArr = res.expandArr;
- this.treeTableArray = res.treeTableArray;
-
- const newDropParentNode = this.visibleNodes[e.dropIndex - 1];
- if (!newDropParentNode || !newDropParentNode.parent_node_id) {
- if (newDropParentNode ?.node_type === 1 && newDropParentNode ?.expand) {
- this.dropUpdateExpandFolder(newDropParentNode, true);
- } else {
- this.getVisiableNodes();
- }
- } else if (newDropParentNode.parent_node_id) {
- if (newDropParentNode.node_type === 1 && newDropParentNode.expand) {
- this.dropUpdateExpandFolder(newDropParentNode, true);
- } else {
- this.dropUpdateExpandFolder(newDropParentNode, false);
- }
- }
- }
-
- dropUpdateExpandFolder(newDropParentNode, isParent) {
- setTimeout(() => {
- let recordExpNode = [];
- if (!isParent) {
- const parent_node_id = newDropParentNode.parent_node_id;
- if (parent_node_id) {
- const pos = this.treeTableArray.findIndex((v) => v.node_id === parent_node_id);
- recordExpNode = this.recordExpandChild(this.treeTableArray[pos]);
- this.changeSingleExpand(this.treeTableArray[pos]);
- }
- } else {
- recordExpNode = this.recordExpandChild(newDropParentNode);
- this.changeSingleExpand(newDropParentNode);
- }
-
- for (let i = 0; i < recordExpNode.length; i++) {
- this.toggleNodeExpand(recordExpNode[i], true);
- }
- });
- }
-
- saveBtn() {
- this.save.emit(this.treeTableArray);
- }
-}
diff --git a/devui/datepicker-pro/datepicker-pro-calendar.component.html b/devui/datepicker-pro/datepicker-pro-calendar.component.html
index 9f038e52..8c5cb690 100644
--- a/devui/datepicker-pro/datepicker-pro-calendar.component.html
+++ b/devui/datepicker-pro/datepicker-pro-calendar.component.html
@@ -1,4 +1,4 @@
- |