import React, {Component} from 'react'; import { View, Text, StyleSheet, ScrollView, StatusBar, DeviceEventEmitter, KeyboardAvoidingView, Platform, } from 'react-native'; import {connect} from 'react-redux'; import { Provider, Button, Toast, List, Picker, InputItem, } from '@ant-design/react-native'; import RadioModal from '../../components/RadioModal'; import ComponentsStyles from '../../components/ComponentsStyles'; import CheckValid from '../../components/CheckValid'; @connect(customer => ({...customer})) class ReportCustomerAdd extends Component { // 报备客户 constructor(props) { super(props); this.state = { name: '', tel: '', gender: 2, village: '', address: '', source: '', project: [], notes: '', project_text: '请选择', CUSTOMER_SOURCE: [], }; } componentDidMount() { this._fetchData(); } _fetchData = () => { this.props.dispatch({ type: 'customer/fetchReportDict', callback: (data) => { let CUSTOMER_SOURCE = []; data.source.map((item, index) => { CUSTOMER_SOURCE.push({ value: item.id, label: item.name, }); }); this.setState({CUSTOMER_SOURCE}); }, }); }; onSave = () => { if (!this.state.name) { Toast.info('请填写姓名', 1); return; } if (!this.state.tel) { Toast.info('请填写手机号', 1); return; } if (!CheckValid(this.state.tel, 'tel')) { Toast.info('请填写正确的手机号', 1); return; } if (!this.state.village) { Toast.info('请填写小区', 1); return; } if (!this.state.address) { Toast.info('请填写地址', 1); return; } if (!this.state.source.length) { Toast.info('请选择来源', 1); return; } if (!this.state.project.length) { Toast.info('请选择项目', 1); return; } this.props.dispatch({ type: 'customer/saveReportCustomer', payload: this.state, callback: () => { DeviceEventEmitter.emit('backRefesh'); this.props.navigation.goBack(); }, }); }; onProjectPress = () => { this.props.navigation.navigate('SearchProject', { callback: this.setProject, checked_ids:this.state.project, checked_names:this.state.project_text, }); }; setProject = (ids, name) => { this.setState({project_text: name, project: ids}); }; render() { const {loading} = this.props.customer; const isIOS = Platform.OS === 'ios' ? true : false; return ( { this.setState({ name: value, }); }} placeholder="请输入客户姓名" > 姓名 性别 this.setState({type: id})} style={ComponentsStyles.radioStyle} innerStyle={{ width: 50, }} > { this.setState({ tel: value, }); }} placeholder="请输入电话" > 电话 { this.setState({ village: value, }); }} placeholder="请输入小区" > 小区 { this.setState({ address: value, }); }} placeholder="请输入地址" > 地址 { this.setState({ source: text, }); }} > 来源 this.onProjectPress()}> {this.state.project_text} } > 项目 { this.setState({ notes: value, }); }} placeholder="请输入备注" > 备注 ); } } const styles = StyleSheet.create({ listStyle: { marginTop: 5, }, dateInput: { borderWidth: 0, alignItems: 'flex-end', }, }); export default ReportCustomerAdd;