addRegistNum.jsx 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. import React, { Component, useState, useEffect } from 'react';
  2. import {
  3. Form,
  4. Icon,
  5. Input,
  6. Button,
  7. DatePicker,
  8. Select,
  9. Card,
  10. Row,
  11. Col,
  12. Pagination,
  13. Alert,
  14. Table,
  15. Avatar,
  16. Radio,
  17. Modal,
  18. Descriptions,
  19. } from 'antd';
  20. import moment from 'moment';
  21. import request from '../../../utils/request';
  22. import apis from '../../../services/apis';
  23. import router from 'umi/router';
  24. import AuthButton from '@/components/AuthButton';
  25. import BuildingSelect from '@/components/SelectButton/BuildSelect';
  26. import WxDictSelect from '@/components/SelectButton/WxDictSelect';
  27. import Prompt from 'umi/prompt';
  28. const { RangePicker } = DatePicker;
  29. const { Option } = Select;
  30. const formItemLayout = {
  31. labelCol: { span: 10 },
  32. wrapperCol: { span: 14 },
  33. };
  34. let daterange = [];
  35. let tableTitle = ['类型'];
  36. let columns = [
  37. {
  38. title: '姓名',
  39. dataIndex: 'nickName',
  40. key: 'nickName',
  41. },
  42. {
  43. title: '电话',
  44. dataIndex: 'phone',
  45. key: 'phone',
  46. },
  47. {
  48. title: '性别',
  49. dataIndex: 'gender',
  50. key: 'gender',
  51. },
  52. {
  53. title: '归属地',
  54. dataIndex: 'province',
  55. key: 'province',
  56. },
  57. {
  58. title: '来源渠道',
  59. dataIndex: 'personFrom',
  60. key: 'personFrom',
  61. },
  62. {
  63. title: '置业顾问',
  64. dataIndex: 'realtyConsultant',
  65. key: 'realtyConsultant',
  66. },
  67. {
  68. title: '置业顾问电话',
  69. dataIndex: 'realtyConsultantPhone',
  70. key: 'realtyConsultantPhone',
  71. },
  72. {
  73. title: '分享者',
  74. dataIndex: 'sharePersonName',
  75. key: 'sharePersonName',
  76. },
  77. {
  78. title: '分享者电话',
  79. dataIndex: 'sharePersonPhone',
  80. key: 'sharePersonPhone',
  81. },
  82. ];
  83. class SharePersonNum extends React.Component {
  84. constructor(props) {
  85. super(props);
  86. let startDate;
  87. let endDate;
  88. if (props.location.query.queryDate) {
  89. startDate =
  90. moment(props.location.query.queryDate)
  91. .hours(0)
  92. .minutes(0)
  93. .seconds(0)
  94. .milliseconds(0)
  95. .format('YYYY-MM-DDTHH:mm:ss') + '.000Z';
  96. endDate =
  97. moment(props.location.query.queryDate)
  98. .hours(23)
  99. .minutes(59)
  100. .seconds(59)
  101. .milliseconds(999)
  102. .format('YYYY-MM-DDTHH:mm:ss') + '.999Z';
  103. } else {
  104. startDate =
  105. moment(props.location.query.startDate)
  106. .hours(0)
  107. .minutes(0)
  108. .seconds(0)
  109. .milliseconds(0)
  110. .format('YYYY-MM-DDTHH:mm:ss') + '.000Z';
  111. endDate =
  112. moment(props.location.query.endDate)
  113. .hours(23)
  114. .minutes(59)
  115. .seconds(59)
  116. .milliseconds(999)
  117. .format('YYYY-MM-DDTHH:mm:ss') + '.999Z';
  118. }
  119. this.state = {
  120. formData: {
  121. personFrom: '',
  122. province: '',
  123. pageNum: '',
  124. pageSize: '',
  125. startDate: startDate,
  126. endDate: endDate,
  127. activityId: props.location.query.activityId,
  128. activityType: props.location.query.activityType,
  129. buildingId: props.location.query.buildingId,
  130. },
  131. personData: [],
  132. dataSoures: [],
  133. tableData: [],
  134. userType: 'all',
  135. activityName: props.location.query.activityName,
  136. };
  137. }
  138. componentDidMount() {
  139. this.getTableList();
  140. }
  141. getTableList() {
  142. const { formData } = this.state;
  143. console.log(formData);
  144. request({ ...apis.activityDataStatis.activityAddRegist, params: formData })
  145. .then(data => {
  146. console.log(data);
  147. this.setState({ tableData: data.records, total: data.total });
  148. })
  149. .catch();
  150. }
  151. handleSubmit = (e, props) => {
  152. let startDate = null;
  153. let endDate = null;
  154. const personFrom = this.props.form.getFieldValue('personFrom');
  155. const province = this.props.form.getFieldValue('province');
  156. const { formData } = this.state;
  157. this.setState(
  158. {
  159. formData: {
  160. ...formData,
  161. personFrom: personFrom,
  162. province: province,
  163. pageNum: 1,
  164. pageSize: 999,
  165. },
  166. },
  167. this.getTableList,
  168. );
  169. };
  170. //重置搜索
  171. handleReset = e => {
  172. this.props.form.resetFields();
  173. let startDate;
  174. let endDate;
  175. if (this.props.location.query.queryDate) {
  176. startDate =
  177. moment(this.props.location.query.queryDate)
  178. .hours(0)
  179. .minutes(0)
  180. .seconds(0)
  181. .milliseconds(0)
  182. .format('YYYY-MM-DDTHH:mm:ss') + '.000Z';
  183. endDate =
  184. moment(this.props.location.query.queryDate)
  185. .hours(23)
  186. .minutes(59)
  187. .seconds(59)
  188. .milliseconds(999)
  189. .format('YYYY-MM-DDTHH:mm:ss') + '.999Z';
  190. } else {
  191. startDate =
  192. moment(this.props.location.query.startDate)
  193. .hours(0)
  194. .minutes(0)
  195. .seconds(0)
  196. .milliseconds(0)
  197. .format('YYYY-MM-DDTHH:mm:ss') + '.000Z';
  198. endDate =
  199. moment(this.props.location.query.endDate)
  200. .hours(23)
  201. .minutes(59)
  202. .seconds(59)
  203. .milliseconds(999)
  204. .format('YYYY-MM-DDTHH:mm:ss') + '.999Z';
  205. }
  206. this.setState(
  207. {
  208. formData: {
  209. personFrom: '',
  210. province: '',
  211. pageNum: '',
  212. pageSize: '',
  213. startDate: startDate,
  214. endDate: endDate,
  215. activityId: this.props.location.query.activityId,
  216. activityType: this.props.location.query.activityType,
  217. buildingId: this.props.location.query.buildingId,
  218. },
  219. personData: [],
  220. dataSoures: [],
  221. tableData: [],
  222. userType: 'all',
  223. activityName: this.props.location.query.activityName,
  224. },
  225. this.getTableList,
  226. );
  227. };
  228. goback = () => {
  229. router.go(-1);
  230. };
  231. exportActivityStats = () => {
  232. const { formData } = this.state;
  233. request({ ...apis.activityDataStatis.activityAddRegistNumExport, params: formData })
  234. .then(data => {
  235. if (!data) {
  236. return;
  237. }
  238. const url = window.URL.createObjectURL(new Blob([data]));
  239. const link = document.createElement('a');
  240. link.style.display = 'none';
  241. link.href = url;
  242. link.setAttribute('download', '分享统计.xlsx');
  243. document.body.append(link);
  244. link.click();
  245. })
  246. .catch();
  247. };
  248. //排序
  249. handleTableChange = (pagination, filters, sorter) => {
  250. console.log(pagination, filters, sorter);
  251. const { formData } = this.state;
  252. this.setState(
  253. {
  254. formData: {
  255. ...formData,
  256. personFrom: formData.personFrom,
  257. pageNum: pagination.current,
  258. pageSize: pagination.pageSize,
  259. },
  260. },
  261. this.getTableList,
  262. );
  263. };
  264. render() {
  265. const { radioVal } = this.state;
  266. const { getFieldDecorator } = this.props.form;
  267. return (
  268. <Card>
  269. <div align="right" style={{ marginBottom: '16px' }}>
  270. <Button onClick={this.goback}>返回</Button>
  271. </div>
  272. {this.state.activityName && (
  273. <div>
  274. <span style={{ marginLeft: '20px' }}>分享内容:{this.state.activityName}</span>
  275. </div>
  276. )}
  277. <Form layout="inline" onSubmit={e => this.handleSubmit(e, this.props)}>
  278. <Form.Item style={{ marginTop: '20px', marginBottom: '20px' }}>
  279. {getFieldDecorator('province')(<Input placeholder="请输入归属地" />)}
  280. </Form.Item>
  281. <Form.Item style={{ marginTop: '20px', marginBottom: '20px' }}>
  282. {getFieldDecorator('personFrom')(<WxDictSelect />)}
  283. </Form.Item>
  284. <Form.Item style={{ marginTop: '20px', marginBottom: '20px' }}>
  285. <Button type="primary" htmlType="submit" style={{ marginLeft: '30px' }}>
  286. 搜索
  287. </Button>
  288. <Button onClick={e => this.handleReset()} style={{ marginLeft: '30px' }}>
  289. 重置
  290. </Button>
  291. </Form.Item>
  292. </Form>
  293. <div>
  294. <AuthButton name="admin.statistical.activity.export" noRight={null}>
  295. <Button
  296. type="primary"
  297. style={{ float: 'right', margin: '20px 0', zIndex: 1 }}
  298. onClick={this.exportActivityStats}
  299. >
  300. 导出
  301. </Button>
  302. </AuthButton>
  303. <Table
  304. style={{ marginTop: '20px' }}
  305. dataSource={this.state.tableData}
  306. columns={columns}
  307. pagination={{ total: this.state.total }}
  308. onChange={this.handleTableChange}
  309. scroll={{ y: 500 }}
  310. ></Table>
  311. </div>
  312. </Card>
  313. );
  314. }
  315. }
  316. const WrappedTypeForm = Form.create()(SharePersonNum);
  317. export default WrappedTypeForm;