memberOrderX.jsx 12 KB

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