|
@@ -1,6 +1,6 @@
|
|
|
|
|
|
import HocError from '@/Hoc/HocError'
|
|
|
-import { Col, Modal, Row, Input, message, Space, Tabs } from 'antd'
|
|
|
+import { Col, Modal, Row, Input, message, Space, Tabs, Button } from 'antd'
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
|
import { columnsMp } from './tableConfig'
|
|
|
import { useAjax } from '@/Hook/useAjax'
|
|
@@ -8,13 +8,21 @@ import { getAdAccountListApi, GetAdAccountParams, putAdAccountApi } from '@/serv
|
|
|
import style from './index.less'
|
|
|
import TableData from '../components/TableData'
|
|
|
import GroupLeft from './groupLeft'
|
|
|
-import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
|
|
|
+import { MenuFoldOutlined, MenuUnfoldOutlined, SwapOutlined } from '@ant-design/icons'
|
|
|
import TeamMembers from '../components/teamMembers'
|
|
|
+import { getAdAccountAllOfMember } from '@/services/launchAdq/adq'
|
|
|
+import AddAccountToGroup from './addAccountToGroup'
|
|
|
+import { delAccountToGroupApi } from '@/services/launchAdq/subgroup'
|
|
|
+import { useModel } from 'umi'
|
|
|
+import ChangeRecord from './changeRecord'
|
|
|
+import CheckAccount from './checkAccount'
|
|
|
+import AppointPut from './appointPut'
|
|
|
|
|
|
/** 投放管理 */
|
|
|
const AdAuthorize: React.FC = () => {
|
|
|
|
|
|
/*************************/
|
|
|
+ const { groupListInit } = useModel('useLaunchAdq.useAdAuthorize')
|
|
|
const [queryForm, setQueryForm] = useState<GetAdAccountParams>({ pageNum: 1, pageSize: 20 })
|
|
|
const [remarkData, set_remarkData] = useState<{ visible: boolean, remark: string, data: any }>({
|
|
|
visible: false,
|
|
@@ -23,17 +31,50 @@ const AdAuthorize: React.FC = () => {
|
|
|
})
|
|
|
const [activeKey, setActiveKey] = useState<string>('1')
|
|
|
const [showLeft, setShowLeft] = useState<boolean>(false)
|
|
|
+ const [crShow, setCrShow] = useState<boolean>(false) // 变更记录控制
|
|
|
+ const [crData, setCrData] = useState<{ name: number, id: number } | null>(null)
|
|
|
+ const [checkAccShow, setCheckAccShow] = useState<boolean>(false)
|
|
|
+ const [data, setData] = useState<{
|
|
|
+ putResourceId?: number | undefined,
|
|
|
+ beginTime?: string | undefined,
|
|
|
+ gdtAccountId?: number,
|
|
|
+ accountIds?: string,
|
|
|
+ accountId?: string,
|
|
|
+ gdtAccountIds?: string,
|
|
|
+ advertiserId?: string,
|
|
|
+ accountName?: string,
|
|
|
+ account?: string,
|
|
|
+ accountPassword?: string,
|
|
|
+ quickAppAccountIds?: string
|
|
|
+ resourceNames?: string
|
|
|
+ } | undefined>(undefined)
|
|
|
+ const [selectAccData, setSelectAccData] = useState<any[]>([])
|
|
|
+ const [puShow, setPuShow] = useState<boolean>(false)
|
|
|
+ const [puData, setPuData] = useState<any>()
|
|
|
+
|
|
|
const putRemark = useAjax((adAccountId: any, remark: any) => putAdAccountApi(adAccountId, remark))
|
|
|
+ const delAccountToGroup = useAjax((params) => delAccountToGroupApi(params))
|
|
|
const getAdAccountList = useAjax((params) => getAdAccountListApi(params), { formatResult: true })
|
|
|
+ const allOfMember = useAjax(() => getAdAccountAllOfMember(), { formatResult: true })
|
|
|
/*************************/
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ groupListInit()
|
|
|
+ }, [])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
getList()
|
|
|
}, [queryForm])
|
|
|
|
|
|
- /** 获取账号列表 */
|
|
|
+ /** 获取账号列表 */
|
|
|
const getList = () => {
|
|
|
- getAdAccountList.run(queryForm)
|
|
|
+ let params = JSON.parse(JSON.stringify(queryForm))
|
|
|
+ if (params.accountIds) {
|
|
|
+ params.accountIds = params.accountIds.split(/[\,\,]/)
|
|
|
+ } else {
|
|
|
+ delete params?.accountIds
|
|
|
+ }
|
|
|
+ getAdAccountList.run(params)
|
|
|
}
|
|
|
|
|
|
const remark = () => {
|
|
@@ -51,18 +92,48 @@ const AdAuthorize: React.FC = () => {
|
|
|
set_remarkData({ ...remarkData, visible: true, data, remark: data.remark })
|
|
|
}, [remarkData])
|
|
|
|
|
|
- return <div style={{ height: '100%' }}>
|
|
|
+ /** 移除分组里账号 */
|
|
|
+ const del = (groupId: number, accountId: number) => {
|
|
|
+ delAccountToGroup.run({ currGroupId: groupId, accountIds: [accountId] }).then(res => {
|
|
|
+ message.success('移出成功')
|
|
|
+ getAdAccountList.refresh()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 切号 */
|
|
|
+ const checkAccount = (value: any[]) => {
|
|
|
+ let ids = value?.map((item: any) => item.id)
|
|
|
+ setData({ resourceNames: value?.map((item: any) => item.putResourceName).toString(), accountIds: value?.map((item: any) => item.accountId).toString(), gdtAccountIds: ids.toString(), putResourceId: undefined, beginTime: undefined })
|
|
|
+ setCheckAccShow(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 变更记录 */
|
|
|
+ const changeRecord = (name: number, id: number) => {
|
|
|
+ setCrData({ name, id })
|
|
|
+ setCrShow(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 指派投手 */
|
|
|
+ const putUserHandle = (data: any) => {
|
|
|
+ setPuData(data)
|
|
|
+ setPuShow(true)
|
|
|
+ }
|
|
|
|
|
|
+ return <div style={{ height: '100%' }}>
|
|
|
<Tabs
|
|
|
tabBarStyle={{ marginBottom: 1 }}
|
|
|
activeKey={activeKey}
|
|
|
type="card"
|
|
|
onChange={(activeKey) => {
|
|
|
+ let newQueryForm = JSON.parse(JSON.stringify(queryForm))
|
|
|
+ delete newQueryForm?.groupId
|
|
|
+ delete newQueryForm?.putUserId
|
|
|
if (activeKey !== 'contract') {
|
|
|
setActiveKey(activeKey)
|
|
|
} else {
|
|
|
setShowLeft(!showLeft)
|
|
|
}
|
|
|
+ setQueryForm(newQueryForm)
|
|
|
}}
|
|
|
>
|
|
|
<Tabs.TabPane tab='我的' key='1' />
|
|
@@ -71,36 +142,80 @@ const AdAuthorize: React.FC = () => {
|
|
|
</Tabs>
|
|
|
|
|
|
<div className={style.manage}>
|
|
|
- {!showLeft && activeKey === '1' && <GroupLeft onChange={(groupId) => setQueryForm({ ...queryForm, groupId })} value={queryForm?.groupId}/>}
|
|
|
- {!showLeft && activeKey === '2' && <TeamMembers onChange={(putUserId) => setQueryForm({ ...queryForm, putUserId })} value={queryForm?.putUserId}/>}
|
|
|
-
|
|
|
+ {!showLeft && activeKey === '1' && <GroupLeft onChange={(groupId) => setQueryForm({ ...queryForm, groupId, pageNum: 1 })} value={queryForm?.groupId} />}
|
|
|
+ {!showLeft && activeKey === '2' && <TeamMembers allOfMember={allOfMember} onChange={(putUserId) => setQueryForm({ ...queryForm, putUserId, pageNum: 1 })} value={queryForm?.putUserId} />}
|
|
|
+
|
|
|
<div className={style.manage__left} style={showLeft ? { width: '100%' } : { width: 'calc(100% - 200px)' }}>
|
|
|
<TableData
|
|
|
ajax={getAdAccountList}
|
|
|
dataSource={getAdAccountList?.data?.data?.records}
|
|
|
loading={getAdAccountList?.loading}
|
|
|
- columns={() => columnsMp(edit)}
|
|
|
+ columns={() => columnsMp(edit, del, checkAccount, changeRecord, putUserHandle, queryForm?.groupId, getAdAccountList)}
|
|
|
total={getAdAccountList?.data?.data?.total}
|
|
|
page={getAdAccountList?.data?.data?.current}
|
|
|
pageSize={getAdAccountList?.data?.data?.size}
|
|
|
size="small"
|
|
|
scroll={{ y: 600 }}
|
|
|
leftChild={<Space>
|
|
|
- {/* <Input placeholder="广告主ID" style={{ width: 150 }} allowClear onChange={(e) => {
|
|
|
- let value = e.target.value
|
|
|
- if (value) {
|
|
|
- let newArr = tableData?.filter(item => String(item.accountId).includes(value))
|
|
|
- setTableData(newArr)
|
|
|
+ <Input.TextArea
|
|
|
+ placeholder="广告账号, 多个以,隔开(id1,id2)"
|
|
|
+ allowClear
|
|
|
+ style={{ minWidth: 200 }}
|
|
|
+ rows={1}
|
|
|
+ value={queryForm?.accountIds}
|
|
|
+ onChange={(e) => {
|
|
|
+ setQueryForm({ ...queryForm, accountIds: e.target.value })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button onClick={getList} type='primary' loading={getAdAccountList.loading}>搜索</Button>
|
|
|
+ <AddAccountToGroup onChange={() => getAdAccountList.refresh()} />
|
|
|
+ {selectAccData?.length > 0 && <Button type="primary" ghost icon={<SwapOutlined />} onClick={() => { checkAccount(selectAccData) }}>批量切号</Button>}
|
|
|
+ </Space>}
|
|
|
+ rowSelection={{
|
|
|
+ selectedRowKeys: selectAccData?.map((item: any) => item.id?.toString()),
|
|
|
+ onSelect: (record: { id: number, mpName: string }, selected: boolean) => {
|
|
|
+ if (selected) {
|
|
|
+ selectAccData.push({ ...record })
|
|
|
+ setSelectAccData([...selectAccData])
|
|
|
} else {
|
|
|
- setTableData(getAdAccount?.data?.data)
|
|
|
+ let newSelectAccData = selectAccData.filter((item: { id: number }) => item.id !== record.id)
|
|
|
+ setSelectAccData([...newSelectAccData])
|
|
|
}
|
|
|
- }} /> */}
|
|
|
- {/* <Button onClick={getList} type='primary'>搜索</Button> */}
|
|
|
- </Space>}
|
|
|
+ },
|
|
|
+ onSelectAll: (selected: boolean, selectedRows: { id: number }[], changeRows: { id: number }[]) => {
|
|
|
+ if (selected) {
|
|
|
+ let newSelectAccData = [...selectAccData]
|
|
|
+ changeRows.forEach((item: { id: number }) => {
|
|
|
+ let index = newSelectAccData.findIndex((ite: { id: number }) => ite.id === item.id)
|
|
|
+ if (index === -1) {
|
|
|
+ newSelectAccData.push({ ...item })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setSelectAccData([...newSelectAccData])
|
|
|
+ } else {
|
|
|
+ let newSelectAccData = selectAccData.filter((item: { id: number }) => {
|
|
|
+ let index = changeRows.findIndex((ite: { id: number }) => ite.id === item.id)
|
|
|
+ if (index !== -1) {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setSelectAccData([...newSelectAccData])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }}
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ {/* 变更记录 */}
|
|
|
+ {crShow && <ChangeRecord visible={crShow} data={crData} onClose={() => { setCrShow(false); setCrData(null) }} />}
|
|
|
+ {/* 切号 */}
|
|
|
+ {checkAccShow && <CheckAccount value={data} visible={checkAccShow} onChange={() => { getList(); setCheckAccShow(false); setSelectAccData([]) }} onClose={() => { setCheckAccShow(false) }} />}
|
|
|
+ {/* 指派 */}
|
|
|
+ {puShow && <AppointPut value={puData} visible={puShow} onClose={() => { setPuShow(false) }} allOfMember={allOfMember} onChange={() => { setPuShow(false); getAdAccountList.refresh() }} />}
|
|
|
+
|
|
|
{remarkData.visible && <Modal
|
|
|
visible={remarkData.visible}
|
|
|
title='编辑账户'
|