|
@@ -1,5 +1,5 @@
|
|
|
import React,{Component} from "react";
|
|
|
-import {Form, Input, Button, Checkbox, Select} from 'antd';
|
|
|
+import {Form, Input, Button, Checkbox, Select, Spin} from 'antd';
|
|
|
import $ from "jquery/src/ajax";
|
|
|
import {message, Modal} from "antd";
|
|
|
|
|
@@ -7,11 +7,11 @@ class AddSoftWritingPrice extends Component{
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state={
|
|
|
-
|
|
|
+ loading: false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //增加
|
|
|
+ //增加 修改
|
|
|
addSoftWritingPriceFn(e) {
|
|
|
e.preventDefault();
|
|
|
this.props.form.validateFields((err, values) => {
|
|
@@ -19,18 +19,25 @@ class AddSoftWritingPrice extends Component{
|
|
|
this.setState({
|
|
|
loading: true
|
|
|
});
|
|
|
+ let api ;
|
|
|
+ if(Object.keys(this.props.infor).length){
|
|
|
+ api = '/api/admin/company/updateSoftWritingPrice';
|
|
|
+ values.id = this.props.infor.id;
|
|
|
+ } else {
|
|
|
+ api = '/api/admin/company/addSoftWritingPrice';
|
|
|
+ }
|
|
|
$.ajax({
|
|
|
method: "post",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
- url:globalConfig.context + '/api/admin/company/addSoftWritingPrice',
|
|
|
+ url:globalConfig.context + api,
|
|
|
data:values,
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
|
loading: false
|
|
|
});
|
|
|
if (!data.error.length) {
|
|
|
- message.success('新增成功!');
|
|
|
+ message.success(Object.keys(this.props.infor).length ? '修改成功!' : '新增成功!');
|
|
|
this.props.successFn();
|
|
|
} else {
|
|
|
message.warning(data.error[0].message);
|
|
@@ -45,69 +52,84 @@ class AddSoftWritingPrice extends Component{
|
|
|
return (
|
|
|
<Modal
|
|
|
className="customeDetails"
|
|
|
- title="新增"
|
|
|
+ title={Object.keys(this.props.infor).length ? "修改" : "新增"}
|
|
|
width='350px'
|
|
|
visible={this.props.visible}
|
|
|
onCancel={this.props.onCancel}
|
|
|
footer={null}
|
|
|
>
|
|
|
- <Form onSubmit={(e)=>{
|
|
|
- this.addSoftWritingPriceFn(e)
|
|
|
- }}>
|
|
|
- <Form.Item label="公司名称">
|
|
|
- {getFieldDecorator('companyName', {
|
|
|
- rules: [{ required: true, message: '请输入公司名称!' }],
|
|
|
- })(
|
|
|
- <Input placeholder="请输入公司名称" style={{width:'250px'}}/>
|
|
|
- )}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="单价">
|
|
|
- {getFieldDecorator('unitPrice', {
|
|
|
- rules: [{ required: true, message: '请输入单价!' }],
|
|
|
- })(
|
|
|
- <Input placeholder="请输入单价" type={'number'} style={{width:'250px'}}/>
|
|
|
- )}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="材料">
|
|
|
- {getFieldDecorator('material', {
|
|
|
- rules: [{ required: true, message: '请选择是否有材料!' }],
|
|
|
- })(
|
|
|
- <Select style={{ width:'200px'}}>
|
|
|
- <Select.Option value={0}>无</Select.Option>
|
|
|
- <Select.Option value={1}>有</Select.Option>
|
|
|
- </Select>
|
|
|
- )}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="加急天数">
|
|
|
- {getFieldDecorator('urgent', {
|
|
|
- rules: [{ required: true, message: '请选择加急天数!' }],
|
|
|
- })(
|
|
|
- <Select style={{ width:'200px'}}>
|
|
|
- <Select.Option value={0}>无加急</Select.Option>
|
|
|
- <Select.Option value={1}>加急3天</Select.Option>
|
|
|
- <Select.Option value={2}>加急4天</Select.Option>
|
|
|
- <Select.Option value={3}>加急5-10天</Select.Option>
|
|
|
- <Select.Option value={4}>加急11-15天</Select.Option>
|
|
|
- <Select.Option value={5}>加急16-20天</Select.Option>
|
|
|
- <Select.Option value={6}>加急21-25天</Select.Option>
|
|
|
- <Select.Option value={7}>加急26-30天</Select.Option>
|
|
|
- </Select>
|
|
|
- )}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="备注">
|
|
|
- {getFieldDecorator('remarks', {
|
|
|
- rules: [{ required: true, message: '请输入备注!' }],
|
|
|
- })(
|
|
|
- <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
|
|
|
- )}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item>
|
|
|
- <Button style={{
|
|
|
- width: '100%',
|
|
|
- marginTop: '18px',
|
|
|
- }} type="primary" htmlType="submit">确定添加</Button>
|
|
|
- </Form.Item>
|
|
|
- </Form>
|
|
|
+ <Spin spinning={this.state.loading}>
|
|
|
+ <Form onSubmit={(e)=>{
|
|
|
+ this.addSoftWritingPriceFn(e)
|
|
|
+ }}>
|
|
|
+ <Form.Item label="单价">
|
|
|
+ {getFieldDecorator('unitPrice', {
|
|
|
+ initialValue: this.props.infor.unitPrice,
|
|
|
+ rules: [{ required: true, message: '请输入单价!' }],
|
|
|
+ })(
|
|
|
+ <Input placeholder="请输入单价" type={'number'} style={{width:'250px'}}/>
|
|
|
+ )}
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="材料">
|
|
|
+ {getFieldDecorator('material', {
|
|
|
+ initialValue: this.props.infor.material,
|
|
|
+ rules: [{ required: true, message: '请选择是否有材料!' }],
|
|
|
+ })(
|
|
|
+ <Select style={{ width:'200px'}}>
|
|
|
+ <Select.Option value={0}>无</Select.Option>
|
|
|
+ <Select.Option value={1}>有</Select.Option>
|
|
|
+ </Select>
|
|
|
+ )}
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="加急天数">
|
|
|
+ {getFieldDecorator('urgent', {
|
|
|
+ initialValue: this.props.infor.urgent,
|
|
|
+ rules: [{ required: true, message: '请选择加急天数!' }],
|
|
|
+ })(
|
|
|
+ <Select style={{ width:'200px'}}>
|
|
|
+ <Select.Option value={0}>无加急</Select.Option>
|
|
|
+ <Select.Option value={1}>加急3天</Select.Option>
|
|
|
+ <Select.Option value={2}>加急4天</Select.Option>
|
|
|
+ <Select.Option value={3}>加急5-10天</Select.Option>
|
|
|
+ <Select.Option value={4}>加急11-15天</Select.Option>
|
|
|
+ <Select.Option value={5}>加急16-20天</Select.Option>
|
|
|
+ <Select.Option value={6}>加急21-25天</Select.Option>
|
|
|
+ <Select.Option value={7}>加急26-30天</Select.Option>
|
|
|
+ </Select>
|
|
|
+ )}
|
|
|
+ </Form.Item>
|
|
|
+ {Object.keys(this.props.infor).length ? <Form.Item label="状态">
|
|
|
+ {getFieldDecorator('status', {
|
|
|
+ initialValue: this.props.infor.status,
|
|
|
+ rules: [{ required: true, message: '请输选择状态!' }],
|
|
|
+ })(
|
|
|
+ <Select style={{ width:'200px'}}>
|
|
|
+ <Select.Option value={0}>正常</Select.Option>
|
|
|
+ <Select.Option value={1}>停用</Select.Option>
|
|
|
+ <Select.Option value={2}>删除</Select.Option>
|
|
|
+ </Select>
|
|
|
+ )}
|
|
|
+ </Form.Item> : <div/>}
|
|
|
+ <Form.Item label="备注">
|
|
|
+ {getFieldDecorator('remarks', {
|
|
|
+ initialValue: this.props.infor.remarks,
|
|
|
+ rules: [{ required: true, message: '请输入备注!' }],
|
|
|
+ })(
|
|
|
+ <Input placeholder="请输入备注" type={'textarea'} style={{width:'250px'}}/>
|
|
|
+ )}
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item>
|
|
|
+ <Button style={{
|
|
|
+ width: '100%',
|
|
|
+ marginTop: '18px',
|
|
|
+ }} type="primary" htmlType="submit">
|
|
|
+ {
|
|
|
+ Object.keys(this.props.infor).length ? '确定修改' : '确定添加'
|
|
|
+ }
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </Spin>
|
|
|
</Modal>
|
|
|
)
|
|
|
}
|