addPatentPrice.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 AddPatentPrice 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/updatePatentPrice';
  23. values.id = this.props.infor.id;
  24. } else {
  25. api = '/api/admin/company/addPatentPrice';
  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. className="customeDetails"
  52. title={Object.keys(this.props.infor).length ? "修改" : "新增"}
  53. width='350px'
  54. visible={this.props.visible}
  55. onCancel={this.props.onCancel}
  56. footer={null}
  57. >
  58. <Spin spinning={this.state.loading}>
  59. <Form onSubmit={(e)=>{
  60. this.addSoftWritingPriceFn(e)
  61. }}>
  62. <Form.Item label="公司名称">
  63. {getFieldDecorator('companyName', {
  64. initialValue: this.props.infor.companyName,
  65. rules: [{ required: true, message: '请输入公司名称!' }],
  66. })(
  67. <Input disabled={Object.keys(this.props.infor).length !== 0} placeholder="请输入公司名称" style={{width:'250px'}}/>
  68. )}
  69. </Form.Item>
  70. <Form.Item label="实用新型(万元)">
  71. {getFieldDecorator('utilityModel', {
  72. initialValue: this.props.infor.utilityModel,
  73. rules: [{ required: true, message: '请输入实用新型的金额!' }],
  74. })(
  75. <Input placeholder="请输入实用新型的金额" type={'number'} style={{width:'250px'}}/>
  76. )}
  77. </Form.Item>
  78. <Form.Item label="外观专利(万元)">
  79. {getFieldDecorator('appearancePatent', {
  80. initialValue: this.props.infor.appearancePatent,
  81. rules: [{ required: true, message: '请输入外观专利的金额!' }],
  82. })(
  83. <Input placeholder="请输入外观专利的金额" type={'number'} style={{width:'250px'}}/>
  84. )}
  85. </Form.Item>
  86. <Form.Item label="发明专利(万元)">
  87. {getFieldDecorator('inventionPatent', {
  88. initialValue: this.props.infor.inventionPatent,
  89. rules: [{ required: true, message: '请输入发明专利的金额!' }],
  90. })(
  91. <Input placeholder="请输入发明专利的金额" type={'number'} style={{width:'250px'}}/>
  92. )}
  93. </Form.Item>
  94. <Form.Item label="备注">
  95. {getFieldDecorator('remarks', {
  96. initialValue: this.props.infor.remarks,
  97. rules: [{ required: false, message: '请输入备注!' }],
  98. })(
  99. <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
  100. )}
  101. </Form.Item>
  102. <Form.Item>
  103. <Button style={{
  104. width: '100%',
  105. marginTop: '18px',
  106. }} type="primary" htmlType="submit">
  107. {
  108. Object.keys(this.props.infor).length ? '确定修改' : '确定添加'
  109. }
  110. </Button>
  111. </Form.Item>
  112. </Form>
  113. </Spin>
  114. </Modal>
  115. )
  116. }
  117. }
  118. const WrappedHorizontalLoginForm = Form.create()(AddPatentPrice);
  119. export default WrappedHorizontalLoginForm