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. };
  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 />
  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 />
  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 />
  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 />
  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 />
  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 />
  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 />
  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 />
  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 />
  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. <Spin spinning={this.state.loading} className='spin-box'>
  311. <Modal title="所得税纳税申报信息" visible={this.state.visible}
  312. onOk={this.handleOk} onCancel={this.handleCancel}
  313. width='800px'
  314. footer=''
  315. >
  316. <RatepayDescFrom
  317. visible={this.state.visible}
  318. data={this.props.data}
  319. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  320. </Modal>
  321. </Spin>
  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;