adviserX.jsx 12 KB

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