import React, { Component } from 'react'
import {
StyleSheet,
View,
Text,
ActivityIndicator,
Dimensions,
StatusBar,
TouchableOpacity,
PixelRatio,
FlatList,
DatePickerAndroid,
RefreshControl,
Platform,
} 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 { accAdd, ReturnDate } from '../../../utils/utils'
import Collapsible from 'react-native-collapsible'
import SelectTime from '../../common/SelectTime'
const { width, height } = Dimensions.get('window')
@connect(({ theme, mine_header, mine_payment }) => ({
...theme,
...mine_header,
...mine_payment,
}))
class ReconciliationDetail extends Component {
constructor(props) {
const date = new Date()
super(props)
this.state = {
dateActive: true,
listActive: 'asdasd',
showSearch: false,
detailList: [],
// 开始时间
startTime: props.navigation.state.params.startTime,
// 结束时间
endTime: props.navigation.state.params.endTime,
// 财务组织
Search_FinaOrg: props.navigation.state.params.Search_FinaOrg,
saleId: props.navigation.state.params.saleId,
}
this.page = 0
this.size = 5
}
componentDidMount = () => {
this.props.navigation.state.params.comeFrom == 'Cost'
? this.props.dispatch(
createAction('mine_header/CastAmountSaga')({
pageInfo: { size: 5, page: 0 },
searchInfo: this.searchInfo(),
castAmt: [],
})
)
: this.props.dispatch(
createAction('mine_payment/PayDetailListSagas')({
payActionData: [],
pageInfo: { page: this.page, size: this.size },
searchInfo: this.statsticInfo(),
})
)
}
// 费用对账请求参数
searchInfo() {
postInfo = {
search_IN_financeOrg: this.state.Search_FinaOrg,
search_IN_customer: CUSTOMERINFO.id,
// search_GTE_billDate_date: new Date(this.state.startTime).getTime(),
// search_LT_billDate_date: new Date(this.state.endTime).getTime()
}
if (this.state.startTime) {
postInfo.search_GTE_billDate_date = new Date(
this.state.startTime
).getTime()
}
if (this.state.endTime) {
postInfo.search_LT_billDate_date = new Date(this.state.endTime).getTime()
}
return postInfo
}
// 应付对账请求参数
statsticInfo() {
let search = {
search_EQ_financeOrg: this.state.Search_FinaOrg,
}
if (this.state.saleId) {
search.search_EQ_saleOrg = this.state.saleId
}
if (this.state.startTime && this.state.endTime) {
search.search_GTE_creationTime_date = this.state.startTime
search.search_LT_creationTime_date = this.state.endTime
}
// if (this.state.searchText) {
// search.search_LIKE_code = this.state.searchText;
// }
return search
}
onRefresh() {
this.props.dispatch(
createAction('mine_header/CastAmountSaga')({
castAmt: [],
pageInfo: { page: 0, size: this.size },
searchInfo: this.searchInfo(),
})
)
this.page = 0
}
// 头部
header() {
return (
this.props.dispatch(NavigationActions.back())}
>
返回
{this.props.navigation.state.params.comeFrom == 'Cost' ? (
费用对账
) : this.state.showSearch ? (
{
this.setState({ activeSection: true })
}}
/>
) : (
应付对账
)}
{/* {this.props.navigation.state.params == "Cost" ? (
this.setState({ dateActive: !this.state.dateActive })
}
>
) : 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 })
}
>
)} */}
)
}
async TimeAndroid(mark) {
const { action, year, month, day } = await DatePickerAndroid.open({
date: new Date(),
// minDate: new Date(),
mode: 'spinner',
})
if (action !== DatePickerAndroid.dismissedAction) {
let newDate = `${year}-${month + 1}-${day}`
if (mark == 'start') {
if (newDate <= this.state.endTime) {
this.setState({
startTime: newDate,
})
}
} else if (mark == 'end') {
if (this.state.startTime <= newDate) {
this.setState({
endTime: newDate,
})
}
}
// 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day
}
}
ReconciliationList(item, index) {
return (
{
if (this.state.listActive == index) {
this.setState({ listActive: 'asdasd' })
} else {
this.props.dispatch(
createAction('mine_header/CastDetailSaga')({ id: item.id })
)
this.setState({ listActive: index })
}
}}
style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}
>
{item.billCode || item.code}
{this.props.navigation.state.params.comeFrom == 'Cost' ? (
{item.castTypeName}
) : null}
{ReturnDate(item.billDate || item.creationTime, true)}
{item.customerName || item.saleOrgName}
{this.props.navigation.state.params.comeFrom == 'Cost' ? (
费用金额
{item.castAmount}
订单冲抵
{accAdd(
item.actualFlushAmount,
item.actualGoodssupplementAmount
)}
余额
{item.castBalance}
) : (
应付金额
{item.receivableMoney}
核销金额
{item.cancellationMoney}
付款核销额
{item.payMoney}
退款核销额
{item.backMoney}
)}
{this.props.navigation.state.params.comeFrom == 'Cost' ? (
订货单编码
订单日期
冲抵金额
) : (
核销金额:{CURRENCY.currencySign}
{item.cancellationMoney}
关联订单号:{item.srcOrderCode}
关联出库单号:{item.srcBillcode}
收款单号
收款核销日
收款核销额
)}
{this.props.navigation.state.params.comeFrom == 'Cost'
? this.props.castDetail.map((item, key) => (
{item.customerOrderCode}
{ReturnDate(item.billDate, true)}
{item.flushAmount}
))
: item.billlistPaymentAccount.map((itempay, key) => (
{itempay.paymentCode}
{ReturnDate(itempay.paymentTime, true)}
{itempay.paymentMoney}
))}
{this.props.navigation.state.params.comeFrom == 'Cost' ? null : (
退款单号
退款核销日期
退款核销额
{item.billlistRefundAccount.map((itemrefund, key) => (
{itemrefund.refundCode}
{itemrefund.refundTime}
{itemrefund.refundMoney}
))}
)}
)
}
// 底部
footerCom() {
if (this.props.showFoot == 0) {
return
} else if (this.props.showFoot == 1) {
return (
没有更多数据
)
} else if (this.props.showFoot == 2) {
return (
正在加载更多数据...
)
}
}
render() {
const { appTheme, castAmtContent, totalPages, payDetailData } = this.props
return (
{this.header()}
{/* 列表 */}
item.id}
data={
this.props.navigation.state.params.comeFrom == 'Cost'
? castAmtContent
: payDetailData
}
extraData={this.state.listActive}
renderItem={({ item, index }) => this.ReconciliationList(item, index)}
ListFooterComponent={this.footerCom.bind(this)}
// initialNumToRender={5}
onEndReachedThreshold={0.1}
onEndReached={e => {
if (this.props.showFoot != 0) {
return
}
if (this.page != 1 && this.page >= totalPages) {
return
} else {
this.page++
}
this.props.navigation.state.params.comeFrom == 'Cost'
? this.props.dispatch(
createAction('mine_header/CastAmountSaga')({
castAmt: castAmtContent,
pageInfo: { page: this.page, size: this.size },
searchInfo: this.searchInfo(),
forUse: 'slipOn',
})
)
: this.props.dispatch(
createAction('mine_payment/PayDetailListSagas')({
payActionData: payDetailData,
pageInfo: { page: this.page, size: this.size },
searchInfo: this.statsticInfo(),
forUse: 'slipOn',
})
)
}}
refreshControl={
this.onRefresh)或者通过bind来绑定this引用来调用方法
tintColor="red"
title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
/>
}
/>
{/* 下拉遮罩 */}
{!this.state.dateActive ? (
) : null}
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
footer: {
flexDirection: 'row',
height: 24,
justifyContent: 'center',
alignItems: 'center',
marginBottom: 10,
marginTop: 10,
},
})
export default ReconciliationDetail