ratepay.jsx 18 KB

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