achievementOrder.jsx 24 KB

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