Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
cc43d846
Commit
cc43d846
authored
Jan 15, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字段过多卡顿问题
parent
4baaf79a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
21 deletions
+100
-21
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+100
-21
No files found.
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
cc43d846
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
}
from
'react'
;
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
}
from
'react'
;
import
{
Input
,
Form
,
Typography
,
Radio
,
Button
,
Popconfirm
,
Select
,
Row
,
Col
,
Popover
,
Checkbox
,
Tooltip
,
Table
}
from
'antd'
;
import
{
Input
,
Form
,
Typography
,
Radio
,
Button
,
Popconfirm
,
Select
,
Row
,
Col
,
Popover
,
Checkbox
,
Tooltip
,
Table
,
Pagination
}
from
'antd'
;
import
{
CloseOutlined
,
CheckOutlined
}
from
'@ant-design/icons'
;
import
{
CloseOutlined
,
CheckOutlined
}
from
'@ant-design/icons'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
update
from
'immutability-helper'
;
import
update
from
'immutability-helper'
;
import
{
generateUUID
,
highlightSearchContentByTerms
,
showMessage
,
inputWidth
}
from
'../../../../util'
;
import
{
generateUUID
,
highlightSearchContentByTerms
,
showMessage
,
inputWidth
,
paginate
}
from
'../../../../util'
;
import
{
dispatch
,
dispatchLatest
}
from
'../../../../model'
;
import
{
dispatch
,
dispatchLatest
}
from
'../../../../model'
;
import
{
addEventListenerForSidebar
,
removeEventListenerForSidebar
}
from
'./Help'
;
import
{
addEventListenerForSidebar
,
removeEventListenerForSidebar
}
from
'./Help'
;
import
{
AppContext
}
from
'../../../../App'
;
import
{
AppContext
}
from
'../../../../App'
;
...
@@ -16,6 +16,7 @@ const { Option } = Select;
...
@@ -16,6 +16,7 @@ const { Option } = Select;
const
type
=
'DragableTableBodyRow'
;
const
type
=
'DragableTableBodyRow'
;
const
perSuggestCount
=
5
;
const
perSuggestCount
=
5
;
const
supportMaxAttributeCountPerPage
=
100
;
const
DatatypeInput
=
({
value
=
{},
datatypes
,
onChange
})
=>
{
const
DatatypeInput
=
({
value
=
{},
datatypes
,
onChange
})
=>
{
...
@@ -245,13 +246,11 @@ const ImportActionTable = (props) => {
...
@@ -245,13 +246,11 @@ const ImportActionTable = (props) => {
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
autoTranslate
,
setAutoTranslate
]
=
useState
(
false
);
const
[
autoTranslate
,
setAutoTranslate
]
=
useState
(
false
);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
filterPageCondition
,
setFilterPageCondition
]
=
useState
({
pageNum
:
1
,
pageSize
:
supportMaxAttributeCountPerPage
,
filterData
:
[]
});
const
[
filterPageData
,
setFilterPageData
]
=
useState
([]);
const
onChangeRef
=
useRef
();
const
{
pageNum
,
pageSize
,
filterData
}
=
filterPageCondition
;
onChangeRef
.
current
=
onChange
;
const
dataRef
=
useRef
();
const
moveRowRef
=
useRef
({
data
,
onChange
,
pageNum
,
pageSize
});
dataRef
.
current
=
data
;
//规则改变的时候 数据表为可编辑状态
//规则改变的时候 数据表为可编辑状态
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -259,12 +258,53 @@ const ImportActionTable = (props) => {
...
@@ -259,12 +258,53 @@ const ImportActionTable = (props) => {
},
[
constraint
,
template
,
modelerData
])
},
[
constraint
,
template
,
modelerData
])
useEffect
(()
=>
{
useEffect
(()
=>
{
setData
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
setData
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
dataRef
.
current
=
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
setFilterData
((
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
filter
(
item
=>
(
item
?.
name
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
cnName
).
indexOf
(
keyword
)
!==-
1
));
},
[
modelerData
,
keyword
])
moveRowRef
.
current
.
data
=
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
let
_filterData
=
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
filter
(
item
=>
(
item
?.
name
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
cnName
).
indexOf
(
keyword
)
!==-
1
);
setFilterPageCondition
({...
filterPageCondition
,
filterData
:
_filterData
});
if
(
_filterData
.
length
>
supportMaxAttributeCountPerPage
)
{
const
_filterPageData
=
paginate
(
_filterData
,
pageNum
,
pageSize
);
setFilterPageData
(
_filterPageData
);
}
else
{
setFilterPageData
(
_filterData
);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
modelerData
])
useEffect
(()
=>
{
let
_filterData
=
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
filter
(
item
=>
(
item
?.
name
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
cnName
).
indexOf
(
keyword
)
!==-
1
);
setFilterPageCondition
({...
filterPageCondition
,
...{
filterData
:
_filterData
,
pageNum
:
1
}
});
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
keyword
])
useEffect
(()
=>
{
moveRowRef
.
current
.
pageNum
=
pageNum
;
moveRowRef
.
current
.
pageSize
=
pageSize
;
if
(
filterData
.
length
>
supportMaxAttributeCountPerPage
)
{
let
_filterPageData
=
paginate
(
filterData
,
pageNum
,
pageSize
);
if
((
_filterPageData
||
[]).
length
===
0
&&
pageNum
>
1
)
{
setFilterPageCondition
({...
filterPageCondition
,
pageNum
:
(
pageNum
-
1
)});
moveRowRef
.
current
.
pageNum
=
pageNum
-
1
;
}
else
{
setFilterPageData
(
_filterPageData
);
}
}
else
{
setFilterPageData
(
filterData
);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
filterPageCondition
])
const
isEditing
=
(
record
)
=>
record
?.
iid
===
editingKey
;
const
isEditing
=
(
record
)
=>
record
?.
iid
===
editingKey
;
const
onAddClick
=
()
=>
{
const
onAddClick
=
()
=>
{
...
@@ -272,7 +312,15 @@ const ImportActionTable = (props) => {
...
@@ -272,7 +312,15 @@ const ImportActionTable = (props) => {
const
iid
=
generateUUID
();
const
iid
=
generateUUID
();
const
newFilterData
=
[...
filterData
,
{
iid
}];
const
newFilterData
=
[...
filterData
,
{
iid
}];
setFilterData
(
newFilterData
);
if
(
newFilterData
.
length
>
supportMaxAttributeCountPerPage
)
{
const
totalNum
=
(
newFilterData
.
length
/
supportMaxAttributeCountPerPage
)
+
((
newFilterData
.
length
%
supportMaxAttributeCountPerPage
===
0
)?
0
:
1
);
setFilterPageCondition
({...
filterPageCondition
,
...{
filterData
:
newFilterData
,
pageNum
:
totalNum
}});
}
else
{
setFilterPageCondition
({...
filterPageCondition
,
...{
filterData
:
newFilterData
}});
}
edit
(
newFilterData
[
newFilterData
.
length
-
1
]);
edit
(
newFilterData
[
newFilterData
.
length
-
1
]);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
document
.
getElementById
(
`field-
${
iid
}
`
)?.
scrollIntoView
();
document
.
getElementById
(
`field-
${
iid
}
`
)?.
scrollIntoView
();
...
@@ -322,7 +370,7 @@ const ImportActionTable = (props) => {
...
@@ -322,7 +370,7 @@ const ImportActionTable = (props) => {
const
item
=
newFilterData
[
index
];
const
item
=
newFilterData
[
index
];
if
(
_index
===-
1
&&
(
!
item
.
name
||
item
.
name
===
''
))
{
if
(
_index
===-
1
&&
(
!
item
.
name
||
item
.
name
===
''
))
{
newFilterData
.
splice
(
index
,
1
);
newFilterData
.
splice
(
index
,
1
);
setFilter
Data
(
newFilterData
);
setFilter
PageCondition
({...
filterPageCondition
,
filterData
:
newFilterData
})
}
}
setEditingKey
(
''
);
setEditingKey
(
''
);
...
@@ -905,18 +953,29 @@ const ImportActionTable = (props) => {
...
@@ -905,18 +953,29 @@ const ImportActionTable = (props) => {
const moveRow = useCallback(
const moveRow = useCallback(
(dragIndex, hoverIndex) => {
(dragIndex, hoverIndex) => {
const dragRow = dataRef.current[dragIndex];
const { data, onChange, pageNum, pageSize } = moveRowRef.current;
let realDragIndex = dragIndex;
let realHoverIndex = hoverIndex;
if ((data||[]).length>supportMaxAttributeCountPerPage) {
realDragIndex = (pageNum-1)*pageSize + dragIndex;
realHoverIndex = (pageNum-1)*pageSize + hoverIndex;
}
const newData = update(dataRef.current, {
const dragRow = data[realDragIndex];
const newData = update(data, {
$splice: [
$splice: [
[
d
ragIndex, 1],
[
realD
ragIndex, 1],
[
h
overIndex, 0, dragRow],
[
realH
overIndex, 0, dragRow],
],
],
})
})
onChangeRef.current && onChangeRef.current(newData);
onChange && onChange(newData);
},
},
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
[
data
Ref.current],
[
moveRow
Ref.current],
);
);
const onSearchInputChange = (e) => {
const onSearchInputChange = (e) => {
...
@@ -1007,7 +1066,7 @@ const ImportActionTable = (props) => {
...
@@ -1007,7 +1066,7 @@ const ImportActionTable = (props) => {
moveRow
moveRow
}
}
}}
}}
dataSource={filterData||[]}
dataSource={filter
Page
Data||[]}
columns={mergedColumns()}
columns={mergedColumns()}
size='small'
size='small'
rowKey='iid'
rowKey='iid'
...
@@ -1070,6 +1129,26 @@ const ImportActionTable = (props) => {
...
@@ -1070,6 +1129,26 @@ const ImportActionTable = (props) => {
/>
/>
</Form>
</Form>
</DndProvider>
</DndProvider>
{
(filterData.length > supportMaxAttributeCountPerPage) && <Pagination
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setFilterPageCondition({...filterPageCondition, ...{ pageNum: _pageNum, pageSize: _pageSize || supportMaxAttributeCountPerPage }})
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setFilterPageCondition({...filterPageCondition, ...{ pageNum: _pageNum || 1, pageSize: _pageSize }})
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={(filterData||[]).length}
pageSizeOptions={[50, supportMaxAttributeCountPerPage]}
showTotal={total => `
共
$
{(
filterData
||
[]).
length
}
条
`}
/>
}
</div>
</div>
</div>
</div>
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment