demandOrderX.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. orderType:3,
  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. commodityId:thisdata.commodityId,
  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. 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: 'sellerName',
  139. key: 'sellerName',
  140. },
  141. {
  142. title: '联系方式',
  143. dataIndex: 'sellerMobile',
  144. key: 'sellerMobile',
  145. render:text=>{
  146. return text?text:"暂无"
  147. }
  148. },
  149. {
  150. title: '评价',
  151. dataIndex: 'pingjia',
  152. key: 'pingjia',
  153. render:(text,recard)=>{
  154. return <Button type="primary" onClick={(e)=>{e.stopPropagation(),this.evaluate(recard)}}>评价</Button>
  155. }
  156. }
  157. ],
  158. dataSource: []
  159. };
  160. },
  161. //评价
  162. evaluate(recard){
  163. this.setState({
  164. remark:'',
  165. star:undefined,
  166. orderNo:recard.orderNo,
  167. ids:recard.commodityId,
  168. evaluateVisible:true
  169. })
  170. },
  171. evaluateOk(){
  172. this.setState({
  173. evaluateVisible:false
  174. })
  175. },
  176. evaluateCancel(){
  177. this.setState({
  178. evaluateVisible:false
  179. })
  180. },
  181. componentWillMount() {
  182. this.loadData();
  183. },
  184. //项目列表整行点击
  185. tableRowClick(record, index) {
  186. this.state.RowData = record;
  187. this.setState({
  188. editvisible: true
  189. });
  190. },
  191. edithandleCancel(e) {
  192. this.setState({
  193. editvisible: false
  194. });
  195. },
  196. search() {
  197. this.loadData();
  198. },
  199. //评价
  200. evaluateSubmit(e){
  201. e.preventDefault();
  202. if(!this.state.remark){
  203. message.warning('请填写评价内容');
  204. return;
  205. }
  206. if(!this.state.star){
  207. message.warning('请选择评星等级');
  208. return;
  209. }
  210. this.setState({
  211. loading:true
  212. })
  213. $.ajax({
  214. method:"post",
  215. dataType:'json',
  216. url:globalConfig.context+'/api/user/comment/apply',
  217. data:{
  218. commodityId:this.state.ids,
  219. content:this.state.remark,
  220. star:this.state.star,
  221. orderNo:this.state.orderNo
  222. },
  223. success:function(data){
  224. if(data&&data.error.length){
  225. message.error(data.error[0].message)
  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. <SpinContainer 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. </SpinContainer>
  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. <SpinContainer 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. </SpinContainer>
  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. <SpinContainer spinning={this.state.loading}>
  421. <p style={{marginLeft:40,fontSize:20,marginBottom:15}}>其他买家需要您的建议哦!</p>
  422. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="评价内容">
  423. <Input
  424. type="textarea"
  425. rows={4}
  426. placeholder="输入你的建议"
  427. value={this.state.remark}
  428. onChange={(e) => {
  429. this.setState({ remark: e.target.value });
  430. }}
  431. />
  432. </FormItem>
  433. <FormItem
  434. labelCol={{ span: 4 }}
  435. wrapperCol={{ span: 8 }}
  436. label="评星"
  437. >
  438. <Rate onChange={(e)=>{this.setState({star:e})}} value={this.state.star} />
  439. </FormItem>
  440. <div className="clearfix">
  441. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  442. <Button className="set-submit" type="primary" htmlType="submit" style={{marginRight:15}}>
  443. 提交
  444. </Button>
  445. <Button className="set-submit" type="ghost" onClick={this.evaluateCancel}>
  446. 取消
  447. </Button>
  448. </FormItem>
  449. </div>
  450. </SpinContainer>
  451. </Form>
  452. </Modal>
  453. </div>
  454. );
  455. }
  456. })
  457. );
  458. export default Order;