addOfficialFeePrice.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. list:[]
  11. }
  12. this.getContactsOption = this.getContactsOption.bind(this);
  13. }
  14. componentDidMount() {
  15. this.getContactsOption();
  16. }
  17. //增加 修改
  18. addSoftWritingPriceFn(e) {
  19. e.preventDefault();
  20. this.props.form.validateFields((err, values) => {
  21. if (!err) {
  22. this.setState({
  23. loading: true
  24. });
  25. let api ;
  26. if(Object.keys(this.props.infor).length){
  27. api = '/api/admin/company/updateOfficialFeePrice';
  28. values.id = this.props.infor.id;
  29. } else {
  30. api = '/api/admin/company/addOfficialFeePrice';
  31. }
  32. $.ajax({
  33. method: "post",
  34. dataType: "json",
  35. crossDomain: false,
  36. url:globalConfig.context + api,
  37. data:values,
  38. }).done(function (data) {
  39. this.setState({
  40. loading: false
  41. });
  42. if (!data.error.length) {
  43. message.success(Object.keys(this.props.infor).length ? '修改成功!' : '新增成功!');
  44. this.props.successFn();
  45. } else {
  46. message.warning(data.error[0].message);
  47. }
  48. }.bind(this));
  49. }
  50. });
  51. }
  52. getContactsOption() {
  53. $.ajax({
  54. method: "get",
  55. dataType: "json",
  56. crossDomain: false,
  57. url: globalConfig.context + '/api/admin/orderProject/getPatentType',
  58. success: function (data) {
  59. if (data.error.length === 0) {
  60. this.setState({
  61. list:data.data
  62. })
  63. }else{
  64. message.warning(data.error[0].message);
  65. };
  66. }.bind(this)
  67. });
  68. }
  69. render() {
  70. const { getFieldDecorator } = this.props.form;
  71. return (
  72. <Modal
  73. maskClosable={false}
  74. className="customeDetails"
  75. title={Object.keys(this.props.infor).length ? "修改" : "新增"}
  76. width='350px'
  77. visible={this.props.visible}
  78. onCancel={this.props.onCancel}
  79. footer={null}
  80. >
  81. <Spin spinning={this.state.loading}>
  82. <Form onSubmit={(e)=>{
  83. this.addSoftWritingPriceFn(e)
  84. }}>
  85. <Form.Item label="项目类型">
  86. {getFieldDecorator('patentType', {
  87. initialValue: this.props.infor.patentType,
  88. rules: [{ required: true, message: '请选择项目类型!' }],
  89. })(
  90. <Select style={{ width:'200px'}}>
  91. {
  92. this.state.list.map((v,k)=>(
  93. <Select.Option key={k} value={v.id}>{v.name}</Select.Option>
  94. ))
  95. }
  96. </Select>
  97. )}
  98. </Form.Item>
  99. <Form.Item label="专利类型">
  100. {getFieldDecorator('type', {
  101. initialValue: this.props.infor.type,
  102. rules: [{ required: true, message: '请选择专利类型!' }],
  103. })(
  104. <Select style={{ width:'200px'}}>
  105. <Select.Option value={0}>实用新型</Select.Option>
  106. <Select.Option value={1}>发明专利</Select.Option>
  107. <Select.Option value={2}>外观专利</Select.Option>
  108. </Select>
  109. )}
  110. </Form.Item>
  111. <Form.Item label="金额">
  112. {getFieldDecorator('amount', {
  113. initialValue: this.props.infor.amount,
  114. rules: [{ required: true, message: '请输入金额!' }],
  115. })(
  116. <Input placeholder="请输入金额" type={'number'} style={{width:'250px'}}/>
  117. )}
  118. </Form.Item>
  119. <Form.Item label="减缴比例85%">
  120. {getFieldDecorator('proportion85', {
  121. initialValue: this.props.infor.proportion85,
  122. rules: [{ required: false, message: '请输入减缴比例85%!' }],
  123. })(
  124. <Input placeholder="请输入减缴比例85%" type={'number'} style={{width:'250px'}}/>
  125. )}
  126. </Form.Item>
  127. <Form.Item label="备注">
  128. {getFieldDecorator('remarks', {
  129. initialValue: this.props.infor.remarks,
  130. rules: [{ required: false, message: '请输入备注!' }],
  131. })(
  132. <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
  133. )}
  134. </Form.Item>
  135. <Form.Item>
  136. <Button style={{
  137. width: '100%',
  138. marginTop: '18px',
  139. }} type="primary" htmlType="submit">
  140. {
  141. Object.keys(this.props.infor).length ? '确定修改' : '确定添加'
  142. }
  143. </Button>
  144. </Form.Item>
  145. </Form>
  146. </Spin>
  147. </Modal>
  148. )
  149. }
  150. }
  151. const WrappedHorizontalLoginForm = Form.create()(AddOfficialFeePrice);
  152. export default WrappedHorizontalLoginForm