ratepay.jsx 18 KB

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