Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
linweijiong
jinfa-platform
Commits
3afb22e1
Commit
3afb22e1
authored
Jun 23, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 业务员管理修复
parent
303edb84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
15 deletions
+52
-15
detail.tsx
src/pages/channel/memberList/detail.tsx
+51
-15
index.tsx
src/pages/channel/memberList/index.tsx
+1
-0
No files found.
src/pages/channel/memberList/detail.tsx
View file @
3afb22e1
...
@@ -76,6 +76,7 @@ const fetchMemberAbilitySelect = async (params) => {
...
@@ -76,6 +76,7 @@ const fetchMemberAbilitySelect = async (params) => {
const
MemberDetail
:
React
.
FC
<
{}
>
=
()
=>
{
const
MemberDetail
:
React
.
FC
<
{}
>
=
()
=>
{
const
ref
=
useRef
<
any
>
({})
const
ref
=
useRef
<
any
>
({})
const
staticData
=
useRef
<
any
>
([])
const
[
rowSelection
,
rowCtl
]
=
useRowSelectionTable
({
customKey
:
'memberId'
})
const
[
rowSelection
,
rowCtl
]
=
useRowSelectionTable
({
customKey
:
'memberId'
})
const
[
realRowSelection
,
realRowCtl
]
=
useRowSelectionTable
({
customKey
:
'relationId'
})
const
[
realRowSelection
,
realRowCtl
]
=
useRowSelectionTable
({
customKey
:
'relationId'
})
const
[
memberVisible
,
setMemberVisible
]
=
useState
(
false
)
const
[
memberVisible
,
setMemberVisible
]
=
useState
(
false
)
...
@@ -113,18 +114,25 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -113,18 +114,25 @@ const MemberDetail: React.FC<{}> = () => {
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
if
(
res
.
code
===
1000
)
{
formAction
.
setFieldValue
(
'userId'
,
[
res
.
data
])
formAction
.
setFieldValue
(
'userId'
,
[
res
.
data
])
setTableData
(
res
.
data
.
data
)
// 添加一个remote标识, 带有此标识的 将会调用接口解绑
setTableData
(
res
.
data
.
data
.
map
(
v
=>
({...
v
,
isRemote
:
true
})))
}
}
})
})
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
staticData
.
current
=
realRowCtl
.
selectedRowKeys
},
[
realRowCtl
.
selectedRowKeys
])
useEffect
(()
=>
{
rowCtl
.
setSelectedRowKeys
(
tableData
.
map
(
v
=>
v
.
memberId
))
rowCtl
.
setSelectedRowKeys
(
tableData
.
map
(
v
=>
v
.
memberId
))
rowCtl
.
setSelectRow
([...
tableData
])
rowCtl
.
setSelectRow
([...
tableData
])
realRowCtl
.
setSelectedRowKeys
(
tableData
.
filter
(
v
=>
!
staticData
.
current
.
includes
(
v
)))
},
[
tableData
])
},
[
tableData
])
const
cacelConnect
=
(
record
)
=>
{
const
cacelConnect
=
(
record
)
=>
{
unBindMember
(
record
.
relationId
)
unBindMember
(
record
)
}
}
const
abilityColumns
:
any
[]
=
[
const
abilityColumns
:
any
[]
=
[
...
@@ -209,8 +217,8 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -209,8 +217,8 @@ const MemberDetail: React.FC<{}> = () => {
title
:
'操作'
,
title
:
'操作'
,
align
:
'center'
,
align
:
'center'
,
render
:
(
_
,
record
)
=>
{
render
:
(
_
,
record
)
=>
{
return
<
Popconfirm
title=
'确定要解除吗'
onConfirm=
{
()
=>
cacelConnect
(
record
)
}
>
return
<
Popconfirm
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
title=
'确定要解除吗'
onConfirm=
{
()
=>
cacelConnect
(
record
)
}
>
<
Button
type=
'link'
>
解除绑定关系
</
Button
>
<
Button
type=
'link'
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
>
解除绑定关系
</
Button
>
</
Popconfirm
>
</
Popconfirm
>
}
}
}
}
...
@@ -267,17 +275,38 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -267,17 +275,38 @@ const MemberDetail: React.FC<{}> = () => {
return
userInfo
&&
userInfo
.
length
>
0
return
userInfo
&&
userInfo
.
length
>
0
}
}
const
unBindMember
=
async
(
relationId
?)
=>
{
const
unBindMember
=
async
(
options
?)
=>
{
if
(
pageStatus
===
PageStatus
.
ADD
)
{
const
relationIds
=
[]
// 新增则无需调用接口 直接删除
if
(
options
)
{
if
(
relationId
)
{
// 单选
const
{
relationId
,
isRemote
}
=
options
if
(
pageStatus
===
PageStatus
.
ADD
||
!
isRemote
)
{
// 新增或者编辑时是未保存状态的渠道业务员则无需调用接口 直接删除
setTableData
(
d
=>
d
.
filter
(
v
=>
v
.
relationId
!==
relationId
))
setTableData
(
d
=>
d
.
filter
(
v
=>
v
.
relationId
!==
relationId
))
}
else
{
return
false
}
relationIds
.
push
(
relationId
)
}
else
{
// 批量
if
(
pageStatus
===
PageStatus
.
ADD
)
{
// 新增情况下 删除本地数据
setTableData
(
d
=>
{
setTableData
(
d
=>
{
return
d
.
filter
(
v
=>
!
realRowCtl
.
selectedRowKeys
.
includes
(
v
.
relationId
))
return
d
.
filter
(
v
=>
!
realRowCtl
.
selectedRowKeys
.
includes
(
v
.
relationId
))
})
})
return
false
}
}
return
false
const
localRow
=
realRowCtl
.
selectRow
.
filter
(
v
=>
!
v
.
isRemote
)
const
localRowKey
=
localRow
.
map
(
v
=>
v
.
relationId
)
const
remoteRowKey
=
realRowCtl
.
selectRow
.
filter
(
v
=>
v
.
isRemote
).
map
(
v
=>
v
.
relationId
)
setTableData
(
d
=>
{
return
d
.
filter
(
v
=>
!
localRow
.
find
(
l
=>
l
.
relationId
===
v
.
relationId
))
})
if
(
remoteRowKey
.
length
===
0
)
{
clearRealRowCtl
(
localRowKey
)
return
false
}
relationIds
.
push
(...
remoteRowKey
)
}
}
if
(
validateMember
())
{
if
(
validateMember
())
{
const
userInfo
=
formAction
.
getFieldValue
(
'userId'
)
const
userInfo
=
formAction
.
getFieldValue
(
'userId'
)
...
@@ -285,12 +314,13 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -285,12 +314,13 @@ const MemberDetail: React.FC<{}> = () => {
const
{
code
}
=
await
PublicApi
.
postMemberAbilitySalesChannelUnbind
({
const
{
code
}
=
await
PublicApi
.
postMemberAbilitySalesChannelUnbind
({
userId
,
userId
,
relationIds
:
relationId
?
[
relationId
]
:
realRowCtl
.
selectedRowKey
s
relationIds
:
relationIds
})
})
if
(
code
===
1000
)
{
if
(
code
===
1000
)
{
setTableData
(
d
=>
{
setTableData
(
d
=>
{
return
d
.
filter
(
v
=>
relationId
?
v
.
relationId
!==
relationId
!
:
realRowCtl
.
selectedRowKeys
.
includes
(
v
.
relationId
))
clearRealRowCtl
(
relationIds
)
return
d
.
filter
(
v
=>
!
relationIds
.
includes
(
v
.
relationId
))
})
})
}
}
}
else
{
}
else
{
...
@@ -298,6 +328,11 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -298,6 +328,11 @@ const MemberDetail: React.FC<{}> = () => {
}
}
}
}
const
clearRealRowCtl
=
(
ids
:
any
[])
=>
{
realRowCtl
.
setSelectRow
([...
realRowCtl
.
selectRow
.
filter
(
v
=>
!
ids
.
includes
(
v
.
relationId
))])
realRowCtl
.
setSelectedRowKeys
([...
realRowCtl
.
selectedRowKeys
.
filter
(
v
=>
!
ids
.
includes
(
v
))])
}
const
handleSubmit
=
async
()
=>
{
const
handleSubmit
=
async
()
=>
{
const
userInfo
=
formAction
.
getFieldValue
(
'userId'
)
const
userInfo
=
formAction
.
getFieldValue
(
'userId'
)
if
(
userInfo
&&
userInfo
.
length
>
0
)
{
if
(
userInfo
&&
userInfo
.
length
>
0
)
{
...
@@ -455,17 +490,17 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -455,17 +490,17 @@ const MemberDetail: React.FC<{}> = () => {
<
TabsItem
tab=
"管理下级渠道"
key=
"2"
>
<
TabsItem
tab=
"管理下级渠道"
key=
"2"
>
<
Row
justify=
'space-between'
style=
{
{
marginBottom
:
20
}
}
>
<
Row
justify=
'space-between'
style=
{
{
marginBottom
:
20
}
}
>
<
Col
>
<
Col
>
<
Button
type=
'default'
onClick=
{
()
=>
unBindMember
()
}
>
批量解除绑定关系
</
Button
>
<
Button
type=
'default'
onClick=
{
()
=>
unBindMember
()
}
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
>
批量解除绑定关系
</
Button
>
</
Col
>
</
Col
>
<
Col
style=
{
{
display
:
'flex'
}
}
>
<
Col
style=
{
{
display
:
'flex'
}
}
>
<
Input
.
Search
value=
{
keywordName
}
onChange=
{
e
=>
setKeywordName
(
e
.
target
.
value
)
}
onPressEnter=
{
fetchSaleChannel
}
/>
<
Input
.
Search
value=
{
keywordName
}
onChange=
{
e
=>
setKeywordName
(
e
.
target
.
value
)
}
onPressEnter=
{
fetchSaleChannel
}
/>
<
Button
type=
'default'
style=
{
{
marginLeft
:
20
}
}
>
重置
</
Button
>
<
Button
type=
'default'
style=
{
{
marginLeft
:
20
}
}
>
重置
</
Button
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
<
Button
block
type=
'dashed'
onClick=
{
()
=>
setMemberVisible
(
true
)
}
>
选择待绑定渠道会员
</
Button
>
<
Button
block
type=
'dashed'
onClick=
{
()
=>
setMemberVisible
(
true
)
}
disabled=
{
pageStatus
===
PageStatus
.
PREVIEW
}
>
选择待绑定渠道会员
</
Button
>
<
StandardTable
<
StandardTable
columns=
{
connectMemberColumns
}
columns=
{
connectMemberColumns
}
rowSelection=
{
realRowSelection
}
rowSelection=
{
pageStatus
!==
PageStatus
.
PREVIEW
&&
realRowSelection
}
rowKey=
'relationId'
rowKey=
'relationId'
tableProps=
{
{
tableProps=
{
{
dataSource
:
tableData
dataSource
:
tableData
...
@@ -484,6 +519,7 @@ const MemberDetail: React.FC<{}> = () => {
...
@@ -484,6 +519,7 @@ const MemberDetail: React.FC<{}> = () => {
columns=
{
modalMemberColumns
}
columns=
{
modalMemberColumns
}
fetchTableData=
{
fetchTableData
}
fetchTableData=
{
fetchTableData
}
rowKey=
{
'memberId'
}
rowKey=
{
'memberId'
}
forceRender
formilyProps=
{
{
formilyProps=
{
{
ctx
:
{
ctx
:
{
schema
:
{
schema
:
{
...
...
src/pages/channel/memberList/index.tsx
View file @
3afb22e1
...
@@ -106,6 +106,7 @@ const ChannelMember: React.FC<{}> = () => {
...
@@ -106,6 +106,7 @@ const ChannelMember: React.FC<{}> = () => {
formilyLayouts=
{
{
formilyLayouts=
{
{
justify
:
'space-between'
justify
:
'space-between'
}
}
}
}
rowKey=
'userId'
formilyChilds=
{
{
formilyChilds=
{
{
layouts
:
{
layouts
:
{
order
:
2
order
:
2
...
...
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