123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import React,{Component} from "react";
- import {Form, Input, Button, Checkbox, Select, Spin} from 'antd';
- import $ from "jquery/src/ajax";
- import {message, Modal} from "antd";
- class AddSoftWritingPrice extends Component{
- constructor(props) {
- super(props);
- this.state={
- loading: false
- }
- }
- //增加 修改
- addSoftWritingPriceFn(e) {
- e.preventDefault();
- this.props.form.validateFields((err, values) => {
- if (!err) {
- 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,
- data:values,
- }).done(function (data) {
- this.setState({
- loading: false
- });
- if (!data.error.length) {
- message.success(Object.keys(this.props.infor).length ? '修改成功!' : '新增成功!');
- this.props.successFn();
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this));
- }
- });
- }
- render() {
- const { getFieldDecorator } = this.props.form;
- return (
- <Modal
- maskClosable={false}
- className="customeDetails"
- title={Object.keys(this.props.infor).length ? "修改" : "新增"}
- width='350px'
- visible={this.props.visible}
- onCancel={this.props.onCancel}
- footer={null}
- >
- <Spin spinning={this.state.loading}>
- <Form onSubmit={(e)=>{
- this.addSoftWritingPriceFn(e)
- }}>
- <Form.Item label="公司名称">
- {getFieldDecorator('companyName', {
- initialValue: this.props.infor.companyName,
- rules: [{ required: true, message: '请输入公司名称!' }],
- })(
- <Input disabled={Object.keys(this.props.infor).length !== 0} placeholder="请输入公司名称" style={{width:'250px'}}/>
- )}
- </Form.Item>
- <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-5个工作日</Select.Option>
- <Select.Option value={2}>加急6-10个工作日</Select.Option>
- <Select.Option value={3}>加急11-15个工作日</Select.Option>
- <Select.Option value={4}>加急16-20个工作日</Select.Option>
- <Select.Option value={5}>加急21-25个工作日</Select.Option>
- <Select.Option value={6}>加急26-30个工作日</Select.Option>
- <Select.Option value={7}>加急45个工作日</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: false, 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>
- )
- }
- }
- const WrappedHorizontalLoginForm = Form.create()(AddSoftWritingPrice);
- export default WrappedHorizontalLoginForm
|