achievementOrderX.jsx 12 KB

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