addSoftWritingPrice.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 AddSoftWritingPrice 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/updateSoftWritingPrice';
  23. values.id = this.props.infor.id;
  24. } else {
  25. api = '/api/admin/company/addSoftWritingPrice';
  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('companyName', {
  65. initialValue: this.props.infor.companyName,
  66. rules: [{ required: true, message: '请输入公司名称!' }],
  67. })(
  68. <Input disabled={Object.keys(this.props.infor).length !== 0} placeholder="请输入公司名称" style={{width:'250px'}}/>
  69. )}
  70. </Form.Item>
  71. <Form.Item label="单价">
  72. {getFieldDecorator('unitPrice', {
  73. initialValue: this.props.infor.unitPrice,
  74. rules: [{ required: true, message: '请输入单价!' }],
  75. })(
  76. <Input placeholder="请输入单价" type={'number'} style={{width:'250px'}}/>
  77. )}
  78. </Form.Item>
  79. <Form.Item label="方案">
  80. {getFieldDecorator('material', {
  81. initialValue: this.props.infor.material,
  82. rules: [{ required: true, message: '请选择是否有方案!' }],
  83. })(
  84. <Select style={{ width:'200px'}}>
  85. <Select.Option value={0}>无</Select.Option>
  86. <Select.Option value={1}>有</Select.Option>
  87. </Select>
  88. )}
  89. </Form.Item>
  90. <Form.Item label="加急天数">
  91. {getFieldDecorator('urgent', {
  92. initialValue: this.props.infor.urgent,
  93. rules: [{ required: true, message: '请选择加急天数!' }],
  94. })(
  95. <Select style={{ width:'200px'}}>
  96. <Select.Option value={0}>无加急</Select.Option>
  97. <Select.Option value={1}>加急3-5个工作日</Select.Option>
  98. <Select.Option value={2}>加急6-10个工作日</Select.Option>
  99. <Select.Option value={3}>加急11-15个工作日</Select.Option>
  100. <Select.Option value={4}>加急16-20个工作日</Select.Option>
  101. <Select.Option value={5}>加急21-25个工作日</Select.Option>
  102. <Select.Option value={6}>加急26-30个工作日</Select.Option>
  103. <Select.Option value={7}>加急45个工作日</Select.Option>
  104. <Select.Option value={8}>加急60个工作日</Select.Option>
  105. </Select>
  106. )}
  107. </Form.Item>
  108. {Object.keys(this.props.infor).length ? <Form.Item label="状态">
  109. {getFieldDecorator('status', {
  110. initialValue: this.props.infor.status,
  111. rules: [{ required: true, message: '请输选择状态!' }],
  112. })(
  113. <Select style={{ width:'200px'}}>
  114. <Select.Option value={0}>正常</Select.Option>
  115. <Select.Option value={1}>停用</Select.Option>
  116. <Select.Option value={2}>删除</Select.Option>
  117. </Select>
  118. )}
  119. </Form.Item> : <div/>}
  120. <Form.Item label="备注">
  121. {getFieldDecorator('remarks', {
  122. initialValue: this.props.infor.remarks,
  123. rules: [{ required: false, message: '请输入备注!' }],
  124. })(
  125. <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
  126. )}
  127. </Form.Item>
  128. <Form.Item>
  129. <Button style={{
  130. width: '100%',
  131. marginTop: '18px',
  132. }} type="primary" htmlType="submit">
  133. {
  134. Object.keys(this.props.infor).length ? '确定修改' : '确定添加'
  135. }
  136. </Button>
  137. </Form.Item>
  138. </Form>
  139. </Spin>
  140. </Modal>
  141. )
  142. }
  143. }
  144. const WrappedHorizontalLoginForm = Form.create()(AddSoftWritingPrice);
  145. export default WrappedHorizontalLoginForm