123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- 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 = (
- <View style={public_css.body}>
- <View style={{flex: 1}}>
- <View>
- <List>
- <DatePicker
- value={this.state.beginDateTime}
- mode="date"
- defaultDate={new Date()}
- minDate={new Date(2020, 0, 1)}
- maxDate={new Date(2030, 11, 3)}
- onChange={(time) => this.beginTimeChange(time)}
- format="YYYY-MM-DD">
- <List.Item arrow="horizontal">开始时间</List.Item>
- </DatePicker>
- </List>
- </View>
- <View>
- <List>
- <DatePicker
- value={this.state.endDateTime}
- mode="date"
- defaultDate={new Date()}
- minDate={this.state.beginDateTime}
- maxDate={new Date(2030, 11, 3)}
- onChange={(time) => this.endTimeChange(time)}
- format="YYYY-MM-DD">
- <List.Item arrow="horizontal">结束时间</List.Item>
- </DatePicker>
- </List>
- </View>
- <InputItem
- clear
- value={this.state.operaterName}
- onChange={(value) => {
- this.setState({
- operaterName: value,
- });
- }}
- placeholder="请输入要查询的操作人员姓名">
- 姓名:
- </InputItem>
- <InputItem
- clear
- value={this.state.operaterMobile}
- onChange={(value) => {
- this.setState({
- operaterMobile: value,
- });
- }}
- placeholder="请输入要查询的操作人员的手机号">
- 手机号:
- </InputItem>
- <InputItem
- clear
- value={this.state.opType}
- onChange={(value) => {
- this.setState({
- opType: value,
- });
- }}
- placeholder="请输入要查询的操作功能模块类型">
- 功能模块类型:
- </InputItem>
- </View>
- <View style={public_css.bottomStaus}>
- <TouchableOpacity
- style={[public_css.statusBtn, public_css.statusLBtn]}
- onPress={() => {
- this.searchDataEmpty();
- }}>
- <Image
- source={require('../../source/img/productImg/clear.png')}
- style={{width: 32, height: 32}}
- />
- <Text>全部清除</Text>
- </TouchableOpacity>
- <TouchableOpacity
- style={[public_css.statusBtn, public_css.statusRBtn]}
- onPress={() => this.initData()}>
- <Image
- source={require('../../source/img/productImg/confirm.png')}
- style={{width: 32, height: 32}}
- />
- <Text style={{color: '#fff'}}>查询</Text>
- </TouchableOpacity>
- </View>
- </View>
- );
- return (
- <View style={{flex: 1}}>
- <Provider>
- <Drawer
- sidebar={draw}
- position="right"
- open={false}
- drawerRef={(el) => (this.drawer = el)}
- onOpenChange={(open) => this.openStatus(open)}
- drawerBackgroundColor="#ccc"
- drawerWidth={300}>
- <View style={public_css.body}>
- <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>
- </Drawer>
- </Provider>
- </View>
- );
- }
- 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 (
- <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={enterprise_css.footer}>
- <ActivityIndicator />
- <Text>正在加载更多数据...</Text>
- </View>
- );
- } else if (this.state.showFoot === 0) {
- return (
- <View style={enterprise_css.footer}>
- <Text />
- </View>
- );
- }
- }
- //判断是否点击了查询
- shouldComponentUpdate(
- nextProps: Readonly<P>,
- nextState: Readonly<S>,
- 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) => (
- <SwipeAction>
- <List.Item>
- <View style={{flex: 1}}>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- margin: 5,
- }}>
- <Text style={operation_audit_css.fontSize}>时间:</Text>
- <Text style={operation_audit_css.fontSize}>
- {data.item.createTime}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- margin: 5,
- }}>
- <Text style={operation_audit_css.fontSize}>操作人员姓名:</Text>
- <Text style={operation_audit_css.fontSize}>
- {data.item.userName}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- margin: 5,
- }}>
- <Text style={operation_audit_css.fontSize}>功能模块类型:</Text>
- <Text style={operation_audit_css.fontSize}>{data.item.opType}</Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- margin: 5,
- }}>
- <Text style={operation_audit_css.fontSize}>操作描述:</Text>
- <Text style={operation_audit_css.fontSize}>{data.item.opDesc}</Text>
- </View>
- </View>
- </List.Item>
- </SwipeAction>
- );
- //查询菜单开关状态
- 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: '',
- });
- };
- }
|