123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import React, {Component} from 'react';
- import {
- View,
- Text,
- ActivityIndicator,
- FlatList,
- RefreshControl,
- } from 'react-native';
- import {List, SwipeAction} from '@ant-design/react-native';
- import moment from 'moment';
- import {RetrieveData} from '../../data/storage';
- import {RequestNetwork} from '../../data/encryption';
- import invoice_red_rush_css from './invoice_red_rush_css';
- let pageNo = 1; //当前第几页
- let totalPage = 5; //总的页数
- export default class invoice_inquiry_completed extends Component {
- constructor(props) {
- super(props);
- this.state = {
- listData: [],
- search_data: '',
- showFoot: 0, // 控制foot, 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
- isLoading: false,
- };
- }
- render() {
- return (
- <View style={invoice_red_rush_css.container}>
- <FlatList
- data={this.state.listData}
- renderItem={item => this.renderItem(item)}
- refreshControl={
- <RefreshControl
- title={'加载中...'}
- colors={['#B7B7B7']} //此颜色无效
- tintColor={'#B7B7B7'}
- titleColor={'#B7B7B7'} //只有ios有效
- refreshing={this.state.isLoading}
- onRefresh={() => {
- this.initData();
- }}
- />
- }
- ListFooterComponent={this._renderFooter.bind(this)}
- onEndReached={this._onEndReached.bind(this)}
- onEndReachedThreshold={0.1}
- />
- </View>
- );
- }
- //初始化数据
- initData = () => {
- this.setState({
- listData: [],
- isLoading: false,
- showFoot: 0,
- });
- pageNo = 1;
- this.getSearchData();
- };
- //上拉加载
- _onEndReached() {
- if (this.state.showFoot === 0) {
- if (pageNo >= totalPage) {
- this.setState({showFoot: 1});
- return;
- } else {
- pageNo++;
- this.setState({showFoot: 2});
- //获取数据
- this.getSearchData();
- }
- }
- }
- //列表尾部显示
- _renderFooter() {
- if (this.state.showFoot === 1) {
- return (
- <View
- style={{
- height: 30,
- alignItems: 'center',
- justifyContent: 'flex-start',
- }}>
- <Text
- style={{
- color: '#999999',
- fontSize: 14,
- marginTop: 5,
- marginBottom: 5,
- }}>
- 没有更多数据了
- </Text>
- </View>
- );
- } else if (this.state.showFoot === 2) {
- return (
- <View style={invoice_red_rush_css.footer}>
- <ActivityIndicator />
- <Text>正在加载更多数据...</Text>
- </View>
- );
- } else if (this.state.showFoot === 0) {
- return (
- <View style={invoice_red_rush_css.footer}>
- <Text />
- </View>
- );
- }
- }
- //页面加载完后显示数据
- componentDidMount(): void {
- this.props.children.getCompletedRef(this);
- this.getSearchData();
- }
- //页面销毁
- componentWillUnmount(): void {
- pageNo = 1;
- if (this.listener) {
- this.listener.remove();
- }
- }
- //获取查询数据
- getSearchData = async () => {
- let beginTime = '';
- let endTime = '';
- if (this.props.children.state.beginDateTime != undefined) {
- beginTime = moment(this.props.children.state.beginDateTime).format(
- 'YYYY-MM-DD',
- );
- beginTime = beginTime + ' 00:00:00';
- }
- if (this.props.children.state.endDateTime != undefined) {
- endTime = moment(this.props.children.state.endDateTime).format(
- 'YYYY-MM-DD',
- );
- endTime = endTime + ' 23:59:59';
- }
- let account = await RetrieveData('account');
- let token = await RetrieveData('token');
- if (token && account) {
- const url = '/sys/hongchongInfo/findPage';
- RequestNetwork(
- url,
- token,
- {
- mobile: account,
- reqChannel: 3,
- pageNum: pageNo,
- pageSize: 10,
- status: 3,
- invoiceDateBegin: beginTime,
- invoiceDateEnd: endTime,
- belongEntTaxId: this.props.children.state.belongEntTaxId,
- invoiceCode: this.props.children.state.invoiceCode,
- invoiceNumber: this.props.children.state.invoiceNumber,
- },
- false,
- 2,
- ).then(res => {
- totalPage = res.data.pages;
- this.setList(res.data.records);
- });
- }
- };
- //设置列表list数据
- setList = data => {
- let listDatas = data.map((_, i) => ({
- key: data[i].hcId,
- invoiceReqFlowNo: data[i].invoiceReqFlowNo,
- oriInvoiceReqFlowNo: data[i].oriInvoiceReqFlowNo,
- oriInvoiceCode: data[i].oriInvoiceCode,
- oriInvoiceNumber: data[i].oriInvoiceNumber,
- belongEntTaxId: data[i].belongEntTaxId,
- belongEntName: data[i].belongEntName,
- customerName: data[i].customerName,
- totalAmountTaxes: data[i].totalAmountTaxes,
- invoiceCode: data[i].invoiceCode,
- invoiceNumber: data[i].invoiceNumber,
- invoiceDate: data[i].invoiceDate,
- pdfUrl: data[i].pdfUrl,
- customerSpUrl: data[i].customerSpUrl,
- retryFlag: data[i].retryFlag,
- }));
- let list = this.state.listData.concat(listDatas);
- this.setState({
- listData: list,
- showFoot: 0,
- });
- };
- //设置列表list数据
- renderItem = data => (
- <SwipeAction autoClose style={{backgroundColor: 'transparent'}}>
- <List.Item onLongPress={() => {}}>
- <Text style={invoice_red_rush_css.itemTop}>
- {data.item.customerName}
- </Text>
- <View style={invoice_red_rush_css.itemView}>
- <Text style={invoice_red_rush_css.itemViewName}>
- 企业名称:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.belongEntName}
- </Text>
- </Text>
- <Text style={invoice_red_rush_css.itemViewName}>
- 企业税号:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.belongEntTaxId}
- </Text>
- </Text>
- </View>
- <View style={invoice_red_rush_css.itemView}>
- <Text style={invoice_red_rush_css.itemViewName}>
- 发票代码:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.invoiceCode}
- </Text>
- </Text>
- <Text style={invoice_red_rush_css.itemViewName}>
- 发票号码:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.invoiceNumber}
- </Text>
- </Text>
- </View>
- <View style={invoice_red_rush_css.itemView}>
- <Text style={invoice_red_rush_css.itemViewName}>
- 红冲金额:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.totalAmountTaxes
- .toString()
- .replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, '$1,')}
- </Text>
- </Text>
- <Text style={invoice_red_rush_css.itemViewName}>
- 开票日期:
- <Text style={invoice_red_rush_css.itemViewText}>
- {data.item.invoiceDate}
- </Text>
- </Text>
- </View>
- </List.Item>
- </SwipeAction>
- );
- }
|