astraGroupIndexEle.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import { useAjax } from '@/Hook/useAjax';
  2. import { getLocalCsgroupDayIndexListApi } from '@/services/adqV3/monitorEWList';
  3. import { Modal, Statistic, Table } from 'antd';
  4. import React, { useEffect, useState } from 'react';
  5. import '../tencentAdPutIn/index.less';
  6. interface AstraGroupHourProps {
  7. localCsgroupName: string;
  8. data: {
  9. day: string;
  10. localCsgroupId: number;
  11. }
  12. }
  13. const AstraGroupIndexEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, data }) => {
  14. /***************************************/
  15. const [visible, setVisible] = useState<boolean>(false);
  16. const [queryParamsNew, setQueryParamsNew] = useState<{ pageNum: number, pageSize: number }>({ pageNum: 1, pageSize: 20 });
  17. const getLocalCsgroupDayIndexList = useAjax((params) => getLocalCsgroupDayIndexListApi(params))
  18. /***************************************/
  19. useEffect(() => {
  20. if (visible) {
  21. getLocalCsgroupDayIndexList.run({ ...data, ...queryParamsNew })
  22. }
  23. }, [data, visible, queryParamsNew]);
  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={1000}
  33. >
  34. <Table
  35. dataSource={getLocalCsgroupDayIndexList?.data?.records}
  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: 'index',
  51. key: 'index',
  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. sorter: 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. sorter: 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. sorter: 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. sorter: true,
  98. align: 'right',
  99. render(value) {
  100. return <span style={{ fontSize: 12 }}>{value}</span>
  101. },
  102. },
  103. {
  104. title: '开始时间',
  105. dataIndex: 'beginTime',
  106. key: 'beginTime',
  107. width: 140,
  108. ellipsis: true,
  109. align: 'center',
  110. render(value) {
  111. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  112. },
  113. },
  114. {
  115. title: '数据更新时间',
  116. dataIndex: 'dataTime',
  117. key: 'dataTime',
  118. width: 140,
  119. ellipsis: true,
  120. align: 'center',
  121. render(value) {
  122. return <span style={{ fontSize: 12 }}>{value}</span>
  123. },
  124. }
  125. ]}
  126. size='small'
  127. bordered
  128. rowKey={'id'}
  129. loading={getLocalCsgroupDayIndexList.loading}
  130. scroll={{ x: 950 }}
  131. pagination={{
  132. total: getLocalCsgroupDayIndexList.data?.total,
  133. defaultPageSize: 20,
  134. current: queryParamsNew.pageNum,
  135. pageSize: queryParamsNew.pageSize,
  136. }}
  137. onChange={(pagination, _, sorter: any) => {
  138. const { current, pageSize } = pagination
  139. const newQueryFormNew = JSON.parse(JSON.stringify(queryParamsNew))
  140. if (sorter && sorter?.order) {
  141. newQueryFormNew['sortAsc'] = sorter?.order === 'ascend' ? true : false
  142. newQueryFormNew['sortFiled'] = sorter?.field
  143. } else {
  144. delete newQueryFormNew['sortAsc']
  145. delete newQueryFormNew['sortFiled']
  146. }
  147. newQueryFormNew.pageNum = current || newQueryFormNew.pageNum
  148. newQueryFormNew.pageSize = pageSize || newQueryFormNew.pageSize
  149. setQueryParamsNew({ ...newQueryFormNew })
  150. }}
  151. />
  152. </Modal>}
  153. </div>;
  154. };
  155. export default React.memo(AstraGroupIndexEle);