import { useAjax } from '@/Hook/useAjax'; import { delPageCustomerGroupApi, getAdqLandingPageOfficialListApi, getCorpRelationAllApi, getCustomerServiceGroupListApi, getPageCustomerGroupListApi, GetPageCustomerGroupListProps } from '@/services/adqV3/global'; import { PlusOutlined, SearchOutlined } from '@ant-design/icons'; import { Button, Input, message, Popconfirm, Select, Table } from 'antd'; import React, { useEffect, useState } from 'react'; import AddPageTieUp from './addPageTieUp'; import { useDebounce } from 'ahooks'; /** * 落地页与客服组关系 * @returns */ const PageTieUp: React.FC<{ adAccountId?: number }> = ({ adAccountId }) => { /*******************************/ const [queryParamsNew, setQueryParamsNew] = useState({ pageNum: 1, pageSize: 50, adAccountId: 0 }) const [visible, setVisible] = useState(false) const [corpList, setCorpList] = useState<{ label: string, value: string }[]>([]) const [groupList, setGroupList] = useState<{ label: string, value: number }[]>([]) const [queryForm, setQueryForm] = useState<{ accountId?: number, pageName?: string, ownerUid?: number, pageSize: number, pageNum: number, isSqDownPage: boolean }>({ pageNum: 1, pageSize: 20, isSqDownPage: false }) const [pageName, setPageName] = useState(); const debouncedValue = useDebounce(pageName, { wait: 500 }); const getPageCustomerGroupList = useAjax((params) => getPageCustomerGroupListApi(params)) const delPageCustomerGroup = useAjax((params) => delPageCustomerGroupApi(params)) const getCorpRelationAll = useAjax((params) => getCorpRelationAllApi(params)) const getCustomerServiceGroupList = useAjax((params) => getCustomerServiceGroupListApi(params)) const listAjax = useAjax((params) => getAdqLandingPageOfficialListApi(params)) /*******************************/ // 落地页 useEffect(() => { if (adAccountId) { const params: any = { ...queryForm, // pageStatus: 'NORMAL', pageType: 'PAGE_TYPE_OFFICIAL', accountId: adAccountId, pageName: debouncedValue } delete params.isSqDownPage listAjax.run(params) } }, [adAccountId, queryForm, debouncedValue]) /** 客服组 */ useEffect(() => { if (adAccountId) { getCustomerServiceGroupList.run({ adAccountId, pageNum: 1, pageSize: 100, tencentCorpId: queryParamsNew?.tencentCorpId }).then(res => { setGroupList(res?.records?.map((item: { groupName: string; groupId: number; }) => ({ label: item.groupName, value: item.groupId }))) }).catch(() => setGroupList([])) } }, [adAccountId, queryParamsNew?.tencentCorpId]) /** 企业列表 */ useEffect(() => { if (adAccountId) { getCorpRelationAll.run({ adAccountId }).then(res => { setCorpList(res?.map((item: { corpName: string; tencentCorpId: string; }) => ({ label: item.corpName, value: item.tencentCorpId }))) }).catch(() => setCorpList([])) } }, [adAccountId]) /** 获取关系列表 */ useEffect(() => { if (adAccountId) { getPageCustomerGroupList.run({ ...queryParamsNew, adAccountId }) } }, [adAccountId, queryParamsNew]) /** * 删除 * @param id */ const handleDel = (id: number) => { delPageCustomerGroup.run(id).then((res) => { if (res) { message.success('删除成功') getPageCustomerGroupList.refresh() } }) } return <>
((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase()) } style={{ width: 200 }} allowClear value={queryParamsNew?.customerGroupId} loading={getCustomerServiceGroupList.loading} onChange={(e) => { setQueryParamsNew({ ...queryParamsNew, customerGroupId: e, pageNum: 1 }) }} options={groupList} /> setQueryParamsNew({ ...queryParamsNew, pageNum: 1, customerGroupName: e.target.value })} placeholder='客服组名称' />