ratepay.jsx 23 KB

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