moveToTencent.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { setMaterialTencentApi } from "@/services/adqV3/cloudNew"
  3. import { getAccountAssetsGroupListAllApi } from "@/services/adqV3/global"
  4. import { getUserAccountListApi } from "@/services/launchAdq/adAuthorize"
  5. import { getGroupListApi } from "@/services/launchAdq/subgroup"
  6. import { Button, Col, Form, Input, message, Modal, Row, Select, Space, Table } from "antd"
  7. import React, { useEffect, useState } from "react"
  8. interface Props {
  9. data: any[]
  10. visible?: boolean
  11. onClose?: () => void
  12. onChange?: () => void
  13. }
  14. /**
  15. * 上传素材到腾讯
  16. * @param param0
  17. * @returns
  18. */
  19. const MoveToTencent: React.FC<Props> = ({ data, visible, onClose, onChange }) => {
  20. /***********************************/
  21. const [form] = Form.useForm()
  22. const [queryForm, setQueryForm] = useState<{ putInType?: string, accountIdList?: number[], adUnitTypeList?: string[], groupId?: number, remark?: string, sysGroupId?: number, pageNum: number, pageSize: number }>({ pageNum: 1, pageSize: 50 })
  23. const [selectedRows, setSelectedRows] = useState<any[]>([])
  24. const [loading, setLoading] = useState<boolean>(false)
  25. const getUserAccountList = useAjax((params) => getUserAccountListApi(params))
  26. const getGroupList = useAjax(() => getGroupListApi())
  27. const getAccountAssetsGroupListAll = useAjax((params) => getAccountAssetsGroupListAllApi(params))
  28. /***********************************/
  29. const onFinish = (data: any) => {
  30. let oldQueryFrom = JSON.parse(JSON.stringify(queryForm))
  31. let params = { ...oldQueryFrom, ...data, pageNum: 1 }
  32. if (params?.accountIdList) {
  33. params.accountIdList = params?.accountIdList.split(/[,,\n\s]+/ig).filter((item: any) => item)
  34. } else {
  35. delete params?.accountIdList
  36. }
  37. setQueryForm(params)
  38. }
  39. useEffect(() => {
  40. getGroupList.run()
  41. }, [])
  42. useEffect(() => {
  43. const { putInType, ...params } = queryForm
  44. getUserAccountList.run({ ...params, adUnitTypeList: putInType === 'NOVEL' ? ['NOVEL', 'NOVEL_IAA', 'SKIT_IAA'] : putInType === 'GAME' ? ['GAME', 'GAME_IAA'] : undefined })
  45. }, [queryForm])
  46. const handleOk = () => {
  47. console.log(data)
  48. if (selectedRows.length) {
  49. const typeDatalist = data.reduce((pre, cur) => {
  50. if (cur.materialType === 'image') {
  51. pre['image']?.length ? pre['image'].push(cur.id) : pre['image'] = [cur.id]
  52. } else if (cur.materialType === 'video') {
  53. pre['video']?.length ? pre['video'].push(cur.id) : pre['video'] = [cur.id]
  54. }
  55. return pre
  56. }, {})
  57. setLoading(true)
  58. const ajaxs = Object.keys(typeDatalist).map(key => {
  59. if (key == 'image') {
  60. return setMaterialTencentApi({ type: 'IMAGE', accountId: selectedRows[0].accountId, sysFileId: typeDatalist[key] })
  61. } else {
  62. return setMaterialTencentApi({ type: 'VIDEO', accountId: selectedRows[0].accountId, sysFileId: typeDatalist[key] })
  63. }
  64. })
  65. Promise.all(ajaxs).then(res => {
  66. setLoading(false)
  67. console.log('66666666', res)
  68. message.success('任务提交成功,结果可以到腾讯查看')
  69. }).catch(() => setLoading(false))
  70. console.log(typeDatalist)
  71. } else {
  72. message.error('请选择账号')
  73. }
  74. }
  75. return <Modal
  76. title={<strong>素材上传至腾讯</strong>}
  77. open={visible}
  78. onCancel={onClose}
  79. onOk={handleOk}
  80. className="modalResetCss"
  81. maskClosable={false}
  82. confirmLoading={loading}
  83. width={1000}
  84. >
  85. <Space direction="vertical" style={{ width: '100%' }}>
  86. <Form layout="inline" className='queryForm' name="basicSelectAcc" form={form} onFinish={onFinish}>
  87. <Row gutter={[0, 6]}>
  88. <Col><Form.Item name='putInType'>
  89. <Select
  90. style={{ width: 120 }}
  91. placeholder="账号类型"
  92. allowClear
  93. filterOption={(input: any, option: any) => {
  94. return option!.children?.toString().toLowerCase().includes(input.toLowerCase())
  95. }}
  96. >
  97. <Select.Option value="NOVEL">小说/短剧</Select.Option>
  98. <Select.Option value="GAME">游戏</Select.Option>
  99. </Select>
  100. </Form.Item></Col>
  101. <Col><Form.Item name='accountIdList'>
  102. <Input.TextArea
  103. rows={1}
  104. autoSize={{ minRows: 1, maxRows: 1 }}
  105. placeholder="账户(多个,,空格换行)"
  106. style={{ width: 180 }}
  107. allowClear
  108. />
  109. </Form.Item></Col>
  110. <Col><Form.Item name='remark'>
  111. <Input
  112. placeholder="备注"
  113. style={{ width: 120 }}
  114. allowClear
  115. />
  116. </Form.Item></Col>
  117. <Col><Form.Item name='sysGroupId'>
  118. <Select
  119. mode="multiple"
  120. style={{ minWidth: 180 }}
  121. placeholder="快捷选择媒体账户组"
  122. maxTagCount={1}
  123. allowClear
  124. filterOption={(input: any, option: any) => {
  125. return option!.children?.toString().toLowerCase().includes(input.toLowerCase())
  126. }}
  127. >
  128. {getGroupList?.data && getGroupList?.data?.map((item: any) => <Select.Option value={item.groupId} key={item.groupId}>{item.groupName}</Select.Option>)}
  129. </Select>
  130. </Form.Item></Col>
  131. <Col><Form.Item name='groupId'>
  132. <Select
  133. allowClear
  134. showSearch
  135. placeholder="账户资产共享组"
  136. filterOption={(input: any, option: any) => {
  137. return option!.children?.toString().toLowerCase().includes(input.toLowerCase())
  138. }}
  139. style={{ width: 145 }}
  140. >
  141. {getAccountAssetsGroupListAll?.data?.map((item: { accountId: any; authMainAccountId: number; id: number; accountGroupName: string }) => <Select.Option value={item.id} key={item.id}>{item.accountGroupName}({item.authMainAccountId})</Select.Option>)}
  142. </Select>
  143. </Form.Item></Col>
  144. <Col>
  145. <Space>
  146. <Button type="primary" htmlType="submit">搜索</Button>
  147. <Button onClick={() => form.resetFields()}>重置</Button>
  148. </Space>
  149. </Col>
  150. </Row>
  151. </Form>
  152. <Table
  153. size={'small'}
  154. bordered
  155. dataSource={getUserAccountList?.data?.records}
  156. rowKey={'accountId'}
  157. scroll={{ y: 220 }}
  158. pagination={{
  159. pageSize: getUserAccountList?.data?.size || 50,
  160. current: getUserAccountList?.data?.current || 1,
  161. showTotal: total => `总共 ${total} 账户`,
  162. total: getUserAccountList?.data?.total,
  163. showSizeChanger: true,
  164. showLessItems: true,
  165. defaultCurrent: 1,
  166. defaultPageSize: 50,//默认初始的每页条数
  167. onChange: (page, pageSize) => {
  168. setQueryForm({ ...queryForm, pageNum: page, pageSize })
  169. }
  170. }}
  171. loading={getUserAccountList.loading}
  172. columns={[
  173. {
  174. title: '账号',
  175. dataIndex: 'accountId',
  176. key: 'accountId',
  177. width: 80,
  178. align: 'center',
  179. render(value) {
  180. return <span style={{ fontSize: 12 }}>{value}</span>
  181. }
  182. },
  183. {
  184. title: '企业',
  185. dataIndex: 'corporationName',
  186. key: 'corporationName',
  187. width: 180,
  188. ellipsis: true,
  189. render(value) {
  190. return <span style={{ fontSize: 12 }}>{value}</span>
  191. }
  192. },
  193. {
  194. title: '企业标识',
  195. dataIndex: 'corporationLicence',
  196. key: 'corporationLicence',
  197. width: 150,
  198. ellipsis: true,
  199. render(value) {
  200. return <span style={{ fontSize: 12 }}>{value}</span>
  201. }
  202. },
  203. {
  204. title: '业务单元ID',
  205. dataIndex: 'adUnitAccountId',
  206. key: 'adUnitAccountId',
  207. width: 90,
  208. align: 'center',
  209. render(value) {
  210. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  211. }
  212. },
  213. {
  214. title: '备注',
  215. dataIndex: 'remark',
  216. key: 'remark',
  217. ellipsis: true,
  218. render(value) {
  219. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  220. }
  221. },
  222. ]}
  223. rowSelection={{
  224. selectedRowKeys: selectedRows.map(item => item.accountId),
  225. type: 'radio',
  226. onChange(_, selectedRows) {
  227. setSelectedRows(selectedRows)
  228. },
  229. }}
  230. />
  231. </Space>
  232. </Modal>
  233. }
  234. export default React.memo(MoveToTencent)