ratepay.jsx 19 KB

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