知与行后台管理端

exchangeRecords.jsx 6.8KB

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