OrderItem.js 1.6 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
import React from 'react'
import { Select,Input,InputNumber,Button } from 'antd';
const Option = Select.Option;


export default class OrderItem extends React.Component {
    constructor(props) {
        super(props);
        const value = props.value || {};
        this.state = {
            stringX:value.stringX,
        };
    }


  componentWillReceiveProps(nextProps) {
        // Should be a controlled component.
        if ('value' in nextProps) {
            const value = nextProps.value;
            this.setState(value);
        }
    }
   
    
    triggerChange = (changedValue) => {
        // Should provide an event to pass value to Form.
        const onChange = this.props.onChange;
        if (onChange) {
            onChange(Object.assign({}, this.state, changedValue));
        }
    };
   
    
    changeStringX=(e)=>{
        
        if (!('value' in this.props)) {
            this.setState({ stringX:e });
        }
        this.triggerChange({ stringX:e });
    };
   
    render() {
    
        const {stringX} =this.state;
   
        return (
            <div>
              <span style={{padding: '0px 10px'}}>
                <Select onChange={this.changeStringX}
                        value={stringX}
                        style={{width:200}}>
                <Option value="desc" key='desc'>降序</Option>
                <Option value="asc" key='asc'>升序</Option>
                </Select>
              </span>
              <span style={{paddingLeft:100}}>
              <Button type="danger" onClick={this.props.deleteOrder}>删除</Button>
                </span>
              </div>)
    }
}