achievementOrder.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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={2}>订单编号:</Col>
  159. <Col span={10}>{theData.serialNumber}</Col>
  160. <Col span={2}>订单状态:</Col>
  161. <Col span={10}>{getOrderStatus(theData.status)}</Col>
  162. </Row>
  163. <Row>
  164. <Col span={2}>成果编号:</Col>
  165. <Col span={10}>{theData.achievementSerialNumber}</Col>
  166. <Col span={2}>成果名称:</Col>
  167. <Col span={10}>{theData.name}</Col>
  168. </Row>
  169. <Row>
  170. <Col span={2}>成果状态:</Col>
  171. <Col span={10}>{(() => {
  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}>订单所有人:</Col>
  181. <Col span={9}>{theData.theName}</Col>
  182. </Row>
  183. <Row>
  184. <Col span={2}>接单时间:</Col>
  185. <Col span={10}>{theData.createTimeFormattedDate}</Col>
  186. </Row>
  187. <Row>
  188. <Col span={2}>订单金额:</Col>
  189. <Col span={10}>
  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={2}>支付金额:</Col>
  198. <Col span={10}>
  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={2}>支付方式:</Col>
  207. <Col span={8}>
  208. <Input
  209. value={this.state.paymentType}
  210. onChange={(e) => { this.setState({ paymentType: e.target.value }) }} />
  211. </Col>
  212. <Col span={2}></Col>
  213. <Col span={2}>订单流水:</Col>
  214. <Col span={8}>
  215. <Input value={this.state.paymentId}
  216. onChange={(e) => { this.setState({ paymentId: e.target.value }) }} />
  217. </Col>
  218. </Row>
  219. <p>订单状态流转记录</p>
  220. <Table columns={this.state.columns}
  221. dataSource={this.state.dataSource}
  222. pagination={false} />
  223. <Row style={{ marginTop: '20px' }}>
  224. <Col span={2}>状态:</Col>
  225. <Col span={10}>
  226. <Select style={{ width: 160 }}
  227. value={this.state.orderStatus}
  228. onChange={(e) => { this.setState({ orderStatus: e }); }}>
  229. {(() => {
  230. let theArr = [];
  231. orderStatusList.map(function (item, i) {
  232. theArr.push(<Select.Option key={item.value}>{item.key}</Select.Option>)
  233. });
  234. return theArr;
  235. })()}
  236. </Select>
  237. </Col>
  238. <Col span={2}>时间:</Col>
  239. <Col span={10}>
  240. <DatePicker style={{ width: '150px' }}
  241. showTime
  242. format="YYYY-MM-DD HH:mm:ss"
  243. placeholder="选择支付时间"
  244. value={this.state.recordTime ? moment(this.state.recordTime, "YYYY-MM-DD HH:mm:ss") : undefined}
  245. onChange={(t, str) => {
  246. this.setState({ recordTime: t });
  247. }} />
  248. </Col>
  249. </Row>
  250. <Row>
  251. <Col span={2}>备注:</Col>
  252. <Col span={20}>
  253. <Input value={this.state.comment} onChange={(e) => { this.setState({ comment: e.target.value }); }} />
  254. </Col>
  255. </Row>
  256. <Row>
  257. <Col span={2}></Col>
  258. <Col span={20}>
  259. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.handleSubmit}>保存</Button>
  260. <Button className="set-submit" type="ghost" onClick={this.handleCancel}>取消</Button>
  261. </Col>
  262. </Row>
  263. </Spin>
  264. </Modal>
  265. </div>
  266. );
  267. } else {
  268. return <div></div>
  269. }
  270. },
  271. });
  272. const AchievementOrderList = React.createClass({
  273. loadData (pageNo, apiUrl) {
  274. this.setState({
  275. loading: true
  276. });
  277. $.ajax({
  278. method: "get",
  279. dataType: "json",
  280. crossDomain: false,
  281. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  282. data: {
  283. pageNo: pageNo || 1,
  284. pageSize: this.state.pagination.pageSize,
  285. status: this.state.status,
  286. unitName: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? null : this.state.searchName,
  287. username: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? this.state.searchName : null
  288. },
  289. success: function (data) {
  290. let theArr = [];
  291. if (!data.data || !data.data.list) {
  292. if (data.error && data.error.length) {
  293. message.warning(data.error[0].message);
  294. };
  295. } else {
  296. for (let i = 0; i < data.data.list.length; i++) {
  297. let thisdata = data.data.list[i];
  298. theArr.push({
  299. key: i,
  300. id: thisdata.id, //线索单/意向单ID
  301. serialNumber: thisdata.serialNumber, //线索单/意向单编号
  302. achievementId: thisdata.achievementId, //科技需求ID
  303. createTime: thisdata.createTime,
  304. status: thisdata.status, //线索单/意向单状态
  305. paymentvalue: thisdata.paymentvalue,
  306. name: thisdata.name, //成果名称,
  307. achievementSerialNumber: thisdata.achievementSerialNumber, //科技成果编号
  308. deletedSign: thisdata.deletedSign, //科技成果删除标记
  309. auditStatus: thisdata.auditStatus, //科技成果审核状态 //个人用户名称
  310. theName: thisdata.username || thisdata.unitName,
  311. uid: thisdata.uid, //个人用户ID
  312. createTimeFormattedDate: thisdata.createTimeFormattedDate, //接单时间
  313. paymentId: thisdata.paymentId,
  314. paymentTime: thisdata.paymentTime,
  315. paymentTimeFormattedDate: thisdata.paymentTimeFormattedDate,
  316. paymentType: thisdata.paymentType,
  317. paymentValue: thisdata.paymentValue,
  318. transferPrice: thisdata.transferPrice
  319. });
  320. };
  321. this.state.pagination.current = data.data.pageNo;
  322. this.state.pagination.total = data.data.totalCount;
  323. };
  324. this.setState({
  325. dataSource: theArr,
  326. pagination: this.state.pagination
  327. });
  328. }.bind(this),
  329. }).always(function () {
  330. this.setState({
  331. loading: false
  332. });
  333. }.bind(this));
  334. },
  335. handleSearch (e) {
  336. if (this.props['data-detailApiUrl'].indexOf('org') != -1) {
  337. $.ajax({
  338. method: "get",
  339. dataType: "json",
  340. crossDomain: false,
  341. url: globalConfig.context + "/api/admin/achievement/orgOwner",
  342. data: { name: e },
  343. success: function (data) {
  344. let theArr = [];
  345. let theObj = {};
  346. if (!data.data) {
  347. if (data.error && data.error.length) {
  348. message.warning(data.error[0].message);
  349. };
  350. } else if (!$.isEmptyObject(data.data)) {
  351. data.data.map(function (item) {
  352. theArr.push(item.unitName);
  353. theObj[item.unitName] = item.uid;
  354. });
  355. };
  356. this.setState({
  357. searchData: theArr,
  358. dataSourceObj: theObj
  359. });
  360. }.bind(this),
  361. });
  362. } else {
  363. $.ajax({
  364. method: "get",
  365. dataType: "json",
  366. crossDomain: false,
  367. url: globalConfig.context + "/api/admin/achievement/userOwner",
  368. data: { name: e },
  369. success: function (data) {
  370. let theArr = [];
  371. let theObj = {};
  372. if (!data.data) {
  373. if (data.error && data.error.length) {
  374. message.warning(data.error[0].message);
  375. };
  376. } else if (!$.isEmptyObject(data.data)) {
  377. for (let item in data.data) {
  378. theArr.push(data.data[item]);
  379. theObj[data.data[item]] = item;
  380. };
  381. };
  382. this.setState({
  383. dataSource: theArr,
  384. dataSourceObj: theObj
  385. });
  386. }.bind(this),
  387. });
  388. };
  389. },
  390. getInitialState () {
  391. return {
  392. searchData: [],
  393. loading: false,
  394. pagination: {
  395. defaultCurrent: 1,
  396. defaultPageSize: 10,
  397. showQuickJumper: true,
  398. pageSize: 10,
  399. onChange: function (page) {
  400. this.loadData(page);
  401. }.bind(this),
  402. showTotal: function (total) {
  403. return '共' + total + '条数据';
  404. }
  405. },
  406. columns: [
  407. {
  408. title: '编号',
  409. dataIndex: 'serialNumber',
  410. key: 'serialNumber',
  411. }, {
  412. title: '成果名称',
  413. dataIndex: 'name',
  414. key: 'name',
  415. }, {
  416. title: '成果编号',
  417. dataIndex: 'achievementSerialNumber',
  418. key: 'achievementSerialNumber',
  419. }, {
  420. title: '订单所有人',
  421. dataIndex: 'theName',
  422. key: 'theName',
  423. }, {
  424. title: '订单状态',
  425. dataIndex: 'status',
  426. key: 'status',
  427. render: (text, record) => { return getOrderStatus(text); }
  428. }, {
  429. title: '订单金额',
  430. dataIndex: 'paymentValue',
  431. key: 'paymentValue',
  432. }, {
  433. title: '接单时间',
  434. dataIndex: 'createTimeFormattedDate',
  435. key: 'createTimeFormattedDate',
  436. }
  437. ],
  438. dataSource: [],
  439. };
  440. },
  441. componentWillMount () {
  442. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  443. let theArr = [], typeArr = [];
  444. orderStatusList.map(function (item) {
  445. theArr.push(
  446. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  447. )
  448. });
  449. this.state.demandTypeOption = typeArr;
  450. this.state.orderStatusOption = theArr;
  451. this.loadData();
  452. },
  453. componentWillReceiveProps (nextProps) {
  454. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  455. this.state.selectedRowKeys = [];
  456. this.state.selectedRows = [];
  457. this.state.status = undefined;
  458. this.state.searchName = undefined;
  459. this.state.searchData = [];
  460. this.loadData(null, nextProps['data-listApiUrl']);
  461. };
  462. },
  463. tableRowClick (record, index) {
  464. this.state.RowData = record;
  465. this.setState({
  466. showDesc: true
  467. });
  468. },
  469. closeDesc (e, s) {
  470. this.state.showDesc = e;
  471. if (s) {
  472. this.loadData();
  473. };
  474. },
  475. search () {
  476. this.loadData();
  477. },
  478. reset () {
  479. this.state.uid = undefined;
  480. this.state.searchName = undefined;
  481. this.state.status = undefined;
  482. this.loadData();
  483. },
  484. render () {
  485. return (
  486. <div className="user-content" >
  487. <div className="content-title">
  488. {this.props['data-listApiUrl'].indexOf('org') == -1 ? <span>个人成果订单管理</span> : <span>组织成果订单管理</span>}
  489. </div>
  490. <div className="user-search">
  491. <Select placeholder="选择状态" style={{ width: 160 }}
  492. value={this.state.status}
  493. onChange={(e) => { this.setState({ status: e }) }}>
  494. {this.state.orderStatusOption}
  495. </Select>
  496. <AutoComplete
  497. dataSource={this.state.searchData}
  498. style={{ width: 200 }}
  499. value={this.state.searchName}
  500. onSearch={this.state.therottleSearch}
  501. placeholder="输入订单所有人"
  502. onChange={(e) => {
  503. this.setState({ searchName: e });
  504. }} />
  505. <Button type="primary" onClick={this.search}>搜索</Button>
  506. <Button onClick={this.reset}>重置</Button>
  507. </div>
  508. <div className="patent-table">
  509. <Spin spinning={this.state.loading}>
  510. <Table columns={this.state.columns} class="no-all-select"
  511. dataSource={this.state.dataSource}
  512. pagination={this.state.pagination}
  513. onRowClick={this.tableRowClick} />
  514. </Spin>
  515. </div>
  516. <AchievementDetail
  517. data={this.state.RowData}
  518. showDesc={this.state.showDesc}
  519. closeDesc={this.closeDesc} />
  520. </div >
  521. );
  522. }
  523. });
  524. export default AchievementOrderList;