achievementOrder.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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. intentionMoney: this.state.intentionMoney * 10000,
  104. contractMoney: this.state.contractMoney * 10000,
  105. commission: this.state.commission * 10000,
  106. serviceMoney: this.state.serviceMoney * 10000,
  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.intentionMoney = nextProps.data.intentionMoney;
  136. this.state.contractMoney = nextProps.data.contractMoney;
  137. this.state.commission = nextProps.data.commission;
  138. this.state.serviceMoney = nextProps.data.serviceMoney;
  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. <InputNumber
  191. value={this.state.intentionMoney}
  192. onChange={(e) => { this.setState({ intentionMoney: Math.round(e * 10000) / 10000 }) }} />
  193. <span> 万元</span>
  194. </Col>
  195. <Col span={2}>合同金:</Col>
  196. <Col span={10}>
  197. <InputNumber
  198. value={this.state.contractMoney}
  199. onChange={(e) => { this.setState({ contractMoney: Math.round(e * 10000) / 10000 }) }} />
  200. <span> 万元</span>
  201. </Col>
  202. </Row>
  203. <Row>
  204. <Col span={2}>佣金:</Col>
  205. <Col span={10}>
  206. <InputNumber
  207. value={this.state.commission}
  208. onChange={(e) => { this.setState({ commission: Math.round(e * 10000) / 10000 }) }} />
  209. <span> 万元</span>
  210. </Col>
  211. <Col span={2}>服务金:</Col>
  212. <Col span={10}>
  213. <InputNumber
  214. value={this.state.serviceMoney}
  215. onChange={(e) => { this.setState({ serviceMoney: Math.round(e * 10000) / 10000 }) }} />
  216. <span> 万元</span>
  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
  241. value={this.state.recordTime || null}
  242. onChange={(e) => { this.setState({ recordTime: e }); }} />
  243. </Col>
  244. </Row>
  245. <Row>
  246. <Col span={2}>备注:</Col>
  247. <Col span={20}>
  248. <Input value={this.state.comment} onChange={(e) => { this.setState({ comment: e.target.value }); }} />
  249. </Col>
  250. </Row>
  251. <Row>
  252. <Col span={2}></Col>
  253. <Col span={20}>
  254. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.handleSubmit}>保存</Button>
  255. <Button className="set-submit" type="ghost" onClick={this.handleCancel}>取消</Button>
  256. </Col>
  257. </Row>
  258. </Spin>
  259. </Modal>
  260. </div>
  261. );
  262. } else {
  263. return <div></div>
  264. }
  265. },
  266. });
  267. const AchievementOrderList = React.createClass({
  268. loadData(pageNo, apiUrl) {
  269. this.setState({
  270. loading: true
  271. });
  272. $.ajax({
  273. method: "get",
  274. dataType: "json",
  275. crossDomain: false,
  276. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  277. data: {
  278. pageNo: pageNo || 1,
  279. pageSize: this.state.pagination.pageSize,
  280. status: this.state.status,
  281. username: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? null : this.state.searchName,
  282. unitName: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? this.state.searchName : null
  283. },
  284. success: function (data) {
  285. let theArr = [];
  286. if (!data.data || !data.data.list) {
  287. if (data.error && data.error.length) {
  288. message.warning(data.error[0].message);
  289. };
  290. } else {
  291. for (let i = 0; i < data.data.list.length; i++) {
  292. let thisdata = data.data.list[i];
  293. theArr.push({
  294. key: i,
  295. id: thisdata.id, //线索单/意向单ID
  296. serialNumber: thisdata.serialNumber, //线索单/意向单编号
  297. achievementId: thisdata.achievementId, //科技需求ID
  298. createTime: thisdata.createTime,
  299. status: thisdata.status, //线索单/意向单状态
  300. intentionMoney: thisdata.intentionMoney / 10000, //意向金
  301. contractMoney: thisdata.contractMoney / 10000, //合同金
  302. commission: thisdata.commission / 10000, //佣金
  303. serviceMoney: thisdata.serviceMoney / 10000, //服务金
  304. name: thisdata.name, //成果名称,
  305. achievementSerialNumber: thisdata.achievementSerialNumber, //科技成果编号
  306. deletedSign: thisdata.deletedSign, //科技成果删除标记
  307. auditStatus: thisdata.auditStatus, //科技成果审核状态 //个人用户名称
  308. theName: thisdata.username || thisdata.unitName,
  309. uid: thisdata.uid, //个人用户ID
  310. createTimeFormattedDate: thisdata.createTimeFormattedDate, //接单时间
  311. });
  312. };
  313. }
  314. this.state.pagination.current = data.data.pageNo;
  315. this.state.pagination.total = data.data.totalCount;
  316. this.setState({
  317. dataSource: theArr,
  318. pagination: this.state.pagination
  319. });
  320. }.bind(this),
  321. }).always(function () {
  322. this.setState({
  323. loading: false
  324. });
  325. }.bind(this));
  326. },
  327. handleSearch(e) {
  328. if (this.props['data-detailApiUrl'].indexOf('org') != -1) {
  329. $.ajax({
  330. method: "get",
  331. dataType: "json",
  332. crossDomain: false,
  333. url: globalConfig.context + "/api/admin/achievement/orgOwner",
  334. data: { name: e },
  335. success: function (data) {
  336. let theArr = [];
  337. let theObj = {};
  338. if (!data.data) {
  339. if (data.error && data.error.length) {
  340. message.warning(data.error[0].message);
  341. };
  342. } else if (!$.isEmptyObject(data.data)) {
  343. data.data.map(function (item) {
  344. theArr.push(item.unitName);
  345. theObj[item.unitName] = item.uid;
  346. });
  347. };
  348. this.setState({
  349. searchData: theArr,
  350. dataSourceObj: theObj
  351. });
  352. }.bind(this),
  353. });
  354. } else {
  355. $.ajax({
  356. method: "get",
  357. dataType: "json",
  358. crossDomain: false,
  359. url: globalConfig.context + "/api/admin/achievement/userOwner",
  360. data: { name: e },
  361. success: function (data) {
  362. let theArr = [];
  363. let theObj = {};
  364. if (!data.data) {
  365. if (data.error && data.error.length) {
  366. message.warning(data.error[0].message);
  367. };
  368. } else if (!$.isEmptyObject(data.data)) {
  369. for (let item in data.data) {
  370. theArr.push(data.data[item]);
  371. theObj[data.data[item]] = item;
  372. };
  373. };
  374. this.setState({
  375. dataSource: theArr,
  376. dataSourceObj: theObj
  377. });
  378. }.bind(this),
  379. });
  380. };
  381. },
  382. getInitialState() {
  383. return {
  384. selectedRowKeys: [],
  385. selectedRows: [],
  386. searchData: [],
  387. loading: false,
  388. pagination: {
  389. defaultCurrent: 1,
  390. defaultPageSize: 10,
  391. showQuickJumper: true,
  392. pageSize: 10,
  393. onChange: function (page) {
  394. this.loadData(page);
  395. }.bind(this),
  396. showTotal: function (total) {
  397. return '共' + total + '条数据';
  398. }
  399. },
  400. columns: [
  401. {
  402. title: '编号',
  403. dataIndex: 'serialNumber',
  404. key: 'serialNumber',
  405. }, {
  406. title: '成果名称',
  407. dataIndex: 'name',
  408. key: 'name',
  409. }, {
  410. title: '成果编号',
  411. dataIndex: 'achievementSerialNumber',
  412. key: 'achievementSerialNumber',
  413. }, {
  414. title: '成果所有人',
  415. dataIndex: 'theName',
  416. key: 'theName',
  417. }, {
  418. title: '订单状态',
  419. dataIndex: 'auditStatus',
  420. key: 'auditStatus',
  421. render: (text, record) => {
  422. if (record.deletedSign == 1) {
  423. return "已删除"
  424. } else if (record.auditStatus != 3) {
  425. return "已下架"
  426. } else {
  427. return "正常"
  428. }
  429. }
  430. }, {
  431. title: '流程状态',
  432. dataIndex: 'status',
  433. key: 'status',
  434. render: (text, record) => { return getOrderStatus(text); }
  435. }, {
  436. title: '意向金(万元)',
  437. dataIndex: 'intentionMoney',
  438. key: 'intentionMoney',
  439. }, {
  440. title: '合同金(万元)',
  441. dataIndex: 'contractMoney',
  442. key: 'contractMoney',
  443. }, {
  444. title: '佣金(万元)',
  445. dataIndex: 'commission',
  446. key: 'commission',
  447. }, {
  448. title: '服务金(万元)',
  449. dataIndex: 'serviceMoney',
  450. key: 'serviceMoney',
  451. }, {
  452. title: '接单时间',
  453. dataIndex: 'createTimeFormattedDate',
  454. key: 'createTimeFormattedDate',
  455. }
  456. ],
  457. dataSource: [],
  458. };
  459. },
  460. componentWillMount() {
  461. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  462. let theArr = [], typeArr = [];
  463. orderStatusList.map(function (item) {
  464. theArr.push(
  465. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  466. )
  467. });
  468. this.state.demandTypeOption = typeArr;
  469. this.state.orderStatusOption = theArr;
  470. // if (window.location.search) {
  471. // let theObj = getSearchUrl(window.location.search);
  472. // if (theObj.rid) {
  473. // theObj.id = theObj.rid;
  474. // if (theObj.rid != 'null') {
  475. // this.tableRowClick(theObj);
  476. // };
  477. // };
  478. // };
  479. this.loadData();
  480. },
  481. componentWillReceiveProps(nextProps) {
  482. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  483. this.state.selectedRowKeys = [];
  484. this.state.selectedRows = [];
  485. this.state.status = undefined;
  486. this.state.searchName = undefined;
  487. this.state.searchData = [];
  488. this.loadData(null, nextProps['data-listApiUrl']);
  489. };
  490. },
  491. tableRowClick(record, index) {
  492. this.state.RowData = record;
  493. this.setState({
  494. showDesc: true
  495. });
  496. },
  497. closeDesc(e, s) {
  498. this.state.showDesc = e;
  499. if (s) {
  500. this.loadData();
  501. };
  502. },
  503. search() {
  504. this.loadData();
  505. },
  506. reset() {
  507. this.state.uid = undefined;
  508. this.state.searchName = undefined;
  509. this.state.status = undefined;
  510. this.loadData();
  511. },
  512. render() {
  513. const rowSelection = {
  514. selectedRowKeys: this.state.selectedRowKeys,
  515. onChange: (selectedRowKeys, selectedRows) => {
  516. this.setState({
  517. selectedRows: selectedRows.splice(-1),
  518. selectedRowKeys: selectedRowKeys.splice(-1)
  519. });
  520. }
  521. };
  522. const hasSelected = this.state.selectedRowKeys.length > 0;
  523. return (
  524. <div className="user-content" >
  525. <div className="content-title">
  526. {this.props['data-listApiUrl'].indexOf('org') == -1 ? <span>个人成果订单管理</span> : <span>组织成果订单管理</span>}
  527. </div>
  528. <div className="user-search">
  529. <Select placeholder="选择状态" style={{ width: 160 }}
  530. value={this.state.status}
  531. onChange={(e) => { this.setState({ status: e }) }}>
  532. {this.state.orderStatusOption}
  533. </Select>
  534. <AutoComplete
  535. dataSource={this.state.searchData}
  536. style={{ width: 200 }}
  537. value={this.state.searchName}
  538. onSearch={this.state.therottleSearch}
  539. placeholder="输入成果所有人"
  540. onChange={(e) => {
  541. this.setState({ searchName: e });
  542. }} />
  543. <Button type="primary" onClick={this.search}>搜索</Button>
  544. <Button onClick={this.reset}>重置</Button>
  545. </div>
  546. <div className="patent-table">
  547. <Spin spinning={this.state.loading}>
  548. <Table columns={this.state.columns}
  549. dataSource={this.state.dataSource}
  550. //rowSelection={rowSelection}
  551. pagination={this.state.pagination}
  552. onRowClick={this.tableRowClick} />
  553. </Spin>
  554. </div>
  555. <AchievementDetail
  556. data={this.state.RowData}
  557. showDesc={this.state.showDesc}
  558. closeDesc={this.closeDesc} />
  559. </div >
  560. );
  561. }
  562. });
  563. export default AchievementOrderList;