ratepay.jsx 21 KB

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