consumptionOrder.jsx 9.1 KB

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