|
|
@@ -1,5 +1,5 @@
|
|
|
import { Button, Checkbox, Popover, Input, message, Spin } from 'antd'
|
|
|
-import React, { useState, useRef, useEffect } from 'react'
|
|
|
+import React, { useState, useRef, useEffect, useMemo } from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
import styles from './index.scss'
|
|
|
import { apiConnOrDelTag, apiUpdateTag } from '@/services/customer'
|
|
|
@@ -55,14 +55,27 @@ const PersonLabel = props => {
|
|
|
tagColumn,
|
|
|
modeType = LabelModeType.column,
|
|
|
checkCallBack,
|
|
|
- contactPersonTags,
|
|
|
- companyPersonTags,
|
|
|
dispatch
|
|
|
} = props
|
|
|
const [dropdownType, setDropdownType] = useState(DropdownTypeEnum.check)
|
|
|
-
|
|
|
+ const tags = useMemo(() => {
|
|
|
+ if (tagColumn === TagDataTypeEnum.CONTACT) {
|
|
|
+ // 联系人
|
|
|
+ if (tagType === TagTypeEnum.PERSONTAG) {
|
|
|
+ return props.contactPersonTags
|
|
|
+ }
|
|
|
+ return props.contactTeamTags
|
|
|
+ }
|
|
|
+ if (tagColumn === TagDataTypeEnum.COMPANY) {
|
|
|
+ // 客户
|
|
|
+ if (tagType === TagTypeEnum.PERSONTAG) {
|
|
|
+ return props.companyPersonTags
|
|
|
+ }
|
|
|
+ return props.companyTeamTags
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ }, [tagType, tagColumn])
|
|
|
const [checkedIds, setCheckedIds] = useState([])
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
if (modeType === LabelModeType.column && tagIds.length) {
|
|
|
setCheckedIds(tagIds)
|
|
|
@@ -97,7 +110,7 @@ const PersonLabel = props => {
|
|
|
checkedIds={checkedIds}
|
|
|
setCheckedIds={setCheckedIds}
|
|
|
dataId={dataId}
|
|
|
- personTags={tagColumn === TagDataTypeEnum.CONTACT ? contactPersonTags : companyPersonTags}
|
|
|
+ tags={tags}
|
|
|
menuType={dropdownType}
|
|
|
tagType={tagType}
|
|
|
tagColumn={tagColumn}
|
|
|
@@ -143,7 +156,7 @@ const DropDownMenu = props => {
|
|
|
menuType,
|
|
|
tagType,
|
|
|
tagColumn,
|
|
|
- personTags,
|
|
|
+ tags,
|
|
|
modeType,
|
|
|
checkCallBack,
|
|
|
initCallBack
|
|
|
@@ -207,7 +220,7 @@ const DropDownMenu = props => {
|
|
|
return (
|
|
|
<ul className={styles.labelContent}>
|
|
|
{menuType === DropdownTypeEnum.check
|
|
|
- ? personTags.map((item, idx) => (
|
|
|
+ ? tags.map((item, idx) => (
|
|
|
<li key={item.id} className={styles.menuItem}>
|
|
|
<div className={styles.labelText}>
|
|
|
<div
|
|
|
@@ -229,7 +242,7 @@ const DropDownMenu = props => {
|
|
|
))
|
|
|
: null}
|
|
|
{menuType === DropdownTypeEnum.edit
|
|
|
- ? personTags.map((item, idx) => (
|
|
|
+ ? tags.map((item, idx) => (
|
|
|
<Spin
|
|
|
key={item.id}
|
|
|
spinning={item.id === activeState.id ? activeState.loading : false}
|
|
|
@@ -271,5 +284,7 @@ const DropDownMenu = props => {
|
|
|
|
|
|
export default connect(({ contact, company }) => ({
|
|
|
contactPersonTags: contact.personTags,
|
|
|
- companyPersonTags: company.personTags
|
|
|
+ contactTeamTags: contact.teamTags,
|
|
|
+ companyPersonTags: company.personTags,
|
|
|
+ companyTeamTags: company.teamTags
|
|
|
}))(PersonLabel)
|