astraGroupHourEle.tsx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import { useAjax } from '@/Hook/useAjax';
  2. import { getLocalCsgroupDayHourListApi } from '@/services/adqV3/monitorEWList';
  3. import { Modal, Statistic, Table, Typography } from 'antd';
  4. import React, { useEffect, useState } from 'react';
  5. import '../tencentAdPutIn/index.less';
  6. const { Text } = Typography;
  7. interface AstraGroupHourProps {
  8. localCsgroupName: string;
  9. data: {
  10. day: string;
  11. localCsgroupId: number;
  12. }
  13. }
  14. const AstraGroupHourEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, data }) => {
  15. /***************************************/
  16. const [visible, setVisible] = useState<boolean>(false);
  17. const getLocalCsgroupDayHourList = useAjax((params) => getLocalCsgroupDayHourListApi(params))
  18. /***************************************/
  19. useEffect(() => {
  20. if (visible) {
  21. getLocalCsgroupDayHourList.run(data)
  22. }
  23. }, [data, visible]);
  24. return <div>
  25. <a style={{ fontSize: 12 }} onClick={() => setVisible(true)}>小时数据</a>
  26. {visible && <Modal
  27. title={<strong>{data.day}_{localCsgroupName} 小时数据</strong>}
  28. open={visible}
  29. onCancel={() => setVisible(false)}
  30. footer={null}
  31. className='modalResetCss'
  32. width={800}
  33. >
  34. <Table
  35. dataSource={getLocalCsgroupDayHourList?.data}
  36. columns={[
  37. {
  38. title: '日期',
  39. dataIndex: 'day',
  40. key: 'day',
  41. width: 80,
  42. ellipsis: true,
  43. align: 'center',
  44. render(value) {
  45. return <span style={{ fontSize: 12 }}>{value}</span>
  46. },
  47. },
  48. {
  49. title: '小时',
  50. dataIndex: 'hour',
  51. key: 'hour',
  52. width: 80,
  53. ellipsis: true,
  54. align: 'center',
  55. render(value) {
  56. return <span style={{ fontSize: 12 }}>{value}</span>
  57. },
  58. },
  59. {
  60. title: '消耗',
  61. dataIndex: 'cost',
  62. key: 'cost',
  63. width: 80,
  64. ellipsis: true,
  65. align: 'right',
  66. render(value) {
  67. return <Statistic value={value || 0} />
  68. },
  69. },
  70. {
  71. title: '加粉次数(广告)',
  72. dataIndex: 'scanFollowCount',
  73. key: 'scanFollowCount',
  74. width: 80,
  75. ellipsis: true,
  76. align: 'right',
  77. render(value) {
  78. return <span style={{ fontSize: 12 }}>{value}</span>
  79. },
  80. },
  81. {
  82. title: '加粉人数(广告)',
  83. dataIndex: 'scanFollowUserCount',
  84. key: 'scanFollowUserCount',
  85. width: 80,
  86. ellipsis: true,
  87. align: 'right',
  88. render(value) {
  89. return <span style={{ fontSize: 12 }}>{value}</span>
  90. },
  91. },
  92. {
  93. title: '加粉人数',
  94. dataIndex: 'addUserCount',
  95. key: 'addUserCount',
  96. width: 80,
  97. ellipsis: true,
  98. align: 'right',
  99. render(value) {
  100. return <span style={{ fontSize: 12 }}>{value}</span>
  101. },
  102. },
  103. {
  104. title: '数据更新时间',
  105. dataIndex: 'dataTime',
  106. key: 'dataTime',
  107. width: 140,
  108. ellipsis: true,
  109. align: 'center',
  110. render(value) {
  111. return <span style={{ fontSize: 12 }}>{value}</span>
  112. },
  113. }
  114. ]}
  115. pagination={false}
  116. summary={pageData => {
  117. let totalCost = 0;
  118. let totalScanFollowCount = 0;
  119. let totalScanFollowUserCount = 0;
  120. let totalAddUserCount = 0;
  121. pageData.forEach(({ cost, scanFollowCount, scanFollowUserCount, addUserCount }) => {
  122. totalCost += cost;
  123. totalScanFollowCount += scanFollowCount;
  124. totalScanFollowUserCount += scanFollowUserCount;
  125. totalAddUserCount += addUserCount;
  126. });
  127. return (
  128. <Table.Summary fixed='top'>
  129. <Table.Summary.Row>
  130. <Table.Summary.Cell index={0} align="center"><Text strong>总计</Text></Table.Summary.Cell>
  131. <Table.Summary.Cell index={1} align="center">--</Table.Summary.Cell>
  132. <Table.Summary.Cell index={2} align="right">
  133. <Text strong>{totalCost}</Text>
  134. </Table.Summary.Cell>
  135. <Table.Summary.Cell index={3} align="right">
  136. <Text strong>{totalScanFollowCount}</Text>
  137. </Table.Summary.Cell>
  138. <Table.Summary.Cell index={4} align="right">
  139. <Text strong>{totalScanFollowUserCount}</Text>
  140. </Table.Summary.Cell>
  141. <Table.Summary.Cell index={5} align="right">
  142. <Text strong>{totalAddUserCount}</Text>
  143. </Table.Summary.Cell>
  144. <Table.Summary.Cell index={6} align="center">--</Table.Summary.Cell>
  145. </Table.Summary.Row>
  146. </Table.Summary>
  147. );
  148. }}
  149. sticky
  150. size='small'
  151. bordered
  152. rowKey={'id'}
  153. loading={getLocalCsgroupDayHourList.loading}
  154. scroll={{ x: 750 }}
  155. />
  156. </Modal>}
  157. </div>;
  158. };
  159. export default React.memo(AstraGroupHourEle);