activityCostList.jsx 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. import React from 'react';
  2. import { Icon, Form, Upload, Button, Input, Spin, Table, message, Select, Modal, DatePicker, InputNumber } from 'antd';
  3. import './activityCostList.less';
  4. import { beforeUploadFile } from '../../tools.js';
  5. import moment from 'moment';
  6. import ajax from 'jquery/src/ajax/xhr.js';
  7. import $ from 'jquery/src/ajax';
  8. const ActivityDescFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false,
  12. activityNumberOption: [],
  13. };
  14. },
  15. componentWillMount() {
  16. let _me = this;
  17. this.props.activityNumberList.map(function (item) {
  18. _me.state.activityNumberOption.push(
  19. <Select.Option value={item.aid} key={item.uid}>{item.activityNumber}</Select.Option>
  20. )
  21. });
  22. },
  23. allCostCount() {
  24. this.state.internalAllCost = this.props.form.getFieldValue('internalLaborCost') + this.props.form.getFieldValue('internalDirectCost') +
  25. this.props.form.getFieldValue('internalDepreciationCost') + this.props.form.getFieldValue('internalAmortizationCost') +
  26. this.props.form.getFieldValue('internalDesignCost') + this.props.form.getFieldValue('internalEquipmentCost') +
  27. this.props.form.getFieldValue('internalOtherCost');
  28. this.state.allCost = this.props.form.getFieldValue('internalLaborCost') + this.props.form.getFieldValue('internalDirectCost') +
  29. this.props.form.getFieldValue('internalDepreciationCost') + this.props.form.getFieldValue('internalAmortizationCost') +
  30. this.props.form.getFieldValue('internalDesignCost') + this.props.form.getFieldValue('internalEquipmentCost') +
  31. this.props.form.getFieldValue('internalOtherCost') + this.props.form.getFieldValue('externalTotalCost');
  32. },
  33. componentDidMount() {
  34. this.allCostCount();
  35. this.setState({
  36. loading: false
  37. });
  38. },
  39. componentWillReceiveProps() {
  40. this.allCostCount();
  41. },
  42. handleSubmit(e) {
  43. e.preventDefault();
  44. this.props.form.validateFields((err, values) => {
  45. if (!err) {
  46. this.props.spinState(true);
  47. $.ajax({
  48. method: "POST",
  49. dataType: "json",
  50. crossDomain: false,
  51. url: globalConfig.context + "/techservice/cognizance/activityCost",
  52. data: {
  53. id: this.props.data.id,
  54. aid: this.state.aid,
  55. activityNumber: this.state.activityNumber,
  56. internalLaborCost: values.internalLaborCost,
  57. internalDirectCost: values.internalDirectCost,
  58. internalDepreciationCost: values.internalDepreciationCost,
  59. internalAmortizationCost: values.internalAmortizationCost,
  60. internalDesignCost: values.internalDesignCost,
  61. internalEquipmentCost: values.internalEquipmentCost,
  62. internalOtherCost: values.internalOtherCost,
  63. externalTotalCost: values.externalTotalCost,
  64. externalAbroadCost: values.externalAbroadCost,
  65. enterpriseFiller: values.enterpriseFiller,
  66. signDateFormattedDate: values.signDate.format('YYYY-MM-DD'),
  67. sortNumber: values.sortNumber
  68. }
  69. }).done(function (data) {
  70. if (!data.error.length) {
  71. message.success('保存成功!');
  72. } else {
  73. message.warning(data.error[0].message);
  74. }
  75. }.bind(this)).always(function () {
  76. this.props.spinState(false);
  77. this.props.closeModal();
  78. this.props.form.resetFields();
  79. }.bind(this));
  80. }
  81. });
  82. },
  83. render() {
  84. const FormItem = Form.Item;
  85. const { getFieldDecorator } = this.props.form;
  86. const theData = this.props.data;
  87. const formItemLayout = {
  88. labelCol: { span: 14 },
  89. wrapperCol: { span: 8 },
  90. };
  91. const _me = this;
  92. return (
  93. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  94. <p className="activityCost-title">项目编号</p>
  95. {
  96. theData.activityNumber ? <span>{theData.activityNumber}</span> :
  97. <Select placeholder="请选择项目编号" style={{ width: 200 }}
  98. onSelect={(e, n) => { this.state.aid = e; this.state.activityNumber = n.props.children }}>
  99. {this.state.activityNumberOption}
  100. </Select>
  101. }
  102. <p className="activityCost-title">内部研究开发费用(万元)</p>
  103. <div className="clearfix activityCost-box">
  104. <FormItem className="half-item"
  105. {...formItemLayout}
  106. label="共计(万元)"
  107. >
  108. {getFieldDecorator('internalAllCost')(
  109. <span className="number-box">
  110. {this.state.internalAllCost}
  111. </span>
  112. )}
  113. </FormItem>
  114. <FormItem className="half-item"
  115. {...formItemLayout}
  116. label="人员人工费用(万元)"
  117. >
  118. {getFieldDecorator('internalLaborCost', {
  119. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  120. initialValue: theData.internalLaborCost
  121. })(
  122. <InputNumber />
  123. )}
  124. </FormItem>
  125. <FormItem className="half-item"
  126. {...formItemLayout}
  127. label="直接投入费用(万元)"
  128. >
  129. {getFieldDecorator('internalDirectCost', {
  130. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  131. initialValue: theData.internalDirectCost
  132. })(
  133. <InputNumber />
  134. )}
  135. </FormItem>
  136. <FormItem className="half-item"
  137. {...formItemLayout}
  138. label="折旧费用与长期待摊费用(万元)"
  139. >
  140. {getFieldDecorator('internalDepreciationCost', {
  141. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  142. initialValue: theData.internalDepreciationCost
  143. })(
  144. <InputNumber />
  145. )}
  146. </FormItem>
  147. <FormItem className="half-item"
  148. {...formItemLayout}
  149. label="无形资产摊销费用(万元)"
  150. >
  151. {getFieldDecorator('internalAmortizationCost', {
  152. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  153. initialValue: theData.internalAmortizationCost
  154. })(
  155. <InputNumber />
  156. )}
  157. </FormItem>
  158. <FormItem className="half-item"
  159. {...formItemLayout}
  160. label="设计费用(万元)"
  161. >
  162. {getFieldDecorator('internalDesignCost', {
  163. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  164. initialValue: theData.internalDesignCost
  165. })(
  166. <InputNumber />
  167. )}
  168. </FormItem>
  169. <FormItem className="half-item"
  170. {...formItemLayout}
  171. label="装备调试费用与实验费用(万元)"
  172. >
  173. {getFieldDecorator('internalEquipmentCost', {
  174. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  175. initialValue: theData.internalEquipmentCost
  176. })(
  177. <InputNumber />
  178. )}
  179. </FormItem>
  180. <FormItem className="half-item"
  181. {...formItemLayout}
  182. label="其他费用(万元)"
  183. >
  184. {getFieldDecorator('internalOtherCost', {
  185. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  186. initialValue: theData.internalOtherCost
  187. })(
  188. <InputNumber />
  189. )}
  190. </FormItem>
  191. </div>
  192. <p className="activityCost-title">委托外部研究开发费用(万元)</p>
  193. <div className="clearfix activityCost-box">
  194. <FormItem className="half-item"
  195. {...formItemLayout}
  196. label="共计(万元)"
  197. >
  198. {getFieldDecorator('externalTotalCost', {
  199. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  200. initialValue: theData.externalTotalCost
  201. })(
  202. <InputNumber />
  203. )}
  204. </FormItem>
  205. <FormItem className="half-item"
  206. {...formItemLayout}
  207. label="境内的外部研发费用"
  208. >
  209. {getFieldDecorator('externalAbroadCost', {
  210. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  211. initialValue: theData.externalAbroadCost
  212. })(
  213. <InputNumber />
  214. )}
  215. </FormItem>
  216. </div>
  217. <p className="activityCost-title">研发开发费用(内、外部)小计(万元)</p>
  218. <div className="clearfix activityCost-box">
  219. <FormItem className="half-item"
  220. {...formItemLayout}
  221. label="共计(万元)"
  222. >
  223. {getFieldDecorator('allCost')(
  224. <span className="number-box">
  225. {this.state.allCost}
  226. </span>
  227. )}
  228. </FormItem>
  229. <FormItem className="half-item"
  230. {...formItemLayout}
  231. label="企业填报人"
  232. >
  233. {getFieldDecorator('enterpriseFiller', {
  234. rules: [{ required: true, message: '此项为必填项!' }],
  235. initialValue: theData.enterpriseFiller
  236. })(
  237. <Input />
  238. )}
  239. </FormItem>
  240. <FormItem className="half-item"
  241. {...formItemLayout}
  242. label="企业填报人签字日期"
  243. >
  244. {getFieldDecorator('signDate', {
  245. rules: [{ type: "object", required: true, message: '此项为必填项!' }],
  246. initialValue: theData.signDate ? moment(theData.signDate) : null
  247. })(
  248. <DatePicker onChange={(date, dateString) => { this.state.signDateFormattedDate = dateString }} />
  249. )}
  250. </FormItem>
  251. <FormItem className="half-item"
  252. {...formItemLayout}
  253. label="排序号"
  254. >
  255. {getFieldDecorator('sortNumber', {
  256. rules: [{ required: true, message: '此项为必填项!' }],
  257. initialValue: theData.sortNumber
  258. })(
  259. <Input />
  260. )}
  261. </FormItem>
  262. </div>
  263. <div style={{ marginTop:'20px',width: '50%' }}>
  264. <Upload
  265. name="ratepay"
  266. action={globalConfig.context + "/techservice/cognizance/upload"}
  267. data={{ 'sign': this.props.year + 'proof' }}
  268. beforeUpload={beforeUploadFile}
  269. onChange={(info) => {
  270. if (info.file.status !== 'uploading') {
  271. console.log(info.file, info.fileList);
  272. }
  273. if (info.file.status === 'done') {
  274. message.success(`${info.file.name} 文件上传成功!`);
  275. this.state.proofUrl = info.file.response.data;
  276. } else if (info.file.status === 'error') {
  277. message.error(`${info.file.name} 文件上传失败。`);
  278. }
  279. }}
  280. >
  281. <Button><Icon type="upload" /> 上传台账 </Button>
  282. </Upload>
  283. </div>
  284. <FormItem style={{ marginTop: '20px' }}>
  285. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  286. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  287. </FormItem>
  288. </Form >
  289. );
  290. },
  291. }));
  292. const ActivityDesc = React.createClass({
  293. getInitialState() {
  294. return {
  295. visible: false,
  296. loading: false
  297. };
  298. },
  299. componentWillReceiveProps(nextProps) {
  300. this.state.visible = nextProps.showDesc
  301. },
  302. showModal() {
  303. this.setState({
  304. visible: true,
  305. });
  306. },
  307. handleOk() {
  308. this.setState({
  309. visible: false,
  310. });
  311. this.props.closeDesc(false);
  312. },
  313. handleCancel(e) {
  314. this.setState({
  315. visible: false,
  316. });
  317. this.props.closeDesc(false);
  318. },
  319. spinChange(e) {
  320. this.setState({
  321. loading: e
  322. });
  323. },
  324. render() {
  325. return (
  326. <div className="patent-addNew">
  327. <Spin spinning={this.state.loading} className='spin-box'>
  328. <Modal title="企业年度研究开发费用结构明细" visible={this.state.visible}
  329. onOk={this.handleOk} onCancel={this.handleCancel}
  330. width='800px'
  331. footer=''
  332. >
  333. <ActivityDescFrom data={this.props.data} activityNumberList={this.props.activityNumberList}
  334. spinState={this.spinChange} closeModal={this.handleCancel} />
  335. </Modal>
  336. </Spin>
  337. </div>
  338. );
  339. },
  340. });
  341. const Activity = React.createClass({
  342. loadData(pageNo) {
  343. this.state.data = [];
  344. this.setState({
  345. loading: true
  346. });
  347. $.when($.ajax({
  348. method: "post",
  349. dataType: "json",
  350. crossDomain: false,
  351. url: globalConfig.context + "/techservice/cognizance/activityCostList",
  352. data: {
  353. pageNo: pageNo || 1,
  354. pageSize: this.state.pagination.pageSize,
  355. activityNumber: this.state.activityNumber,
  356. startDate: this.state.startDate,
  357. endDate: this.state.endDate
  358. }
  359. }), $.ajax({
  360. method: "get",
  361. dataType: "json",
  362. crossDomain: false,
  363. url: globalConfig.context + "/techservice/cognizance/activityNumber",
  364. })).done((data1, data2) => {
  365. let data = data1[0];
  366. let activityNumber = data2[0];
  367. if (data.error.length || !data.data || !data.data.list) {
  368. message.warning(data.error[0].message);
  369. return;
  370. };
  371. if (activityNumber.error.length || !activityNumber.data) {
  372. message.warning(activityNumber.error[0].message);
  373. return;
  374. };
  375. for (let i = 0; i < data.data.list.length; i++) {
  376. let thisdata = data.data.list[i];
  377. this.state.data.push({
  378. key: i,
  379. id: thisdata.id,
  380. uid: thisdata.uid,
  381. aid: thisdata.aid,
  382. activityNumber: thisdata.activityNumber,
  383. startDate: thisdata.startDate,
  384. endDate: thisdata.endDate,
  385. internalAllCost:
  386. thisdata.internalLaborCost + thisdata.internalDirectCost + thisdata.internalDepreciationCost +
  387. thisdata.internalAmortizationCost + thisdata.internalAmortizationCost + thisdata.internalDesignCost +
  388. thisdata.internalEquipmentCost + thisdata.internalOtherCost,
  389. internalLaborCost: thisdata.internalLaborCost,
  390. internalDirectCost: thisdata.internalDirectCost,
  391. internalDepreciationCost: thisdata.internalDepreciationCost,
  392. internalAmortizationCost: thisdata.internalAmortizationCost,
  393. internalDesignCost: thisdata.internalDesignCost,
  394. internalEquipmentCost: thisdata.internalEquipmentCost,
  395. internalOtherCost: thisdata.internalOtherCost,
  396. externalTotalCost: thisdata.externalTotalCost,
  397. externalAbroadCost: thisdata.externalAbroadCost,
  398. allCost:
  399. thisdata.internalLaborCost + thisdata.internalDirectCost + thisdata.internalDepreciationCost +
  400. thisdata.internalAmortizationCost + thisdata.internalAmortizationCost + thisdata.internalDesignCost +
  401. thisdata.internalEquipmentCost + thisdata.internalOtherCost + thisdata.externalTotalCost,
  402. enterpriseFiller: thisdata.enterpriseFiller,
  403. signDate: thisdata.signDate,
  404. signDateFormattedDate: thisdata.signDateFormattedDate,
  405. sortNumber: thisdata.sortNumber,
  406. startDateFormattedDate: thisdata.startDateFormattedDate,
  407. endDateFormattedDate: thisdata.endDateFormattedDate
  408. });
  409. };
  410. this.state.activityNumberList = activityNumber.data;
  411. this.state.pagination.current = data.data.pageNo;
  412. this.state.pagination.total = data.data.totalCount;
  413. this.setState({
  414. dataSource: this.state.data,
  415. pagination: this.state.pagination
  416. });
  417. }).always(function () {
  418. this.setState({
  419. loading: false
  420. });
  421. }.bind(this));
  422. },
  423. getInitialState() {
  424. return {
  425. selectedRowKeys: [],
  426. selectedRows: [],
  427. loading: false,
  428. pagination: {
  429. defaultCurrent: 1,
  430. defaultPageSize: 10,
  431. showQuickJumper: true,
  432. pageSize: 10,
  433. onChange: function (page) {
  434. this.loadData(page);
  435. }.bind(this),
  436. showTotal: function (total) {
  437. return '共' + total + '条数据';
  438. }
  439. },
  440. columns: [
  441. {
  442. title: '研发活动编号',
  443. dataIndex: 'activityNumber',
  444. key: 'activityNumber'
  445. }, {
  446. title: '内部研究开发费用',
  447. dataIndex: 'internalAllCost',
  448. key: 'internalAllCost'
  449. }, {
  450. title: '人员人工费用',
  451. dataIndex: 'internalLaborCost',
  452. key: 'internalLaborCost'
  453. }, {
  454. title: '直接投入费用',
  455. dataIndex: 'internalDirectCost',
  456. key: 'internalDirectCost'
  457. }, {
  458. title: '折旧费用与长期待摊费用',
  459. dataIndex: 'internalDepreciationCost',
  460. key: 'internalDepreciationCost'
  461. }, {
  462. title: '设计费用',
  463. dataIndex: 'internalDesignCost',
  464. key: 'internalDesignCost'
  465. }, {
  466. title: '装备调试费用与试验费用',
  467. dataIndex: 'internalEquipmentCost',
  468. key: 'internalEquipmentCost'
  469. }, {
  470. title: '无形资产摊销费用',
  471. dataIndex: 'internalAmortizationCost',
  472. key: 'internalAmortizationCost'
  473. }, {
  474. title: '其他费用',
  475. dataIndex: 'internalOtherCost',
  476. key: 'internalOtherCost'
  477. }, {
  478. title: '委托外部研究开发费用',
  479. dataIndex: 'externalTotalCost',
  480. key: 'externalTotalCost'
  481. }, {
  482. title: '境内外部研发费用',
  483. dataIndex: 'externalAbroadCost',
  484. key: 'externalAbroadCost'
  485. }, {
  486. title: '研发费用合计',
  487. dataIndex: 'allCost',
  488. key: 'allCost'
  489. }, {
  490. title: '企业填报人',
  491. dataIndex: 'enterpriseFiller',
  492. key: 'enterpriseFiller'
  493. }, {
  494. title: '企业填报人签字日期',
  495. dataIndex: 'signDateFormattedDate',
  496. key: 'signDateFormattedDate'
  497. }, {
  498. title: '排序号',
  499. dataIndex: 'sortNumber',
  500. key: 'sortNumber'
  501. }
  502. ],
  503. dataSource: []
  504. };
  505. },
  506. componentWillMount() {
  507. this.loadData();
  508. },
  509. tableRowClick(record, index) {
  510. this.state.RowData = record;
  511. this.setState({
  512. showDesc: true
  513. });
  514. },
  515. delectRow() {
  516. let deletedIds = [];
  517. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  518. let rowItem = this.state.selectedRows[idx];
  519. if (rowItem.id) {
  520. deletedIds.push(rowItem.id)
  521. }
  522. }
  523. this.setState({
  524. selectedRowKeys: [],
  525. loading: deletedIds.length > 0
  526. });
  527. $.ajax({
  528. method: "POST",
  529. dataType: "json",
  530. crossDomain: false,
  531. url: globalConfig.context + "/techservice/cognizance/deleteActivityCost",
  532. data: {
  533. ids: deletedIds
  534. }
  535. }).done(function (data) {
  536. if (!data.error.length) {
  537. message.success('保存成功!');
  538. this.setState({
  539. loading: false,
  540. });
  541. } else {
  542. message.warning(data.error[0].message);
  543. };
  544. this.loadData();
  545. }.bind(this));
  546. },
  547. closeDesc(e) {
  548. this.state.showDesc = e;
  549. this.loadData();
  550. },
  551. search() {
  552. this.loadData();
  553. },
  554. reset() {
  555. this.state.startDateFormattedDate = undefined;
  556. this.state.endDateFormattedDate = undefined;
  557. this.state.activityNumber = undefined;
  558. this.loadData();
  559. },
  560. render() {
  561. const rowSelection = {
  562. selectedRowKeys: this.state.selectedRowKeys,
  563. onChange: (selectedRowKeys, selectedRows) => {
  564. this.setState({
  565. selectedRows: selectedRows,
  566. selectedRowKeys: selectedRowKeys
  567. });
  568. }
  569. };
  570. const hasSelected = this.state.selectedRowKeys.length > 0;
  571. return (
  572. <div className="user-content" >
  573. <div className="content-title">
  574. <span>企业研究开发活动情况表</span>
  575. </div>
  576. <div className="user-search">
  577. <Input placeholder="研发活动编号" value={this.state.activityNumber}
  578. onChange={(e) => { this.setState({ activityNumber: e.target.value }); }} />
  579. <span>开始日期:</span>
  580. <DatePicker
  581. value={this.state.startDateFormattedDate ? moment(this.state.startDateFormattedDate) : null}
  582. onChange={(data, dataString) => { this.setState({ startDateFormattedDate: dataString }); }} />
  583. <span>结束日期:</span>
  584. <DatePicker
  585. value={this.state.endDateFormattedDate ? moment(this.state.endDateFormattedDate) : null}
  586. onChange={(data, dataString) => { this.setState({ endDateFormattedDate: dataString }); }} />
  587. <Button type="primary" onClick={this.search}>搜索</Button>
  588. <Button onClick={this.reset}>重置</Button>
  589. <p>
  590. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  591. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  592. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  593. disabled={!hasSelected}
  594. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  595. </p>
  596. </div>
  597. <div className="patent-table">
  598. <Spin spinning={this.state.loading}>
  599. <Table columns={this.state.columns}
  600. dataSource={this.state.dataSource}
  601. pagination={this.state.pagination}
  602. rowSelection={rowSelection}
  603. onRowClick={this.tableRowClick} />
  604. </Spin>
  605. </div>
  606. <ActivityDesc data={this.state.RowData}
  607. activityNumberList={this.state.activityNumberList}
  608. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  609. </div >
  610. );
  611. }
  612. });
  613. export default Activity;