achievementOrder.jsx 24 KB

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