operation_audit_list.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. TouchableOpacity,
  5. Image,
  6. Text,
  7. RefreshControl,
  8. FlatList,
  9. ActivityIndicator,
  10. } from 'react-native';
  11. import {
  12. DatePicker,
  13. Drawer,
  14. List,
  15. Provider,
  16. Tabs,
  17. Picker,
  18. InputItem,
  19. SwipeAction,
  20. } from '@ant-design/react-native';
  21. import public_css from '../../source/css/public_css';
  22. import operation_audit_css from './operation_audit_css';
  23. import enterprise_css from '../enterpriseInformation/enterprise_css';
  24. import {RetrieveData} from '../../data/storage';
  25. import {GetDataPost} from '../../data/encryption';
  26. import moment from 'moment';
  27. let pageNo = 1; //当前第几页
  28. let totalPage = 5; //总的页数
  29. export default class operation_audit_list extends Component {
  30. constructor(props) {
  31. super(props);
  32. this.props.navigation.dangerouslyGetParent().setOptions({
  33. tabBarVisible: false,
  34. });
  35. this.state = {
  36. listData: [],
  37. search_data: '',
  38. showFoot: 0, // 控制foot, 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
  39. isLoading: false,
  40. operaterName: '',
  41. operaterMobile: '',
  42. opType: '',
  43. clickNum: 0,
  44. visible1: false,
  45. beginDateTime: undefined,
  46. endDateTime: undefined,
  47. };
  48. }
  49. render() {
  50. let draw = (
  51. <View style={public_css.body}>
  52. <View style={{flex: 1}}>
  53. <View>
  54. <List>
  55. <DatePicker
  56. value={this.state.beginDateTime}
  57. mode="date"
  58. defaultDate={new Date()}
  59. minDate={new Date(2020, 0, 1)}
  60. maxDate={new Date(2030, 11, 3)}
  61. onChange={(time) => this.beginTimeChange(time)}
  62. format="YYYY-MM-DD">
  63. <List.Item arrow="horizontal">开始时间</List.Item>
  64. </DatePicker>
  65. </List>
  66. </View>
  67. <View>
  68. <List>
  69. <DatePicker
  70. value={this.state.endDateTime}
  71. mode="date"
  72. defaultDate={new Date()}
  73. minDate={this.state.beginDateTime}
  74. maxDate={new Date(2030, 11, 3)}
  75. onChange={(time) => this.endTimeChange(time)}
  76. format="YYYY-MM-DD">
  77. <List.Item arrow="horizontal">结束时间</List.Item>
  78. </DatePicker>
  79. </List>
  80. </View>
  81. <InputItem
  82. clear
  83. value={this.state.operaterName}
  84. onChange={(value) => {
  85. this.setState({
  86. operaterName: value,
  87. });
  88. }}
  89. placeholder="请输入要查询的操作人员姓名">
  90. 姓名:
  91. </InputItem>
  92. <InputItem
  93. clear
  94. value={this.state.operaterMobile}
  95. onChange={(value) => {
  96. this.setState({
  97. operaterMobile: value,
  98. });
  99. }}
  100. placeholder="请输入要查询的操作人员的手机号">
  101. 手机号:
  102. </InputItem>
  103. <InputItem
  104. clear
  105. value={this.state.opType}
  106. onChange={(value) => {
  107. this.setState({
  108. opType: value,
  109. });
  110. }}
  111. placeholder="请输入要查询的操作功能模块类型">
  112. 功能模块类型:
  113. </InputItem>
  114. </View>
  115. <View style={public_css.bottomStaus}>
  116. <TouchableOpacity
  117. style={[public_css.statusBtn, public_css.statusLBtn]}
  118. onPress={() => {
  119. this.searchDataEmpty();
  120. }}>
  121. <Image
  122. source={require('../../source/img/productImg/clear.png')}
  123. style={{width: 32, height: 32}}
  124. />
  125. <Text>全部清除</Text>
  126. </TouchableOpacity>
  127. <TouchableOpacity
  128. style={[public_css.statusBtn, public_css.statusRBtn]}
  129. onPress={() => this.initData()}>
  130. <Image
  131. source={require('../../source/img/productImg/confirm.png')}
  132. style={{width: 32, height: 32}}
  133. />
  134. <Text style={{color: '#fff'}}>查询</Text>
  135. </TouchableOpacity>
  136. </View>
  137. </View>
  138. );
  139. return (
  140. <View style={{flex: 1}}>
  141. <Provider>
  142. <Drawer
  143. sidebar={draw}
  144. position="right"
  145. open={false}
  146. drawerRef={(el) => (this.drawer = el)}
  147. onOpenChange={(open) => this.openStatus(open)}
  148. drawerBackgroundColor="#ccc"
  149. drawerWidth={300}>
  150. <View style={public_css.body}>
  151. <FlatList
  152. data={this.state.listData}
  153. renderItem={(item) => this.renderItem(item)}
  154. refreshControl={
  155. <RefreshControl
  156. title={'加载中...'}
  157. colors={['#B7B7B7']} //此颜色无效
  158. tintColor={'#B7B7B7'}
  159. titleColor={'#B7B7B7'} //只有ios有效
  160. refreshing={this.state.isLoading}
  161. onRefresh={() => {
  162. this.initData();
  163. }}
  164. />
  165. }
  166. ListFooterComponent={this._renderFooter.bind(this)}
  167. onEndReached={this._onEndReached.bind(this)}
  168. onEndReachedThreshold={0.1}
  169. />
  170. </View>
  171. </Drawer>
  172. </Provider>
  173. </View>
  174. );
  175. }
  176. componentDidMount() {
  177. this.getOperationData();
  178. }
  179. //数据初始化
  180. initData = () => {
  181. this.drawer.closeDrawer();
  182. this.setState({
  183. listData: [],
  184. isLoading: false,
  185. showFoot: 0,
  186. });
  187. pageNo = 1;
  188. this.getOperationData();
  189. };
  190. //上拉加载
  191. _onEndReached() {
  192. if (this.state.showFoot === 0) {
  193. if (pageNo >= totalPage) {
  194. this.setState({showFoot: 1});
  195. return;
  196. } else {
  197. pageNo++;
  198. this.setState({showFoot: 2});
  199. //获取数据
  200. this.getOperationData();
  201. }
  202. }
  203. }
  204. //显示list尾部
  205. _renderFooter() {
  206. if (this.state.showFoot === 1) {
  207. return (
  208. <View
  209. style={{
  210. height: 30,
  211. alignItems: 'center',
  212. justifyContent: 'flex-start',
  213. }}>
  214. <Text
  215. style={{
  216. color: '#999999',
  217. fontSize: 14,
  218. marginTop: 5,
  219. marginBottom: 5,
  220. }}>
  221. 没有更多数据了
  222. </Text>
  223. </View>
  224. );
  225. } else if (this.state.showFoot === 2) {
  226. return (
  227. <View style={enterprise_css.footer}>
  228. <ActivityIndicator />
  229. <Text>正在加载更多数据...</Text>
  230. </View>
  231. );
  232. } else if (this.state.showFoot === 0) {
  233. return (
  234. <View style={enterprise_css.footer}>
  235. <Text />
  236. </View>
  237. );
  238. }
  239. }
  240. //判断是否点击了查询
  241. shouldComponentUpdate(
  242. nextProps: Readonly<P>,
  243. nextState: Readonly<S>,
  244. nextContext: any,
  245. ): boolean {
  246. if (nextProps.route.params != undefined) {
  247. if (nextProps.route.params.isShow) {
  248. console.log(this.state.clickNum);
  249. if (this.state.clickNum === 0) {
  250. this.setState({
  251. isShowSearch: true,
  252. clickNum: this.state.clickNum++,
  253. });
  254. this.drawer.openDrawer();
  255. this.props.navigation.setParams({
  256. isShow: false,
  257. });
  258. }
  259. }
  260. }
  261. return true;
  262. }
  263. //获取查询数据
  264. getOperationData = async () => {
  265. let beginTime = '';
  266. let endTime = '';
  267. if (this.state.beginDateTime != undefined) {
  268. beginTime = moment(this.state.beginDateTime).format('YYYY-MM-DD');
  269. beginTime = beginTime + ' 00:00:00';
  270. }
  271. if (this.state.endDateTime != undefined) {
  272. endTime = moment(this.state.endDateTime).format('YYYY-MM-DD');
  273. endTime = endTime + ' 23:59:59';
  274. }
  275. let account = await RetrieveData('account');
  276. let token = await RetrieveData('token');
  277. if (token && account) {
  278. account = account.substring(1, account.length - 1);
  279. token = token.substring(1, token.length - 1);
  280. const url = 'https://app.taxbk.cn:9443/auth/log/findPage';
  281. GetDataPost(
  282. url,
  283. token,
  284. {
  285. mobile: account,
  286. operaterMobile: this.state.operaterMobile,
  287. operaterName: this.state.operaterName,
  288. createBeginTime: beginTime,
  289. createEndTime: endTime,
  290. opType: this.state.opType,
  291. pageNum: pageNo,
  292. pageSize: 10,
  293. },
  294. false,
  295. 2,
  296. ).then((res) => {
  297. console.log(res);
  298. totalPage = res.data.pages;
  299. this.setList(res.data.records);
  300. });
  301. }
  302. };
  303. //设置客户数据列表
  304. setList = (data) => {
  305. let listDatas = data.map((_, i) => ({
  306. key: data[i].id,
  307. userName: data[i].userName,
  308. mobile: data[i].mobile,
  309. opType: data[i].opType,
  310. opDesc: data[i].opDesc,
  311. ip: data[i].ip,
  312. createTime: data[i].createTime,
  313. }));
  314. let list = this.state.listData.concat(listDatas);
  315. this.setState({
  316. listData: list,
  317. showFoot: 0,
  318. });
  319. };
  320. //加载客户列表数据
  321. renderItem = (data) => (
  322. <SwipeAction>
  323. <List.Item>
  324. <View style={{flex: 1}}>
  325. <View
  326. style={{
  327. flexDirection: 'row',
  328. justifyContent: 'space-between',
  329. margin: 5,
  330. }}>
  331. <Text style={operation_audit_css.fontSize}>时间:</Text>
  332. <Text style={operation_audit_css.fontSize}>
  333. {data.item.createTime}
  334. </Text>
  335. </View>
  336. <View
  337. style={{
  338. flexDirection: 'row',
  339. justifyContent: 'space-between',
  340. margin: 5,
  341. }}>
  342. <Text style={operation_audit_css.fontSize}>操作人员姓名:</Text>
  343. <Text style={operation_audit_css.fontSize}>
  344. {data.item.userName}
  345. </Text>
  346. </View>
  347. <View
  348. style={{
  349. flexDirection: 'row',
  350. justifyContent: 'space-between',
  351. margin: 5,
  352. }}>
  353. <Text style={operation_audit_css.fontSize}>功能模块类型:</Text>
  354. <Text style={operation_audit_css.fontSize}>{data.item.opType}</Text>
  355. </View>
  356. <View
  357. style={{
  358. flexDirection: 'row',
  359. justifyContent: 'space-between',
  360. margin: 5,
  361. }}>
  362. <Text style={operation_audit_css.fontSize}>操作描述:</Text>
  363. <Text style={operation_audit_css.fontSize}>{data.item.opDesc}</Text>
  364. </View>
  365. </View>
  366. </List.Item>
  367. </SwipeAction>
  368. );
  369. //查询菜单开关状态
  370. openStatus = (open) => {
  371. if (open) {
  372. } else {
  373. // this.props.children.setClickNum();
  374. }
  375. };
  376. //获取查询开始时间
  377. beginTimeChange = (time) => {
  378. this.setState({
  379. beginDateTime: time,
  380. });
  381. };
  382. //获取查询结束时间
  383. endTimeChange = (time) => {
  384. this.setState({
  385. endDateTime: time,
  386. });
  387. };
  388. //清空查询数据
  389. searchDataEmpty = () => {
  390. this.setState({
  391. beginDateTime: undefined,
  392. endDateTime: undefined,
  393. operaterName: '',
  394. operaterMobile: '',
  395. opType: '',
  396. });
  397. };
  398. }