memberOrderList.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, message, DatePicker, Modal, InputNumber, Radio } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import './content.less';
  6. import moment from 'moment';
  7. import { getTime } from '../../tools';
  8. const OrderList = React.createClass({
  9. loadData (pageNo) {
  10. this.state.data = [];
  11. this.setState({
  12. loading: true
  13. });
  14. $.ajax({
  15. method: "get",
  16. dataType: "json",
  17. crossDomain: false,
  18. url: globalConfig.context + "/api/admin/member/selectMemberOrderBa",
  19. data: {
  20. pageNo: pageNo || 1,
  21. pageSize: this.state.pagination.pageSize,
  22. id: this.state.searchOrderNumber,
  23. nickname: this.state.searchName,
  24. mobile: this.state.searchAftNumber,
  25. orderState: this.state.searchOrderStatus, //支付状态 0,1
  26. startTime: this.state.searchTime[0],
  27. endTime: this.state.searchTime[1]
  28. },
  29. success: function (data) {
  30. if (!data.data || !data.data.list) {
  31. if (data.error && data.error.length) {
  32. message.warning(data.error[0].message);
  33. };
  34. } else {
  35. for (let i = 0; i < data.data.list.length; i++) {
  36. let thisdata = data.data.list[i];
  37. this.state.data.push({
  38. key: i,
  39. id: thisdata.id,
  40. formattedOrderTime: thisdata.formattedOrderTime,
  41. formattedPaymentTime: thisdata.formattedPaymentTime,
  42. formattedValidTime: thisdata.formattedValidTime,
  43. gradeName: thisdata.gradeName,
  44. menberType: thisdata.menberType,
  45. nickname: thisdata.nickname,
  46. mobile: thisdata.mobile,
  47. orderState: thisdata.orderState,
  48. orderTime: thisdata.orderTime,
  49. paymentId: thisdata.paymentId,
  50. paymentTime: thisdata.paymentTime,
  51. paymentType: thisdata.paymentType,
  52. paymentValue: thisdata.paymentValue,
  53. price: thisdata.price,
  54. userId: thisdata.userId,
  55. validMonth: thisdata.validMonth,
  56. validTime: thisdata.validTime,
  57. });
  58. };
  59. this.state.pagination.current = data.data.pNo;
  60. this.state.pagination.total = data.data.countWhere;
  61. };
  62. this.setState({
  63. dataSource: this.state.data,
  64. pagination: this.state.pagination
  65. });
  66. }.bind(this),
  67. }).always(function () {
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this));
  72. },
  73. getInitialState () {
  74. return {
  75. searchMore: true,
  76. data: [],
  77. modalData: {},
  78. visible: false,
  79. delVisible: false,
  80. searchTime: [],
  81. loading: false,
  82. selectedRowKeys: [],
  83. selectedRows: [],
  84. pagination: {
  85. defaultCurrent: 1,
  86. defaultPageSize: 10,
  87. showQuickJumper: true,
  88. pageSize: 10,
  89. onChange: function (page) {
  90. this.loadData(page);
  91. }.bind(this),
  92. showTotal: function (total) {
  93. return '共' + total + '条数据';
  94. }
  95. },
  96. columns: [
  97. {
  98. title: '订单编号',
  99. dataIndex: 'id',
  100. key: 'id',
  101. }, {
  102. title: '账号',
  103. dataIndex: 'mobile',
  104. key: 'mobile',
  105. }, {
  106. title: '认证名称',
  107. dataIndex: 'nickname',
  108. key: 'nickname',
  109. }, {
  110. title: '会员类型',
  111. dataIndex: 'gradeName',
  112. key: 'gradeName',
  113. }, {
  114. title: '订单状态',
  115. dataIndex: 'orderState',
  116. key: 'orderState',
  117. render: (text) => {
  118. if (text == 1) {
  119. return '已支付'
  120. } else {
  121. return '未支付'
  122. };
  123. }
  124. }, {
  125. title: '生成时间',
  126. dataIndex: 'formattedOrderTime',
  127. key: 'formattedOrderTime',
  128. }, {
  129. title: '支付时间',
  130. dataIndex: 'formattedPaymentTime',
  131. key: 'formattedPaymentTime',
  132. }, {
  133. title: '有效时间',
  134. dataIndex: 'formattedValidTime',
  135. key: 'formattedValidTime',
  136. render: (index, record) => {
  137. if (record.paymentTime && record.validMonth && record.orderState == 1) {
  138. return getTime(record.paymentTime) + ' -- ' + getTime(record.paymentTime, record.validMonth)
  139. }
  140. }
  141. }
  142. ],
  143. dataSource: []
  144. };
  145. },
  146. componentWillMount () {
  147. this.loadData();
  148. },
  149. search () {
  150. this.loadData();
  151. },
  152. reset () {
  153. this.state.searchOrderNumber = undefined;
  154. this.state.searchAftNumber = undefined;
  155. this.state.searchOrderStatus = undefined;
  156. this.state.searchName = undefined;
  157. this.state.searchTime = [];
  158. this.loadData();
  159. },
  160. submit () {
  161. if (this.state.modalData.paymentType == 1 && !this.state.modalData.formattedPaymentTime) {
  162. message.warning('状态为已支付时支付时间必填');
  163. return
  164. }
  165. this.setState({ loading: true });
  166. $.ajax({
  167. method: "post",
  168. dataType: "json",
  169. crossDomain: false,
  170. url: globalConfig.context + "/api/admin/member/updateMemberOrder",
  171. data: {
  172. id: this.state.modalData.id,
  173. userId: this.state.modalData.userId,
  174. memberRank: this.state.modalData.menberType,
  175. validMonth: this.state.modalData.validMonth,
  176. paymentValue: this.state.modalData.paymentValue,
  177. orderState: this.state.modalData.orderState,
  178. paymentTime: this.state.modalData.formattedPaymentTime,
  179. paymentType: this.state.modalData.paymentType,
  180. paymentId: this.state.modalData.paymentId
  181. }
  182. }).done(function (data) {
  183. if (!data.error.length) {
  184. message.success('保存成功!');
  185. this.setState({ loading: false, visible: false });
  186. this.loadData();
  187. } else {
  188. message.warning(data.error[0].message);
  189. }
  190. }.bind(this)).always(function () {
  191. this.setState({ loading: false });
  192. }.bind(this));
  193. },
  194. tableRowClick (record, index) {
  195. let theObj = {};
  196. for (let item in record) {
  197. theObj[item] = record[item]
  198. }
  199. this.state.modalData = theObj;
  200. this.setState({ visible: true });
  201. },
  202. deleteRow () {
  203. let deletedId;
  204. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  205. let rowItem = this.state.selectedRows[idx];
  206. if (rowItem.orderState !== 0) {
  207. message.warning('订单状态不是未支付,无法删除!');
  208. this.setState({ delVisible: false });
  209. return;
  210. }
  211. if (rowItem.id) {
  212. deletedId = rowItem.id
  213. };
  214. };
  215. this.setState({
  216. selectedRowKeys: [],
  217. loading: deletedId.length > 0
  218. });
  219. $.ajax({
  220. method: "POST",
  221. dataType: "json",
  222. crossDomain: false,
  223. url: globalConfig.context + "/api/admin/member/delMemberOrder",
  224. data: {
  225. id: deletedId
  226. }
  227. }).done(function (data) {
  228. if (!data.error.length) {
  229. message.success('删除成功!');
  230. } else {
  231. message.warning(data.error[0].message);
  232. };
  233. this.setState({
  234. loading: false,
  235. delVisible: false
  236. });
  237. this.loadData();
  238. }.bind(this));
  239. },
  240. render () {
  241. const rowSelection = {
  242. selectedRowKeys: this.state.selectedRowKeys,
  243. onChange: (selectedRowKeys, selectedRows) => {
  244. this.setState({
  245. selectedRows: selectedRows.slice(-1),
  246. selectedRowKeys: selectedRowKeys.slice(-1)
  247. });
  248. }
  249. };
  250. const hasSelected = this.state.selectedRowKeys.length > 0;
  251. const { RangePicker } = DatePicker;
  252. const Option = Select.Option;
  253. return (
  254. <div className="user-content" >
  255. <div className="content-title">
  256. <span>会员订单列表</span>
  257. </div>
  258. <div className="user-search">
  259. <Input placeholder="订单编号" value={this.state.searchOrderNumber}
  260. onChange={(e) => { this.setState({ searchOrderNumber: e.target.value }); }} />
  261. <Input placeholder="用户账号" value={this.state.searchAftNumber}
  262. onChange={(e) => { this.setState({ searchAftNumber: e.target.value }); }} />
  263. <Input placeholder="认证名称" value={this.state.searchName}
  264. onChange={(e) => { this.setState({ searchName: e.target.value }); }} />
  265. <Select placeholder="订单状态" value={this.state.searchOrderStatus} style={{ width: 120 }}
  266. onChange={(e) => { this.setState({ searchOrderStatus: e }) }}>
  267. <Option value="0">未付款</Option>
  268. <Option value="1">已付款</Option>
  269. </Select>
  270. <div className="search-div">
  271. <span>订单生成时间:</span>
  272. <RangePicker
  273. allowClear={false}
  274. value={[this.state.searchTime[0] ? moment(this.state.searchTime[0]) : null,
  275. this.state.searchTime[1] ? moment(this.state.searchTime[1]) : null]}
  276. onChange={(data, dataString) => { this.setState({ searchTime: dataString }); }} />
  277. </div>
  278. <Button type="primary" onClick={this.search}>搜索</Button>
  279. <Button onClick={this.reset}>重置</Button>
  280. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  281. disabled={!hasSelected}
  282. onClick={() => { this.setState({ delVisible: true }) }}>删除<Icon type="minus" /></Button>
  283. </div>
  284. <div className="patent-table">
  285. <Spin spinning={this.state.loading}>
  286. <Table className="no-all-select"
  287. columns={this.state.columns}
  288. dataSource={this.state.dataSource}
  289. rowSelection={rowSelection}
  290. style={{
  291. cursor: 'pointer',
  292. }}
  293. pagination={this.state.pagination}
  294. onRowClick={this.tableRowClick} />
  295. </Spin>
  296. </div>
  297. <Modal title="订单详情" width={600} className="activity-modal"
  298. visible={this.state.visible}
  299. maskClosable={false}
  300. footer={null}
  301. afterClose={() => { this.state.modalData = {}; }}
  302. onCancel={() => { this.setState({ visible: false }) }} >
  303. <Spin spinning={this.state.loading}>
  304. <div className="clearfix">
  305. <div className="modal-box">
  306. <span className="modal-box-title">会员等级</span>
  307. <div className="modal-box-detail">
  308. <Select placeholder="选择会员等级"
  309. style={{ width: 120 }}
  310. value={this.state.modalData.menberType ? this.state.modalData.menberType.toString() : undefined}
  311. onChange={(e) => {
  312. this.state.modalData.menberType = e;
  313. this.setState({ modalData: this.state.modalData });
  314. }}>
  315. <Select.Option value="1">Lv.1</Select.Option>
  316. <Select.Option value="2">Lv.2</Select.Option>
  317. <Select.Option value="3">Lv.3</Select.Option>
  318. <Select.Option value="4">Lv.4</Select.Option>
  319. <Select.Option value="5">Lv.5</Select.Option>
  320. </Select>
  321. </div>
  322. </div>
  323. <div className="modal-box">
  324. <span className="modal-box-title">会员时长</span>
  325. <div className="modal-box-detail" style={{ width: '160px' }}>
  326. <InputNumber value={this.state.modalData.validMonth} step={1} onChange={(e) => {
  327. this.state.modalData.validMonth = e;
  328. this.setState({ modalData: this.state.modalData });
  329. }} />
  330. <span> 月</span>
  331. </div>
  332. </div>
  333. <div className="modal-box">
  334. <span className="modal-box-title">订单金额</span>
  335. <div className="modal-box-detail" style={{ width: '160px' }}>
  336. <span>{this.state.modalData.price}</span>
  337. <span> 元</span>
  338. </div>
  339. <span className="modal-box-title">实际支付金额</span>
  340. <div className="modal-box-detail" style={{ width: '160px' }}>
  341. <InputNumber value={this.state.modalData.paymentValue} step={0.01} onChange={(e) => {
  342. this.state.modalData.paymentValue = e;
  343. this.setState({ modalData: this.state.modalData });
  344. }} />
  345. <span> 元</span>
  346. </div>
  347. </div>
  348. <div className="modal-box">
  349. <span className="modal-box-title">支付方式</span>
  350. <div className="modal-box-detail" style={{ width: '160px' }}>
  351. <Input value={this.state.modalData.paymentType} onChange={(e) => {
  352. this.state.modalData.paymentType = e.target.value;
  353. this.setState({ modalData: this.state.modalData });
  354. }} />
  355. </div>
  356. <span className="modal-box-title">流水号</span>
  357. <div className="modal-box-detail" style={{ width: '160px' }}>
  358. <Input value={this.state.modalData.paymentId} onChange={(e) => {
  359. this.state.modalData.paymentId = e.target.value;
  360. this.setState({ modalData: this.state.modalData });
  361. }} />
  362. </div>
  363. </div>
  364. <div className="modal-box">
  365. <span className="modal-box-title">支付状态</span>
  366. <div className="modal-box-detail">
  367. <Radio.Group value={this.state.modalData.orderState}
  368. onChange={(e) => {
  369. this.state.modalData.orderState = e.target.value;
  370. this.setState({ modalData: this.state.modalData });
  371. }} >
  372. <Radio value={0}>未支付</Radio>
  373. <Radio value={1}>已支付</Radio>
  374. </Radio.Group>
  375. </div>
  376. </div>
  377. <div className="modal-box">
  378. <span className="modal-box-title">支付时间</span>
  379. <div className="modal-box-detail">
  380. <DatePicker style={{ width: '150px' }}
  381. showTime
  382. format="YYYY-MM-DD HH:mm:ss"
  383. placeholder="选择支付时间"
  384. value={this.state.modalData.formattedPaymentTime ? moment(this.state.modalData.formattedPaymentTime, "YYYY-MM-DD HH:mm:ss") : undefined}
  385. onChange={(t, str) => {
  386. this.state.modalData.formattedPaymentTime = str;
  387. this.setState({ modalData: this.state.modalData });
  388. }} />
  389. </div>
  390. </div>
  391. </div>
  392. <div className="modal-box" style={{ marginTop: '100px' }}>
  393. <Button type="primary" onClick={this.submit}>提交</Button>
  394. <Button type="ghost" onClick={() => { this.setState({ visible: false }) }}>取消</Button>
  395. </div>
  396. </Spin>
  397. </Modal>
  398. <Modal title="删除确认" width={600} className="activity-modal"
  399. visible={this.state.delVisible}
  400. maskClosable={false}
  401. footer={null}
  402. onCancel={() => { this.setState({ delVisible: false }) }} >
  403. <Spin spinning={this.state.loading}>
  404. <div className="clearfix">
  405. <div className="modal-box">
  406. <span>是否确定删除这条记录?删除后数据不可恢复!</span>
  407. </div>
  408. <div className="modal-box" >
  409. <Button type="primary" onClick={this.deleteRow}>提交</Button>
  410. <Button type="ghost" onClick={() => { this.setState({ delVisible: false }) }}>取消</Button>
  411. </div>
  412. </div>
  413. </Spin>
  414. </Modal>
  415. </div >
  416. );
  417. }
  418. });
  419. export default OrderList;