| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useIntl, FormattedMessage, useAccess } from '@umijs/max'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components'; |
| | | import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, UnlockOutlined } from '@ant-design/icons'; |
| | | import { getLogininforList, removeLogininfor, exportLogininfor, unlockLogininfor, cleanLogininfor } from '@/services/monitor/logininfor'; |
| | | import { request } from '@umijs/max'; |
| | | import { getLogininforList, removeLogininfor, exportLogininfor} from '@/services/monitor/logininfor'; |
| | | import Http from '@/utils/http' |
| | | |
| | | |
| | |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('删除失败,请重试'); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | const handleClean = async () => { |
| | | const hide = message.loading('请稍候'); |
| | | try { |
| | | const resp = await cleanLogininfor(); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('清空成功,即将刷新'); |
| | | } else { |
| | | message.error(resp.msg); |
| | | } |
| | | return true; |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('请求失败,请重试'); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | const handleUnlock = async (userName) => { |
| | | const hide = message.loading('正在解锁'); |
| | | try { |
| | | const resp = await unlockLogininfor(userName); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('解锁成功,即将刷新'); |
| | | } else { |
| | | message.error(resp.msg); |
| | | } |
| | | return true; |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('解锁失败,请重试'); |
| | | return false; |
| | | } |
| | | }; |
| | |
| | | > |
| | | <DeleteOutlined /> |
| | | <FormattedMessage id="pages.searchTable.delete" defaultMessage="删除" /> |
| | | </Button>, |
| | | <Button |
| | | type="primary" |
| | | key="clean" |
| | | danger |
| | | hidden={selectedRows?.length === 0} |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '是否确认清空所有数据项?', |
| | | icon: <ExclamationCircleOutlined />, |
| | | content: '请谨慎操作', |
| | | async onOk() { |
| | | const success = await handleClean(); |
| | | if (success) { |
| | | setSelectedRows([]); |
| | | actionRef.current?.reloadAndRest?.(); |
| | | } |
| | | }, |
| | | onCancel() { }, |
| | | }); |
| | | }} |
| | | > |
| | | <DeleteOutlined /> |
| | | <FormattedMessage id="pages.searchTable.cleanAll" defaultMessage="清空" /> |
| | | </Button>, |
| | | <Button |
| | | type="primary" |
| | | key="unlock" |
| | | hidden={selectedRows?.length === 0} |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '是否确认解锁该用户的数据项?', |
| | | icon: <ExclamationCircleOutlined />, |
| | | content: '请谨慎操作', |
| | | async onOk() { |
| | | const success = await handleUnlock(selectedRows[0].userName); |
| | | if (success) { |
| | | setSelectedRows([]); |
| | | actionRef.current?.reloadAndRest?.(); |
| | | } |
| | | }, |
| | | onCancel() { }, |
| | | }); |
| | | }} |
| | | > |
| | | <UnlockOutlined /> |
| | | <FormattedMessage id="monitor.logininfor.unlock" defaultMessage="解锁" /> |
| | | </Button>, |
| | | <Button |
| | | type="primary" |