import React, {Component} from 'react'; import { StyleSheet, View, Text, DeviceEventEmitter, TextInput, } from 'react-native'; import {SearchBar, List,} from '@ant-design/react-native'; import ReadUHF from "../../utils/ReadUHF"; import {connect} from 'react-redux' import {Button} from "../../components"; @connect(home => ({...home})) class SearchHome extends Component { constructor(props) { super(props); this.state = { value: '', no: '', searchData: {}, searchState: 0, }; } componentDidMount() { ReadUHF.changeFlag(0) DeviceEventEmitter.addListener('MsgFromAndroid', this._onSearch); } componentWillUnmount() { ReadUHF.stopRead() } componentWillUnmount() { this.props.dispatch({ type: 'home/clear' }); } _onSearch = (value) => { this.props.dispatch({ type: 'home/search', payload: { cross_code: value, }, callback: (data) => { if (data.searchState === 1) { this.setState({searchData: data.searchData, searchState: data.searchState, value: value, no: '',}) } else { this.setState({ searchData: data.searchData, searchState: data.searchState, value: value, no: value, }) } } }) this.setState({no: value,}) } _cancel = () => { this.props.dispatch({ type: 'home/clear' }); this.setState({value: ''}); }; _start = () => { ReadUHF.doRead() } render() { const {searchData, searchState,} = this.state; return ( {/*搜索*/} this._onSearch(value)}> 未查询到该编码 {this.state.value} 编码 产品 分销商 出库时间 出库人 审核时间 审核人