ratepay.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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.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. 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. if (!info.file.response.error.length) {
  199. message.success(`${info.file.name} 文件上传成功!`);
  200. } else {
  201. message.warning(info.file.response.error[0].message);
  202. return;
  203. };
  204. this.state.ratepayUrl = info.file.response.data;
  205. } else if (info.file.status === 'error') {
  206. message.error(`${info.file.name} 文件上传失败。`);
  207. }
  208. }}
  209. >
  210. <Button><Icon type="upload" /> 上传文件 </Button>
  211. </Upload>
  212. </div>
  213. <FormItem style={{ marginTop: '20px' }}>
  214. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  215. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  216. </FormItem>
  217. </Form >
  218. );
  219. },
  220. }));
  221. const RatepayDesc = React.createClass({
  222. getInitialState() {
  223. return {
  224. visible: false,
  225. loading: false
  226. };
  227. },
  228. componentWillReceiveProps(nextProps) {
  229. this.state.visible = nextProps.showDesc
  230. },
  231. showModal() {
  232. this.setState({
  233. visible: true,
  234. });
  235. },
  236. handleOk() {
  237. this.setState({
  238. visible: false,
  239. });
  240. this.props.closeDesc(false, true);
  241. },
  242. handleCancel(e) {
  243. this.setState({
  244. visible: false,
  245. });
  246. this.props.closeDesc(false);
  247. },
  248. spinChange(e) {
  249. this.setState({
  250. loading: e
  251. });
  252. },
  253. render() {
  254. return (
  255. <div className="patent-addNew">
  256. <Spin spinning={this.state.loading} className='spin-box'>
  257. <Modal title="纳税申报信息" visible={this.state.visible}
  258. onOk={this.handleOk} onCancel={this.handleCancel}
  259. width='800px'
  260. footer=''
  261. >
  262. <RatepayDescFrom data={this.props.data}
  263. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  264. </Modal>
  265. </Spin>
  266. </div>
  267. );
  268. },
  269. });
  270. const Ratepay = React.createClass({
  271. loadData(pageNo) {
  272. this.state.data = [];
  273. this.setState({
  274. loading: true
  275. });
  276. $.ajax({
  277. method: "get",
  278. dataType: "json",
  279. crossDomain: false,
  280. url: globalConfig.context + "/techservice/cognizance/ratepay",
  281. data: {
  282. pageNo: pageNo || 1,
  283. pageSize: this.state.pagination.pageSize
  284. }
  285. }).done((data) => {
  286. if (data.error.length || !data.data || !data.data.list) {
  287. message.warning(data.error[0].message);
  288. return;
  289. };
  290. for (let i = 0; i < data.data.list.length; i++) {
  291. let thisdata = data.data.list[i];
  292. this.state.data.push({
  293. key: i,
  294. id: thisdata.id,
  295. uid: thisdata.uid,
  296. operatingIncome: thisdata.operatingIncome,
  297. managementCost: thisdata.managementCost,
  298. operatingProfit: thisdata.operatingProfit,
  299. nonOperatingIncome: thisdata.nonOperatingIncome,
  300. nonTaxableIncome: thisdata.nonTaxableIncome,
  301. taxExemptIncome: thisdata.taxExemptIncome,
  302. subsidyIncome: thisdata.subsidyIncome,
  303. grossProfit: thisdata.grossProfit,
  304. researchCost: thisdata.researchCost,
  305. year: thisdata.year,
  306. taxReturnUrl: thisdata.taxReturnUrl
  307. });
  308. };
  309. this.state.pagination.current = data.data.pageNo;
  310. this.state.pagination.total = data.data.totalCount;
  311. this.setState({
  312. dataSource: this.state.data,
  313. pagination: this.state.pagination
  314. });
  315. }).always(function () {
  316. this.setState({
  317. loading: false
  318. });
  319. }.bind(this));
  320. },
  321. getInitialState() {
  322. return {
  323. selectedRowKeys: [],
  324. selectedRows: [],
  325. loading: false,
  326. pagination: {
  327. defaultCurrent: 1,
  328. defaultPageSize: 10,
  329. showQuickJumper: true,
  330. pageSize: 10,
  331. onChange: function (page) {
  332. this.loadData(page);
  333. }.bind(this),
  334. showTotal: function (total) {
  335. return '共' + total + '条数据';
  336. }
  337. },
  338. columns: [
  339. {
  340. title: '年份',
  341. dataIndex: 'year',
  342. key: 'year'
  343. }, {
  344. title: '营业收入(万元)',
  345. dataIndex: 'operatingIncome',
  346. key: 'operatingIncome'
  347. }, {
  348. title: '管理费用(万元)',
  349. dataIndex: 'managementCost',
  350. key: 'managementCost'
  351. }, {
  352. title: '营业利润(万元)',
  353. dataIndex: 'operatingProfit',
  354. key: 'operatingProfit',
  355. }, {
  356. title: '营业外收入(万元)',
  357. dataIndex: 'nonOperatingIncome',
  358. key: 'nonOperatingIncome',
  359. }, {
  360. title: '相关附件',
  361. dataIndex: 'taxReturnUrl',
  362. key: 'taxReturnUrl',
  363. render: (text) => {
  364. <a href="" onClick={() => {
  365. window.open(globalConfig.context + "/techservice/patent/downloadFile?path=" + text + "&sign=" + "type")
  366. }}></a>
  367. }
  368. }
  369. ],
  370. dataSource: []
  371. };
  372. },
  373. componentWillMount() {
  374. this.loadData();
  375. },
  376. tableRowClick(record, index) {
  377. this.state.RowData = record;
  378. this.setState({
  379. showDesc: true
  380. });
  381. },
  382. delectRow() {
  383. let deletedIds = [];
  384. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  385. let rowItem = this.state.selectedRows[idx];
  386. if (rowItem.id) {
  387. deletedIds.push(rowItem.id)
  388. }
  389. }
  390. this.setState({
  391. selectedRowKeys: [],
  392. loading: deletedIds.length > 0
  393. });
  394. $.ajax({
  395. method: "POST",
  396. dataType: "json",
  397. crossDomain: false,
  398. url: globalConfig.context + "/techservice/cognizance/deleteRatepay",
  399. data: {
  400. ids: deletedIds
  401. }
  402. }).done(function (data) {
  403. if (!data.error.length) {
  404. message.success('保存成功!');
  405. this.setState({
  406. loading: false,
  407. });
  408. } else {
  409. message.warning(data.error[0].message);
  410. };
  411. this.loadData();
  412. }.bind(this));
  413. },
  414. closeDesc(e, s) {
  415. this.state.showDesc = e;
  416. if (s) {
  417. this.loadData();
  418. };
  419. },
  420. search() {
  421. this.loadData();
  422. },
  423. reset() {
  424. this.loadData();
  425. },
  426. render() {
  427. const rowSelection = {
  428. selectedRowKeys: this.state.selectedRowKeys,
  429. onChange: (selectedRowKeys, selectedRows) => {
  430. this.setState({
  431. selectedRows: selectedRows,
  432. selectedRowKeys: selectedRowKeys
  433. });
  434. }
  435. };
  436. const hasSelected = this.state.selectedRowKeys.length > 0;
  437. return (
  438. <div className="user-content" >
  439. <div className="content-title">
  440. <span>纳税申报信息</span>
  441. </div>
  442. <div className="user-search">
  443. <p>
  444. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  445. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  446. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  447. disabled={!hasSelected}
  448. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  449. </p>
  450. </div>
  451. <div className="patent-table">
  452. <Spin spinning={this.state.loading}>
  453. <Table columns={this.state.columns}
  454. dataSource={this.state.dataSource}
  455. pagination={this.state.pagination}
  456. rowSelection={rowSelection}
  457. onRowClick={this.tableRowClick} />
  458. </Spin>
  459. </div>
  460. <RatepayDesc data={this.state.RowData}
  461. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  462. </div >
  463. );
  464. }
  465. });
  466. export default Ratepay;