import React, {Component} from 'react'; import { View, FlatList, Text, StyleSheet, StatusBar, } from 'react-native'; import {connect} from 'react-redux'; import TreeSelect from 'react-native-tree-select'; @connect(customer => ({...customer})) class SearchProcess extends Component { // 搜索进度 constructor(props) { super(props); this.state = { callback: this.props.navigation.state.params.callback, data: [], StageCount: [], field: '', field_name: '', store_id: '', }; } componentDidMount() { this._fetchData(); this._fetchStageCount(); } _fetchData = () => { this.props.dispatch({ type: 'customer/fetchEmployeeTree', callback: (data) => { this.setState({data: data}); }, }); }; _fetchStageCount = (type, id) => { this.props.dispatch({ type: 'customer/queryStageCount', payload: {type, id}, callback: (data) => { this.setState({StageCount: data}); }, }); }; _onClickLeaf = (item) => { this._fetchStageCount(item.item.field, item.item.id); this.setState({field: item.item.field, field_name: item.item.name, store_id: item.item.id}); }; _onStagePress = (stage_id, event, text) => { const {field, store_id, field_name} = this.state; let param = ''; if (field && store_id) { param = field + '_' + store_id; } const searchText = field_name + '-' + text this.state.callback(stage_id, event, param, searchText); this.props.navigation.goBack(); }; renderItem = (data, index) => { return ( this._onStagePress(data.stage_id, 'stage', '总数')} style={[styles.tableCell, {width: '30%'}]}>{data.stage} this._onStagePress(data.stage_id, 'total', '总数')} style={[styles.tableCell, {width: '20%'}]}>{data.total_count} this._onStagePress(data.stage_id, 'today', '今日')} style={[styles.tableCell, {width: '25%'}]}>{data.today_count} this._onStagePress(data.stage_id, 'overdue', '逾期')} style={[styles.tableCell, {width: '25%'}]}>{data.overdue_count} ); }; render() { return ( {'\ue617'}, closeIcon: {'\ue601'}, }} /> 阶段 总数 今日 逾期 this.renderItem(item, index)} keyExtractor={(item, index) => index.toString()} /> ); } } const styles = StyleSheet.create({ icon: { fontFamily: 'iconfont', fontSize: 14, color: '#2b90ea', padding: 3, }, tableHeader: { backgroundColor: '#03C762', flexDirection: 'row', }, tableHeaderItem: { color: '#fff', paddingVertical: 10, textAlign: 'center', // flex: 1 }, tableRowOdd: { flexDirection: 'row', }, tableRowEven: { flexDirection: 'row', backgroundColor: '#f8f8f8', }, tableCell: { color: '#666', padding: 10, textAlign: 'center', // flex: 1 }, }); export default SearchProcess;