ratepay.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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/admin/disposeRatepay",
  38. data: {
  39. id: this.props.data.id,
  40. uid: this.props.uid,
  41. operatingIncome: values.operatingIncome,
  42. managementCost: values.managementCost,
  43. operatingProfit: values.operatingProfit,
  44. nonOperatingIncome: values.nonOperatingIncome,
  45. nonTaxableIncome: values.nonTaxableIncome,
  46. taxExemptIncome: values.taxExemptIncome,
  47. subsidyIncome: values.subsidyIncome,
  48. grossProfit: values.grossProfit,
  49. researchCost: values.researchCost,
  50. year: this.state.year || this.props.data.year,
  51. taxReturnUrl: this.state.taxReturnUrl
  52. }
  53. }).done(function (data) {
  54. if (!data.error.length) {
  55. message.success('保存成功!');
  56. this.props.clickOk();
  57. this.props.spinState(false);
  58. this.props.form.resetFields();
  59. } else {
  60. message.warning(data.error[0].message);
  61. this.props.spinState(false);
  62. }
  63. }.bind(this));
  64. }
  65. });
  66. },
  67. componentWillReceiveProps(nextProps) {
  68. if (!this.props.visible && nextProps.visible) {
  69. this.props.form.resetFields();
  70. };
  71. },
  72. render() {
  73. const FormItem = Form.Item;
  74. const { getFieldDecorator } = this.props.form;
  75. const theData = this.props.data;
  76. const formItemLayout = {
  77. labelCol: { span: 10 },
  78. wrapperCol: { span: 12 },
  79. };
  80. const _me = this;
  81. return (
  82. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  83. <div className="activityCost-title"><span>年份: </span>
  84. {
  85. theData.year ? <span>{theData.year}</span> :
  86. <Select placeholder="请选择年份" style={{ width: 200 }}
  87. onSelect={(e, n) => { this.state.year = e }}>
  88. {this.state.yearOption}
  89. </Select>
  90. }
  91. </div>
  92. <div className="clearfix">
  93. <FormItem className="half-item"
  94. {...formItemLayout}
  95. label="营业收入(万元)"
  96. >
  97. {getFieldDecorator('operatingIncome', {
  98. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  99. initialValue: theData.operatingIncome
  100. })(
  101. <InputNumber />
  102. )}
  103. </FormItem>
  104. <FormItem className="half-item"
  105. {...formItemLayout}
  106. label="管理费用(万元)"
  107. >
  108. {getFieldDecorator('managementCost', {
  109. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  110. initialValue: theData.managementCost
  111. })(
  112. <InputNumber />
  113. )}
  114. </FormItem>
  115. <FormItem className="half-item"
  116. {...formItemLayout}
  117. label="营业利润(万元)"
  118. >
  119. {getFieldDecorator('operatingProfit', {
  120. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  121. initialValue: theData.operatingProfit
  122. })(
  123. <InputNumber />
  124. )}
  125. </FormItem>
  126. <FormItem className="half-item"
  127. {...formItemLayout}
  128. label="营业外收入(万元)"
  129. >
  130. {getFieldDecorator('nonOperatingIncome', {
  131. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  132. initialValue: theData.nonOperatingIncome
  133. })(
  134. <InputNumber />
  135. )}
  136. </FormItem>
  137. <FormItem className="half-item"
  138. {...formItemLayout}
  139. label="不征税收入(万元)"
  140. >
  141. {getFieldDecorator('nonTaxableIncome', {
  142. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  143. initialValue: theData.nonTaxableIncome
  144. })(
  145. <InputNumber />
  146. )}
  147. </FormItem>
  148. <FormItem className="half-item"
  149. {...formItemLayout}
  150. label="免税收入(万元)"
  151. >
  152. {getFieldDecorator('taxExemptIncome', {
  153. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  154. initialValue: theData.taxExemptIncome
  155. })(
  156. <InputNumber />
  157. )}
  158. </FormItem>
  159. <FormItem className="half-item"
  160. {...formItemLayout}
  161. label="政府补助收入(万元)"
  162. >
  163. {getFieldDecorator('subsidyIncome', {
  164. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  165. initialValue: theData.subsidyIncome
  166. })(
  167. <InputNumber />
  168. )}
  169. </FormItem>
  170. <FormItem className="half-item"
  171. {...formItemLayout}
  172. label="利润总额(万元)"
  173. >
  174. {getFieldDecorator('grossProfit', {
  175. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  176. initialValue: theData.grossProfit
  177. })(
  178. <InputNumber />
  179. )}
  180. </FormItem>
  181. <FormItem className="half-item"
  182. {...formItemLayout}
  183. label="研发费用(万元)"
  184. >
  185. {getFieldDecorator('researchCost', {
  186. rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
  187. initialValue: theData.researchCost
  188. })(
  189. <InputNumber />
  190. )}
  191. </FormItem>
  192. </div>
  193. <div className="hrSituation-roster">
  194. <Upload
  195. name="ratepay"
  196. action={globalConfig.context + "/api/admin/uploadRatepay"}
  197. data={{ 'sign': 'ratepay','year': (this.state.year || theData.year),'uid': this.props.uid }}
  198. beforeUpload={beforeUploadFile}
  199. showUploadList={false}
  200. onChange={(info) => {
  201. if (info.file.status !== 'uploading') {
  202. console.log(info.file, info.fileList);
  203. }
  204. if (info.file.status === 'done') {
  205. if (!info.file.response.error.length) {
  206. message.success(`${info.file.name} 文件上传成功!`);
  207. } else {
  208. message.warning(info.file.response.error[0].message);
  209. return;
  210. };
  211. this.state.taxReturnUrl = info.file.response.data;
  212. } else if (info.file.status === 'error') {
  213. message.error(`${info.file.name} 文件上传失败。`);
  214. }
  215. }}
  216. >
  217. <Button><Icon type="upload" /> 上传企业纳税申报表 </Button>
  218. </Upload>
  219. <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>
  220. </div>
  221. <FormItem style={{ marginTop: '20px' }}>
  222. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  223. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  224. </FormItem>
  225. </Form >
  226. );
  227. },
  228. }));
  229. const RatepayDesc = React.createClass({
  230. getInitialState() {
  231. return {
  232. visible: false,
  233. loading: false
  234. };
  235. },
  236. componentWillReceiveProps(nextProps) {
  237. this.state.visible = nextProps.showDesc
  238. },
  239. showModal() {
  240. this.setState({
  241. visible: true,
  242. });
  243. },
  244. handleOk() {
  245. this.setState({
  246. visible: false,
  247. });
  248. this.props.closeDesc(false, true);
  249. },
  250. handleCancel(e) {
  251. this.setState({
  252. visible: false,
  253. });
  254. this.props.closeDesc(false);
  255. },
  256. spinChange(e) {
  257. this.setState({
  258. loading: e
  259. });
  260. },
  261. render() {
  262. return (
  263. <div className="patent-addNew">
  264. <Spin spinning={this.state.loading} className='spin-box'>
  265. <Modal title="纳税申报信息" visible={this.state.visible}
  266. onOk={this.handleOk} onCancel={this.handleCancel}
  267. width='800px'
  268. footer=''
  269. >
  270. <RatepayDescFrom
  271. uid={this.props.uid}
  272. data={this.props.data}
  273. visible={this.state.visible}
  274. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  275. </Modal>
  276. </Spin>
  277. </div>
  278. );
  279. },
  280. });
  281. const Ratepay = React.createClass({
  282. loadData(pageNo) {
  283. this.state.data = [];
  284. this.setState({
  285. loading: true
  286. });
  287. $.ajax({
  288. method: "post",
  289. dataType: "json",
  290. crossDomain: false,
  291. url: globalConfig.context + "/api/admin/ratepay",
  292. data: {
  293. pageNo: pageNo || 1,
  294. pageSize: this.state.pagination.pageSize,
  295. uid: this.props.data.uid
  296. }
  297. }).done((data) => {
  298. if (data.error.length || !data.data || !data.data.list) {
  299. message.warning(data.error[0].message);
  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. researchCost: thisdata.researchCost,
  316. grossProfit: thisdata.grossProfit,
  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/admin/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. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  458. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  459. disabled={!hasSelected}
  460. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  461. </p>
  462. </div>
  463. <div className="patent-table">
  464. <Spin spinning={this.state.loading}>
  465. <Table columns={this.state.columns}
  466. dataSource={this.state.dataSource}
  467. pagination={this.state.pagination}
  468. rowSelection={rowSelection}
  469. onRowClick={this.tableRowClick} />
  470. </Spin>
  471. </div>
  472. <RatepayDesc
  473. uid={this.props.data.uid}
  474. data={this.state.RowData}
  475. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  476. </div >
  477. );
  478. }
  479. });
  480. export default Ratepay;