consultList.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, message, DatePicker, Modal } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import './content.less';
  6. import { getTime } from '../../tools'
  7. const OrderList = React.createClass({
  8. loadData (pageNo) {
  9. this.state.data = [];
  10. this.setState({
  11. loading: true
  12. });
  13. $.ajax({
  14. method: "get",
  15. dataType: "json",
  16. crossDomain: false,
  17. url: globalConfig.context + "/api/user/consultorder/list",
  18. data: {
  19. pageNo: pageNo || 1,
  20. pageSize: this.state.pagination.pageSize,
  21. number: this.state.searchNumber,
  22. toNumber: this.state.searchToNumber,
  23. id: this.state.searchId,
  24. paymentId: this.state.searchPaymentId,
  25. state: this.state.searchState
  26. },
  27. success: function (data) {
  28. if (!data.data || !data.data.list) {
  29. if (data.error && data.error.length) {
  30. message.warning(data.error[0].message);
  31. };
  32. } else {
  33. for (let i = 0; i < data.data.list.length; i++) {
  34. let thisdata = data.data.list[i];
  35. this.state.data.push({
  36. key: i,
  37. id: thisdata.id,
  38. price: thisdata.price,
  39. orderState: thisdata.orderState,
  40. orderTime: thisdata.orderTime,
  41. orderTimeFormatted: thisdata.orderTimeFormatted,
  42. userId: thisdata.userId,
  43. toUserId: thisdata.toUserId,
  44. nickname: thisdata.nickname,
  45. number: thisdata.number,
  46. toNickname: thisdata.toUsername || thisdata.toNickname,
  47. toNumber: thisdata.toNumber,
  48. paymentTime: thisdata.paymentTime,
  49. paymentTimeFormatted: thisdata.paymentTimeFormatted,
  50. paymentValue: thisdata.paymentValue,
  51. paymentType: thisdata.paymentType,
  52. paymentId: thisdata.paymentId,
  53. });
  54. };
  55. this.state.pagination.current = data.data.pageNo;
  56. this.state.pagination.total = data.data.totalCount;
  57. };
  58. this.setState({
  59. dataSource: this.state.data,
  60. pagination: this.state.pagination
  61. });
  62. }.bind(this),
  63. }).always(function () {
  64. this.setState({
  65. loading: false
  66. });
  67. }.bind(this));
  68. },
  69. getInitialState () {
  70. return {
  71. searchMore: true,
  72. visible: false,
  73. deleteId: null,
  74. data: [],
  75. searchTime: [],
  76. loading: false,
  77. pagination: {
  78. defaultCurrent: 1,
  79. defaultPageSize: 10,
  80. showQuickJumper: true,
  81. pageSize: 10,
  82. onChange: function (page) {
  83. this.loadData(page);
  84. }.bind(this),
  85. showTotal: function (total) {
  86. return '共' + total + '条数据';
  87. }
  88. },
  89. columns: [
  90. {
  91. title: '订单编号',
  92. dataIndex: 'id',
  93. key: 'id',
  94. }, {
  95. title: '专家编号',
  96. dataIndex: 'toNumber',
  97. key: 'toNumber',
  98. }, {
  99. title: '专家名称',
  100. dataIndex: 'toNickname',
  101. key: 'toNickname'
  102. }, {
  103. title: '订单状态',
  104. dataIndex: 'orderState',
  105. key: 'orderState',
  106. render: (text, record) => {
  107. if (text == 1) {
  108. return '已支付'
  109. } else if (text == 9) {
  110. return '已取消'
  111. } else if (text == 2) {
  112. return '支付中'
  113. } else {
  114. let now = new Date();
  115. let endTime = new Date(record.orderTime + 24 * 60 * 60 * 1000 * 15)
  116. if (now > endTime) {
  117. return '已失效'
  118. } else {
  119. return '未支付'
  120. }
  121. }
  122. }
  123. }, {
  124. title: '生成时间',
  125. dataIndex: 'orderTimeFormatted',
  126. key: 'orderTimeFormatted',
  127. }, {
  128. title: '支付金额',
  129. dataIndex: 'price',
  130. key: 'price',
  131. render: (index, record) => {
  132. if (record.paymentValue && record.paymentValue != 0) {
  133. return record.paymentValue
  134. } else {
  135. return index
  136. }
  137. }
  138. }, {
  139. title: '支付时间',
  140. dataIndex: 'paymentTimeFormatted',
  141. key: 'paymentTimeFormatted',
  142. }, {
  143. title: '支付流水',
  144. dataIndex: 'paymentId',
  145. key: 'paymentId'
  146. }, {
  147. title: '操作',
  148. dataIndex: 'action',
  149. key: 'action',
  150. render: (text, record) => {
  151. let now = new Date();
  152. let endTime = new Date(record.orderTime + 24 * 60 * 60 * 1000 * 15)
  153. if (record.orderState == 0 && now < endTime) {
  154. return <div>
  155. <Button type="primary" onClick={() => { }}>支付</Button>
  156. <Button style={{ marginLeft: '10px' }} type="primary"
  157. onClick={() => { this.setState({ visible: true, deleteId: record.id }) }} >取消订单</Button>
  158. </div>
  159. } else if (record.orderState == 0) {
  160. return <div><Button type="primary"
  161. onClick={() => { this.setState({ visible: true, deleteId: record.id }) }}>取消订单</Button></div>
  162. }
  163. }
  164. }
  165. ],
  166. dataSource: []
  167. };
  168. },
  169. delRow () {
  170. this.setState({
  171. loading: true
  172. });
  173. $.ajax({
  174. method: "post",
  175. dataType: "json",
  176. crossDomain: false,
  177. url: globalConfig.context + "/api/user/consultorder/del",
  178. data: {
  179. id: this.state.deleteId
  180. }
  181. }).done(function (data) {
  182. if (!data.error.length) {
  183. message.success('删除成功!');
  184. } else {
  185. message.warning(data.error[0].message);
  186. };
  187. this.setState({
  188. deleteId: null,
  189. visible: false,
  190. loading: false,
  191. });
  192. this.loadData();
  193. }.bind(this));
  194. },
  195. componentWillMount () {
  196. this.loadData();
  197. },
  198. search () {
  199. this.loadData();
  200. },
  201. reset () {
  202. this.state.searchNumber = undefined;
  203. this.state.searchToNumber = undefined;
  204. this.state.searchId = undefined;
  205. this.state.searchPaymentId = undefined;
  206. this.state.searchState = undefined;
  207. this.state.searchTime = [];
  208. this.loadData();
  209. },
  210. render () {
  211. const { RangePicker } = DatePicker;
  212. const Option = Select.Option;
  213. return (
  214. <div className="collection" >
  215. <div className="content-title">
  216. <span>咨询订单列表</span>
  217. </div>
  218. <div className="user-search">
  219. <Input placeholder="会员编号" value={this.state.searchNumber}
  220. onChange={(e) => { this.setState({ searchNumber: e.target.value }); }} />
  221. <Input placeholder="专家编号" value={this.state.searchToNumber}
  222. onChange={(e) => { this.setState({ searchToNumber: e.target.value }); }} />
  223. <Input placeholder="订单编号" value={this.state.searchId}
  224. onChange={(e) => { this.setState({ searchId: e.target.value }); }} />
  225. <Select placeholder="订单状态" value={this.state.searchState} style={{ width: 120 }}
  226. onChange={(e) => { this.setState({ searchState: e }) }}>
  227. <Option value="0">未付款</Option>
  228. <Option value="1">已付款</Option>
  229. <Option value="9">已取消</Option>
  230. <Option value="10">已失效</Option>
  231. </Select>
  232. <Input placeholder="支付流水" value={this.state.searchPaymentId}
  233. onChange={(e) => { this.setState({ searchPaymentId: e.target.value }); }} />
  234. <div className="search-div" style={{ display: 'none' }}>
  235. <span>订单生成时间:</span>
  236. <RangePicker
  237. allowClear={false}
  238. value={[this.state.searchTime[0] ? moment(this.state.searchTime[0]) : null,
  239. this.state.searchTime[1] ? moment(this.state.searchTime[1]) : null]}
  240. onChange={(data, dataString) => { this.setState({ searchTime: dataString }); }} />
  241. </div>
  242. <Button type="primary" onClick={this.search}>搜索</Button>
  243. <Button onClick={this.reset}>重置</Button>
  244. </div>
  245. <div className="patent-table">
  246. <Spin spinning={this.state.loading}>
  247. <Table size="middle" columns={this.state.columns}
  248. dataSource={this.state.dataSource}
  249. style={{
  250. cursor: 'pointer',
  251. }}
  252. pagination={this.state.pagination}
  253. onRowClick={this.tableRowClick} />
  254. </Spin>
  255. </div>
  256. <Modal title="取消确认" width={600} className="activity-modal"
  257. visible={this.state.visible}
  258. maskClosable={false}
  259. footer={null}
  260. onCancel={() => { this.setState({ visible: false }) }} >
  261. <Spin spinning={this.state.loading}>
  262. <div className="clearfix">
  263. <div>
  264. <span>是否确定取消这个订单?取消后后订单不可恢复!</span>
  265. </div>
  266. <div className="modal-box" >
  267. <Button type="primary" onClick={this.delRow}>确认</Button>
  268. <Button type="ghost" onClick={() => { this.setState({ visible: false }) }}>取消</Button>
  269. </div>
  270. </div>
  271. </Spin>
  272. </Modal>
  273. </div >
  274. );
  275. }
  276. });
  277. export default OrderList;