NumberEditView.js 2.28 KB
import React, {Component} from 'react';
import {
    View,
    Text,
    TextInput,
    Image,
} from 'react-native';

export default class NumberEditView extends Component {

    constructor(props) {
        super(props);
        this.state = {
            value: '',
        };
        this.attrData = this.props.attrData;
        this.type = this.props.type;// 金额或数字
        this.onChangeText = this.props.onChangeText;
        this.inputType = this.props.inputType || 'numeric';// 输入类型
    }

    render() {
        let {name, code, type, uom, description, isRequired, isPreview} = this.attrData;
        let extendData = JSON.parse(this.attrData.data);
        let {placeholder, showChinese} = extendData;
        return(
            <View style={{width: '100%', backgroundColor: 'white', paddingHorizontal: 5, paddingVertical: 10}}>
                <View style={{flexDirection: 'row'}}>
                    {isRequired&&<Text style={{ color: "#FF3030" }}>* {" "}</Text>}
                    {!isRequired&&<Text style={{ color: "#fff" }}>* {" "}</Text>}
                    <Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)', marginBottom: 5}}>{name||""}</Text>
                </View>
                <View style={{flexDirection: 'row', alignItems: 'center'}}>
                    <TextInput
                        style={{flex: 1, backgroundColor: 'white', textAlign: 'left', paddingVertical: 5}}
                        maxLength={18}
                        multiline={false}
                        keyboardType={this.inputType}
                        onChangeText={text => {
                            if (this.onChangeText) {
                                this.onChangeText(text, type)
                            }
                        }}
                        placeholderTextColor={'#999'}
                        placeholder={placeholder}
                        underlineColorAndroid="transparent"
                    />
                    <Text style={{fontSize: 16, color: 'rgba(0, 0 , 0, 1)', marginLeft: 5}}>{uom}</Text>
                </View>
                {showChinese && <View style={{flexDirection: 'row'}}>
                    <Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)'}}>大写</Text>
                </View>
                }
            </View>
        )
    }
}