serviceOrder.jsx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. update:2018/07/16
  3. author:liting
  4. */
  5. import React from 'react';
  6. import $ from 'jquery/src/ajax';
  7. import { Form, Button, Input, Select, Spin, Table, message, Modal, Tooltip, Switch, DatePicker } from 'antd';
  8. import { orderType } from '@/dataDic';
  9. import { getOrderType } from '@/tools.js';
  10. import moment from 'moment';
  11. //主体
  12. const Order = Form.create()(
  13. React.createClass({
  14. loadData(pageNo) {
  15. this.state.data = [];
  16. this.setState({
  17. loading: true,
  18. page: pageNo
  19. });
  20. $.ajax({
  21. method: 'get',
  22. dataType: 'json',
  23. crossDomain: false,
  24. url: globalConfig.context + '/api/user/jtOrder/list',
  25. data: {
  26. pageNo: pageNo || 1,
  27. pageSize: this.state.pagination.pageSize,
  28. orderNo: this.state.numberSearch,
  29. userType:1,
  30. commodityName: this.state.entryNameSearch,
  31. buyerName: this.state.companyNameSearch,
  32. startCreateDate: this.state.releaseDate[0],
  33. endCreateDate: this.state.releaseDate[1]
  34. },
  35. success: function(data) {
  36. let theArr = [];
  37. if (!data.data || !data.data.list) {
  38. if (data.error && data.error.length) {
  39. message.warning(data.error[0].message);
  40. }
  41. } else {
  42. for (let i = 0; i < data.data.list.length; i++) {
  43. let thisdata = data.data.list[i];
  44. theArr.push({
  45. key: i,
  46. sellerId: thisdata.sellerId,
  47. buyerId:thisdata.buyerId,
  48. orderNo:thisdata.orderNo,
  49. commodityType:thisdata.commodityType,
  50. orderAmount:thisdata.orderAmount,
  51. commodityName:thisdata.commodityName,
  52. buyerName:thisdata.buyerName,
  53. buyerMobile:thisdata.buyerMobile,
  54. createTime: thisdata.createTime ? new Date(thisdata.createTime).toLocaleString() : ''
  55. });
  56. }
  57. this.state.pagination.current = data.data.pageNo;
  58. this.state.pagination.total = data.data.totalCount;
  59. }
  60. this.setState({
  61. dataSource: theArr,
  62. pagination: this.state.pagination
  63. });
  64. }.bind(this)
  65. }).always(
  66. function() {
  67. this.setState({
  68. loading: false
  69. });
  70. }.bind(this)
  71. );
  72. },
  73. getInitialState() {
  74. return {
  75. searchMore: true,
  76. selectedRowKeys: [],
  77. selectedRows: [],
  78. loading: false,
  79. releaseDate: [],
  80. pagination: {
  81. defaultCurrent: 1,
  82. defaultPageSize: 10,
  83. showQuickJumper: true,
  84. pageSize: 10,
  85. onChange: function(page) {
  86. this.loadData(page);
  87. this.setState({
  88. selectedRowKeys: []
  89. });
  90. }.bind(this),
  91. showTotal: function(total) {
  92. return '共' + total + '条数据';
  93. }
  94. },
  95. columns: [
  96. {
  97. title: '订单编号',
  98. dataIndex: 'orderNo',
  99. key: 'orderNo'
  100. },
  101. {
  102. title: '订单类型',
  103. dataIndex: 'commodityType',
  104. key: 'commodityType',
  105. render: (text) => {
  106. return getOrderType(text);
  107. }
  108. },
  109. {
  110. title: '订单日期',
  111. dataIndex: 'createTime',
  112. key: 'createTime'
  113. },
  114. {
  115. title: '订单金额',
  116. dataIndex: 'orderAmount',
  117. key: 'orderAmount'
  118. },
  119. {
  120. title: '项目名称',
  121. dataIndex: 'commodityName',
  122. key: 'commodityName',
  123. render: (text) => {
  124. return (
  125. <Tooltip title={text}>
  126. {text && text.length > 6 ? text.substr(0, 6) + '...' : text}
  127. </Tooltip>
  128. );
  129. }
  130. },
  131. {
  132. title: '消费者',
  133. dataIndex: 'buyerName',
  134. key: 'buyerName',
  135. },
  136. {
  137. title: '联系方式',
  138. dataIndex: 'buyerMobile',
  139. key: 'buyerMobile'
  140. },
  141. ],
  142. dataSource: []
  143. };
  144. },
  145. componentWillMount() {
  146. this.loadData();
  147. },
  148. //项目列表整行点击
  149. tableRowClick(record, index) {
  150. this.state.RowData = record;
  151. this.setState({
  152. editvisible: true
  153. });
  154. },
  155. edithandleCancel(e) {
  156. this.setState({
  157. editvisible: false
  158. });
  159. },
  160. search() {
  161. this.loadData();
  162. },
  163. //搜索部分的清零
  164. reset() {
  165. this.state.numberSearch = '';
  166. this.state.typeSearch = undefined;
  167. this.state.companyNameSearch = '';
  168. this.state.entryNameSearch = '';
  169. this.state.releaseDate = [];
  170. this.state.searchMore=true;
  171. this.loadData();
  172. },
  173. searchSwitch() {
  174. this.setState({
  175. searchMore: !this.state.searchMore
  176. });
  177. },
  178. render() {
  179. const FormItem = Form.Item;
  180. const rowSelection = {
  181. selectedRowKeys: this.state.selectedRowKeys,
  182. onChange: (selectedRowKeys, selectedRows) => {
  183. this.setState({
  184. selectedRows: selectedRows.slice(-1),
  185. selectedRowKeys: selectedRowKeys.slice(-1)
  186. });
  187. }
  188. };
  189. const { RangePicker } = DatePicker;
  190. const theData = this.state.RowData || {};
  191. return (
  192. <div className="user-content">
  193. <div className="content-title">
  194. <span>我的订单</span>
  195. </div>
  196. <div className="user-search">
  197. <Input
  198. placeholder="订单编号"
  199. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  200. value={this.state.numberSearch}
  201. onChange={(e) => {
  202. this.setState({ numberSearch: e.target.value });
  203. }}
  204. />
  205. <Input
  206. placeholder="公司名称"
  207. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  208. value={this.state.companyNameSearch}
  209. onChange={(e) => {
  210. this.setState({ companyNameSearch: e.target.value });
  211. }}
  212. />
  213. <Input
  214. placeholder="项目名称"
  215. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  216. value={this.state.entryNameSearch}
  217. onChange={(e) => {
  218. this.setState({ entryNameSearch: e.target.value });
  219. }}
  220. />
  221. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  222. 搜索
  223. </Button>
  224. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  225. 重置
  226. </Button>
  227. <span>
  228. 更多搜索<Switch checked={!this.state.searchMore} onChange={this.searchSwitch} />
  229. </span>
  230. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  231. <span style={{ marginRight: 10 }}>发布时间 :</span>
  232. <RangePicker
  233. value={[
  234. this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  235. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null
  236. ]}
  237. onChange={(data, dataString) => {
  238. this.setState({ releaseDate: dataString });
  239. }}
  240. />
  241. </div>
  242. </div>
  243. <div className="patent-table">
  244. <Spin spinning={this.state.loading}>
  245. <Table
  246. columns={this.state.columns}
  247. dataSource={this.state.dataSource}
  248. rowSelection={rowSelection}
  249. pagination={this.state.pagination}
  250. onRowClick={this.tableRowClick}
  251. />
  252. </Spin>
  253. </div>
  254. <div className="patent-desc">
  255. <Modal
  256. className="customeDetails"
  257. title="订单详情"
  258. width="1000px"
  259. visible={this.state.editvisible}
  260. onOk={this.edithandleCancel}
  261. onCancel={this.edithandleCancel}
  262. footer=""
  263. >
  264. <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
  265. <Spin spinning={this.state.loading}>
  266. <div className="clearfix">
  267. <FormItem
  268. className="half-item"
  269. labelCol={{ span: 8 }}
  270. wrapperCol={{ span: 12 }}
  271. label="订单编号"
  272. >
  273. <span>{theData.orderNo}</span>
  274. </FormItem>
  275. <FormItem
  276. className="half-item"
  277. labelCol={{ span: 8 }}
  278. wrapperCol={{ span: 12 }}
  279. label="订单类型"
  280. >
  281. <span>{getOrderType(theData.commodityType)}</span>
  282. </FormItem>
  283. </div>
  284. <div className="clearfix">
  285. <FormItem
  286. className="half-item"
  287. labelCol={{ span: 8 }}
  288. wrapperCol={{ span: 12 }}
  289. label="订单日期"
  290. >
  291. <span>{theData.createTime}</span>
  292. </FormItem>
  293. <FormItem
  294. className="half-item"
  295. labelCol={{ span: 8 }}
  296. wrapperCol={{ span: 12 }}
  297. label="订单金额"
  298. >
  299. <span>{theData.orderAmount ? theData.orderAmount + '万元' : ''}</span>
  300. </FormItem>
  301. </div>
  302. <div className="clearfix">
  303. <FormItem
  304. className="half-item"
  305. labelCol={{ span: 8 }}
  306. wrapperCol={{ span: 12 }}
  307. label="项目名称"
  308. >
  309. <span>{theData.commodityName}</span>
  310. </FormItem>
  311. </div>
  312. <div className="clearfix">
  313. <FormItem
  314. className="half-item"
  315. labelCol={{ span: 8 }}
  316. wrapperCol={{ span: 12 }}
  317. label="消费者"
  318. >
  319. <span>{theData.buyerName}</span>
  320. </FormItem>
  321. <FormItem
  322. className="half-item"
  323. labelCol={{ span: 8 }}
  324. wrapperCol={{ span: 12 }}
  325. label="联系方式"
  326. >
  327. <span>{theData.buyerMobile}</span>
  328. </FormItem>
  329. </div>
  330. </Spin>
  331. </Form>
  332. </Modal>
  333. </div>
  334. </div>
  335. );
  336. }
  337. })
  338. );
  339. export default Order;