ConsumeOrder.jsx 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import React, { useState, useEffect } from 'react';
  2. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  3. import { Form, Pagination, Button, Icon, message, Modal, Table, Select, Input, DatePicker } from 'antd';
  4. import router from 'umi/router';
  5. import moment from 'moment';
  6. import className from 'classnames';
  7. import Cell from '../../components/Cell';
  8. import styles from './style.less';
  9. import { fetch, apis } from '../../utils/request';
  10. import request from '../../utils/request';
  11. import AuthButton from '@/components/AuthButton';
  12. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  13. function header(props) {
  14. // 获取初始化数据
  15. const [data, setData] = useState({})
  16. const [visible, setVisible] = useState(false)
  17. const [demandIdList, setDemandIdList] = useState([])
  18. const [personInfo, setPersonInfo] = useState({})
  19. const orgId = props.orgId || ''
  20. useEffect(() => {
  21. getList({ pageNum: 1, pageSize: 10, orderType: 'redPacket' });
  22. }, [])
  23. // 查询列表
  24. const getList = (params) => {
  25. request({ ...apis.fund.taOrgOrder, params: { ...params, orgId } }).then((data) => {
  26. console.log(data)
  27. setData(data)
  28. })
  29. }
  30. // 提交事件
  31. const handleSubmit = (e, props) => {
  32. e.preventDefault();
  33. props.form.validateFields((err, values) => {
  34. if (!err) {
  35. let { LocalDate, ...submitValue } = values
  36. if (null != LocalDate && LocalDate.length > 0) {
  37. const [startDate, endDate] = LocalDate
  38. submitValue.startDate = moment(startDate).format('YYYY-MM-DD');
  39. submitValue.endDate = moment(endDate).format('YYYY-MM-DD');
  40. } else {
  41. submitValue.startDate = null
  42. submitValue.endDate = null
  43. }
  44. getList({ pageNum: 1, pageSize: 10, orderType: 'redPacket', ...submitValue })
  45. }
  46. });
  47. }
  48. const changePageNum = (pageNumber) => {
  49. let { LocalDate, ...submitValue } = props.form.getFieldsValue()
  50. if (null != LocalDate && LocalDate.length > 0) {
  51. const [startDate, endDate] = LocalDate
  52. submitValue.startDate = moment(startDate).format('YYYY-MM-DD');
  53. submitValue.endDate = moment(endDate).format('YYYY-MM-DD');
  54. } else {
  55. submitValue.startDate = null
  56. submitValue.endDate = null
  57. }
  58. getList({ pageNum: pageNumber, pageSize: 10, orderType: 'redPacket', ...submitValue })
  59. }
  60. /**
  61. *
  62. * @param {*} props
  63. * @returns
  64. */
  65. const columns = [
  66. {
  67. title: '订单编号',
  68. dataIndex: 'tradeNo',
  69. key: 'tradeNo',
  70. align: 'center',
  71. },
  72. {
  73. title: '消费组织',
  74. dataIndex: 'miniAppName',
  75. key: 'miniAppName',
  76. align: 'center',
  77. },
  78. {
  79. title: '消费金额',
  80. dataIndex: 'amount',
  81. key: 'amount',
  82. align: 'center',
  83. },
  84. {
  85. title: '消费方式',
  86. dataIndex: 'consumeType',
  87. key: 'consumeType',
  88. align: 'center',
  89. },
  90. {
  91. title: '活动名称',
  92. dataIndex: 'activityName',
  93. key: 'activityName',
  94. align: 'center',
  95. },
  96. {
  97. title: '消费下单时间',
  98. dataIndex: 'createDate',
  99. key: 'createDate',
  100. align: 'center',
  101. render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  102. },
  103. {
  104. title: '接收人手机号',
  105. dataIndex: 'phone',
  106. key: 'phone',
  107. align: 'center',
  108. render: (x, row) => <><span className={styles.blue} onClick={() => Info(row)}>{row.phone || '13160056114'}</span></>
  109. },
  110. {
  111. title: '消费状态',
  112. dataIndex: 'tradingStatus',
  113. key: 'tradingStatus',
  114. align: 'center',
  115. render: (x, row) => <><span>{row.tradingStatus == '1' ? '成功' : '失败'}</span></>
  116. },
  117. ];
  118. const Info = (row) => {
  119. request({ ...apis.fund.receiveInfo, params: { phone: row.phone, orgId: row.orgId } }).then((data) => {
  120. setPersonInfo(data)
  121. setVisible(true)
  122. })
  123. }
  124. function handleReset() {
  125. props.form.resetFields();
  126. getList({ pageNum: 1, pageSize: 10, orderType: 'redPacket' })
  127. }
  128. const { getFieldDecorator } = props.form
  129. return (
  130. <>
  131. <Modal
  132. visible={visible}
  133. title="接收人消息"
  134. onCancel={() => setVisible(false)}
  135. footer={null}
  136. >
  137. <div style={{ paddingLeft:'36%'}}>
  138. <p>昵称:{personInfo.nickname || ''}</p>
  139. <p>头像:<img src={personInfo.avatarurl || ''} className={styles.touxiang} /></p>
  140. <p>姓名:{personInfo.name || ''}</p>
  141. <p>手机号:{personInfo.phone || ''}</p>
  142. </div>
  143. </Modal>
  144. <Form layout="inline" onSubmit={e => handleSubmit(e, props)} style={{ marginBottom: '16px' }}>
  145. <Form.Item>
  146. {getFieldDecorator('tradeNo')(
  147. <Input
  148. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  149. placeholder="订单编号"
  150. />,
  151. )}
  152. </Form.Item>
  153. <Form.Item>
  154. {getFieldDecorator('miniAppName')(
  155. <Input
  156. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  157. placeholder="消费组织"
  158. />,
  159. )}
  160. </Form.Item>
  161. <Form.Item>
  162. <span style={{ marginRight: '10px' }}>消费时间段:</span>
  163. {getFieldDecorator('LocalDate')(
  164. <RangePicker placeholder={['开始时间', '结束时间']} />
  165. )}
  166. </Form.Item>
  167. <Form.Item>
  168. {getFieldDecorator('itemType')(
  169. <Select style={{ width: '180px' }} placeholder="消费方式">
  170. <Select.Option value="">全部</Select.Option>
  171. <Select.Option value="redPacket">红包</Select.Option>
  172. </Select>,
  173. )}
  174. </Form.Item>
  175. <Form.Item>
  176. {getFieldDecorator('tradingStatus')(
  177. <Select style={{ width: '180px' }} placeholder="消费状态">
  178. <Select.Option value="">全部</Select.Option>
  179. <Select.Option value="1">成功</Select.Option>
  180. <Select.Option value="2">失败</Select.Option>
  181. </Select>,
  182. )}
  183. </Form.Item>
  184. <Form.Item>
  185. {getFieldDecorator('receivePhone')(
  186. <Input
  187. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  188. placeholder="接收人手机号"
  189. />,
  190. )}
  191. </Form.Item>
  192. <Form.Item>
  193. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  194. 搜索
  195. </Button>
  196. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  197. 重置
  198. </Button>
  199. </Form.Item>
  200. </Form>
  201. <Table rowKey={r => r.tradeNo} dataSource={data.records} columns={columns} pagination={false} />
  202. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  203. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
  204. </div>
  205. </>
  206. )
  207. }
  208. const WrappedHeader = Form.create({ name: 'header' })(header);
  209. export default WrappedHeader