serviceList.jsx 11 KB

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