@bit-sun/business-component 2.2.41 → 2.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +2 -2
- package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +2 -2
- package/dist/components/Business/BsLayouts/index.d.ts +2 -2
- package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +1 -0
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +1 -0
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +2 -2
- package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +3 -0
- package/dist/index.esm.js +265 -134
- package/dist/index.js +272 -141
- package/dist/utils/TableUtils.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +37 -11
- package/src/components/Business/BsSulaQueryTable/index.less +6 -4
- package/src/components/Business/BsSulaQueryTable/setting.tsx +37 -11
- package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +92 -0
- package/src/components/Business/moreTreeTable/index.tsx +13 -3
package/package.json
CHANGED
|
@@ -79,7 +79,7 @@ class SearchItemTable extends React.Component {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
patchConfigToLocalstorage = (configvalue) => {
|
|
82
|
-
const { setShowSearchFields } = this.props;
|
|
82
|
+
const { setShowSearchFields, datasource = [] } = this.props;
|
|
83
83
|
const { sortDataSource, bsTableCode } = this.state;
|
|
84
84
|
let config = localStorage.getItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION) || '[]'
|
|
85
85
|
let configArray = JSON.parse(config)
|
|
@@ -97,7 +97,22 @@ class SearchItemTable extends React.Component {
|
|
|
97
97
|
this.setState({
|
|
98
98
|
visible: false,
|
|
99
99
|
});
|
|
100
|
-
|
|
100
|
+
if(configvalue){
|
|
101
|
+
setShowSearchFields([...sortDataSource]);
|
|
102
|
+
}else{
|
|
103
|
+
this.setState({
|
|
104
|
+
isDefaultValue: true,
|
|
105
|
+
dataSource: [...datasource.map((item)=>({
|
|
106
|
+
...item,
|
|
107
|
+
hidden: false
|
|
108
|
+
}))],
|
|
109
|
+
sortDataSource: [...datasource.map((item)=>({
|
|
110
|
+
...item,
|
|
111
|
+
hidden: false
|
|
112
|
+
}))]
|
|
113
|
+
});
|
|
114
|
+
setShowSearchFields([...datasource]);
|
|
115
|
+
}
|
|
101
116
|
};
|
|
102
117
|
|
|
103
118
|
setInitValue = (isClick = false) => {
|
|
@@ -362,6 +377,10 @@ class SearchItemTable extends React.Component {
|
|
|
362
377
|
this.setInitValue(true);
|
|
363
378
|
};
|
|
364
379
|
|
|
380
|
+
handleResetSetting = () =>{
|
|
381
|
+
this.patchUserSearchFieldsConfig('');
|
|
382
|
+
}
|
|
383
|
+
|
|
365
384
|
onSearch = (e: any) => {
|
|
366
385
|
this.setState({
|
|
367
386
|
searchDataSource: e.target.value,
|
|
@@ -396,15 +415,22 @@ class SearchItemTable extends React.Component {
|
|
|
396
415
|
onOk={this.handleOk}
|
|
397
416
|
onCancel={this.handleCancel}
|
|
398
417
|
footer={[
|
|
399
|
-
<
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
418
|
+
<div>
|
|
419
|
+
<Button key="back" onClick={this.handleReset} style={{marginRight: 0}}>
|
|
420
|
+
恢复默认
|
|
421
|
+
</Button>,
|
|
422
|
+
<Button key="back" onClick={this.handleResetSetting}>
|
|
423
|
+
重置设置
|
|
424
|
+
</Button>
|
|
425
|
+
</div>,
|
|
426
|
+
<div>
|
|
427
|
+
<Button key="submit" onClick={this.handleCancel} style={{marginRight: 0}}>
|
|
428
|
+
取消
|
|
429
|
+
</Button>,
|
|
430
|
+
<Button key="submit" type="primary" onClick={this.handleOk}>
|
|
431
|
+
确认
|
|
432
|
+
</Button>
|
|
433
|
+
</div>,
|
|
408
434
|
]}
|
|
409
435
|
>
|
|
410
436
|
<div className={'sort_table'}>
|
|
@@ -145,7 +145,9 @@
|
|
|
145
145
|
height: 70px;
|
|
146
146
|
border: 0;
|
|
147
147
|
padding: 20px;
|
|
148
|
-
|
|
148
|
+
display: flex;
|
|
149
|
+
justify-content: space-between;
|
|
150
|
+
|
|
149
151
|
.ant-btn {
|
|
150
152
|
width: 80px;
|
|
151
153
|
height: 34px;
|
|
@@ -160,9 +162,9 @@
|
|
|
160
162
|
line-height: 20px;
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
&:first-child {
|
|
164
|
-
|
|
165
|
-
}
|
|
165
|
+
// &:first-child {
|
|
166
|
+
// margin-right: 524px;
|
|
167
|
+
// }
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
@@ -86,7 +86,7 @@ class SortableTable extends React.Component {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
patchConfigToLocalstorage = (configvalue) => {
|
|
89
|
-
const { setShowColumns } = this.props;
|
|
89
|
+
const { setShowColumns, datasource = [] } = this.props;
|
|
90
90
|
const { sortDataSource, bsTableCode } = this.state;
|
|
91
91
|
let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]'
|
|
92
92
|
let configArray = JSON.parse(config)
|
|
@@ -104,7 +104,22 @@ class SortableTable extends React.Component {
|
|
|
104
104
|
this.setState({
|
|
105
105
|
visible: false,
|
|
106
106
|
});
|
|
107
|
-
|
|
107
|
+
if(configvalue){
|
|
108
|
+
setShowColumns([...sortDataSource]);
|
|
109
|
+
}else{
|
|
110
|
+
this.setState({
|
|
111
|
+
isDefaultValue: true,
|
|
112
|
+
dataSource: [...datasource.map((item)=>({
|
|
113
|
+
...item,
|
|
114
|
+
hidden: false
|
|
115
|
+
}))],
|
|
116
|
+
sortDataSource: [...datasource.map((item)=>({
|
|
117
|
+
...item,
|
|
118
|
+
hidden: false
|
|
119
|
+
}))]
|
|
120
|
+
});
|
|
121
|
+
setShowColumns([...datasource]);
|
|
122
|
+
}
|
|
108
123
|
};
|
|
109
124
|
|
|
110
125
|
setInitValue = (isClick = false) => {
|
|
@@ -570,6 +585,10 @@ class SortableTable extends React.Component {
|
|
|
570
585
|
this.setInitValue(true);
|
|
571
586
|
};
|
|
572
587
|
|
|
588
|
+
handleResetSetting = () =>{
|
|
589
|
+
this.patchUserColumnConfig('');
|
|
590
|
+
}
|
|
591
|
+
|
|
573
592
|
onSearch = (e: any) => {
|
|
574
593
|
this.setState({
|
|
575
594
|
searchDataSource: e.target.value,
|
|
@@ -606,15 +625,22 @@ class SortableTable extends React.Component {
|
|
|
606
625
|
onOk={this.handleOk}
|
|
607
626
|
onCancel={this.handleCancel}
|
|
608
627
|
footer={[
|
|
609
|
-
<
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
628
|
+
<div>
|
|
629
|
+
<Button key="back" onClick={this.handleReset} style={{marginRight: 0}}>
|
|
630
|
+
恢复默认
|
|
631
|
+
</Button>,
|
|
632
|
+
<Button key="back" onClick={this.handleResetSetting}>
|
|
633
|
+
重置设置
|
|
634
|
+
</Button>
|
|
635
|
+
</div>,
|
|
636
|
+
<div>
|
|
637
|
+
<Button key="submit" onClick={this.handleCancel} style={{marginRight: 0}}>
|
|
638
|
+
取消
|
|
639
|
+
</Button>,
|
|
640
|
+
<Button key="submit" type="primary" onClick={this.handleOk}>
|
|
641
|
+
确认
|
|
642
|
+
</Button>
|
|
643
|
+
</div>
|
|
618
644
|
]}
|
|
619
645
|
>
|
|
620
646
|
<div className={'sort_table'}>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, {useEffect, useImperativeHandle, useRef, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
function getOffset(node: any) {
|
|
4
|
+
const box = node.getBoundingClientRect();
|
|
5
|
+
const docElem = document.documentElement;
|
|
6
|
+
console.log(box, 'box', {
|
|
7
|
+
left: box.left + (window.pageXOffset || docElem.scrollLeft) -
|
|
8
|
+
(docElem.clientLeft || document.body.clientLeft || 0),
|
|
9
|
+
top: box.top + (window.pageYOffset || docElem.scrollTop) -
|
|
10
|
+
(docElem.clientTop || document.body.clientTop || 0),
|
|
11
|
+
})
|
|
12
|
+
// < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft
|
|
13
|
+
return {
|
|
14
|
+
left: box.left + (window.pageXOffset || docElem.scrollLeft) -
|
|
15
|
+
(docElem.clientLeft || document.body.clientLeft || 0),
|
|
16
|
+
top: box.top + (window.pageYOffset || docElem.scrollTop) -
|
|
17
|
+
(docElem.clientTop || document.body.clientTop || 0),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const FixedScrollBar = ({viewPort, width}: any, ref: any) => {
|
|
23
|
+
|
|
24
|
+
const [scrollState, setScrollState] = useState({
|
|
25
|
+
isHiddenScrollBar: false
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const onContainerScroll = () => {
|
|
29
|
+
if (!viewPort.current) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const tableOffsetTop = getOffset(viewPort.current).top;
|
|
33
|
+
const tableBottomOffset = tableOffsetTop + viewPort.current.offsetHeight;
|
|
34
|
+
const currentClientOffset = document.documentElement.scrollTop + window.innerHeight
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
tableBottomOffset - 1 <= currentClientOffset ||
|
|
38
|
+
tableOffsetTop >= currentClientOffset
|
|
39
|
+
) {
|
|
40
|
+
setScrollState(state => ({
|
|
41
|
+
...state,
|
|
42
|
+
isHiddenScrollBar: true,
|
|
43
|
+
}));
|
|
44
|
+
} else {
|
|
45
|
+
ref.current?.scrollTo(viewPort.current.scrollLeft, 0)
|
|
46
|
+
setScrollState(state => ({
|
|
47
|
+
...state,
|
|
48
|
+
isHiddenScrollBar: false,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
document.addEventListener('scroll', onContainerScroll)
|
|
55
|
+
return () => {
|
|
56
|
+
document.removeEventListener('scroll', onContainerScroll)
|
|
57
|
+
}
|
|
58
|
+
},[])
|
|
59
|
+
|
|
60
|
+
if(scrollState.isHiddenScrollBar){
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
ref={ref}
|
|
67
|
+
onScroll={(e) => {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
viewPort.current.scrollTo(e.target.scrollLeft, 0)
|
|
70
|
+
}}
|
|
71
|
+
style={{
|
|
72
|
+
position:'fixed',
|
|
73
|
+
zIndex: '9999',
|
|
74
|
+
bottom: '45px',
|
|
75
|
+
overflowY: 'hidden',
|
|
76
|
+
overflowX: 'auto',
|
|
77
|
+
width: viewPort.current?.offsetWidth || 0,
|
|
78
|
+
background:'#fff',
|
|
79
|
+
opacity: 0.6,
|
|
80
|
+
}}>
|
|
81
|
+
<div
|
|
82
|
+
className={'ant-table-sticky-scroll-bar'}
|
|
83
|
+
style={{
|
|
84
|
+
height: '1px',
|
|
85
|
+
backgroundColor: '#fff',
|
|
86
|
+
width,
|
|
87
|
+
}}></div>
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default React.forwardRef(FixedScrollBar)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React, { useState, useEffect, useImperativeHandle, forwardRef, useMemo, useRef } from 'react';
|
|
3
3
|
import { getAllColumns, convertToRows, headersToRows } from './utils';
|
|
4
4
|
import './index.less';
|
|
5
|
+
import FixedScrollBar from "./FixedScrollBar";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export default forwardRef((props, ref) => {
|
|
@@ -21,10 +22,11 @@ export default forwardRef((props, ref) => {
|
|
|
21
22
|
const itemWidth = 100; // 表格每一项宽度
|
|
22
23
|
|
|
23
24
|
const viewPort = useRef(null);
|
|
25
|
+
const topScrollBar = useRef(null)
|
|
24
26
|
|
|
25
27
|
//起始渲染item
|
|
26
28
|
const [startIndex, setStartIndex] = useState(0);
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
//结束渲染item
|
|
29
31
|
const endIndex = useMemo(() => {
|
|
30
32
|
return startIndex + viewCount;
|
|
@@ -41,6 +43,9 @@ export default forwardRef((props, ref) => {
|
|
|
41
43
|
}, [])
|
|
42
44
|
|
|
43
45
|
const onScroll = () => {
|
|
46
|
+
if(topScrollBar.current){
|
|
47
|
+
topScrollBar.current.scrollTo(viewPort.current.scrollLeft, 0)
|
|
48
|
+
}
|
|
44
49
|
const scrollWidth = viewPort.current.scrollLeft;
|
|
45
50
|
const startIndex = Math.floor(scrollWidth/itemWidth);
|
|
46
51
|
const offsetWidth = startIndex * itemWidth;
|
|
@@ -134,8 +139,8 @@ export default forwardRef((props, ref) => {
|
|
|
134
139
|
// if (!show) {
|
|
135
140
|
// return <div>loading</div>;
|
|
136
141
|
// }
|
|
137
|
-
|
|
138
|
-
const {width, height } = props;
|
|
142
|
+
|
|
143
|
+
const {width, height, tableProps } = props;
|
|
139
144
|
let tableWidth = width ? `${width}px` : '100%';
|
|
140
145
|
let tableHeight = `${height || 400}px`;
|
|
141
146
|
const rightAreaWidth = 'calc(100% - ' + `${config.colHeaderWidth}px` + ')';
|
|
@@ -147,6 +152,11 @@ export default forwardRef((props, ref) => {
|
|
|
147
152
|
onScroll={onScroll}
|
|
148
153
|
ref={viewPort}
|
|
149
154
|
>
|
|
155
|
+
{tableProps?.sticky && <FixedScrollBar
|
|
156
|
+
viewPort={viewPort}
|
|
157
|
+
width={`${config.colHeaderWidth + 1 + placeholderWidth}px`}
|
|
158
|
+
ref={topScrollBar}
|
|
159
|
+
/>}
|
|
150
160
|
<div style={{
|
|
151
161
|
width: `${config.colHeaderWidth + 1 + placeholderWidth}px`,
|
|
152
162
|
position: 'absolute',
|