exchangeRecords.jsx 7.5KB

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