ratepay.jsx 19 KB

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