addOfficialFeePrice.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import React,{Component} from "react";
  2. import {Form, Input, Button, Checkbox, Select, Spin} from 'antd';
  3. import $ from "jquery/src/ajax";
  4. import {message, Modal} from "antd";
  5. class AddOfficialFeePrice extends Component{
  6. constructor(props) {
  7. super(props);
  8. this.state={
  9. loading: false
  10. }
  11. }
  12. //增加 修改
  13. addSoftWritingPriceFn(e) {
  14. e.preventDefault();
  15. this.props.form.validateFields((err, values) => {
  16. if (!err) {
  17. this.setState({
  18. loading: true
  19. });
  20. let api ;
  21. if(Object.keys(this.props.infor).length){
  22. api = '/api/admin/company/updateOfficialFeePrice';
  23. values.id = this.props.infor.id;
  24. } else {
  25. api = '/api/admin/company/addOfficialFeePrice';
  26. }
  27. $.ajax({
  28. method: "post",
  29. dataType: "json",
  30. crossDomain: false,
  31. url:globalConfig.context + api,
  32. data:values,
  33. }).done(function (data) {
  34. this.setState({
  35. loading: false
  36. });
  37. if (!data.error.length) {
  38. message.success(Object.keys(this.props.infor).length ? '修改成功!' : '新增成功!');
  39. this.props.successFn();
  40. } else {
  41. message.warning(data.error[0].message);
  42. }
  43. }.bind(this));
  44. }
  45. });
  46. }
  47. render() {
  48. const { getFieldDecorator } = this.props.form;
  49. return (
  50. <Modal
  51. maskClosable={false}
  52. className="customeDetails"
  53. title={Object.keys(this.props.infor).length ? "修改" : "新增"}
  54. width='350px'
  55. visible={this.props.visible}
  56. onCancel={this.props.onCancel}
  57. footer={null}
  58. >
  59. <Spin spinning={this.state.loading}>
  60. <Form onSubmit={(e)=>{
  61. this.addSoftWritingPriceFn(e)
  62. }}>
  63. <Form.Item label="专利类型">
  64. {getFieldDecorator('type', {
  65. initialValue: this.props.infor.type,
  66. rules: [{ required: true, message: '请选择专利类型!' }],
  67. })(
  68. <Select style={{ width:'200px'}}>
  69. <Select.Option value={0}>实用新型</Select.Option>
  70. <Select.Option value={1}>外观专利</Select.Option>
  71. <Select.Option value={2}>发明专利</Select.Option>
  72. </Select>
  73. )}
  74. </Form.Item>
  75. <Form.Item label="金额">
  76. {getFieldDecorator('amount', {
  77. initialValue: this.props.infor.amount,
  78. rules: [{ required: true, message: '请输入金额!' }],
  79. })(
  80. <Input placeholder="请输入金额" type={'number'} style={{width:'250px'}}/>
  81. )}
  82. </Form.Item>
  83. <Form.Item label="减缴比例85%">
  84. {getFieldDecorator('proportion85', {
  85. initialValue: this.props.infor.proportion85,
  86. rules: [{ required: true, message: '请输入减缴比例85%!' }],
  87. })(
  88. <Input placeholder="请输入减缴比例85%" type={'number'} style={{width:'250px'}}/>
  89. )}
  90. </Form.Item>
  91. <Form.Item label="备注">
  92. {getFieldDecorator('remarks', {
  93. initialValue: this.props.infor.remarks,
  94. rules: [{ required: true, message: '请输入备注!' }],
  95. })(
  96. <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
  97. )}
  98. </Form.Item>
  99. <Form.Item>
  100. <Button style={{
  101. width: '100%',
  102. marginTop: '18px',
  103. }} type="primary" htmlType="submit">
  104. {
  105. Object.keys(this.props.infor).length ? '确定修改' : '确定添加'
  106. }
  107. </Button>
  108. </Form.Item>
  109. </Form>
  110. </Spin>
  111. </Modal>
  112. )
  113. }
  114. }
  115. const WrappedHorizontalLoginForm = Form.create()(AddOfficialFeePrice);
  116. export default WrappedHorizontalLoginForm