import React, { Component } from 'react'
import {
StyleSheet,
ScrollView,
View,
Text,
Dimensions,
StatusBar,
TouchableOpacity,
PixelRatio,
FlatList,
DatePickerAndroid,
Platform,
} from 'react-native'
import { connect } from 'react-redux'
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'
import { setNowFormatDate } from '../../../utils/utils'
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_header, mine }) => ({ ...theme, ...mine_header, mine }))
class CostReconciliation extends Component {
constructor(props) {
const date = new Date()
super(props)
this.state = {
reflsh: true,
castAmtData: [],
FinancialOrg: props.mine.FinancialOrg,
Show_FinaOrg:
props.mine.FinancialOrg.length > 0
? props.mine.FinancialOrg[0].finanOrgName
: '应收组织',
Search_FinaOrg:
props.mine.FinancialOrg.length > 0
? props.mine.FinancialOrg[0].finanOrgId
: '',
activeSection: true,
dateActive: true,
echartData: data[0],
touchIndex: 0,
// 开始时间 --显示用
startTime: setNowFormatDate(true),
// 结束时间 ---显示用
endTime: setNowFormatDate(),
}
}
componentDidMount = () => {
this.searchTouch()
}
searchTouch() {
this.props
.dispatch(
createAction('mine_header/CastAmountSaga')({
pageInfo: { size: 5, page: 0 },
castAmt: [],
searchInfo: this.searchCast(),
})
)
.finally(() => {
if (this.props.castAmtData) {
this.state.castAmtData = this.props.castAmtData
this.setState({
castAmtData: this.props.castAmtData,
})
}
})
}
searchCast() {
postInfo = {
search_IN_financeOrg: this.state.Search_FinaOrg,
search_IN_customer: CUSTOMERINFO.id,
}
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
}
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.searchTouch()
}
}
// 头部
header() {
return (
this.props.dispatch(NavigationActions.back())}
>
返回
费用对账
this.setState({
dateActive: !this.state.dateActive,
activeSection: true,
reflsh: false,
})
}
>
)
}
_topOrganization(item, index) {
return (
{
this.state.Search_FinaOrg = item.finanOrgId
this.setState({
activeSection: true,
Show_FinaOrg: item.finanOrgName,
touchIndex: index,
reflsh: true,
})
this.searchTouch()
}}
style={{
flexDirection: 'row',
justifyContent: 'space-between',
padding: 10,
backgroundColor: '#FFF',
}}
>
{item.finanOrgName}
{this.state.touchIndex == index ? (
) : null}
)
}
// 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
// }
// }
render() {
const { appTheme } = this.props
const { castAmtData } = this.state
// echart 刷新问题 后期优化
let echartDatas = {
proTitle: this.state.reflsh,
creditBalance: castAmtData.endBalance,
creditLimit: 0,
}
return (
{this.header()}
this.setState({
activeSection: !this.state.activeSection,
dateActive: true,
reflsh: false,
})
}
style={{
flexDirection: 'row',
padding: 10,
backgroundColor: '#FFF',
borderBottomColor: '#DDD',
borderBottomWidth: 1 / PixelRatio.get(),
}}
>
{this.state.Show_FinaOrg}
{/* 图表 */}
{/* 余额显示 */}
期初余额
{castAmtData.openBalance || 0}
增加
{castAmtData.castIncre || 0}
减少
{castAmtData.castReduce || 0}
{/* 查看详情 */}
this.props.dispatch(
NavigationActions.navigate({
routeName: 'ReconciliationDetail',
params: {
comeFrom: 'Cost',
startTime: this.state.startTime,
endTime: this.state.endTime,
Search_FinaOrg: this.state.Search_FinaOrg,
},
})
)
}
style={{
alignSelf: 'center',
paddingVertical: 9,
paddingHorizontal: 36,
backgroundColor: '#F56151',
borderRadius: 100,
}}
>
查看详情
{/* 下拉遮罩 */}
{!this.state.activeSection || !this.state.dateActive ? (
) : null}
{/* 应收组织折叠 ---悬浮*/}
item.id + index}
data={this.state.FinancialOrg}
extraData={this.state.touchIndex}
renderItem={({ item, index }) =>
this._topOrganization(item, index)
}
/>
{/* 时间弹窗 */}
this.dateCbFn(data)}
/>
{/* (this.showTime = showTime)}
cb={(date, mark) => {
let newDate =
date &&
`${date.getFullYear()}-${date.getMonth() +
1}-${date.getDate()}`;
if (mark == "start") {
// if (newDate <= this.endTime) {
this.setState({
startTime: newDate
});
// }
} else if (mark == "end") {
// if (this.startTime <= newDate) {
this.setState({
endTime: newDate
});
// }
}
}}
/> */}
{/* 时间选择下拉 */}
{/*
开始时间
Platform.OS == "ios"
? this.showTime._openModal("start")
: this.TimeAndroid("start")
}
style={{
paddingHorizontal: 40,
paddingVertical: 7,
marginTop: 16,
borderColor: "#DDD",
borderWidth: 1,
borderRadius: 100
}}
>
{this.state.startTime}
~
结束时间
Platform.OS == "ios"
? this.showTime._openModal("end")
: this.TimeAndroid("end")
}
style={{
paddingHorizontal: 40,
paddingVertical: 7,
marginTop: 16,
borderColor: "#DDD",
borderWidth: 1,
borderRadius: 100
}}
>
{this.state.endTime}
{
this.setState({
dateActive: true,
startTime: this.startTime,
endTime: this.endTime
});
}}
style={{
width: width / 2,
backgroundColor: "#FFF",
justifyContent: "center"
}}
>
取消
{
this.startTime = this.state.startTime;
this.endTime = this.state.endTime;
this.setState({
dateActive: true,
reflsh: true
});
this.searchTouch();
}}
style={{
width: width / 2,
backgroundColor: "#E70013",
justifyContent: "center"
}}
>
确定
*/}
)
}
}
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 CostReconciliation