Commit 3987c76a authored by 前端-许佳敏's avatar 前端-许佳敏

fix: 业务员管理修复部分bug

parent e73879ea
......@@ -80,7 +80,6 @@ const Relevance = props => {
}
setVisible(true);
};
return (
<RowStyleLayout>
<Input
......
......@@ -81,6 +81,7 @@ const MemberDetail: React.FC<{}> = () => {
const [memberVisible, setMemberVisible] = useState(false)
const { pageStatus, id} = usePageStatus()
const [tableData, setTableData] = useState<any[]>([])
const [keywordName, setKeywordName] = useState<string>('')
const fetchMemberSaleChannel = async (params) => {
const userInfo = formAction.getFieldValue('userId')
if (userInfo && userInfo.length > 0) {
......@@ -97,27 +98,33 @@ const MemberDetail: React.FC<{}> = () => {
return []
}
}
useEffect(() => {
if (id) {
PublicApi.getMemberAbilitySalesGet({
userId: id
}).then((res) => {
if (res.code === 1000) {
formAction.setFieldValue('userId', [res.data])
}
})
fetchSaleChannel()
}
}, [id])
const fetchSaleChannel = async () => {
PublicApi.getMemberAbilitySalesChannel({
userId: id,
current: '1',
pageSize: '20',
name: keywordName,
}).then((res) => {
if (res.code === 1000) {
formAction.setFieldValue('userId', [res.data])
setTableData(res.data.data)
}
})
}
useEffect(() => {
if (tableData.length > 0) {
rowCtl.setSelectedRowKeys(tableData.map(v => v.memberId))
}
rowCtl.setSelectedRowKeys(tableData.map(v => v.memberId))
rowCtl.setSelectRow([...tableData])
}, [tableData])
const cacelConnect = (record) => {
unBindMember(record.memberId)
unBindMember(record.relationId)
}
const abilityColumns: any[] = [
......@@ -260,21 +267,31 @@ const MemberDetail: React.FC<{}> = () => {
return userInfo && userInfo.length > 0
}
const unBindMember = async (id?) => {
const unBindMember = async (relationId?) => {
if (pageStatus === PageStatus.ADD) {
// 新增则无需调用接口 直接删除
if (relationId) {
setTableData(d => d.filter(v => v.relationId !== relationId))
} else {
setTableData(d => {
return d.filter(v => !realRowCtl.selectedRowKeys.includes(v.relationId))
})
}
return false
}
if (validateMember()) {
const userInfo = formAction.getFieldValue('userId')
const userId = userInfo[0].userId
const { code } = await PublicApi.postMemberAbilitySalesChannelUnbind({
userId,
relationIds: id ? [id] : realRowCtl.selectedRowKeys
relationIds: relationId ? [relationId] : realRowCtl.selectedRowKeys
})
if (code === 1000) {
setTableData(d => {
return d.filter(v => !realRowCtl.selectedRowKeys.includes(v.memberId))
return d.filter(v => relationId ? v.relationId !== relationId! : realRowCtl.selectedRowKeys.includes(v.relationId))
})
message.success('解绑成功')
}
} else {
message.error('请先选择业务员')
......@@ -441,7 +458,7 @@ const MemberDetail: React.FC<{}> = () => {
<Button type='default' onClick={() => unBindMember()}>批量解除绑定关系</Button>
</Col>
<Col style={{display: 'flex'}}>
<Input.Search/>
<Input.Search value={keywordName} onChange={e => setKeywordName(e.target.value)} onPressEnter={fetchSaleChannel}/>
<Button type='default' style={{marginLeft: 20}}>重置</Button>
</Col>
</Row>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment