projectOrderX.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:10,
  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. buyerId:thisdata.buyerId,
  48. orderNo:thisdata.orderNo,
  49. commodityId:thisdata.commodityId,
  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. render:(text)=>{
  140. return text && text.length >12 ? text.substr(0,12) + '...' : text
  141. }
  142. },
  143. {
  144. title: '联系方式',
  145. dataIndex: 'sellerMobile',
  146. key: 'sellerMobile'
  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. componentWillMount() {
  161. this.loadData();
  162. },
  163. //项目列表整行点击
  164. tableRowClick(record, index) {
  165. this.state.RowData = record;
  166. this.setState({
  167. editvisible: true
  168. });
  169. },
  170. edithandleCancel(e) {
  171. this.setState({
  172. editvisible: false
  173. });
  174. },
  175. search() {
  176. this.loadData();
  177. },
  178. //评价
  179. evaluate(recard){
  180. this.setState({
  181. remark:'',
  182. star:undefined,
  183. orderNo:recard.orderNo,
  184. ids:recard.commodityId,
  185. evaluateVisible:true
  186. })
  187. },
  188. evaluateOk(){
  189. this.setState({
  190. evaluateVisible:false
  191. })
  192. },
  193. evaluateCancel(){
  194. this.setState({
  195. evaluateVisible:false
  196. })
  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. return;
  226. }
  227. message.success('提交成功,感谢您的评价!')
  228. this.loadData(this.state.page);
  229. }.bind(this)
  230. }).always(
  231. function() {
  232. this.setState({
  233. evaluateVisible:false,
  234. loading: false
  235. });
  236. }.bind(this)
  237. );
  238. },
  239. //搜索部分的清零
  240. reset() {
  241. this.state.numberSearch = '';
  242. this.state.typeSearch = undefined;
  243. this.state.companyNameSearch = '';
  244. this.state.entryNameSearch = '';
  245. this.state.releaseDate = [];
  246. this.state.searchMore=true;
  247. this.loadData();
  248. },
  249. searchSwitch() {
  250. this.setState({
  251. searchMore: !this.state.searchMore
  252. });
  253. },
  254. render() {
  255. const FormItem = Form.Item;
  256. const rowSelection = {
  257. selectedRowKeys: this.state.selectedRowKeys,
  258. onChange: (selectedRowKeys, selectedRows) => {
  259. this.setState({
  260. selectedRows: selectedRows.slice(-1),
  261. selectedRowKeys: selectedRowKeys.slice(-1)
  262. });
  263. }
  264. };
  265. const { RangePicker } = DatePicker;
  266. const theData = this.state.RowData || {};
  267. return (
  268. <div className="user-content">
  269. <div className="content-title">
  270. <span>订单列表</span>
  271. </div>
  272. <div className="user-search">
  273. <Input
  274. placeholder="订单编号"
  275. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  276. value={this.state.numberSearch}
  277. onChange={(e) => {
  278. this.setState({ numberSearch: e.target.value });
  279. }}
  280. />
  281. <Input
  282. placeholder="服务商名称"
  283. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  284. value={this.state.companyNameSearch}
  285. onChange={(e) => {
  286. this.setState({ companyNameSearch: e.target.value });
  287. }}
  288. />
  289. <Input
  290. placeholder="项目名称"
  291. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  292. value={this.state.entryNameSearch}
  293. onChange={(e) => {
  294. this.setState({ entryNameSearch: e.target.value });
  295. }}
  296. />
  297. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  298. 搜索
  299. </Button>
  300. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  301. 重置
  302. </Button>
  303. <span>
  304. 更多搜索<Switch checked={!this.state.searchMore} onChange={this.searchSwitch} />
  305. </span>
  306. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  307. <span style={{ marginRight: 10 }}>订单时间 :</span>
  308. <RangePicker
  309. value={[
  310. this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  311. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null
  312. ]}
  313. onChange={(data, dataString) => {
  314. this.setState({ releaseDate: dataString });
  315. }}
  316. />
  317. </div>
  318. </div>
  319. <div className="patent-table">
  320. <Spin spinning={this.state.loading}>
  321. <Table
  322. columns={this.state.columns}
  323. dataSource={this.state.dataSource}
  324. rowSelection={rowSelection}
  325. pagination={this.state.pagination}
  326. onRowClick={this.tableRowClick}
  327. />
  328. </Spin>
  329. </div>
  330. <div className="patent-desc">
  331. <Modal
  332. className="customeDetails"
  333. title="订单详情"
  334. width="1000px"
  335. visible={this.state.editvisible}
  336. onOk={this.edithandleCancel}
  337. onCancel={this.edithandleCancel}
  338. footer=""
  339. >
  340. <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
  341. <Spin spinning={this.state.loading}>
  342. <div className="clearfix">
  343. <FormItem
  344. className="half-item"
  345. labelCol={{ span: 8 }}
  346. wrapperCol={{ span: 12 }}
  347. label="订单编号"
  348. >
  349. <span>{theData.orderNo}</span>
  350. </FormItem>
  351. <FormItem
  352. className="half-item"
  353. labelCol={{ span: 8 }}
  354. wrapperCol={{ span: 12 }}
  355. label="订单类型"
  356. >
  357. <span>{getOrderType(theData.commodityType)}</span>
  358. </FormItem>
  359. </div>
  360. <div className="clearfix">
  361. <FormItem
  362. className="half-item"
  363. labelCol={{ span: 8 }}
  364. wrapperCol={{ span: 12 }}
  365. label="订单日期"
  366. >
  367. <span>{theData.createTime}</span>
  368. </FormItem>
  369. <FormItem
  370. className="half-item"
  371. labelCol={{ span: 8 }}
  372. wrapperCol={{ span: 12 }}
  373. label="订单金额(万元)"
  374. >
  375. <span>{theData.orderAmount ? theData.orderAmount + '万元' : '面议'}</span>
  376. </FormItem>
  377. </div>
  378. <div className="clearfix">
  379. <FormItem
  380. className="half-item"
  381. labelCol={{ span: 8 }}
  382. wrapperCol={{ span: 12 }}
  383. label="项目名称"
  384. >
  385. <span>{theData.commodityName}</span>
  386. </FormItem>
  387. </div>
  388. <div className="clearfix">
  389. <FormItem
  390. className="half-item"
  391. labelCol={{ span: 8 }}
  392. wrapperCol={{ span: 12 }}
  393. label="服务商"
  394. >
  395. <span>{theData.sellerName}</span>
  396. </FormItem>
  397. <FormItem
  398. className="half-item"
  399. labelCol={{ span: 8 }}
  400. wrapperCol={{ span: 12 }}
  401. label="联系方式"
  402. >
  403. <span>{theData.sellerMobile}</span>
  404. </FormItem>
  405. </div>
  406. </Spin>
  407. </Form>
  408. </Modal>
  409. </div>
  410. <Modal
  411. title="评价"
  412. width="600px"
  413. visible={this.state.evaluateVisible}
  414. onOk={this.evaluateOk}
  415. okText="提交"
  416. onCancel={this.evaluateCancel}
  417. footer=''
  418. >
  419. <Form layout="horizontal" onSubmit={this.evaluateSubmit} >
  420. <Spin spinning={this.state.loading}>
  421. <p style={{marginLeft:40,fontSize:20,marginBottom:15}}>其他买家需要您的建议哦!</p>
  422. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }}
  423. label={<span><i style={{color:'#f00'}}> * </i>评价内容</span>}>
  424. <Input
  425. type="textarea"
  426. rows={4}
  427. placeholder="输入你的建议"
  428. value={this.state.remark}
  429. onChange={(e) => {
  430. this.setState({ remark: e.target.value });
  431. }}
  432. />
  433. </FormItem>
  434. <FormItem
  435. labelCol={{ span: 4 }}
  436. wrapperCol={{ span: 8 }}
  437. label={<span><i style={{color:'#f00'}}> * </i>评星</span>}
  438. >
  439. <Rate onChange={(e)=>{this.setState({star:e})}} value={this.state.star} />
  440. </FormItem>
  441. <div className="clearfix">
  442. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  443. <Button className="set-submit" type="primary" htmlType="submit" style={{marginRight:15}}>
  444. 提交
  445. </Button>
  446. <Button className="set-submit" type="ghost" onClick={this.evaluateCancel}>
  447. 取消
  448. </Button>
  449. </FormItem>
  450. </div>
  451. </Spin>
  452. </Form>
  453. </Modal>
  454. </div>
  455. );
  456. }
  457. })
  458. );
  459. export default Order;