ratepay.jsx 18 KB

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