projectOrderS.jsx 9.2 KB

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