|
@@ -1,14 +1,10 @@
|
|
|
import ContactDetail from '@/pages/Customer/Contact/components/ContactDetail'
|
|
import ContactDetail from '@/pages/Customer/Contact/components/ContactDetail'
|
|
|
import Addcontact from '@/pages/Customer/Contact/components/AddContact'
|
|
import Addcontact from '@/pages/Customer/Contact/components/AddContact'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
-// import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
|
|
|
-import { message, Tag } from 'antd'
|
|
|
|
|
|
|
+import { Button, message, Tag } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
import { connect } from 'dva'
|
|
|
import React, { useEffect, useState } from 'react'
|
|
import React, { useEffect, useState } from 'react'
|
|
|
-import useAutoTable, { useTableScroll } from '@/hooks/useAutoTable'
|
|
|
|
|
import consts from '@/consts'
|
|
import consts from '@/consts'
|
|
|
-import { queryContact, apiAddClient } from '@/services/contact'
|
|
|
|
|
-import styles from './index.less'
|
|
|
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
|
import { useDebounceFn } from 'ahooks'
|
|
import { useDebounceFn } from 'ahooks'
|
|
|
import { useModal } from '@/components/Modal'
|
|
import { useModal } from '@/components/Modal'
|
|
@@ -17,14 +13,23 @@ import PersonLabel from '../Company/components/PersonLabel'
|
|
|
import { TagTypeEnum } from '../Company/components/PersonLabel'
|
|
import { TagTypeEnum } from '../Company/components/PersonLabel'
|
|
|
import { TagDataTypeEnum } from '../Company/components/PersonLabel'
|
|
import { TagDataTypeEnum } from '../Company/components/PersonLabel'
|
|
|
import { IconPark } from '@/components/SvgIcon'
|
|
import { IconPark } from '@/components/SvgIcon'
|
|
|
|
|
+import { useTableScroll } from '@/hooks/useAutoTable'
|
|
|
|
|
+import { apiAddClient, queryContact } from '@/services/contact'
|
|
|
|
|
+import { LabelModeType } from '../Company/components/PersonLabel'
|
|
|
|
|
+import { apiBatchLink } from '@/services/customer'
|
|
|
|
|
|
|
|
const Contact = props => {
|
|
const Contact = props => {
|
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
- const { personTagColorMap, teamTagColorMap } = props
|
|
|
|
|
- // const needSubtractHeight = 48 + 48 + 48 + 64 + 24 + 32 // 需要被裁掉的高度
|
|
|
|
|
- // const needSubtractWidth = 48 + 48 + 48 // 需要被裁掉的高度
|
|
|
|
|
|
|
+ const { personTagColorMap, teamTagColorMap, personTags, teamTags, dispatch } = props
|
|
|
|
|
|
|
|
- // const [x, y] = useAutoTable(needSubtractHeight, needSubtractWidth)
|
|
|
|
|
|
|
+ const [tagState, setTagState] = useState({
|
|
|
|
|
+ tagIds: [],
|
|
|
|
|
+ tagCooperationIds: []
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const toolbarOptionsChange = (type, ids) => {
|
|
|
|
|
+ setTagState({ ...tagState, [type]: ids })
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const [selectKeys, setSelectKeys] = useState([])
|
|
const [selectKeys, setSelectKeys] = useState([])
|
|
|
const hanleRowSelectChange = selectedRowKeys => {
|
|
const hanleRowSelectChange = selectedRowKeys => {
|
|
@@ -67,12 +72,11 @@ const Contact = props => {
|
|
|
|
|
|
|
|
const handleAddClient = async values => {
|
|
const handleAddClient = async values => {
|
|
|
const payload = formatValues(values)
|
|
const payload = formatValues(values)
|
|
|
- const { code = -1 } = await apiAddClient(payload)
|
|
|
|
|
|
|
+ const { code = -1, msg = '新增失败' } = await apiAddClient(payload)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
await initData()
|
|
await initData()
|
|
|
- return message.success('新增成功')
|
|
|
|
|
}
|
|
}
|
|
|
- // 请求完了
|
|
|
|
|
|
|
+ return message.success(msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 展示drawer
|
|
// 展示drawer
|
|
@@ -162,19 +166,22 @@ const Contact = props => {
|
|
|
key: 'tag',
|
|
key: 'tag',
|
|
|
width: 100,
|
|
width: 100,
|
|
|
render: (_, record) => (
|
|
render: (_, record) => (
|
|
|
- <div>
|
|
|
|
|
- {record.tagIds.map((item, idx) => (
|
|
|
|
|
- <Tag key={record.id + item.id} color={personTagColorMap[item]}>
|
|
|
|
|
- {record.tagName[idx]}
|
|
|
|
|
- </Tag>
|
|
|
|
|
|
|
+ <div className="zh-align-center zh-flex-wrap">
|
|
|
|
|
+ {record.tagIds.map(item => (
|
|
|
|
|
+ <span
|
|
|
|
|
+ key={record.id + item.id}
|
|
|
|
|
+ className="zh-circle-icon zh-mg-right-3"
|
|
|
|
|
+ style={{ backgroundColor: personTagColorMap[item] }}
|
|
|
|
|
+ />
|
|
|
))}
|
|
))}
|
|
|
<PersonLabel
|
|
<PersonLabel
|
|
|
dataId={record.id}
|
|
dataId={record.id}
|
|
|
tagIds={record.tagIds}
|
|
tagIds={record.tagIds}
|
|
|
tagType={TagTypeEnum.PERSONTAG}
|
|
tagType={TagTypeEnum.PERSONTAG}
|
|
|
tagColumn={TagDataTypeEnum.CONTACT}
|
|
tagColumn={TagDataTypeEnum.CONTACT}
|
|
|
- checkCallBack={() => initData()}>
|
|
|
|
|
- <IconPark type="add" fill="#868e96" size={14} />
|
|
|
|
|
|
|
+ checkCallBack={initData}
|
|
|
|
|
+ modeType={LabelModeType.column}>
|
|
|
|
|
+ <IconPark type="add" theme="filled" size="20" fill="#868e96" className="zh-pointer" />
|
|
|
</PersonLabel>
|
|
</PersonLabel>
|
|
|
</div>
|
|
</div>
|
|
|
),
|
|
),
|
|
@@ -366,6 +373,18 @@ const Contact = props => {
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
initData()
|
|
initData()
|
|
|
|
|
+ if (!personTags.length) {
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'customer/fetchTags',
|
|
|
|
|
+ payload: { tagType: TagTypeEnum.PERSONTAG, tagColumn: TagDataTypeEnum.CONTACT }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!teamTags.length) {
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'customer/fetchTags',
|
|
|
|
|
+ payload: { tagType: TagTypeEnum.TEAMTAG, tagColumn: TagDataTypeEnum.CONTACT }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
const handleSearch = value => {
|
|
const handleSearch = value => {
|
|
@@ -383,6 +402,27 @@ const Contact = props => {
|
|
|
initData({ province, city, area })
|
|
initData({ province, city, area })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 批量设置-确认触发
|
|
|
|
|
+ const tagsSettingConfirm = async clientIds => {
|
|
|
|
|
+ if (tagState.tagIds.length) {
|
|
|
|
|
+ await apiBatchLink({
|
|
|
|
|
+ tagIds: tagState.tagIds,
|
|
|
|
|
+ dataIds: clientIds,
|
|
|
|
|
+ dataType: TagDataTypeEnum.CONTACT,
|
|
|
|
|
+ tagType: TagTypeEnum.PERSONTAG
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ if (tagState.tagCooperationIds.length) {
|
|
|
|
|
+ await apiBatchLink({
|
|
|
|
|
+ tagIds: tagState.tagIds,
|
|
|
|
|
+ dataIds: clientIds,
|
|
|
|
|
+ dataType: TagDataTypeEnum.CONTACT,
|
|
|
|
|
+ tagType: TagTypeEnum.PERSONTAG
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ initData()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<ProTable
|
|
<ProTable
|
|
|
rowKey={record => record.id}
|
|
rowKey={record => record.id}
|
|
@@ -405,7 +445,64 @@ const Contact = props => {
|
|
|
onChange: (page, size) => initData({ page, size })
|
|
onChange: (page, size) => initData({ page, size })
|
|
|
}}
|
|
}}
|
|
|
tableAlertRender={({ selectedRowKeys }) => {
|
|
tableAlertRender={({ selectedRowKeys }) => {
|
|
|
- return <div>2222</div>
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="zh-flex-row">
|
|
|
|
|
+ <div className="zh-mg-right-5">
|
|
|
|
|
+ <PersonLabel
|
|
|
|
|
+ tagType={TagTypeEnum.PERSONTAG}
|
|
|
|
|
+ tagColumn={TagDataTypeEnum.CONTACT}
|
|
|
|
|
+ checkCallBack={toolbarOptionsChange}
|
|
|
|
|
+ modeType={LabelModeType.toolbar}>
|
|
|
|
|
+ {tagState.tagIds.length ? (
|
|
|
|
|
+ <Button>
|
|
|
|
|
+ {tagState.tagIds.map(item => (
|
|
|
|
|
+ <span
|
|
|
|
|
+ key={item}
|
|
|
|
|
+ className="zh-circle-icon zh-mg-right-3"
|
|
|
|
|
+ style={{ backgroundColor: personTagColorMap[item] }}
|
|
|
|
|
+ />
|
|
|
|
|
+ ))}
|
|
|
|
|
+ <IconPark type="down" />
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <Button>
|
|
|
|
|
+ 个人标签
|
|
|
|
|
+ <IconPark type="down" />
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </PersonLabel>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="zh-mg-right-5">
|
|
|
|
|
+ <PersonLabel
|
|
|
|
|
+ tagType={TagTypeEnum.TEAMTAG}
|
|
|
|
|
+ tagColumn={TagDataTypeEnum.CONTACT}
|
|
|
|
|
+ checkCallBack={toolbarOptionsChange}
|
|
|
|
|
+ modeType={LabelModeType.toolbar}>
|
|
|
|
|
+ {tagState.tagCooperationIds.length ? (
|
|
|
|
|
+ <Button>
|
|
|
|
|
+ {tagState.tagCooperationIds.map(item => (
|
|
|
|
|
+ <span
|
|
|
|
|
+ key={item}
|
|
|
|
|
+ className="zh-square-icon zh-mg-right-3"
|
|
|
|
|
+ style={{ backgroundColor: teamTagColorMap[item] }}
|
|
|
|
|
+ />
|
|
|
|
|
+ ))}
|
|
|
|
|
+ <IconPark type="down" />
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <Button>
|
|
|
|
|
+ 协作标签
|
|
|
|
|
+ <IconPark type="down" />
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </PersonLabel>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Button onClick={() => tagsSettingConfirm(selectedRowKeys)}>
|
|
|
|
|
+ <IconPark type="check" size={14} />
|
|
|
|
|
+ 确认
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
}}
|
|
}}
|
|
|
rowSelection={{
|
|
rowSelection={{
|
|
|
onChange: hanleRowSelectChange,
|
|
onChange: hanleRowSelectChange,
|
|
@@ -439,5 +536,7 @@ const Contact = props => {
|
|
|
|
|
|
|
|
export default connect(({ customer }) => ({
|
|
export default connect(({ customer }) => ({
|
|
|
personTagColorMap: customer.personTagColorMap,
|
|
personTagColorMap: customer.personTagColorMap,
|
|
|
- teamTagColorMap: customer.teamTagColorMap
|
|
|
|
|
|
|
+ personTags: customer.personTags,
|
|
|
|
|
+ teamTagColorMap: customer.teamTagColorMap,
|
|
|
|
|
+ teamTags: customer.teamTags
|
|
|
}))(Contact)
|
|
}))(Contact)
|