shenwu 1 год назад
Родитель
Сommit
17e13e7475

+ 73 - 7
src/pages/launchSystemNew/account/index.tsx

@@ -1,6 +1,6 @@
 
 import HocError from '@/Hoc/HocError'
-import { Col, Modal, Row, Input, message, Space, Tabs, Button, Radio } from 'antd'
+import { Col, Modal, Row, Input, message, Space, Tabs, Button, Radio, Select } from 'antd'
 import React, { useCallback, useEffect, useState } from 'react'
 import { columnsMp } from './tableConfig'
 import { useAjax } from '@/Hook/useAjax'
@@ -11,7 +11,7 @@ import GroupLeft from './groupLeft'
 import QQAuth from './qqAuto'
 import { MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
 import TeamMembers from '../components/teamMembers'
-import { getAdAccountAllOfMember, getErpUserAll } from '@/services/launchAdq/adq'
+import { getAdAccountAllOfMember, getErpUserAll, getServiceProviderAll, putConfigServiceProvider } from '@/services/launchAdq/adq'
 import AddAccountToGroup from './addAccountToGroup'
 import { delAccountToGroupApi } from '@/services/launchAdq/subgroup'
 import { useModel } from 'umi'
@@ -36,6 +36,8 @@ const AdAuthorize: React.FC = () => {
     const [crShow, setCrShow] = useState<boolean>(false) // 变更记录控制
     const [crData, setCrData] = useState<{ name: number, id: number } | null>(null)
     const [checkAccShow, setCheckAccShow] = useState<boolean>(false)
+    const [openServer, setOpenServer] = useState<any[]>([])//配置服务商数据
+    const [serverName, setServerName] = useState<any>(null)//选择的服务商名称
     const [data, setData] = useState<{
         putResourceId?: number | undefined,
         beginTime?: string | undefined,
@@ -53,18 +55,20 @@ const AdAuthorize: React.FC = () => {
     const [selectAccData, setSelectAccData] = useState<any[]>([])
     const [puShow, setPuShow] = useState<boolean>(false)
     const [puData, setPuData] = useState<any[]>([])
-    const [switchType, setSwitchType] = useState<'account' | 'putUser'>('account')
-
+    const [switchType, setSwitchType] = useState<'account' | 'putUser' | 'setServer'>('account')
     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 })
     const erpUserALL = useAjax(() => getErpUserAll(), { formatResult: true })
+    const api_getServiceProviderAll = useAjax(() => getServiceProviderAll(), { formatResult: true })
+    const api_putConfigServiceProvider = useAjax((params) => putConfigServiceProvider(params), { formatResult: true })
     /*************************/
 
     useEffect(() => {
         groupListInit()
         !erpUserALL.data && erpUserALL.run()
+        !api_getServiceProviderAll.data && api_getServiceProviderAll.run()
     }, [])
 
     useEffect(() => {
@@ -123,7 +127,20 @@ const AdAuthorize: React.FC = () => {
         setPuData(data)
         setPuShow(true)
     }
-
+    // 批量配置服务商
+    const setServiceProviderName = (accountIds: any) => {
+        api_putConfigServiceProvider.run({ accountIds, serviceProviderName: serverName.label }).then(res => {
+            if (res.data) {
+                message.success("配置成功!")
+                setOpenServer([]);
+                setServerName(null)
+                getAdAccountList.refresh()
+            } else {
+                message.error("配置失败!")
+            }
+        })
+    }
+    // 
     return <div style={{ height: '100%' }}>
         <Tabs
             tabBarStyle={{ marginBottom: 1 }}
@@ -156,7 +173,7 @@ const AdAuthorize: React.FC = () => {
                     ajax={getAdAccountList}
                     dataSource={getAdAccountList?.data?.data?.records}
                     loading={getAdAccountList?.loading}
-                    columns={() => columnsMp(edit, del, checkAccount, changeRecord, putUserHandle, activeKey, userInfo?.userId?.toString(), queryForm?.groupId, getAdAccountList)}
+                    columns={() => columnsMp(edit, setOpenServer, del, checkAccount, changeRecord, putUserHandle, activeKey, userInfo?.userId?.toString(), queryForm?.groupId, getAdAccountList)}
                     total={getAdAccountList?.data?.data?.total}
                     page={getAdAccountList?.data?.data?.current}
                     pageSize={getAdAccountList?.data?.data?.size}
@@ -166,6 +183,7 @@ const AdAuthorize: React.FC = () => {
                         <Radio.Group value={switchType} onChange={(e) => { setSwitchType(e.target.value); setSelectAccData([]) }}>
                             <Radio.Button value="account">批量切号</Radio.Button>
                             <Radio.Button value="putUser">批量指派投放助理</Radio.Button>
+                            <Radio.Button value="setServer">批量配置服务商</Radio.Button>
                         </Radio.Group>
                         <Input.TextArea
                             placeholder="多个广告账号以,隔开(id1,id2)"
@@ -182,7 +200,9 @@ const AdAuthorize: React.FC = () => {
                         <Button type='primary' onClick={() => setVisible(true)}><PlusOutlined />广告账号授权</Button>
                         {switchType === 'account' ?
                             (selectAccData?.length > 0 && <Button type="primary" ghost icon={<SwapOutlined />} onClick={() => { checkAccount(selectAccData) }}>批量切号</Button>) :
-                            (selectAccData?.length > 0 && <Button type="primary" ghost icon={<SwapOutlined />} onClick={() => { putUserHandle(selectAccData) }}>批量指派投放助理</Button>)}
+                            switchType === 'putUser' ? (selectAccData?.length > 0 && <Button type="primary" ghost icon={<SwapOutlined />} onClick={() => { putUserHandle(selectAccData) }}>批量指派投放助理</Button>) :
+                                selectAccData?.length > 0 && <Button type="primary" ghost icon={<SwapOutlined />} onClick={() => { setOpenServer(selectAccData) }}>批量配置服务商</Button>
+                        }
                     </Space>}
                     rowSelection={{
                         selectedRowKeys: selectAccData?.map((item: any) => item.id?.toString()),
@@ -229,6 +249,52 @@ const AdAuthorize: React.FC = () => {
                 />
             </div>
         </div>
+        {/* 批量设置服务商 */}
+        {openServer.length > 0 && <Modal
+            title="配置服务商"
+            onOk={() => setServiceProviderName(openServer?.map(item => item.accountId))}
+            onCancel={() => { setOpenServer([]); setServerName(null) }}
+            visible={openServer.length > 0}
+            confirmLoading={api_putConfigServiceProvider.loading}
+        >
+            <Row gutter={[20, 20]}>
+                <Col span={24}>
+                    <Row>
+                        <Col span={3}><b>广告主:</b></Col>
+                        <Col span={21}>
+                            {openServer.map((item, index) => {
+                                return index === openServer.length - 1 ? item.accountId : item.accountId + ','
+                            })}
+                        </Col>
+                    </Row>
+                </Col>
+                <Col span={24}>
+                    <Row>
+                        <Col span={3}><b>服务商:</b></Col>
+                        <Col span={21}>
+                            <Select
+                                style={{ minWidth: 200 }}
+                                showSearch
+                                allowClear
+                                placeholder="请选择服务商"
+                                optionFilterProp="children"
+                                onChange={(value: any, option: any) => {
+                                    setServerName(option)
+                                }}
+                                filterOption={(input, option: any) =>
+                                    (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
+                                }
+                                value={serverName}
+                                options={api_getServiceProviderAll?.data?.data?.map((item: { id: any, serviceProviderName: any }) => {
+                                    return { value: item.id, label: item.serviceProviderName }
+                                })}
+                            />
+                        </Col>
+                    </Row>
+                </Col>
+            </Row>
+
+        </Modal>}
         {/* 广告授权 */}
         {visible && <QQAuth qqVisible={visible} callBack={() => setVisible(false)} />}
         {/* 变更记录 */}

+ 7 - 4
src/pages/launchSystemNew/account/tableConfig.tsx

@@ -1,10 +1,10 @@
 import { FundStatusEnum } from "@/services/launchAdq/enum"
-import { EditOutlined, FileSearchOutlined, SwapOutlined, UploadOutlined, UserSwitchOutlined } from "@ant-design/icons"
+import { EditOutlined, FileSearchOutlined, SettingOutlined, SwapOutlined, UploadOutlined, UserSwitchOutlined } from "@ant-design/icons"
 import { Badge, Button, Popconfirm, Space, Tooltip } from "antd"
 import React from "react"
 import DivideIntoGroups from "./divideIntoGroups"
 import './index.less'
-export function columnsMp(edit: (params: any) => void, del: (groupId: number, accountId: number) => void, checkAccount: (value: any[]) => void, changeRecord: (accountId: number, id: number) => void, putUserHandle: (data: any) => void, activeKey: string, userId: string | undefined, groupId?: number, getAdAccountList?: any): any {
+export function columnsMp(edit: (params: any) => void, setOpenServer: (data: any) => void, del: (groupId: number, accountId: number) => void, checkAccount: (value: any[]) => void, changeRecord: (accountId: number, id: number) => void, putUserHandle: (data: any) => void, activeKey: string, userId: string | undefined, groupId?: number, getAdAccountList?: any): any {
     return [
         {
             title: 'ID',
@@ -172,10 +172,13 @@ export function columnsMp(edit: (params: any) => void, del: (groupId: number, ac
             dataIndex: 'cz',
             key: 'cz',
             align: 'center',
-            width: 180,
+            width: 200,
             fixed: 'right',
             render: (a: any, b: any) => {
                 return <Space>
+                    <Tooltip title="配置服务商">
+                        <Button size="small" style={{ color: "#00bcd4" }} onClick={() => setOpenServer([b])} icon={<SettingOutlined />}></Button>
+                    </Tooltip>
                     <Tooltip title="备注">
                         <Button size="small" style={{ color: '#52c41a' }} onClick={() => edit(b)} icon={<EditOutlined />}></Button>
                     </Tooltip>
@@ -186,7 +189,7 @@ export function columnsMp(edit: (params: any) => void, del: (groupId: number, ac
                         <Button size="small" style={{ color: '#4d5aaf' }} onClick={() => changeRecord(b?.accountId, b?.id)} icon={<FileSearchOutlined />}></Button>
                     </Tooltip>
                     {activeKey === '1' && <>
-                        {userId === b?.putUserInfo?.userId?.toString() && <Tooltip title="指派投放助理">
+                        {userId == b?.putUserInfo?.userId?.toString() && <Tooltip title="指派投放助理">
                             <Button size="small" style={{ color: '#0eb83a' }} onClick={() => putUserHandle([b])} icon={<UserSwitchOutlined />}></Button>
                         </Tooltip>}
                         {!groupId && <DivideIntoGroups groupIds={b?.groupIds} getAdAccountList={getAdAccountList} accountId={b?.accountId} />}

+ 18 - 5
src/services/launchAdq/adq.ts

@@ -10,9 +10,9 @@ export async function getAdAccountAllOfMember() {
 /***
  * 无权限限制获取全部用户列表
  * 
- */ 
-export async function getErpUserAll(){
-  return request(api+`/erp/user/all`)
+ */
+export async function getErpUserAll() {
+  return request(api + `/erp/user/all`)
 }
 
 
@@ -340,7 +340,7 @@ export async function getLogListApi(data: { accountId?: number, adgroupId?: numb
 
 /**
  * 获取推广目标列表
- * */ 
+ * */
 export async function getPromotedObjectList(data: { accountId?: number, promotedObjectType?: string, promotedObjectName?: string, pageNum: number, pageSize: number }) {
   return request(api + `/adq/promotedObject/list`, {
     method: 'POST',
@@ -350,7 +350,7 @@ export async function getPromotedObjectList(data: { accountId?: number, promoted
 
 /**
  * 同步推广目标列表
- * */ 
+ * */
 
 export async function putPromotedObjectSync(data: any) {
   return request(api + `/adq/promotedObject/sync/all`, {
@@ -381,4 +381,17 @@ export async function putModifyCustomAudienceApi(data: { adAccountId: number, ad
     method: 'PUT',
     data
   });
+}
+/**获取服务商列表*/
+export async function getServiceProviderAll() {
+  return request(api + `/adq/serviceProvider/all`, {
+    method: 'GET',
+  });
+}
+/*配置服务商*/
+export async function putConfigServiceProvider(data: { accountIds: any[], serviceProviderName: string }) {
+  return request(api + `/adq/adAccount/configServiceProvider`, {
+    method: 'PUT',
+    data
+  });
 }