index.tsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import HocError from '@/Hoc/HocError'
  2. import { Col, Modal, Row, Input, message, Space, Tabs } from 'antd'
  3. import React, { useCallback, useEffect, useState } from 'react'
  4. import { columnsMp } from './tableConfig'
  5. import { useAjax } from '@/Hook/useAjax'
  6. import { getAdAccountListApi, GetAdAccountParams, putAdAccountApi } from '@/services/launchAdq/adAuthorize'
  7. import style from './index.less'
  8. import TableData from '../components/TableData'
  9. import GroupLeft from './groupLeft'
  10. import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
  11. /** 投放管理 */
  12. const AdAuthorize: React.FC = () => {
  13. /*************************/
  14. const [queryForm, setQueryForm] = useState<GetAdAccountParams>({ pageNum: 1, pageSize: 20 })
  15. const [remarkData, set_remarkData] = useState<{ visible: boolean, remark: string, data: any }>({
  16. visible: false,
  17. remark: '',
  18. data: null
  19. })
  20. const [activeKey, setActiveKey] = useState<string>('1')
  21. const [showLeft, setShowLeft] = useState<boolean>(false)
  22. const putRemark = useAjax((adAccountId: any, remark: any) => putAdAccountApi(adAccountId, remark))
  23. const getAdAccountList = useAjax((params) => getAdAccountListApi(params), { formatResult: true })
  24. /*************************/
  25. useEffect(() => {
  26. getList()
  27. }, [queryForm])
  28. /** 获取账号列表 */
  29. const getList = () => {
  30. getAdAccountList.run(queryForm)
  31. }
  32. const remark = () => {
  33. if (remarkData.remark && remarkData.data) {
  34. putRemark.run(remarkData.data.id, remarkData.remark).then(res => {
  35. set_remarkData({ ...remarkData, visible: false, remark: '', data: null })
  36. getList()
  37. })
  38. } else {
  39. message.error('请输入备注!')
  40. }
  41. }
  42. const edit = useCallback((data) => {
  43. set_remarkData({ ...remarkData, visible: true, data, remark: data.remark })
  44. }, [remarkData])
  45. return <div style={{ height: '100%' }}>
  46. <Tabs
  47. tabBarStyle={{ marginBottom: 1 }}
  48. activeKey={activeKey}
  49. type="card"
  50. onChange={(activeKey) => {
  51. if (activeKey !== 'contract') {
  52. setActiveKey(activeKey)
  53. } else {
  54. setShowLeft(!showLeft)
  55. }
  56. }}
  57. >
  58. <Tabs.TabPane tab='我的' key='1' />
  59. <Tabs.TabPane tab='组员' key='2' />
  60. <Tabs.TabPane tab={showLeft ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />} key='contract' />
  61. </Tabs>
  62. <div className={style.manage}>
  63. {!showLeft && activeKey === '1' && <GroupLeft onChange={(groupId) => setQueryForm({ ...queryForm, groupId })}/>}
  64. <div className={style.manage__left} style={showLeft ? { width: '100%' } : { width: 'calc(100% - 200px)' }}>
  65. <TableData
  66. ajax={getAdAccountList}
  67. dataSource={getAdAccountList?.data?.data?.records}
  68. loading={getAdAccountList?.loading}
  69. columns={() => columnsMp(edit)}
  70. total={getAdAccountList?.data?.data?.total}
  71. page={getAdAccountList?.data?.data?.current}
  72. pageSize={getAdAccountList?.data?.data?.size}
  73. size="small"
  74. scroll={{ y: 600 }}
  75. leftChild={<Space>
  76. {/* <Input placeholder="广告主ID" style={{ width: 150 }} allowClear onChange={(e) => {
  77. let value = e.target.value
  78. if (value) {
  79. let newArr = tableData?.filter(item => String(item.accountId).includes(value))
  80. setTableData(newArr)
  81. } else {
  82. setTableData(getAdAccount?.data?.data)
  83. }
  84. }} /> */}
  85. {/* <Button onClick={getList} type='primary'>搜索</Button> */}
  86. </Space>}
  87. />
  88. </div>
  89. </div>
  90. {remarkData.visible && <Modal
  91. visible={remarkData.visible}
  92. title='编辑账户'
  93. onCancel={() => { set_remarkData({ ...remarkData, visible: false, data: null }) }}
  94. onOk={remark}
  95. >
  96. <Row gutter={[20, 20]}>
  97. <Col span={24} className={style.boxCol}><strong>广告主ID:</strong><span>{remarkData?.data.accountId}</span></Col>
  98. <Col span={24} className={style.boxCol}><strong>类型:</strong><span>{remarkData?.data.sourceType === 0 ? '微信' : 'QQ'}</span></Col>
  99. <Col span={24} className={style.boxCol}><strong>公众号信息:</strong><span>{remarkData?.data.wechatAccountName || '无'}</span></Col>
  100. <Col span={24} className={style.boxCol}><strong>企业名称:</strong><span>{remarkData?.data.corporationName || '无'}</span></Col>
  101. <Col span={24} className={style.boxCol}><strong>服务商ID列表:</strong><span>{remarkData?.data.agencyIdList ? remarkData.data.agencyIdList?.join() : '无'}</span></Col>
  102. <Col span={24} className={style.boxCol}><strong>行业ID:</strong><span>{remarkData?.data.systemIndustryId || '无'}</span></Col>
  103. <Col span={24} className={style.boxCol}><strong>授权状态:</strong><span>{remarkData?.data.authStatus || '无'}</span></Col>
  104. <Col span={24} className={style.boxCol}><strong>日限额(分):</strong><span>{remarkData?.data.dailyBudget || '无'}</span></Col>
  105. <Col span={24} className={style.boxCol}><strong>授权时间:</strong><span>{remarkData?.data.createTime || '无'}</span></Col>
  106. <Col span={24} className={style.boxCol}><strong>备注:</strong><span><Input.TextArea rows={5} maxLength={200} value={remarkData.remark} onChange={(e) => {
  107. let value = e.target.value
  108. set_remarkData({ ...remarkData, remark: value })
  109. }} /></span></Col>
  110. </Row>
  111. </Modal>}
  112. </div>
  113. }
  114. export default HocError(AdAuthorize)