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