ratepay.jsx 19 KB

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