知与行后台管理端

exchangeRecords.jsx 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Input, Button, Icon, Select, DatePicker, Table, Pagination } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import styles from '../style/GoodsList.less';
  5. import router from 'umi/router';
  6. import moment from 'moment';
  7. import BuildSelect from '../../components/SelectButton/BuildSelect'
  8. import request from '../../utils/request'
  9. /**
  10. @param {*} props
  11. @returns
  12. */
  13. const { Option } = Select;
  14. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  15. function record(props) {
  16. const { getFieldDecorator } = props.form
  17. // 获取初始化数据
  18. const [ data, setData ] = useState({})
  19. useEffect(() => {
  20. getList({ pageNum: 1, pageSize: 10 });
  21. },[])
  22. // 查询列表
  23. const getList = (params) => {
  24. request({
  25. url: '/api/admin/taPointsExchange',
  26. method: 'GET',
  27. params: { ...params },
  28. }).then((data) => {
  29. setData(data)
  30. })
  31. }
  32. // 提交事件
  33. const handleSubmit = (e, props) => {
  34. e.preventDefault();
  35. props.form.validateFields((err, values) => {
  36. if (!err) {
  37. let {exchangeTime,receiveTime, ...submitValue} = values
  38. if(null != exchangeTime && exchangeTime.length > 0){
  39. const [startCreateDate, endCreateDate] = exchangeTime
  40. submitValue.startCreateDate = moment(startCreateDate).format('YYYY-MM-DD');
  41. submitValue.endCreateDate = moment(endCreateDate).format('YYYY-MM-DD');
  42. }else{
  43. submitValue.startCreateDate = null
  44. submitValue.endCreateDate = null
  45. }
  46. if(null != receiveTime && receiveTime.length > 0){
  47. const [startVerifyDate, endVerifyDate] = receiveTime
  48. submitValue.startVerifyDate = moment(startVerifyDate).format('YYYY-MM-DD');
  49. submitValue.endVerifyDate = moment(endVerifyDate).format('YYYY-MM-DD');
  50. }else{
  51. submitValue.startVerifyDate = null
  52. submitValue.endVerifyDate = null
  53. }
  54. console.log(submitValue)
  55. getList({ pageNum: 1, pageSize: 10, ...submitValue })
  56. }
  57. });
  58. }
  59. const changePageNum = (pageNumber) => {
  60. getList({ pageNum: pageNumber, pageSize: 10 })
  61. }
  62. const columns = [
  63. {
  64. title: '用户姓名',
  65. dataIndex: 'personName',
  66. key: 'personName',
  67. align: 'center',
  68. },
  69. {
  70. title: '用户类型',
  71. dataIndex: 'personType',
  72. key: 'personType',
  73. align: 'center',
  74. render: (personType)=> <><span>{personType === 'Realty Consultant' ? '置业顾问' : personType === 'Sales Executive' ? '销售主管' : personType === 'estate agent' ? '经纪人' : ''}</span></>
  75. },
  76. {
  77. title: '手机号',
  78. dataIndex: 'phone',
  79. key: 'phone',
  80. align: 'center',
  81. },
  82. {
  83. title: '商品图片',
  84. dataIndex: 'image',
  85. key: 'image',
  86. align: 'center',
  87. render: (text, record) => <img src={record.image} className={styles.touxiang} />,
  88. },
  89. {
  90. title: '商品名称',
  91. dataIndex: 'targetName',
  92. key: 'targetName',
  93. align: 'center',
  94. },
  95. {
  96. title: '兑换时间',
  97. dataIndex: 'createDate',
  98. key: 'createDate',
  99. align: 'center',
  100. render: (createDate) => <><span>{moment(createDate).format('YYYY-MM-DD HH:mm')}</span></>
  101. },
  102. {
  103. title: '领取时间',
  104. dataIndex: 'verifyDate',
  105. key: 'verifyDate',
  106. align: 'center',
  107. render: (verifyDate) => <><span>{verifyDate != null ? moment(verifyDate).format('YYYY-MM-DD HH:mm') : ''}</span></>
  108. },
  109. {
  110. title: '状态',
  111. dataIndex: 'status',
  112. key: 'status',
  113. align: 'center',
  114. render: (status)=> <><span>{status == 1 ? '已领取' : '未领取'}</span></>
  115. },
  116. ];
  117. return (
  118. <>
  119. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  120. <div style={{ display: 'flex' }}>
  121. <Form.Item>
  122. {getFieldDecorator('personName')(
  123. <Input
  124. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  125. placeholder="用户姓名"
  126. />,
  127. )}
  128. </Form.Item>
  129. <Form.Item>
  130. {getFieldDecorator('phone')(
  131. <Input
  132. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  133. placeholder="手机号"
  134. />,
  135. )}
  136. </Form.Item>
  137. <Form.Item>
  138. {getFieldDecorator('targetName')(
  139. <Input
  140. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  141. placeholder="商品名称"
  142. />,
  143. )}
  144. </Form.Item>
  145. <Form.Item>
  146. {getFieldDecorator('personType')(
  147. <Select style={{ width: '220px' }} placeholder="用户类型">
  148. <Option value="Realty Consultant">置业顾问</Option>
  149. <Option value="Sales Executive">销售主管</Option>
  150. <Option value="estate agent">经纪人</Option>
  151. </Select>,
  152. )}
  153. </Form.Item>
  154. <Form.Item>
  155. {getFieldDecorator('status')(
  156. <Select style={{ width: '220px' }} placeholder="状态">
  157. <Option value="1">已领取</Option>
  158. <Option value="0">未领取</Option>
  159. </Select>,
  160. )}
  161. </Form.Item>
  162. <Form.Item>
  163. {getFieldDecorator('exchangeTime')(
  164. <RangePicker placeholder={['兑换开始时间','兑换结束时间']}/>
  165. )}
  166. </Form.Item>
  167. <Form.Item>
  168. {getFieldDecorator('receiveTime')(
  169. <RangePicker placeholder={['领取开始时间','领取结束时间']}/>
  170. )}
  171. </Form.Item>
  172. <Form.Item>
  173. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  174. 搜索
  175. </Button>
  176. </Form.Item>
  177. </div>
  178. </Form>
  179. <Table style={{marginTop:'40px'}} dataSource={data.records} columns={columns} pagination={false} />
  180. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  181. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
  182. </div>
  183. </>
  184. )
  185. }
  186. const WrappedHeader = Form.create({ name: 'record' })(record);
  187. export default WrappedHeader