expertX.jsx 12 KB

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