memberOrderX.jsx 13 KB

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