demandOrderX.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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,Rate, 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. orderType:3,
  30. commodityName: this.state.entryNameSearch,
  31. sellerName: 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. commodityId:thisdata.commodityId,
  48. buyerId:thisdata.buyerId,
  49. orderNo:thisdata.orderNo,
  50. commodityType:thisdata.commodityType,
  51. orderAmount:thisdata.orderAmount,
  52. commodityName:thisdata.commodityName,
  53. sellerName:thisdata.sellerName!=null?thisdata.sellerName:'佚名',
  54. sellerMobile:thisdata.sellerMobile,
  55. createTime: thisdata.createTime ? new Date(thisdata.createTime).toLocaleString() : ''
  56. });
  57. }
  58. this.state.pagination.current = data.data.pageNo;
  59. this.state.pagination.total = data.data.totalCount;
  60. }
  61. this.setState({
  62. dataSource: theArr,
  63. pagination: this.state.pagination
  64. });
  65. }.bind(this)
  66. }).always(
  67. function() {
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this)
  72. );
  73. },
  74. getInitialState() {
  75. return {
  76. searchMore: true,
  77. selectedRowKeys: [],
  78. selectedRows: [],
  79. loading: false,
  80. releaseDate: [],
  81. pagination: {
  82. defaultCurrent: 1,
  83. defaultPageSize: 10,
  84. showQuickJumper: true,
  85. pageSize: 10,
  86. onChange: function(page) {
  87. this.loadData(page);
  88. this.setState({
  89. selectedRowKeys: []
  90. });
  91. }.bind(this),
  92. showTotal: function(total) {
  93. return '共' + total + '条数据';
  94. }
  95. },
  96. columns: [
  97. {
  98. title: '订单编号',
  99. dataIndex: 'orderNo',
  100. key: 'orderNo'
  101. },
  102. {
  103. title: '订单类型',
  104. dataIndex: 'commodityType',
  105. key: 'commodityType',
  106. render: (text) => {
  107. return getOrderType(text);
  108. }
  109. },
  110. {
  111. title: '订单日期',
  112. dataIndex: 'createTime',
  113. key: 'createTime'
  114. },
  115. {
  116. title: '订单金额(万元)',
  117. dataIndex: 'orderAmount',
  118. key: 'orderAmount',
  119. render:(text)=>{
  120. return text?text:'面议'
  121. }
  122. },
  123. {
  124. title: '项目名称',
  125. dataIndex: 'commodityName',
  126. key: 'commodityName',
  127. render: (text) => {
  128. return (
  129. <Tooltip title={text}>
  130. {text && text.length >12 ? text.substr(0, 12) + '...' : text}
  131. </Tooltip>
  132. );
  133. }
  134. },
  135. {
  136. title: '服务商',
  137. dataIndex: 'sellerName',
  138. key: 'sellerName',
  139. },
  140. {
  141. title: '联系方式',
  142. dataIndex: 'sellerMobile',
  143. key: 'sellerMobile',
  144. render:text=>{
  145. return text?text:"暂无"
  146. }
  147. },
  148. {
  149. title: '评价',
  150. dataIndex: 'pingjia',
  151. key: 'pingjia',
  152. render:(text,recard)=>{
  153. return <Button type="primary" onClick={(e)=>{e.stopPropagation(),this.evaluate(recard)}}>评价</Button>
  154. }
  155. }
  156. ],
  157. dataSource: []
  158. };
  159. },
  160. //评价
  161. evaluate(recard){
  162. this.setState({
  163. remark:'',
  164. star:undefined,
  165. orderNo:recard.orderNo,
  166. ids:recard.commodityId,
  167. evaluateVisible:true
  168. })
  169. },
  170. evaluateOk(){
  171. this.setState({
  172. evaluateVisible:false
  173. })
  174. },
  175. evaluateCancel(){
  176. this.setState({
  177. evaluateVisible:false
  178. })
  179. },
  180. componentWillMount() {
  181. this.loadData();
  182. },
  183. //项目列表整行点击
  184. tableRowClick(record, index) {
  185. this.state.RowData = record;
  186. this.setState({
  187. editvisible: true
  188. });
  189. },
  190. edithandleCancel(e) {
  191. this.setState({
  192. editvisible: false
  193. });
  194. },
  195. search() {
  196. this.loadData();
  197. },
  198. //评价
  199. evaluateSubmit(e){
  200. e.preventDefault();
  201. if(!this.state.remark){
  202. message.warning('请填写评价内容');
  203. return;
  204. }
  205. if(!this.state.star){
  206. message.warning('请选择评星等级');
  207. return;
  208. }
  209. this.setState({
  210. loading:true
  211. })
  212. $.ajax({
  213. method:"post",
  214. dataType:'json',
  215. url:globalConfig.context+'/api/user/comment/apply',
  216. data:{
  217. commodityId:this.state.ids,
  218. content:this.state.remark,
  219. star:this.state.star,
  220. orderNo:this.state.orderNo
  221. },
  222. success:function(data){
  223. if(data&&data.error.length){
  224. message.error(data.error[0].message)
  225. }
  226. message.success('提交成功,感谢您的评价!')
  227. this.loadData(this.state.page);
  228. }.bind(this)
  229. }).always(
  230. function() {
  231. this.setState({
  232. evaluateVisible:false,
  233. loading: false
  234. });
  235. }.bind(this)
  236. );
  237. },
  238. //搜索部分的清零
  239. reset() {
  240. this.state.numberSearch = '';
  241. this.state.typeSearch = undefined;
  242. this.state.companyNameSearch = '';
  243. this.state.entryNameSearch = '';
  244. this.state.releaseDate = [];
  245. this.state.searchMore=true;
  246. this.loadData();
  247. },
  248. searchSwitch() {
  249. this.setState({
  250. searchMore: !this.state.searchMore
  251. });
  252. },
  253. render() {
  254. const FormItem = Form.Item;
  255. const rowSelection = {
  256. selectedRowKeys: this.state.selectedRowKeys,
  257. onChange: (selectedRowKeys, selectedRows) => {
  258. this.setState({
  259. selectedRows: selectedRows.slice(-1),
  260. selectedRowKeys: selectedRowKeys.slice(-1)
  261. });
  262. }
  263. };
  264. const { RangePicker } = DatePicker;
  265. const theData = this.state.RowData || {};
  266. return (
  267. <div className="user-content">
  268. <div className="content-title">
  269. <span>需求订单列表</span>
  270. </div>
  271. <div className="user-search">
  272. <Input
  273. placeholder="订单编号"
  274. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  275. value={this.state.numberSearch}
  276. onChange={(e) => {
  277. this.setState({ numberSearch: e.target.value });
  278. }}
  279. />
  280. <Input
  281. placeholder="服务商名称"
  282. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  283. value={this.state.companyNameSearch}
  284. onChange={(e) => {
  285. this.setState({ companyNameSearch: e.target.value });
  286. }}
  287. />
  288. <Input
  289. placeholder="项目名称"
  290. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  291. value={this.state.entryNameSearch}
  292. onChange={(e) => {
  293. this.setState({ entryNameSearch: e.target.value });
  294. }}
  295. />
  296. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  297. 搜索
  298. </Button>
  299. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  300. 重置
  301. </Button>
  302. <span>
  303. 更多搜索<Switch checked={!this.state.searchMore} onChange={this.searchSwitch} />
  304. </span>
  305. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  306. <span style={{ marginRight: 10 }}>订单时间 :</span>
  307. <RangePicker
  308. value={[
  309. this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  310. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null
  311. ]}
  312. onChange={(data, dataString) => {
  313. this.setState({ releaseDate: dataString });
  314. }}
  315. />
  316. </div>
  317. </div>
  318. <div className="patent-table">
  319. <Spin spinning={this.state.loading}>
  320. <Table
  321. columns={this.state.columns}
  322. dataSource={this.state.dataSource}
  323. rowSelection={rowSelection}
  324. pagination={this.state.pagination}
  325. onRowClick={this.tableRowClick}
  326. />
  327. </Spin>
  328. </div>
  329. <div className="patent-desc">
  330. <Modal
  331. className="customeDetails"
  332. title="订单详情"
  333. width="1000px"
  334. visible={this.state.editvisible}
  335. onOk={this.edithandleCancel}
  336. onCancel={this.edithandleCancel}
  337. footer=""
  338. >
  339. <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
  340. <Spin spinning={this.state.loading}>
  341. <div className="clearfix">
  342. <FormItem
  343. className="half-item"
  344. labelCol={{ span: 8 }}
  345. wrapperCol={{ span: 12 }}
  346. label="订单编号"
  347. >
  348. <span>{theData.orderNo}</span>
  349. </FormItem>
  350. <FormItem
  351. className="half-item"
  352. labelCol={{ span: 8 }}
  353. wrapperCol={{ span: 12 }}
  354. label="订单类型"
  355. >
  356. <span>{getOrderType(theData.commodityType)}</span>
  357. </FormItem>
  358. </div>
  359. <div className="clearfix">
  360. <FormItem
  361. className="half-item"
  362. labelCol={{ span: 8 }}
  363. wrapperCol={{ span: 12 }}
  364. label="订单日期"
  365. >
  366. <span>{theData.createTime}</span>
  367. </FormItem>
  368. <FormItem
  369. className="half-item"
  370. labelCol={{ span: 8 }}
  371. wrapperCol={{ span: 12 }}
  372. label="订单金额(万元)"
  373. >
  374. <span>{theData.orderAmount ? theData.orderAmount + '万元' : '面议'}</span>
  375. </FormItem>
  376. </div>
  377. <div className="clearfix">
  378. <FormItem
  379. className="half-item"
  380. labelCol={{ span: 8 }}
  381. wrapperCol={{ span: 12 }}
  382. label="项目名称"
  383. >
  384. <span>{theData.commodityName}</span>
  385. </FormItem>
  386. </div>
  387. <div className="clearfix">
  388. <FormItem
  389. className="half-item"
  390. labelCol={{ span: 8 }}
  391. wrapperCol={{ span: 12 }}
  392. label="服务商"
  393. >
  394. <span>{theData.sellerName}</span>
  395. </FormItem>
  396. <FormItem
  397. className="half-item"
  398. labelCol={{ span: 8 }}
  399. wrapperCol={{ span: 12 }}
  400. label="联系方式"
  401. >
  402. <span>{theData.sellerMobile}</span>
  403. </FormItem>
  404. </div>
  405. </Spin>
  406. </Form>
  407. </Modal>
  408. </div>
  409. <Modal
  410. title="评价"
  411. width="600px"
  412. visible={this.state.evaluateVisible}
  413. onOk={this.evaluateOk}
  414. okText="提交"
  415. onCancel={this.evaluateCancel}
  416. footer=''
  417. >
  418. <Form layout="horizontal" onSubmit={this.evaluateSubmit} >
  419. <Spin spinning={this.state.loading}>
  420. <p style={{marginLeft:40,fontSize:20,marginBottom:15}}>其他买家需要您的建议哦!</p>
  421. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="评价内容">
  422. <Input
  423. type="textarea"
  424. rows={4}
  425. placeholder="输入你的建议"
  426. value={this.state.remark}
  427. onChange={(e) => {
  428. this.setState({ remark: e.target.value });
  429. }}
  430. />
  431. </FormItem>
  432. <FormItem
  433. labelCol={{ span: 4 }}
  434. wrapperCol={{ span: 8 }}
  435. label="评星"
  436. >
  437. <Rate onChange={(e)=>{this.setState({star:e})}} value={this.state.star} />
  438. </FormItem>
  439. <div className="clearfix">
  440. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  441. <Button className="set-submit" type="primary" htmlType="submit" style={{marginRight:15}}>
  442. 提交
  443. </Button>
  444. <Button className="set-submit" type="ghost" onClick={this.evaluateCancel}>
  445. 取消
  446. </Button>
  447. </FormItem>
  448. </div>
  449. </Spin>
  450. </Form>
  451. </Modal>
  452. </div>
  453. );
  454. }
  455. })
  456. );
  457. export default Order;