ratepay.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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 + "/techservice/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 + "/techservice/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>未上传!</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 + "/techservice/cognizance/ratepay",
  290. data: {
  291. pageNo: pageNo || 1,
  292. pageSize: this.state.pagination.pageSize
  293. }
  294. }).done((data) => {
  295. if (data.error.length || !data.data || !data.data.list) {
  296. message.warning(data.error[0].message);
  297. return;
  298. };
  299. for (let i = 0; i < data.data.list.length; i++) {
  300. let thisdata = data.data.list[i];
  301. this.state.data.push({
  302. key: i,
  303. id: thisdata.id,
  304. uid: thisdata.uid,
  305. operatingIncome: thisdata.operatingIncome,
  306. managementCost: thisdata.managementCost,
  307. operatingProfit: thisdata.operatingProfit,
  308. nonOperatingIncome: thisdata.nonOperatingIncome,
  309. nonTaxableIncome: thisdata.nonTaxableIncome,
  310. taxExemptIncome: thisdata.taxExemptIncome,
  311. subsidyIncome: thisdata.subsidyIncome,
  312. grossProfit: thisdata.grossProfit,
  313. researchCost: thisdata.researchCost,
  314. year: thisdata.year,
  315. taxReturnUrl: thisdata.taxReturnUrl,
  316. taxReturnDownloadFileName: thisdata.taxReturnDownloadFileName,
  317. taxReturn: [thisdata.taxReturnUrl, thisdata.taxReturnDownloadFileName]
  318. });
  319. };
  320. this.state.pagination.current = data.data.pageNo;
  321. this.state.pagination.total = data.data.totalCount;
  322. this.setState({
  323. dataSource: this.state.data,
  324. pagination: this.state.pagination
  325. });
  326. }).always(function () {
  327. this.setState({
  328. loading: false
  329. });
  330. }.bind(this));
  331. },
  332. getInitialState() {
  333. return {
  334. selectedRowKeys: [],
  335. selectedRows: [],
  336. loading: false,
  337. pagination: {
  338. defaultCurrent: 1,
  339. defaultPageSize: 10,
  340. showQuickJumper: true,
  341. pageSize: 10,
  342. onChange: function (page) {
  343. this.loadData(page);
  344. }.bind(this),
  345. showTotal: function (total) {
  346. return '共' + total + '条数据';
  347. }
  348. },
  349. columns: [
  350. {
  351. title: '年份',
  352. dataIndex: 'year',
  353. key: 'year'
  354. }, {
  355. title: '营业收入(万元)',
  356. dataIndex: 'operatingIncome',
  357. key: 'operatingIncome'
  358. }, {
  359. title: '管理费用(万元)',
  360. dataIndex: 'managementCost',
  361. key: 'managementCost'
  362. }, {
  363. title: '营业利润(万元)',
  364. dataIndex: 'operatingProfit',
  365. key: 'operatingProfit',
  366. }, {
  367. title: '营业外收入(万元)',
  368. dataIndex: 'nonOperatingIncome',
  369. key: 'nonOperatingIncome',
  370. }, {
  371. title: '相关附件',
  372. dataIndex: 'taxReturn',
  373. key: 'taxReturn',
  374. render: (text) => {
  375. return <a onClick={downloadFile.bind(null, text[0], text[1])}>{text[1]}</a>
  376. }
  377. }
  378. ],
  379. dataSource: []
  380. };
  381. },
  382. componentWillMount() {
  383. this.loadData();
  384. },
  385. tableRowClick(record, index) {
  386. this.state.RowData = record;
  387. this.setState({
  388. showDesc: true
  389. });
  390. },
  391. delectRow() {
  392. let deletedIds = [];
  393. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  394. let rowItem = this.state.selectedRows[idx];
  395. if (rowItem.id) {
  396. deletedIds.push(rowItem.id)
  397. }
  398. }
  399. this.setState({
  400. selectedRowKeys: [],
  401. loading: deletedIds.length > 0
  402. });
  403. $.ajax({
  404. method: "POST",
  405. dataType: "json",
  406. crossDomain: false,
  407. url: globalConfig.context + "/techservice/cognizance/deleteRatepay",
  408. data: {
  409. ids: deletedIds
  410. }
  411. }).done(function (data) {
  412. if (!data.error.length) {
  413. message.success('保存成功!');
  414. this.setState({
  415. loading: false,
  416. });
  417. } else {
  418. message.warning(data.error[0].message);
  419. };
  420. this.loadData();
  421. }.bind(this));
  422. },
  423. closeDesc(e, s) {
  424. this.state.showDesc = e;
  425. if (s) {
  426. this.loadData();
  427. };
  428. },
  429. search() {
  430. this.loadData();
  431. },
  432. reset() {
  433. this.loadData();
  434. },
  435. render() {
  436. const rowSelection = {
  437. selectedRowKeys: this.state.selectedRowKeys,
  438. onChange: (selectedRowKeys, selectedRows) => {
  439. this.setState({
  440. selectedRows: selectedRows,
  441. selectedRowKeys: selectedRowKeys
  442. });
  443. }
  444. };
  445. const hasSelected = this.state.selectedRowKeys.length > 0;
  446. return (
  447. <div className="user-content" >
  448. <div className="content-title">
  449. <span>纳税申报信息</span>
  450. </div>
  451. <div className="user-search">
  452. <p>
  453. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  454. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  455. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  456. disabled={!hasSelected}
  457. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  458. </p>
  459. </div>
  460. <div className="patent-table">
  461. <Spin spinning={this.state.loading}>
  462. <Table columns={this.state.columns}
  463. dataSource={this.state.dataSource}
  464. pagination={this.state.pagination}
  465. rowSelection={rowSelection}
  466. onRowClick={this.tableRowClick} />
  467. </Spin>
  468. </div>
  469. <RatepayDesc data={this.state.RowData}
  470. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  471. </div >
  472. );
  473. }
  474. });
  475. export default Ratepay;