achievementOrder.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. import React from 'react';
  2. import { AutoComplete, Icon, Button, Input, InputNumber, Select, Spin, Table, message, Modal, Row, Col, DatePicker } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import './techAchievement.less';
  7. import { orderStatusList } from '../../dataDic.js';
  8. import { befoFile, getSearchUrl, getOrderStatus, companySearch } from '../../tools.js';
  9. import BatchImport from './batchImport';
  10. import throttle from '../../throttle.js';
  11. const AchievementDetail = React.createClass({
  12. getInitialState () {
  13. return {
  14. visible: false,
  15. loading: false,
  16. columns: [
  17. {
  18. title: '状态',
  19. dataIndex: 'status',
  20. key: 'status',
  21. render: text => { return getOrderStatus(text) }
  22. }, {
  23. title: '操作时间',
  24. dataIndex: 'recordTimeFormattedDate',
  25. key: 'recordTimeFormattedDate',
  26. }, {
  27. title: '管理员',
  28. dataIndex: 'operator',
  29. key: 'operator',
  30. }, {
  31. title: '备注',
  32. dataIndex: 'comment',
  33. key: 'comment',
  34. }
  35. ],
  36. dataSource: [],
  37. };
  38. },
  39. loadLogs (id) {
  40. this.setState({
  41. loading: true
  42. });
  43. $.ajax({
  44. method: "get",
  45. dataType: "json",
  46. crossDomain: false,
  47. url: globalConfig.context + "/api/admin/portal/order/achievementOrderLog",
  48. data: {
  49. achievementOrderId: id
  50. },
  51. success: function (data) {
  52. let theArr = [];
  53. if (!data.data) {
  54. if (data.error && data.error.length) {
  55. message.warning(data.error[0].message);
  56. };
  57. } else {
  58. for (let i = 0; i < data.data.length; i++) {
  59. let thisdata = data.data[i];
  60. theArr.push({
  61. key: i,
  62. recordTime: thisdata.recordTime,
  63. status: thisdata.status,
  64. comment: thisdata.comment,
  65. operator: thisdata.operator,
  66. recordTimeFormattedDate: thisdata.recordTimeFormattedDate
  67. });
  68. };
  69. };
  70. this.setState({
  71. dataSource: theArr
  72. });
  73. }.bind(this),
  74. }).always(function () {
  75. this.setState({
  76. loading: false
  77. });
  78. }.bind(this));
  79. },
  80. handleSubmit (e) {
  81. //keyword长度判断
  82. if (this.state.orderStatus || this.state.comment || this.state.recordTime) {
  83. if (this.state.orderStatus && this.state.comment && this.state.recordTime) {
  84. } else {
  85. message.warning('请填写完整的状态流转记录!');
  86. return;
  87. };
  88. };
  89. this.setState({
  90. loading: true
  91. });
  92. $.ajax({
  93. method: "POST",
  94. dataType: "json",
  95. crossDomain: false,
  96. url: globalConfig.context + '/api/admin/portal/order/updateAchievementOrder',
  97. data: {
  98. id: this.props.data.id,
  99. achievementId: this.props.data.achievementId,
  100. status: this.state.orderStatus || this.props.data.status,
  101. recordTimeFormattedDate: this.state.recordTime ? this.state.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined,
  102. comment: this.state.comment,
  103. paymentId: this.state.paymentId,
  104. paymentType: this.state.paymentType,
  105. paymentValue: this.state.paymentValue,
  106. transferPrice: this.state.transferPrice,
  107. }
  108. }).done(function (data) {
  109. this.setState({
  110. loading: false
  111. });
  112. if (!data.error.length) {
  113. message.success('保存成功!');
  114. this.handleOk();
  115. } else {
  116. message.warning(data.error[0].message);
  117. };
  118. }.bind(this));
  119. },
  120. handleCancel (e) {
  121. this.setState({
  122. visible: false,
  123. });
  124. this.props.closeDesc(false);
  125. },
  126. handleOk (e) {
  127. this.setState({
  128. visible: false,
  129. });
  130. this.props.closeDesc(false, true);
  131. },
  132. componentWillReceiveProps (nextProps) {
  133. if (!this.state.visible && nextProps.showDesc && nextProps.data) {
  134. this.loadLogs(nextProps.data.id);
  135. this.state.paymentId = nextProps.data.paymentId;
  136. this.state.paymentType = nextProps.data.paymentType;
  137. this.state.paymentValue = nextProps.data.paymentValue;
  138. this.state.transferPrice = nextProps.data.transferPrice;
  139. this.state.orderStatus = undefined;
  140. this.state.comment = undefined;
  141. this.state.recordTime = undefined;
  142. };
  143. this.state.visible = nextProps.showDesc;
  144. },
  145. render () {
  146. let theData = this.props.data;
  147. if (theData) {
  148. return (
  149. <div className="patent-desc">
  150. <Modal maskClosable={false} visible={this.state.visible}
  151. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  152. width='800px'
  153. footer={null}
  154. title="订单详情"
  155. className="demand-order-content">
  156. <Spin spinning={this.state.loading}>
  157. <Row>
  158. <Col span={3} style={{textAlign:'right'}}>订单编号:</Col>
  159. <Col span={9}>{theData.serialNumber}</Col>
  160. <Col span={3} style={{textAlign:'right'}}>订单状态:</Col>
  161. <Col span={9}>{getOrderStatus(theData.status)}</Col>
  162. </Row>
  163. <Row>
  164. <Col span={3} style={{textAlign:'right'}}>成果编号:</Col>
  165. <Col span={9}>{theData.achievementSerialNumber}</Col>
  166. <Col span={3} style={{textAlign:'right'}}>成果名称:</Col>
  167. <Col span={9}>{theData.name}</Col>
  168. </Row>
  169. <Row>
  170. <Col span={3} style={{textAlign:'right'}}>成果状态:</Col>
  171. <Col span={9}>{(() => {
  172. if (theData.deletedSign == 1) {
  173. return "已删除"
  174. } else if (theData.auditStatus != 3) {
  175. return "已下架"
  176. } else {
  177. return "正常"
  178. }
  179. })()}</Col>
  180. <Col span={3} style={{textAlign:'right'}}>订单所有人:</Col>
  181. <Col span={9}>{theData.theName}</Col>
  182. </Row>
  183. <Row>
  184. <Col span={3} style={{textAlign:'right'}}>接单时间:</Col>
  185. <Col span={9}>{theData.createTimeFormattedDate}</Col>
  186. </Row>
  187. <Row>
  188. <Col span={3} style={{textAlign:'right'}}>订单金额:</Col>
  189. <Col span={9}>
  190. {theData.bargainingMode == 0 ? <div>
  191. <span>价格面议</span>
  192. </div> : <InputNumber
  193. value={this.state.transferPrice}
  194. onChange={(e) => { this.setState({ transferPrice: e }) }} />}
  195. <span> 万元</span>
  196. </Col>
  197. <Col span={3} style={{textAlign:'right'}}>支付金额:</Col>
  198. <Col span={9}>
  199. <InputNumber style={{ width: '160px' }}
  200. value={this.state.paymentValue}
  201. onChange={(e) => { this.setState({ paymentValue: e }) }} />
  202. <span> 元</span>
  203. </Col>
  204. </Row>
  205. <Row>
  206. <Col span={3} style={{textAlign:'right'}}>支付方式:</Col>
  207. <Col span={9}>
  208. <Input
  209. value={this.state.paymentType}
  210. onChange={(e) => { this.setState({ paymentType: e.target.value }) }} />
  211. </Col>
  212. <Col span={3} style={{textAlign:'right'}}>订单流水:</Col>
  213. <Col span={9}>
  214. <Input value={this.state.paymentId}
  215. onChange={(e) => { this.setState({ paymentId: e.target.value }) }} />
  216. </Col>
  217. </Row>
  218. <p>订单状态流转记录</p>
  219. <Table columns={this.state.columns}
  220. dataSource={this.state.dataSource}
  221. pagination={false} />
  222. <Row style={{ marginTop: '20px' }}>
  223. <Col span={3} style={{textAlign:'right'}}>状态:</Col>
  224. <Col span={9}>
  225. <Select style={{ width: 160 }}
  226. value={this.state.orderStatus}
  227. onChange={(e) => { this.setState({ orderStatus: e }); }}>
  228. {(() => {
  229. let theArr = [];
  230. orderStatusList.map(function (item, i) {
  231. theArr.push(<Select.Option key={item.value}>{item.key}</Select.Option>)
  232. });
  233. return theArr;
  234. })()}
  235. </Select>
  236. </Col>
  237. <Col span={3} style={{textAlign:'right'}}>时间:</Col>
  238. <Col span={9}>
  239. <DatePicker style={{ width: '150px' }}
  240. showTime
  241. format="YYYY-MM-DD HH:mm:ss"
  242. placeholder="选择支付时间"
  243. value={this.state.recordTime ? moment(this.state.recordTime, "YYYY-MM-DD HH:mm:ss") : undefined}
  244. onChange={(t, str) => {
  245. this.setState({ recordTime: t });
  246. }} />
  247. </Col>
  248. </Row>
  249. <Row>
  250. <Col span={3} style={{textAlign:'right'}}>备注:</Col>
  251. <Col span={20}>
  252. <Input value={this.state.comment} onChange={(e) => { this.setState({ comment: e.target.value }); }} />
  253. </Col>
  254. </Row>
  255. <Row>
  256. <Col span={3}></Col>
  257. <Col span={20}>
  258. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.handleSubmit}>保存</Button>
  259. <Button className="set-submit" type="ghost" onClick={this.handleCancel}>取消</Button>
  260. </Col>
  261. </Row>
  262. </Spin>
  263. </Modal>
  264. </div>
  265. );
  266. } else {
  267. return <div></div>
  268. }
  269. },
  270. });
  271. const AchievementOrderList = React.createClass({
  272. loadData (pageNo, apiUrl) {
  273. this.setState({
  274. loading: true
  275. });
  276. $.ajax({
  277. method: "get",
  278. dataType: "json",
  279. crossDomain: false,
  280. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  281. data: {
  282. pageNo: pageNo || 1,
  283. pageSize: this.state.pagination.pageSize,
  284. status: this.state.status,
  285. username: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? null : this.state.searchName,
  286. unitName: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? this.state.searchName : null
  287. },
  288. success: function (data) {
  289. let theArr = [];
  290. if (!data.data || !data.data.list) {
  291. if (data.error && data.error.length) {
  292. message.warning(data.error[0].message);
  293. };
  294. } else {
  295. for (let i = 0; i < data.data.list.length; i++) {
  296. let thisdata = data.data.list[i];
  297. theArr.push({
  298. key: i,
  299. id: thisdata.id, //线索单/意向单ID
  300. serialNumber: thisdata.serialNumber, //线索单/意向单编号
  301. achievementId: thisdata.achievementId, //科技需求ID
  302. createTime: thisdata.createTime,
  303. status: thisdata.status, //线索单/意向单状态
  304. paymentvalue: thisdata.paymentvalue,
  305. name: thisdata.name, //成果名称,
  306. achievementSerialNumber: thisdata.achievementSerialNumber, //科技成果编号
  307. deletedSign: thisdata.deletedSign, //科技成果删除标记
  308. auditStatus: thisdata.auditStatus, //科技成果审核状态 //个人用户名称
  309. theName: thisdata.username || thisdata.unitName,
  310. uid: thisdata.uid, //个人用户ID
  311. createTimeFormattedDate: thisdata.createTimeFormattedDate, //接单时间
  312. paymentId: thisdata.paymentId,
  313. paymentTime: thisdata.paymentTime,
  314. paymentTimeFormattedDate: thisdata.paymentTimeFormattedDate,
  315. paymentType: thisdata.paymentType,
  316. paymentValue: thisdata.paymentValue,
  317. transferPrice: thisdata.transferPrice
  318. });
  319. };
  320. this.state.pagination.current = data.data.pageNo;
  321. this.state.pagination.total = data.data.totalCount;
  322. };
  323. this.setState({
  324. dataSource: theArr,
  325. pagination: this.state.pagination
  326. });
  327. }.bind(this),
  328. }).always(function () {
  329. this.setState({
  330. loading: false
  331. });
  332. }.bind(this));
  333. },
  334. handleSearch (e) {
  335. if (this.props['data-detailApiUrl'].indexOf('org') != -1) {
  336. $.ajax({
  337. method: "get",
  338. dataType: "json",
  339. crossDomain: false,
  340. url: globalConfig.context + "/api/admin/achievement/orgOwner",
  341. data: { name: e },
  342. success: function (data) {
  343. let theArr = [];
  344. let theObj = {};
  345. if (!data.data) {
  346. if (data.error && data.error.length) {
  347. message.warning(data.error[0].message);
  348. };
  349. } else if (!$.isEmptyObject(data.data)) {
  350. data.data.map(function (item) {
  351. theArr.push(item.unitName);
  352. theObj[item.unitName] = item.uid;
  353. });
  354. };
  355. this.setState({
  356. searchData: theArr,
  357. dataSourceObj: theObj
  358. });
  359. }.bind(this),
  360. });
  361. } else {
  362. $.ajax({
  363. method: "get",
  364. dataType: "json",
  365. crossDomain: false,
  366. url: globalConfig.context + "/api/admin/achievement/userOwner",
  367. data: { name: e },
  368. success: function (data) {
  369. let theArr = [];
  370. let theObj = {};
  371. if (!data.data) {
  372. if (data.error && data.error.length) {
  373. message.warning(data.error[0].message);
  374. };
  375. } else if (!$.isEmptyObject(data.data)) {
  376. for (let item in data.data) {
  377. theArr.push(data.data[item]);
  378. theObj[data.data[item]] = item;
  379. };
  380. };
  381. this.setState({
  382. dataSource: theArr,
  383. dataSourceObj: theObj
  384. });
  385. }.bind(this),
  386. });
  387. };
  388. },
  389. getInitialState () {
  390. return {
  391. searchData: [],
  392. loading: false,
  393. pagination: {
  394. defaultCurrent: 1,
  395. defaultPageSize: 10,
  396. showQuickJumper: true,
  397. pageSize: 10,
  398. onChange: function (page) {
  399. this.loadData(page);
  400. }.bind(this),
  401. showTotal: function (total) {
  402. return '共' + total + '条数据';
  403. }
  404. },
  405. columns: [
  406. {
  407. title: '编号',
  408. dataIndex: 'serialNumber',
  409. key: 'serialNumber',
  410. }, {
  411. title: '成果名称',
  412. dataIndex: 'name',
  413. key: 'name',
  414. }, {
  415. title: '成果编号',
  416. dataIndex: 'achievementSerialNumber',
  417. key: 'achievementSerialNumber',
  418. }, {
  419. title: '订单所有人',
  420. dataIndex: 'theName',
  421. key: 'theName',
  422. }, {
  423. title: '订单状态',
  424. dataIndex: 'status',
  425. key: 'status',
  426. render: (text, record) => { return getOrderStatus(text); }
  427. }, {
  428. title: '订单金额',
  429. dataIndex: 'paymentValue',
  430. key: 'paymentValue',
  431. }, {
  432. title: '接单时间',
  433. dataIndex: 'createTimeFormattedDate',
  434. key: 'createTimeFormattedDate',
  435. }
  436. ],
  437. dataSource: [],
  438. };
  439. },
  440. componentWillMount () {
  441. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  442. let theArr = [], typeArr = [];
  443. orderStatusList.map(function (item) {
  444. theArr.push(
  445. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  446. )
  447. });
  448. this.state.demandTypeOption = typeArr;
  449. this.state.orderStatusOption = theArr;
  450. this.loadData();
  451. },
  452. componentWillReceiveProps (nextProps) {
  453. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  454. this.state.selectedRowKeys = [];
  455. this.state.selectedRows = [];
  456. this.state.status = undefined;
  457. this.state.searchName = undefined;
  458. this.state.searchData = [];
  459. this.loadData(null, nextProps['data-listApiUrl']);
  460. };
  461. },
  462. tableRowClick (record, index) {
  463. this.state.RowData = record;
  464. this.setState({
  465. showDesc: true
  466. });
  467. },
  468. closeDesc (e, s) {
  469. this.state.showDesc = e;
  470. if (s) {
  471. this.loadData();
  472. };
  473. },
  474. search () {
  475. this.loadData();
  476. },
  477. reset () {
  478. this.state.uid = undefined;
  479. this.state.searchName = undefined;
  480. this.state.status = undefined;
  481. this.loadData();
  482. },
  483. render () {
  484. return (
  485. <div className="user-content" >
  486. <div className="content-title">
  487. {this.props['data-listApiUrl'].indexOf('org') == -1 ? <span>个人成果订单管理</span> : <span>组织成果订单管理</span>}
  488. </div>
  489. <div className="user-search">
  490. <Select placeholder="选择状态" style={{ width: 160 }}
  491. value={this.state.status}
  492. onChange={(e) => { this.setState({ status: e }) }}>
  493. {this.state.orderStatusOption}
  494. </Select>
  495. <AutoComplete
  496. dataSource={this.state.searchData}
  497. style={{ width: 200 }}
  498. value={this.state.searchName}
  499. onSearch={this.state.therottleSearch}
  500. placeholder="输入订单所有人"
  501. onChange={(e) => {
  502. this.setState({ searchName: e });
  503. }} />
  504. <Button type="primary" onClick={this.search}>搜索</Button>
  505. <Button onClick={this.reset}>重置</Button>
  506. </div>
  507. <div className="patent-table">
  508. <Spin spinning={this.state.loading}>
  509. <Table columns={this.state.columns} class="no-all-select"
  510. dataSource={this.state.dataSource}
  511. pagination={this.state.pagination}
  512. style={{
  513. cursor: 'pointer',
  514. }}
  515. onRowClick={this.tableRowClick} />
  516. </Spin>
  517. </div>
  518. <AchievementDetail
  519. data={this.state.RowData}
  520. showDesc={this.state.showDesc}
  521. closeDesc={this.closeDesc} />
  522. </div >
  523. );
  524. }
  525. });
  526. export default AchievementOrderList;