|
|
@@ -8,6 +8,7 @@ import dayjs from 'dayjs';
|
|
|
import MindTags from '../mindTags';
|
|
|
import SelectBook from '../SelectBook';
|
|
|
import SelectChapter from '../SelectChapter';
|
|
|
+import { getCorpAllListApi } from '@/API/global';
|
|
|
|
|
|
interface NewFilterUserProps {
|
|
|
configType: BUSINES_SPLAN_API.ConfigTypeProps
|
|
|
@@ -32,15 +33,23 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
const platformKey = Form.useWatch('platformKey', form)
|
|
|
const lastBookNameList = Form.useWatch('lastBookNameList', form)
|
|
|
const isRepeat = Form.useWatch('isRepeat', form)
|
|
|
+ const isGroupRepeat = Form.useWatch('isGroupRepeat', form)
|
|
|
const [isSave, setIsSave] = useState<boolean>(false)
|
|
|
|
|
|
const addSiftPopulationConfig = useAjax((params) => addSiftPopulationConfigApi(params))
|
|
|
const updateSiftPopulationConfig = useAjax((params) => updateSiftPopulationConfigApi(params))
|
|
|
+ const getCorpAllList = useAjax((params) => getCorpAllListApi(params))
|
|
|
/***********************************/
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (isRepeat || isGroupRepeat)
|
|
|
+ getCorpAllList.run({})
|
|
|
+ }, [isRepeat, isGroupRepeat])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (value && Object.keys(value).length > 0) {
|
|
|
- const { beginTime, endTime, lastRechargeTimeMin, lastRechargeTimeMax, groupChatNames, groupChatBeginTime, groupChatEndTime, lastReadTimeMin, lastReadTimeMax, ...params } = value
|
|
|
+ console.log('value', value)
|
|
|
+ const { beginTime, endTime, lastRechargeTimeMin, lastRechargeTimeMax, groupChatNames, groupChatBeginTime, groupChatEndTime, lastReadTimeMin, lastReadTimeMax, groupNameList, groupRepeatRang, ...params } = value
|
|
|
if (beginTime) {
|
|
|
params.beginTime = dayjs(beginTime)
|
|
|
}
|
|
|
@@ -59,14 +68,21 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
if (groupChatNames?.length) {
|
|
|
params.groupChatNames = groupChatNames.join(',')
|
|
|
}
|
|
|
- const keys = Object.keys(params)
|
|
|
- if ((keys.includes('repeatRangType') && params?.repeatRangType !== null) ||
|
|
|
- (keys.includes('repeatOperateType') && params?.repeatOperateType !== null) ||
|
|
|
- (keys.includes('minCorpIdCount') && params?.minCorpIdCount !== null) ||
|
|
|
- (keys.includes('minCorpUserIdCount') && params?.minCorpUserIdCount !== null)
|
|
|
- ) {
|
|
|
+ if ((params?.repeatOperateType !== null)) {
|
|
|
+ if (params.repeatRang) {
|
|
|
+ params.repeatRang = Object.entries(params.repeatRang || {}).map(([corpId, corpName]: [string, string]) => `${corpId}&&${corpName}`)
|
|
|
+ }
|
|
|
params.isRepeat = true
|
|
|
}
|
|
|
+
|
|
|
+ if (params?.groupOperateType !== null) {
|
|
|
+ params.groupNameList = groupNameList.join(',')
|
|
|
+ params.isGroupRepeat = true
|
|
|
+ console.log('groupNameList', groupRepeatRang)
|
|
|
+ if (!!groupRepeatRang) {
|
|
|
+ params.groupRepeatRang = Object.entries(groupRepeatRang || {}).map(([corpId, corpName]: [string, string]) => `${corpId}&&${corpName}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
form.setFieldsValue(params)
|
|
|
}
|
|
|
}, [value])
|
|
|
@@ -74,8 +90,8 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
const handleOk = () => {
|
|
|
form.validateFields().then((values) => {
|
|
|
console.log(values)
|
|
|
- const { configName, isRepeat, ...configContent } = values
|
|
|
- if (configContent && Object.keys(configContent).length > 0 && Object.keys(configContent).some(key => configContent[key])) {
|
|
|
+ const { configName, isRepeat, repeatRang, isGroupRepeat, groupRepeatRang, groupNameList, ...configContent } = values
|
|
|
+ if (configContent && Object.keys(configContent).length > 0 && Object.keys(configContent).some(key => configContent[key] || configContent[key] === 0)) {
|
|
|
const {
|
|
|
beginTime, endTime, lastRechargeTime, lastReadTime, groupChatNames, groupChatTime, firstAddGroupTime,
|
|
|
lastAddGroupTime, lastExitTime,
|
|
|
@@ -117,6 +133,23 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
dta.lastExitTimeMin = dayjs(lastExitTime[0]).format('YYYY-MM-DD');
|
|
|
dta.lastExitTimeMax = dayjs(lastExitTime[1]).format('YYYY-MM-DD');
|
|
|
}
|
|
|
+ if (repeatRang?.length) {
|
|
|
+ dta.repeatRang = repeatRang.reduce((pre, cur) => {
|
|
|
+ const [corpId, corpName] = cur.split('&&')
|
|
|
+ pre[corpId] = corpName
|
|
|
+ return pre
|
|
|
+ }, {})
|
|
|
+ }
|
|
|
+ if (groupRepeatRang?.length) {
|
|
|
+ dta.groupRepeatRang = groupRepeatRang.reduce((pre, cur) => {
|
|
|
+ const [corpId, corpName] = cur.split('&&')
|
|
|
+ pre[corpId] = corpName
|
|
|
+ return pre
|
|
|
+ }, {})
|
|
|
+ }
|
|
|
+ if (groupNameList) {
|
|
|
+ dta.groupNameList = groupNameList.split(/[,,\n\s]+/ig).filter((item: any) => item)
|
|
|
+ }
|
|
|
|
|
|
// 直接新增
|
|
|
if (isBackVal && !isSave) {
|
|
|
@@ -168,6 +201,23 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ const validateAnyFieldRequired = async (_, value) => {
|
|
|
+ const values = form.getFieldsValue([
|
|
|
+ 'minCorpIdCount',
|
|
|
+ 'maxCorpIdCount',
|
|
|
+ 'minCorpUserIdCount',
|
|
|
+ 'maxCorpUserIdCount',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const hasValue = Object.values(values).some((v) => v !== undefined && v !== null && v !== '');
|
|
|
+
|
|
|
+ if (!hasValue) {
|
|
|
+ return Promise.reject(new Error('至少填写一个添加数值'));
|
|
|
+ }
|
|
|
+
|
|
|
+ return Promise.resolve();
|
|
|
+ };
|
|
|
+
|
|
|
const title = configType === 'GROUP_GROUP' ? '群人群包' : '用户人群包';
|
|
|
return <Modal
|
|
|
title={isBackVal ? <strong style={{ fontSize: 14 }}>
|
|
|
@@ -491,14 +541,18 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
</div>
|
|
|
{isRepeat && <>
|
|
|
<div className={style.newSpace}>
|
|
|
- <Form.Item name="repeatRangType" label={<strong>重粉范围</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请选择重粉范围' }]}>
|
|
|
+ <Form.Item name="repeatRang" label={<strong>重粉范围</strong>} style={{ marginBottom: 0 }}>
|
|
|
<Select
|
|
|
- placeholder='重粉范围'
|
|
|
+ showSearch
|
|
|
+ mode='multiple'
|
|
|
+ style={{ minWidth: 110 }}
|
|
|
+ maxTagCount={1}
|
|
|
+ placeholder="请选择主体"
|
|
|
+ filterOption={(input, option) =>
|
|
|
+ ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ }
|
|
|
allowClear
|
|
|
- options={[
|
|
|
- { value: 0, label: '任务内' },
|
|
|
- { value: 1, label: '集团内' }
|
|
|
- ]}
|
|
|
+ options={getCorpAllList?.data?.data?.map((item: any) => ({ label: item.corpName, value: item.corpId + '&&' + item.corpName }))}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</div>
|
|
|
@@ -515,26 +569,26 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
</Form.Item>
|
|
|
</div>
|
|
|
<div className={style.newSpace}>
|
|
|
- <Form.Item label={<strong>添加主体</strong>} style={{ marginBottom: 0 }}>
|
|
|
+ <Form.Item label={<strong>添加主体</strong>} style={{ marginBottom: 0 }} required>
|
|
|
<Space>
|
|
|
- <Form.Item name="minCorpIdCount" noStyle rules={[{ required: true, message: '请输入添加主体最小数' }]}>
|
|
|
+ <Form.Item name="minCorpIdCount" noStyle rules={[{ validator: validateAnyFieldRequired }]}>
|
|
|
<InputNumber placeholder="添加主体最小数" style={{ width: 200 }} />
|
|
|
</Form.Item>
|
|
|
<span>-</span>
|
|
|
- <Form.Item name="maxCorpIdCount" noStyle rules={[{ required: true, message: '请输入添加主体最大数' }]}>
|
|
|
+ <Form.Item name="maxCorpIdCount" noStyle>
|
|
|
<InputNumber placeholder="添加主体最大数" style={{ width: 200 }} />
|
|
|
</Form.Item>
|
|
|
</Space>
|
|
|
</Form.Item>
|
|
|
</div>
|
|
|
<div className={style.newSpace}>
|
|
|
- <Form.Item label={<strong>添加客服</strong>} style={{ marginBottom: 0 }}>
|
|
|
+ <Form.Item label={<strong>添加客服</strong>} style={{ marginBottom: 0 }} required>
|
|
|
<Space>
|
|
|
- <Form.Item name="minCorpUserIdCount" noStyle rules={[{ required: true, message: '请输入添加客服最小数' }]}>
|
|
|
+ <Form.Item name="minCorpUserIdCount" noStyle>
|
|
|
<InputNumber placeholder="添加客服最小数" style={{ width: 200 }} />
|
|
|
</Form.Item>
|
|
|
<span>-</span>
|
|
|
- <Form.Item name="maxCorpUserIdCount" noStyle rules={[{ required: true, message: '请输入添加客服最大数' }]}>
|
|
|
+ <Form.Item name="maxCorpUserIdCount" noStyle>
|
|
|
<InputNumber placeholder="添加客服最大数" style={{ width: 200 }} />
|
|
|
</Form.Item>
|
|
|
</Space>
|
|
|
@@ -640,6 +694,47 @@ const NewFilterUser: React.FC<NewFilterUserProps> = ({ bookCityList, configType
|
|
|
<Checkbox>是否查询所有公司</Checkbox>
|
|
|
</Form.Item>
|
|
|
</div>
|
|
|
+ <Divider orientation="left">群重名过滤</Divider>
|
|
|
+ <div className={style.newSpace}>
|
|
|
+ <Form.Item name="isGroupRepeat" label={<strong>群重名过滤筛选</strong>} style={{ marginBottom: 0 }} valuePropName='checked'>
|
|
|
+ <Checkbox>是否开启群重名过滤筛选</Checkbox>
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+ {isGroupRepeat && <>
|
|
|
+ <div className={style.newSpace}>
|
|
|
+ <Form.Item name="groupRepeatRang" label={<strong>群重名过滤范围</strong>} style={{ marginBottom: 0 }}>
|
|
|
+ <Select
|
|
|
+ showSearch
|
|
|
+ mode='multiple'
|
|
|
+ style={{ minWidth: 110 }}
|
|
|
+ maxTagCount={1}
|
|
|
+ placeholder="请选择主体"
|
|
|
+ filterOption={(input, option) =>
|
|
|
+ ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ }
|
|
|
+ allowClear
|
|
|
+ options={getCorpAllList?.data?.data?.map((item: any) => ({ label: item.corpName, value: item.corpId + '&&' + item.corpName }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+ <div className={style.newSpace}>
|
|
|
+ <Form.Item name="groupOperateType" label={<strong>群重名操作类型</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请选择群重名操作类型' }]}>
|
|
|
+ <Select
|
|
|
+ placeholder='群重名操作类型'
|
|
|
+ allowClear
|
|
|
+ options={[
|
|
|
+ { value: 0, label: '历史群' },
|
|
|
+ { value: 1, label: '当前所在群' }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+ <div className={style.newSpace}>
|
|
|
+ <Form.Item name="groupNameList" label={<strong>群名称列表</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请输入群名称列表' }]}>
|
|
|
+ <Input.TextArea placeholder="请输入群名称列表(多个,分割)" rows={2} />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+ </>}
|
|
|
</>}
|
|
|
</Form>
|
|
|
</Modal>
|