import React, {Component} from 'react'; import { View, TouchableOpacity, Image, Text, RefreshControl, FlatList, ActivityIndicator, } from 'react-native'; import { DatePicker, Drawer, List, Provider, Tabs, Picker, InputItem, SwipeAction, } from '@ant-design/react-native'; import public_css from '../../source/css/public_css'; import operation_audit_css from './operation_audit_css'; import enterprise_css from '../enterpriseInformation/enterprise_css'; import {RetrieveData} from '../../data/storage'; import {GetDataPost} from '../../data/encryption'; import moment from 'moment'; let pageNo = 1; //当前第几页 let totalPage = 5; //总的页数 export default class operation_audit_list extends Component { constructor(props) { super(props); this.props.navigation.dangerouslyGetParent().setOptions({ tabBarVisible: false, }); this.state = { listData: [], search_data: '', showFoot: 0, // 控制foot, 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中 isLoading: false, operaterName: '', operaterMobile: '', opType: '', clickNum: 0, visible1: false, beginDateTime: undefined, endDateTime: undefined, }; } render() { let draw = ( this.beginTimeChange(time)} format="YYYY-MM-DD"> 开始时间 this.endTimeChange(time)} format="YYYY-MM-DD"> 结束时间 { this.setState({ operaterName: value, }); }} placeholder="请输入要查询的操作人员姓名"> 姓名: { this.setState({ operaterMobile: value, }); }} placeholder="请输入要查询的操作人员的手机号"> 手机号: { this.setState({ opType: value, }); }} placeholder="请输入要查询的操作功能模块类型"> 功能模块类型: { this.searchDataEmpty(); }}> 全部清除 this.initData()}> 查询 ); return ( (this.drawer = el)} onOpenChange={(open) => this.openStatus(open)} drawerBackgroundColor="#ccc" drawerWidth={300}> this.renderItem(item)} refreshControl={ { this.initData(); }} /> } ListFooterComponent={this._renderFooter.bind(this)} onEndReached={this._onEndReached.bind(this)} onEndReachedThreshold={0.1} /> ); } componentDidMount() { this.getOperationData(); } //数据初始化 initData = () => { this.drawer.closeDrawer(); this.setState({ listData: [], isLoading: false, showFoot: 0, }); pageNo = 1; this.getOperationData(); }; //上拉加载 _onEndReached() { if (this.state.showFoot === 0) { if (pageNo >= totalPage) { this.setState({showFoot: 1}); return; } else { pageNo++; this.setState({showFoot: 2}); //获取数据 this.getOperationData(); } } } //显示list尾部 _renderFooter() { if (this.state.showFoot === 1) { return ( 没有更多数据了 ); } else if (this.state.showFoot === 2) { return ( 正在加载更多数据... ); } else if (this.state.showFoot === 0) { return ( ); } } //判断是否点击了查询 shouldComponentUpdate( nextProps: Readonly

, nextState: Readonly, nextContext: any, ): boolean { if (nextProps.route.params != undefined) { if (nextProps.route.params.isShow) { console.log(this.state.clickNum); if (this.state.clickNum === 0) { this.setState({ isShowSearch: true, clickNum: this.state.clickNum++, }); this.drawer.openDrawer(); this.props.navigation.setParams({ isShow: false, }); } } } return true; } //获取查询数据 getOperationData = async () => { let beginTime = ''; let endTime = ''; if (this.state.beginDateTime != undefined) { beginTime = moment(this.state.beginDateTime).format('YYYY-MM-DD'); beginTime = beginTime + ' 00:00:00'; } if (this.state.endDateTime != undefined) { endTime = moment(this.state.endDateTime).format('YYYY-MM-DD'); endTime = endTime + ' 23:59:59'; } let account = await RetrieveData('account'); let token = await RetrieveData('token'); if (token && account) { account = account.substring(1, account.length - 1); token = token.substring(1, token.length - 1); const url = 'https://app.taxbk.cn:9443/auth/log/findPage'; GetDataPost( url, token, { mobile: account, operaterMobile: this.state.operaterMobile, operaterName: this.state.operaterName, createBeginTime: beginTime, createEndTime: endTime, opType: this.state.opType, pageNum: pageNo, pageSize: 10, }, false, 2, ).then((res) => { console.log(res); totalPage = res.data.pages; this.setList(res.data.records); }); } }; //设置客户数据列表 setList = (data) => { let listDatas = data.map((_, i) => ({ key: data[i].id, userName: data[i].userName, mobile: data[i].mobile, opType: data[i].opType, opDesc: data[i].opDesc, ip: data[i].ip, createTime: data[i].createTime, })); let list = this.state.listData.concat(listDatas); this.setState({ listData: list, showFoot: 0, }); }; //加载客户列表数据 renderItem = (data) => ( 时间: {data.item.createTime} 操作人员姓名: {data.item.userName} 功能模块类型: {data.item.opType} 操作描述: {data.item.opDesc} ); //查询菜单开关状态 openStatus = (open) => { if (open) { } else { // this.props.children.setClickNum(); } }; //获取查询开始时间 beginTimeChange = (time) => { this.setState({ beginDateTime: time, }); }; //获取查询结束时间 endTimeChange = (time) => { this.setState({ endDateTime: time, }); }; //清空查询数据 searchDataEmpty = () => { this.setState({ beginDateTime: undefined, endDateTime: undefined, operaterName: '', operaterMobile: '', opType: '', }); }; }