import React, { Component } from 'react' import { StyleSheet, ScrollView, View, Image, ImageBackground, Text, Dimensions, StatusBar, TouchableOpacity, FlatList, PixelRatio, Platform, DatePickerAndroid, } from 'react-native' import { connect } from 'react-redux' import Input from '../../../components/input/index' import Icon from '../../../components/Iconfont/Iconfont' import { NavigationActions, createAction } from '../../../utils' import SelectTime from '../../common/SelectTime' import Collapsible from 'react-native-collapsible' import SelectTimeCom from '../../../components/selectTime/selectTime' import { ReturnDate } from '../../../utils/utils' const { width, height } = Dimensions.get('window') @connect(({ theme, mine, mine_payment }) => ({ ...theme, ...mine, ...mine_payment, })) class PayReconciliation extends Component { constructor(props) { const date = new Date() super(props) this.state = { data: [], showSearch: false, dateActive: true, //时间折叠-true为关 activeSection: true, // 应收组织Index receiveIndex: 0, // 销售组织Index saleIndex: 'fff', // 应收组织 receivableOrgan: props.FinancialOrg && props.FinancialOrg.length > 0 ? props.FinancialOrg[0].finanOrgName : '', receivableId: props.FinancialOrg && props.FinancialOrg.length > 0 ? props.FinancialOrg[0].finanOrgId : '', // 销售组织 saleOrgan: '请选择销售组织', // props.SupplierInfo && props.SupplierInfo.length > 0 // ? props.SupplierInfo[0].saleOrganizationName // : "请选择销售组织", saleId: '', // props.SupplierInfo && props.SupplierInfo.length > 0 // ? props.SupplierInfo[0].saleOrganizationId // : "", // saleOrgan: "请选择销售组织", // 头部inputText inputText: '', // 开始时间 startTime: '', // 结束时间 endTime: '', } // this.startTime = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + 1; // this.endTime = // date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); // this.startTime = 0; // this.endTime = 0; } componentDidMount() { // 可用财务组织 this.props.dispatch( createAction('mine/getCusSup')({ customerId: CUSTOMERINFO.id, customerRankCode: CUSTOMERINFO.customerRankCode, }) ) this.statisticPatch() this.findSaleOrg() } // 应收组织统计页 statisticPatch() { this.props.dispatch( createAction('mine_payment/getPayStatistic')({ searchInfo: this.statsticInfo(), }) ) } statsticInfo() { let search = { financeOrgId: this.state.receivableId, } if (this.state.saleId) { search.saleOrgId = this.state.saleId } if (this.state.startTime && this.state.endTime) { search.startTime = this.state.startTime search.endTime = this.state.endTime } return search } findSaleOrg() { // 通过财务组织找销售组织 this.props.dispatch( createAction('mine/findSaleOrgByFinance')({ search_EQ_finanOrg: this.state.receivableId, size: 20, page: 0, }) ) } // 头部 header() { return ( this.props.dispatch(NavigationActions.back())} > 返回 {this.state.showSearch ? ( { this.setState({ inputText: e }) }} /> ) : ( 应付对账 )} {this.state.showSearch ? ( this.setState({ showSearch: false, activeSection: true }) } style={{ position: 'absolute', right: 10, flexDirection: 'row' }} > 取消 ) : ( {/* this.setState({ showSearch: true, activeSection: true }) } > */} this.setState({ dateActive: !this.state.dateActive }) } > )} ) } collapsibleData(item, index) { return ( { if (this.state.filiter == 'Receivable') { this.state.receivableId = item.finanOrgId this.setState({ receivableOrgan: item.finanOrgName, receivableId: item.finanOrgId, activeSection: true, receiveIndex: index, }) } else { this.state.saleId = item.saleOrganizationId this.setState({ saleOrgan: item.saleOrganizationName, saleId: item.saleOrganizationId, activeSection: true, saleIndex: index, }) } this.statisticPatch() }} style={{ flexDirection: 'row', padding: 10, justifyContent: 'space-between', }} > {this.state.filiter == 'Receivable' ? item.finanOrgName : item.saleOrganizationName} {this.state.filiter == 'Receivable' && this.state.receiveIndex == index ? ( ) : null} {this.state.filiter == 'Sale' && this.state.saleIndex == index ? ( ) : null} ) } HeadScreening(from) { if (this.state.filiter !== from) { this.setState({ activeSection: false }) } else if (this.state.filiter == from) { if (this.state.activeSection == false) { this.setState({ activeSection: true }) } else { this.setState({ activeSection: false }) } } switch (from) { case 'Receivable': this.state.filiter = 'Receivable' this.setState({ data: this.props.FinancialOrg }) break case 'Sale': this.state.filiter = 'Sale' this.setState({ data: this.props.SupplierInfo }) break } } 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, }) this.statisticPatch() } } receiveList(item, index) { return ( this.props.dispatch( NavigationActions.navigate({ routeName: 'ReconciliationDetail', params: { comeFrom: 'Pay', startTime: this.state.startTime, endTime: this.endTime, Search_FinaOrg: item.financeOrgId, saleId: item.saleOrgId, }, }) ) } style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }} > {item.saleOrgName} 期初余额 {item.initialBalance} 本期发生 {item.occurrenceOfThisPeriod} 本期收款 {item.currenTreceipts} 期末余额 {item.finalBalance} ) } render() { const { appTheme, payStaticData } = this.props return ( {this.header()} {/* 头部筛选条件 */} this.HeadScreening('Receivable')} style={{ flex: 1, alignItems: 'center', borderRightColor: '#EEE', borderRightWidth: 1, }} > {this.state.receivableOrgan} this.HeadScreening('Sale')} style={{ flex: 1, alignItems: 'center', }} > {this.state.saleOrgan || '-'} index} data={payStaticData} renderItem={({ item, index }) => this.receiveList(item, index)} /> {/* 下拉遮罩 */} {!this.state.activeSection || !this.state.dateActive ? ( ) : null} {/* 筛选条件下拉 */} index} data={this.state.data} extraData={this.state} renderItem={({ item, index }) => this.collapsibleData(item, index) } /> this.dateCbFn(data)} /> ) } } const styles = StyleSheet.create({ container: { flex: 1, }, pngstyle: { width: width, }, buttonStyle: { backgroundColor: 'transparent', flexDirection: 'column', alignItems: 'center', }, buttonText: { marginTop: 9, fontSize: 14, color: '#FFF', }, }) export default PayReconciliation