ratepay.jsx 17 KB

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