ratepay.jsx 17 KB

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