activityCostList.jsx 31 KB

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