index.jsx 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import React, { Component, useState, useEffect } from 'react';
  2. import { Card, Row, Col, Statistic, Icon, Table } from 'antd';
  3. // import IndexEcharts from './components/indexEcharts';
  4. // import Swiper from './swiper/index';
  5. import moment from 'moment';
  6. import router from 'umi/router';
  7. import request from '@/utils/request';
  8. import apis from '@/services/apis';
  9. import TimeSelect from '../compents/TimeSelect';
  10. import BuildingSelect from '@/components/SelectButton/BuildSelect';
  11. import Navigate from '@/components/Navigate';
  12. // import Count from './components/Count';
  13. // import SourceRole from './components/SourceRole';
  14. // import UserSex from './components/UserSex';
  15. // import UserConversion from './components/UserConversion';
  16. // import BuildingStatistic from './BuildingStatistic';
  17. const DataReport = props => {
  18. const [data, setData] = useState({});
  19. const [time, setTime] = useState();
  20. const [buildingValue, setBuildingValue] = useState('');
  21. useEffect(() => {
  22. if (time) {
  23. getTableList({
  24. buildingId:buildingValue,
  25. startDate: moment(time[0]).format('YYYY-MM-DDT00:00:00.000') + 'Z',
  26. endDate: moment(time[1]).format('YYYY-MM-DDT23:59:59.999') + 'Z',
  27. });
  28. }
  29. }, [time,buildingValue]);
  30. const columns = [
  31. {
  32. title: '活动名称',
  33. dataIndex: 'title',
  34. key: 'title',
  35. // sorter: true,
  36. },
  37. {
  38. title: '访问人数',
  39. dataIndex: 'visitPersonNum',
  40. key: 'visitPersonNum',
  41. width:'25%',
  42. sorter: true,
  43. render: (text)=>text||0
  44. },
  45. {
  46. title: '访问次数',
  47. dataIndex: 'visitNum',
  48. key: 'visitNum',
  49. width:'25%',
  50. sorter: true,
  51. render: (text)=>text||0
  52. },
  53. {
  54. title: '报名人数',
  55. dataIndex: 'signNum',
  56. key: 'signNum',
  57. width:'25%',
  58. sorter: true,
  59. // render: (text)=>text||0
  60. render: (text, record) => (
  61. text? <Navigate onClick={()=>toAddVisitNum(record)}>{record.signNum}</Navigate>:0
  62. // <a style={{ color: '#66B3FF' }} onClick={toAddVisitNum(record)}><span>{record.visitNum}</span></a>
  63. ),
  64. },
  65. ];
  66. const toAddVisitNum = (record)=>{
  67. router.push({
  68. pathname: '/activity/SignupActivity/registrationRecord',
  69. query: {
  70. dynamicId:record.dynamicId
  71. },
  72. });
  73. }
  74. //排序
  75. const handleTableChange = (pagination, filters, sorter) => {
  76. console.log(pagination, filters, sorter);
  77. getTableList({
  78. buildingId:buildingValue,
  79. startDate: moment(time[0]).format('YYYY-MM-DDT00:00:00.000') + 'Z',
  80. endDate: moment(time[1]).format('YYYY-MM-DDT23:59:59.999') + 'Z',
  81. pageNum: pagination.current,
  82. pageSize: pagination.pageSize,
  83. sort: sorter.order,
  84. sortField: sorter.columnKey,
  85. });
  86. // const { formData } = this.state
  87. // this.setState({
  88. // formData: {
  89. // ...formData,
  90. // startDate: formData.startDate,
  91. // endDate: formData.endDate,
  92. // buildingId: formData.buildingId,
  93. // targetType: formData.targetType,
  94. // pageNum: pagination.current,
  95. // pageSize: pagination.pageSize,
  96. // sort: sorter.order,
  97. // colKey: sorter.columnKey
  98. // }
  99. // }, this.getTableList)
  100. };
  101. function getTableList(params) {
  102. request({
  103. ...apis.activityDataStatis.activityDetailTableData,
  104. params: {
  105. ...params,
  106. },
  107. })
  108. .then(data => {
  109. console.log(data);
  110. setData(data);
  111. // this.setState({ tableData: data.records, total: data.total });
  112. })
  113. .catch();
  114. }
  115. const onTimeChange = e => {
  116. setTime(e);
  117. };
  118. return (
  119. <Card
  120. title={<BuildingSelect value={buildingValue} onChange={e => setBuildingValue(e)} all />}
  121. headStyle={{ textAlign: 'left' }}
  122. extra={<TimeSelect onChange={onTimeChange}></TimeSelect>}
  123. >
  124. <Table
  125. columns={columns}
  126. dataSource={data?.records}
  127. key="dynamicId"
  128. pagination={{current:data?.current, pageSize: 10, total: data?.total }}
  129. onChange={handleTableChange}
  130. ></Table>
  131. </Card>
  132. );
  133. };
  134. export default DataReport;