ratepay.jsx 21 KB

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