import React, {Component} from 'react'; import { View, Text, StyleSheet, ScrollView, Dimensions, DeviceEventEmitter, } from 'react-native'; import {Tabs, Provider, Button, Modal, Toast, List, Picker} from '@ant-design/react-native'; import {createAction} from '../../utils'; import {connect} from 'react-redux'; import CallPhone from '../../components/CallPhone'; import ComponentsStyles from '../../components/ComponentsStyles'; import RefreshFlatList from 'react-native-refresh-flatlist'; import SyncStorage from 'sync-storage'; const tabs = [ {title: '基本信息', id: 1}, {title: '跟踪记录', id: 2}, ]; const {width} = Dimensions.get('window'); @connect(customer => ({...customer})) class ReviewDetail extends Component { // 潜客跟踪 constructor(props) { super(props); this.state = { getParm: { page: 1, rows: 10, customer: this.props.navigation.state.params.id, }, moreModelVisible: false, dispatchVisible: false, USERS: [], new_user: '', }; }; componentDidMount() { this._fetchReviewReoprt(); this._fetchData(); this.refeshReport = DeviceEventEmitter.addListener('refeshReport', (param) => { this._fetchReviewReoprt(1); }); this.refeshCustomerDetail = DeviceEventEmitter.addListener('refeshCustomerDetail', (param) => { this._fetchData(1); }); } componentWillUnmount() { this.refeshReport.remove(); this.refeshCustomerDetail.remove(); } _fetchData = () => { this.props.dispatch({ type: 'customer/fetchCustomerDetail', payload: {id: this.state.getParm.customer}, }); }; _fetchMore = () => { const {page, totalRecord} = this.props.customer; if (page * this.state.getParm.rows >= totalRecord) { return; } const currentPage = page + 1; this._fetchReviewReoprt(currentPage); }; _keyExtractor = (item, index) => { return index.toString(); }; _fetchReviewReoprt = (page) => { if (page) { this.state.getParm.page = page; } this.props.dispatch(createAction('customer/fetchReviewRecord')(this.state.getParm)); }; baseInfo = (reviewDetailData) => { return {reviewDetailData.name}} arrow="empty"> 姓名 {reviewDetailData.gender_text}} arrow="empty"> 性别 电话 {'\ue61a'} CallPhone(reviewDetailData.tel, 1)}> {reviewDetailData.tel} {reviewDetailData.address}} wrap multipleLine arrow="empty"> 地址 {reviewDetailData.village}} wrap multipleLine arrow="empty"> 小区 {reviewDetailData.source_text}} arrow="empty"> 来源 {reviewDetailData.project_text}} arrow="empty"> 项目 {reviewDetailData.stage_progress_text}} arrow="empty"> 阶段进度 {reviewDetailData.status_text}} arrow="empty"> 状态 {reviewDetailData.track_user_text}} arrow="empty"> 跟踪人员 {reviewDetailData.store_text}} arrow="empty"> 门店 {reviewDetailData.next_time_f}} arrow="empty"> 下次跟踪 {reviewDetailData.enter_count}} arrow="empty"> 进店次数 {reviewDetailData.last_enter_time}} arrow="empty"> 最后进店时间 {reviewDetailData.create_time_f}} arrow="empty"> 建档时间 {reviewDetailData.create_user_text}} arrow="empty"> 建档人 备注 {reviewDetailData.notes} ; }; renderItem = (data) => { const item = data.item; return {'\ue619'} {item.create_user_text} {'\ue6ed'} {item.description} {'\ue6cc'} {item.create_time_f} 支援或放弃: {item.instruction} 审核: {item.check_status_text}--{item.check_comment} ; }; addProject = (ids, name) => { this.props.dispatch({ type: 'customer/addCustomerProject', payload: {projects: ids, id: this.state.getParm.customer}, callback: () => { Toast.info('添加成功!', 1, () => { DeviceEventEmitter.emit('backRefesh'); this.props.navigation.goBack(); }); }, }); }; getUsers = () => { this.setState({moreModelVisible: false, dispatchVisible: true}); this.props.dispatch({ type: 'customer/getUser', callback: (data) => { let USERS = []; data.map((item, index) => { USERS.push({ value: item.value, label: item.lable, }); }); this.setState({USERS}); }, }); }; againDispatch = (id) => { if (!this.state.new_user) { Toast.info('请选择人员', 1); return; } this.props.dispatch({ type: 'customer/againDispatchUser', payload: {id: id, user: this.state.new_user}, callback: () => { DeviceEventEmitter.emit('backRefesh'); this.props.navigation.goBack(); }, }); }; render() { const {reviewRecordData, reviewRecordRState, customerDetail} = this.props.customer; const dispatchButtons = [ {text: '取消', onPress: () => this.setState({dispatchVisible: false})}, {text: '保存', onPress: () => this.againDispatch(customerDetail.id)}, ]; const premissions = SyncStorage.get('premissions'); return ( {/*基本信息*/} {this.baseInfo(customerDetail)} {/* 跟踪记录*/} this.renderItem(item)} keyExtractor={this._keyExtractor} themeColor="#5eafe4" refreshState={reviewRecordRState} footerRefreshingText="正在加载" footerFailureText="加载失败" onHeaderRefresh={() => this._fetchReviewReoprt(1)} onFooterRefresh={() => this._fetchMore()} ListHeaderComponent={() => } ItemSeparatorComponent={() => } /> this.setState({moreModelVisible: false})} > {premissions.indexOf('customer.inner_review') > -1 && { this.props.navigation.navigate('WriteInternalReport', { item: customerDetail, }); this.setState({moreModelVisible: false}); } } >内部跟踪 } { this.props.navigation.navigate('EditCustomer', { item: customerDetail, }); this.setState({moreModelVisible: false}); } } >修改信息 { this.props.navigation.navigate('SearchProject', { callback: this.addProject, disabled_ids: customerDetail.project, }); this.setState({moreModelVisible: false}); } } >添加项目 {premissions.indexOf('customer.again_dispatch') > -1 && this.getUsers() } >重新分配 } { this.props.navigation.navigate('UpdateProcess', { customer: customerDetail.id, }); this.setState({moreModelVisible: false}); } } >更新进度 this.setState({moreModelVisible: false})}> 取消 this.setState({new_user: val})} > 选择人员 ); } } const styles = StyleSheet.create({ modalText: { color: '#333', fontSize: 16, textAlign: 'center', textAlignVertical: 'center', }, textInput: { width: '80%', textAlign: 'left', paddingHorizontal: 10, }, modalContainer: { flexDirection: 'row', paddingHorizontal: 10, paddingLeft: 13, borderBottomWidth: 1, borderBottomColor: '#eee', }, textStyle: { fontSize: 16, paddingVertical: 10, }, telItemView: { flex: 1, flexDirection: 'row', marginLeft: 15, paddingRight: 18, paddingVertical: 8, borderBottomWidth: 0.5, borderBottomColor: '#eaeaea', }, telName: { color: '#333', fontSize: 18, }, telView: { flex: 1, flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center', }, telText: { color: '#2b90ea', fontSize: 15, }, listStyle: { borderBottomWidth: 10, borderBottomColor: '#f6f7f8', }, reportMain: { marginTop: 5, // marginBottom: 5, backgroundColor: '#fff', paddingHorizontal: 10, // borderWidth:1, }, customerText: { color: '#333', fontSize: 16, }, row5: { flexDirection: 'row', paddingVertical: 3, }, red5: { fontSize: 15, color: 'red', padding: 2, }, descView: { marginHorizontal: 15, paddingVertical: 2, borderBottomWidth: 1, borderBottomColor: '#eee', }, descText: { color: '#928f8f', paddingVertical: 2, }, }); export default ReviewDetail;