ratepay.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Spin, Table, message, Select, Modal, InputNumber, Upload } from 'antd';
  3. import './techProduct.less';
  4. import { beforeUploadFile, newDownloadFile } from '../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. const RatepayDescFrom = Form.create()(React.createClass({
  8. loadData(year) {
  9. this.setState({
  10. loading: true
  11. });
  12. $.ajax({
  13. method: "get",
  14. dataType: "json",
  15. crossDomain: false,
  16. url: globalConfig.context + "/api/user/cognizance/ratepayDetail",
  17. data: {
  18. year: year != undefined ? year : this.props.data.year
  19. }
  20. }).done((data) => {
  21. if (!data.data) {
  22. if (data.error && data.error.length) {
  23. message.warning(data.error[0].message);
  24. };
  25. return;
  26. };
  27. this.setState({
  28. managementCost: data.data.managementCost,
  29. researchCost: data.data.researchCost,
  30. grossProfit: data.data.grossProfit,
  31. operatingProfit: data.data.operatingProfit
  32. });
  33. }).always(function () {
  34. this.setState({
  35. loading: false
  36. });
  37. }.bind(this));
  38. },
  39. getInitialState() {
  40. return {
  41. loading: false,
  42. yearOption: [],
  43. };
  44. },
  45. componentWillMount() {
  46. let d = new Date();
  47. let _me = this;
  48. d = d.getFullYear();
  49. for (let i = d; i > d - 20; i--) {
  50. _me.state.yearOption.push(
  51. <Select.Option value={i.toString()} key={i}>{i}</Select.Option>
  52. )
  53. };
  54. if (this.props.data.year) {
  55. this.loadData();
  56. };
  57. },
  58. handleSubmit(e) {
  59. e.preventDefault();
  60. if (!this.state.year && !this.props.data.year) {
  61. message.warning("请选择一个年份!")
  62. return;
  63. };
  64. this.props.form.validateFields((err, values) => {
  65. if (!err) {
  66. this.props.spinState(true);
  67. $.ajax({
  68. method: "POST",
  69. dataType: "json",
  70. crossDomain: false,
  71. url: globalConfig.context + "/api/user/cognizance/disposeRatepay",
  72. data: {
  73. id: this.props.data.id,
  74. operatingIncome: values.operatingIncome,
  75. managementCost: values.managementCost,
  76. operatingProfit: values.operatingProfit,
  77. nonOperatingIncome: values.nonOperatingIncome,
  78. nonTaxableIncome: values.nonTaxableIncome,
  79. taxExemptIncome: values.taxExemptIncome,
  80. subsidyIncome: values.subsidyIncome,
  81. year: this.state.year || this.props.data.year,
  82. taxReturnUrl: this.state.taxReturnUrl,
  83. grossProfit: values.grossProfit,
  84. researchCost: values.researchCost
  85. }
  86. }).done(function (data) {
  87. if (!data.error.length) {
  88. message.success('保存成功!');
  89. this.props.clickOk();
  90. this.props.spinState(false);
  91. this.props.form.resetFields();
  92. } else {
  93. message.warning(data.error[0].message);
  94. this.props.spinState(false);
  95. }
  96. }.bind(this));
  97. }
  98. });
  99. },
  100. componentWillReceiveProps(nextProps) {
  101. if (!this.props.visible && nextProps.visible) {
  102. if (nextProps.data.year) {
  103. this.loadData(nextProps.data.year);
  104. };
  105. this.props.form.resetFields();
  106. this.state.fileList = [];
  107. this.state.managementCost = undefined;
  108. this.state.researchCost = undefined;
  109. this.state.grossProfit = undefined;
  110. this.state.operatingProfit = undefined;
  111. this.state.taxReturnUrl = undefined;
  112. };
  113. },
  114. render() {
  115. const FormItem = Form.Item;
  116. const { getFieldDecorator } = this.props.form;
  117. const theData = this.props.data;
  118. const formItemLayout = {
  119. labelCol: { span: 8 },
  120. wrapperCol: { span: 16 },
  121. };
  122. const _me = this;
  123. return (
  124. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  125. <div className="activityCost-title"><span>年份: </span>
  126. {
  127. theData.year ? <span>{theData.year}</span> :
  128. <Select placeholder="请选择年份" style={{ width: 200 }}
  129. onSelect={(e, n) => { this.state.year = e, this.loadData(e); }}>
  130. {this.state.yearOption}
  131. </Select>
  132. }
  133. </div>
  134. <div className="clearfix">
  135. <FormItem className="half-item"
  136. {...formItemLayout}
  137. label="营业收入(万元)"
  138. >
  139. {getFieldDecorator('operatingIncome', {
  140. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  141. initialValue: theData.operatingIncome
  142. })(
  143. <InputNumber min={0} max={999999} step={0.01} />
  144. )}
  145. </FormItem>
  146. <FormItem className="half-item"
  147. {...formItemLayout}
  148. label="管理费用(万元)"
  149. >
  150. {getFieldDecorator('managementCost', {
  151. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  152. initialValue: theData.managementCost
  153. })(
  154. <InputNumber min={0} max={999999} step={0.01} />
  155. )}
  156. {this.state.managementCost && this.state.managementCost != this.props.form.getFieldValue('managementCost') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
  157. </FormItem>
  158. <FormItem className="half-item"
  159. {...formItemLayout}
  160. label="营业利润(万元)"
  161. >
  162. {getFieldDecorator('operatingProfit', {
  163. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  164. initialValue: theData.operatingProfit
  165. })(
  166. <InputNumber min={0} max={999999} step={0.01} />
  167. )}
  168. {this.state.operatingProfit && this.state.operatingProfit != this.props.form.getFieldValue('operatingProfit') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
  169. </FormItem>
  170. <FormItem className="half-item"
  171. {...formItemLayout}
  172. label="营业外收入(万元)"
  173. >
  174. {getFieldDecorator('nonOperatingIncome', {
  175. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  176. initialValue: theData.nonOperatingIncome
  177. })(
  178. <InputNumber min={0} max={999999} step={0.01} />
  179. )}
  180. </FormItem>
  181. <FormItem className="half-item"
  182. {...formItemLayout}
  183. label="不征税收入(万元)"
  184. >
  185. {getFieldDecorator('nonTaxableIncome', {
  186. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  187. initialValue: theData.nonTaxableIncome
  188. })(
  189. <InputNumber min={0} max={999999} step={0.01} />
  190. )}
  191. </FormItem>
  192. <FormItem className="half-item"
  193. {...formItemLayout}
  194. label="免税收入(万元)"
  195. >
  196. {getFieldDecorator('taxExemptIncome', {
  197. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  198. initialValue: theData.taxExemptIncome
  199. })(
  200. <InputNumber min={0} max={999999} step={0.01} />
  201. )}
  202. </FormItem>
  203. <FormItem className="half-item"
  204. {...formItemLayout}
  205. label="政府补助收入(万元)"
  206. >
  207. {getFieldDecorator('subsidyIncome', {
  208. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  209. initialValue: theData.subsidyIncome
  210. })(
  211. <InputNumber min={0} max={999999} step={0.01} />
  212. )}
  213. </FormItem>
  214. <FormItem className="half-item"
  215. {...formItemLayout}
  216. label="利润总额(万元)"
  217. >
  218. {getFieldDecorator('grossProfit', {
  219. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  220. initialValue: theData.grossProfit
  221. })(
  222. <InputNumber min={0} max={999999} step={0.01} />
  223. )}
  224. {this.state.grossProfit && this.state.grossProfit != this.props.form.getFieldValue('grossProfit') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
  225. </FormItem>
  226. <FormItem className="half-item"
  227. {...formItemLayout}
  228. label="研发费用(万元)"
  229. >
  230. {getFieldDecorator('researchCost', {
  231. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  232. initialValue: theData.researchCost
  233. })(
  234. <InputNumber min={0} max={999999} step={0.01} />
  235. )}
  236. {this.state.researchCost && this.state.researchCost != this.props.form.getFieldValue('researchCost') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
  237. </FormItem>
  238. </div>
  239. <div className="hrSituation-roster">
  240. <Upload
  241. name="ratepay"
  242. action={globalConfig.context + "/api/user/cognizance/uploadRatepay"}
  243. data={{ 'sign': 'ratepay', year: this.state.year || theData.year }}
  244. beforeUpload={beforeUploadFile}
  245. fileList={this.state.fileList}
  246. onChange={(info) => {
  247. if (info.file.status !== 'uploading') {
  248. console.log(info.file, info.fileList);
  249. }
  250. if (info.file.status === 'done') {
  251. if (!info.file.response.error.length) {
  252. message.success(`${info.file.name} 文件上传成功!`);
  253. } else {
  254. message.warning(info.file.response.error[0].message);
  255. return;
  256. };
  257. this.state.taxReturnUrl = info.file.response.data;
  258. } else if (info.file.status === 'error') {
  259. message.error(`${info.file.name} 文件上传失败。`);
  260. };
  261. this.setState({ fileList: info.fileList.slice(-1) });
  262. }}
  263. >
  264. <Button><Icon type="upload" /> 上传企业所得税纳税申报表 </Button>
  265. </Upload>
  266. <p style={{ marginTop: '10px' }}>{theData.taxReturnUrl ? <a onClick={newDownloadFile.bind(null, theData.id, 'ratepay', '/api/user/cognizance/downloadRatepay')}>{theData.taxReturnDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  267. </div>
  268. <FormItem style={{ marginTop: '20px' }}>
  269. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  270. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  271. </FormItem>
  272. </Form >
  273. );
  274. },
  275. }));
  276. const RatepayDesc = React.createClass({
  277. getInitialState() {
  278. return {
  279. visible: false,
  280. loading: false
  281. };
  282. },
  283. componentWillReceiveProps(nextProps) {
  284. this.state.visible = nextProps.showDesc
  285. },
  286. showModal() {
  287. this.setState({
  288. visible: true,
  289. });
  290. },
  291. handleOk() {
  292. this.setState({
  293. visible: false,
  294. });
  295. this.props.closeDesc(false, true);
  296. },
  297. handleCancel(e) {
  298. this.setState({
  299. visible: false,
  300. });
  301. this.props.closeDesc(false);
  302. },
  303. spinChange(e) {
  304. this.setState({
  305. loading: e
  306. });
  307. },
  308. render() {
  309. return (
  310. <div className="patent-addNew">
  311. <Modal maskClosable={false} title="所得税纳税申报信息" visible={this.state.visible}
  312. onOk={this.handleOk} onCancel={this.handleCancel}
  313. width='800px'
  314. footer='' >
  315. <Spin spinning={this.state.loading} className='spin-box'>
  316. <RatepayDescFrom
  317. visible={this.state.visible}
  318. data={this.props.data}
  319. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  320. </Spin>
  321. </Modal>
  322. </div>
  323. );
  324. },
  325. });
  326. const Ratepay = React.createClass({
  327. loadData(pageNo) {
  328. this.state.data = [];
  329. this.setState({
  330. loading: true
  331. });
  332. $.ajax({
  333. method: "get",
  334. dataType: "json",
  335. crossDomain: false,
  336. url: globalConfig.context + "/api/user/cognizance/ratepay",
  337. data: {
  338. pageNo: pageNo || 1,
  339. pageSize: this.state.pagination.pageSize
  340. }
  341. }).done((data) => {
  342. if (!data.data) {
  343. if (data.error && data.error.length) {
  344. message.warning(data.error[0].message);
  345. this.state.ButtonDisabled = true;
  346. }
  347. return;
  348. };
  349. for (let i = 0; i < data.data.list.length; i++) {
  350. let thisdata = data.data.list[i];
  351. this.state.data.push({
  352. key: i,
  353. id: thisdata.id,
  354. uid: thisdata.uid,
  355. operatingIncome: thisdata.operatingIncome,
  356. managementCost: thisdata.managementCost,
  357. operatingProfit: thisdata.operatingProfit,
  358. nonOperatingIncome: thisdata.nonOperatingIncome,
  359. nonTaxableIncome: thisdata.nonTaxableIncome,
  360. taxExemptIncome: thisdata.taxExemptIncome,
  361. subsidyIncome: thisdata.subsidyIncome,
  362. grossProfit: thisdata.grossProfit,
  363. researchCost: thisdata.researchCost,
  364. year: thisdata.year,
  365. taxReturnUrl: thisdata.taxReturnUrl,
  366. taxReturnDownloadFileName: thisdata.taxReturnDownloadFileName,
  367. taxReturn: [thisdata.id, thisdata.taxReturnDownloadFileName]
  368. });
  369. };
  370. this.state.pagination.current = data.data.pageNo;
  371. this.state.pagination.total = data.data.totalCount;
  372. this.setState({
  373. dataSource: this.state.data,
  374. pagination: this.state.pagination
  375. });
  376. }).always(function () {
  377. this.setState({
  378. loading: false
  379. });
  380. }.bind(this));
  381. },
  382. getInitialState() {
  383. return {
  384. selectedRowKeys: [],
  385. selectedRows: [],
  386. loading: false,
  387. pagination: {
  388. defaultCurrent: 1,
  389. defaultPageSize: 10,
  390. showQuickJumper: true,
  391. pageSize: 10,
  392. onChange: function (page) {
  393. this.loadData(page);
  394. }.bind(this),
  395. showTotal: function (total) {
  396. return '共' + total + '条数据';
  397. }
  398. },
  399. columns: [
  400. {
  401. title: '年份',
  402. dataIndex: 'year',
  403. key: 'year'
  404. }, {
  405. title: '营业收入(万元)',
  406. dataIndex: 'operatingIncome',
  407. key: 'operatingIncome'
  408. }, {
  409. title: '管理费用(万元)',
  410. dataIndex: 'managementCost',
  411. key: 'managementCost'
  412. }, {
  413. title: '营业利润(万元)',
  414. dataIndex: 'operatingProfit',
  415. key: 'operatingProfit',
  416. }, {
  417. title: '营业外收入(万元)',
  418. dataIndex: 'nonOperatingIncome',
  419. key: 'nonOperatingIncome',
  420. }, {
  421. title: '相关附件',
  422. dataIndex: 'taxReturn',
  423. key: 'taxReturn',
  424. render: (text) => {
  425. return <a onClick={newDownloadFile.bind(null, text[0], 'ratepay', '/api/user/cognizance/downloadRatepay')}>{text[1]}</a>
  426. }
  427. }
  428. ],
  429. dataSource: []
  430. };
  431. },
  432. componentWillMount() {
  433. this.loadData();
  434. },
  435. tableRowClick(record, index) {
  436. this.state.RowData = record;
  437. this.setState({
  438. showDesc: true
  439. });
  440. },
  441. delectRow() {
  442. let deletedIds = [];
  443. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  444. let rowItem = this.state.selectedRows[idx];
  445. if (rowItem.id) {
  446. deletedIds.push(rowItem.id)
  447. }
  448. }
  449. this.setState({
  450. selectedRowKeys: [],
  451. loading: deletedIds.length > 0
  452. });
  453. $.ajax({
  454. method: "POST",
  455. dataType: "json",
  456. crossDomain: false,
  457. url: globalConfig.context + "/api/user/cognizance/deleteRatepay",
  458. data: {
  459. ids: deletedIds
  460. }
  461. }).done(function (data) {
  462. if (!data.error.length) {
  463. message.success('删除成功!');
  464. this.setState({
  465. loading: false,
  466. });
  467. } else {
  468. message.warning(data.error[0].message);
  469. };
  470. this.loadData();
  471. }.bind(this));
  472. },
  473. closeDesc(e, s) {
  474. this.state.showDesc = e;
  475. if (s) {
  476. this.loadData();
  477. };
  478. },
  479. search() {
  480. this.loadData();
  481. },
  482. reset() {
  483. this.loadData();
  484. },
  485. render() {
  486. const rowSelection = {
  487. selectedRowKeys: this.state.selectedRowKeys,
  488. onChange: (selectedRowKeys, selectedRows) => {
  489. this.setState({
  490. selectedRows: selectedRows,
  491. selectedRowKeys: selectedRowKeys
  492. });
  493. }
  494. };
  495. const hasSelected = this.state.selectedRowKeys.length > 0;
  496. return (
  497. <div className="user-content" >
  498. <div className="content-title">
  499. <span>所得税纳税申报信息</span>
  500. </div>
  501. <div className="user-search">
  502. <p>
  503. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  504. disabled={this.state.ButtonDisabled}
  505. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  506. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  507. disabled={!hasSelected}
  508. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  509. </p>
  510. </div>
  511. <div className="patent-table">
  512. <Spin spinning={this.state.loading}>
  513. <Table columns={this.state.columns}
  514. dataSource={this.state.dataSource}
  515. pagination={this.state.pagination}
  516. rowSelection={rowSelection}
  517. onRowClick={this.tableRowClick} />
  518. </Spin>
  519. </div>
  520. <RatepayDesc data={this.state.RowData}
  521. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  522. </div >
  523. );
  524. }
  525. });
  526. export default Ratepay;