Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
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
shenshaokai
jinfa-admin
Commits
f43e616b
Commit
f43e616b
authored
Sep 18, 2021
by
前端-黄佳鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix(TableLayout 组件): 修改跨页多选的问题
parent
e12fcc8f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
index.tsx
src/components/TableLayout/index.tsx
+11
-9
useRowSelectionTable.ts
src/hooks/useRowSelectionTable.ts
+10
-4
index.tsx
...es/marketingManage/marketing/waitAddedMarketing/index.tsx
+2
-2
No files found.
src/components/TableLayout/index.tsx
View file @
f43e616b
...
@@ -9,6 +9,7 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
...
@@ -9,6 +9,7 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
import
{
useStateFilterSearchLinkageEffect
}
from
'@/formSchema/effects/useFilterSearch'
;
import
{
useStateFilterSearchLinkageEffect
}
from
'@/formSchema/effects/useFilterSearch'
;
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
;
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
;
import
{
searchSelectGetSelectCategoryOptionEffect
}
from
'@/pages/systemManage/effect'
;
import
{
searchSelectGetSelectCategoryOptionEffect
}
from
'@/pages/systemManage/effect'
;
import
{
useRowSelectionTable
}
from
'@/hooks/useRowSelectionTable'
;
const
{
onFormMount$
}
=
FormEffectHooks
const
{
onFormMount$
}
=
FormEffectHooks
interface
Iprops
{
interface
Iprops
{
...
@@ -51,6 +52,13 @@ const Table: React.FC<Iprops> = (props: any) => {
...
@@ -51,6 +52,13 @@ const Table: React.FC<Iprops> = (props: any) => {
useStateEffects
useStateEffects
}
=
props
;
}
=
props
;
const
tableRef
=
useRef
<
any
>
({});
const
tableRef
=
useRef
<
any
>
({});
const
[
selectRow
,
selectRowFns
]
=
useRowSelectionTable
({
extendsSelection
:
{
onChange
:
()
=>
{
fetchRowkeys
(
selectRowFns
.
selectedRowKeys
)
},
}
});
/** 列表数据 */
/** 列表数据 */
const
fetchData
=
(
params
?:
any
)
=>
{
const
fetchData
=
(
params
?:
any
)
=>
{
...
@@ -63,18 +71,12 @@ const Table: React.FC<Iprops> = (props: any) => {
...
@@ -63,18 +71,12 @@ const Table: React.FC<Iprops> = (props: any) => {
/**多选 */
/**多选 */
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
Array
<
number
>>
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
Array
<
number
>>
([]);
const
rowSelection
=
{
selectedRowKeys
:
selectedRowKeys
,
onChange
:
(
rowKeys
:
any
)
=>
{
console
.
log
(
rowKeys
,
98
)
fetchRowkeys
(
rowKeys
)
setSelectedRowKeys
(
rowKeys
);
},
}
useImperativeHandle
(
reload
,
()
=>
({
useImperativeHandle
(
reload
,
()
=>
({
reload
:
()
=>
{
reload
:
()
=>
{
tableRef
.
current
.
reload
();
tableRef
.
current
.
reload
();
selectRowFns
.
setSelectRow
([])
selectRowFns
.
setSelectedRowKeys
([])
}
}
}));
}));
...
@@ -107,7 +109,7 @@ const Table: React.FC<Iprops> = (props: any) => {
...
@@ -107,7 +109,7 @@ const Table: React.FC<Iprops> = (props: any) => {
currentRef=
{
tableRef
}
currentRef=
{
tableRef
}
columns=
{
columns
}
columns=
{
columns
}
tableProps=
{
{
rowKew
:
'id'
}
}
tableProps=
{
{
rowKew
:
'id'
}
}
rowSelection=
{
selectedRow
&&
rowSelection
}
rowSelection=
{
selectedRow
&&
selectRow
}
fetchTableData=
{
(
params
:
any
)
=>
fetchData
(
params
)
}
fetchTableData=
{
(
params
:
any
)
=>
fetchData
(
params
)
}
controlRender=
{
controlRender=
{
<
NiceForm
<
NiceForm
...
...
src/hooks/useRowSelectionTable.ts
View file @
f43e616b
...
@@ -12,7 +12,11 @@ interface useRowSelectionTableCtl {
...
@@ -12,7 +12,11 @@ interface useRowSelectionTableCtl {
interface
useRowSelectionOptions
{
interface
useRowSelectionOptions
{
type
?:
'checkbox'
|
'radio'
,
type
?:
'checkbox'
|
'radio'
,
customKey
?:
string
customKey
?:
string
,
// 可通过该参数扩展多选选项
// https://ant.design/components/table-cn/#components-table-demo-row-selection
extendsSelection
?:
TableRowSelection
<
any
>
}
}
/**
/**
...
@@ -20,7 +24,7 @@ interface useRowSelectionOptions {
...
@@ -20,7 +24,7 @@ interface useRowSelectionOptions {
* @auth xjm
* @auth xjm
*/
*/
export
const
useRowSelectionTable
=
(
options
:
useRowSelectionOptions
=
{}):
[
TableRowSelection
<
any
>
,
useRowSelectionTableCtl
]
=>
{
export
const
useRowSelectionTable
=
(
options
:
useRowSelectionOptions
=
{}):
[
TableRowSelection
<
any
>
,
useRowSelectionTableCtl
]
=>
{
const
{
type
=
'checkbox'
,
customKey
=
'id'
}
=
options
const
{
type
=
'checkbox'
,
customKey
=
'id'
,
extendsSelection
=
{}
}
=
options
const
[
selectRow
,
setSelectRow
]
=
useState
<
any
[]
>
([])
// 模态框选择的行数据
const
[
selectRow
,
setSelectRow
]
=
useState
<
any
[]
>
([])
// 模态框选择的行数据
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
any
[]
>
(()
=>
[])
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
any
[]
>
(()
=>
[])
...
@@ -59,7 +63,7 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
...
@@ -59,7 +63,7 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
// 单选情况下
// 单选情况下
setSelectedRowKeys
([
record
[
customKey
]])
setSelectedRowKeys
([
record
[
customKey
]])
setSelectRow
([
record
])
setSelectRow
([
record
])
return
;
return
;
}
}
const
findIds
=
selectedRowKeys
.
indexOf
(
record
[
customKey
])
const
findIds
=
selectedRowKeys
.
indexOf
(
record
[
customKey
])
if
(
findIds
===
-
1
)
{
if
(
findIds
===
-
1
)
{
...
@@ -79,7 +83,9 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
...
@@ -79,7 +83,9 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
setSelectedRowKeys
(
removeRowsKeys
(
changeRows
.
map
(
v
=>
v
[
customKey
])))
setSelectedRowKeys
(
removeRowsKeys
(
changeRows
.
map
(
v
=>
v
[
customKey
])))
setSelectRow
(
removeRows
(
changeRows
))
setSelectRow
(
removeRows
(
changeRows
))
}
}
}
},
...
extendsSelection
}
}
return
[
rowSelection
,
{
selectRow
,
setSelectRow
,
selectedRowKeys
,
setSelectedRowKeys
}]
return
[
rowSelection
,
{
selectRow
,
setSelectRow
,
selectedRowKeys
,
setSelectedRowKeys
}]
...
...
src/pages/marketingManage/marketing/waitAddedMarketing/index.tsx
View file @
f43e616b
...
@@ -263,14 +263,14 @@ const WaitAddedMarketing = () => {
...
@@ -263,14 +263,14 @@ const WaitAddedMarketing = () => {
icon=
{
<
DeleteOutlined
/>
}
icon=
{
<
DeleteOutlined
/>
}
loading=
{
loading
}
loading=
{
loading
}
onClick=
{
()
=>
fetchDeleteBatch
()
}
onClick=
{
()
=>
fetchDeleteBatch
()
}
disabled=
{
rowkeys
.
length
=
==
0
}
disabled=
{
rowkeys
.
length
!
==
0
}
>
>
批量删除
批量删除
</
Button
>
</
Button
>
<
Button
<
Button
loading=
{
loading
}
loading=
{
loading
}
onClick=
{
()
=>
fetchSubmitBatch
()
}
onClick=
{
()
=>
fetchSubmitBatch
()
}
disabled=
{
rowkeys
.
length
=
==
0
}
disabled=
{
rowkeys
.
length
!
==
0
}
>
>
批量提交审核
批量提交审核
</
Button
>
</
Button
>
...
...
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