ratepay.jsx 22 KB

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