import React, { Component } from 'react' import { StyleSheet, ScrollView, View, Text, Dimensions, StatusBar, TouchableOpacity, PixelRatio, FlatList, RefreshControl, } from 'react-native' import { connect } from 'react-redux' import { ReturnDate } from '../../../utils/utils' import Icon from '../../../components/Iconfont/Iconfont' import { NavigationActions, createAction } from '../../../utils' import Echarts from '../../../components/echarts/EchartsComponent' import Collapsible from 'react-native-collapsible' import SelectTimeCom from '../../../components/selectTime/selectTime' const { width, height } = Dimensions.get('window') const data = [ { proTitle: 'A应收组织', Quota: 8000, Occupancy: 2330 }, { proTitle: 'B应收组织', Quota: 4000, Occupancy: 2330 }, { proTitle: 'C应收组织', Quota: 12000, Occupancy: 5748 }, ] @connect(({ theme, mine, mine_account }) => ({ ...theme, ...mine, ...mine_account, })) class Account extends Component { constructor(props) { super(props) this.state = { reflsh: true, activeSection: true, selectText: '全部', // props.FinancialOrg && props.FinancialOrg.length > 0 // ? props.FinancialOrg[0].finanOrgName // : "", finanOrgId: '', // props.FinancialOrg && props.FinancialOrg.length > 0 // ? props.FinancialOrg[0].finanOrgId // : "", echartData: '', touchIndex: 0, listIndex: 'dsadsa', dateActive: true, //时间折叠-true为关 startTime: '', endTime: '', IsScrollEnabled: true, } // console.disableYellowBox = true; this.page = 0 this.size = 5 } componentDidMount() { // 可用财务组织 this.props.dispatch( createAction('mine/getCusSup')({ customerId: CUSTOMERINFO.id, customerRankCode: CUSTOMERINFO.customerRankCode, }) ) this.FindAmount() this.onRefresh() } FindAmount() { // 预付余额 this.props.dispatch( createAction('mine_account/getAccountBalance')({ searchInfo: { financeOrgId: this.state.finanOrgId }, }) ) } onRefresh() { this.props.dispatch( createAction('mine_account/AccountSagas')({ searchInfo: this.searchInfoFn(), pageInfo: { size: 5, page: 0 }, accountReturn: [], }) ) } searchInfoFn() { let searchData = {} // 时间格式需要search_ 和 _date if (this.state.startTime) { searchData.search_GTE_creationTime_date = new Date( this.state.startTime ).getTime() } if (this.state.endTime) { searchData.search_LT_creationTime_date = new Date( this.state.endTime ).getTime() } return searchData } // 头部 header() { return ( this.props.dispatch(NavigationActions.back())} > 返回 账户余额 this.setState({ dateActive: !this.state.dateActive, activeSection: true, reflsh: false, }) } > ) } _topOrganization(item, index) { return ( { this.state.finanOrgId = item.finanOrgId this.setState({ activeSection: true, selectText: item.finanOrgName, finanOrgId: item.finanOrgId, echartData: item, touchIndex: index, reflsh: true, }) this.FindAmount() }} style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10, backgroundColor: '#FFF', }} > {item.finanOrgName} {this.state.touchIndex == index ? ( ) : null} ) } jobList(item, key) { const stateList = [ '', '保存', '提交', '审批通过', '审批中', '收回', '审批不过', ] return ( this.state.listIndex == key ? this.setState({ listIndex: 'dsadsa', reflsh: false }) : this.setState({ listIndex: key, reflsh: false }) } key={key} style={{ backgroundColor: '#FFF', flex: 1, marginTop: 10 }} > {item.code} {item.isRedflush == 0 ? '付款单' : '退款单'} {item.billreceiptState ? stateList[item.billreceiptState] : ''} {ReturnDate(item.creationTime, true, '/')} 付款金额 {item.money} 核销金额 {item.alreadyMoney || 0} 余额 {item.remainMoney || 0} 结算方式:{item.settleMethodName} 收款银行账户:{item.receiptAccountAccountNumber} 产品线:{item.productLineName} 收款业务类型:{item.billreceiptTypeName} 收款金额:{CURRENCY.currencySign} {item.money} 核销订单 核销金额 index} data={item.billlistCheck} extraData={this.state.touchIndex} renderItem={({ item, index }) => ( {item.checkCode || ''} {item.checkMoney || ''} )} /> ) } dateCbFn(data) { if (data.fn && data.fn == 'cancel') { this.setState({ dateActive: true }) } else { this.state.startTime = data.startTime this.state.endTime = data.endTime this.setState({ dateActive: true, reflsh: true, }) this.onRefresh() } } // 底部 footerCom() { if (this.props.showFoot == 0) { return } else if (this.props.showFoot == 1) { return ( 没有更多数据 ) } else if (this.props.showFoot == 2) { return ( 正在加载更多数据... ) } } render() { const { appTheme, accountData, accountBalance, totalPages } = this.props // echart 刷新问题 后期优化 echartDatas = { proTitle: this.state.reflsh, creditBalance: accountBalance, creditLimit: 0, } return ( {this.header()} { // console.log("开始"); // this.setState({ IsScrollEnabled: true }); // }} // onMomentumScrollEnd={() => { // console.log("结束"); // this.setState({ IsScrollEnabled: false }); // }} > this.setState({ activeSection: !this.state.activeSection, reflsh: false, }) } style={{ flexDirection: 'row', padding: 7, backgroundColor: '#FFF', borderBottomColor: '#DDD', borderBottomWidth: 1 / PixelRatio.get(), }} > {this.state.selectText} {/* 图表 */} item.id} data={accountData} renderItem={({ item, index }) => this.jobList(item, index)} ListFooterComponent={this.footerCom.bind(this)} onEndReachedThreshold={0.1} onEndReached={e => { if (this.props.showFoot != 0) { return } if (this.page != 1 && this.page >= totalPages) { return } else { this.page++ } this.props.dispatch( createAction('mine_account/AccountSagas')({ accountReturn: accountData, pageInfo: { page: this.page, size: this.size }, searchInfo: this.searchInfoFn(), forUse: 'slipOn', }) ) }} refreshControl={ this.onRefresh)或者通过bind来绑定this引用来调用方法 tintColor="red" title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'} /> } /> {/* 下拉遮罩 */} {!this.state.activeSection || !this.state.dateActive ? ( ) : null} {/* 应收组织折叠 ---悬浮*/} index} data={this.props.FinancialOrg} extraData={this.state.touchIndex} renderItem={({ item, index }) => this._topOrganization(item, index) } /> this.dateCbFn(data)} /> ) } } const styles = StyleSheet.create({ container: { flex: 1, }, footer: { flexDirection: 'row', height: 24, justifyContent: 'center', alignItems: 'center', marginBottom: 10, marginTop: 10, }, }) export default Account