| | |
| | | // 前置守卫 |
| | | requestInterceptors: [ |
| | | (url, options) => { |
| | | console.log('request ====>:', url); |
| | | const token = getToken(); |
| | | if (token && options.headers) { |
| | | options.headers[TOKEN_HEADER_NAME] = token; |
| | |
| | | if (token) { |
| | | setToken(token); |
| | | } |
| | | console.log(response?.data); |
| | | return response; |
| | | } |
| | | ] |
| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { Button, message, Modal, Table } from 'antd'; |
| | | import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components'; |
| | | import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import { getLogininforList, removeLogininfor, exportLogininfor } from '@/services/monitor/logininfor'; |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleRemove = async (selectedRows) => { |
| | | if (!selectedRows) return true; |
| | | const handleRemove = async (rows) => { |
| | | if (!rows) return true; |
| | | const hide = message.loading('正在删除'); |
| | | try { |
| | | const resp = await removeLogininfor(selectedRows.map((row) => row.infoId).join(',')); |
| | | const resp = await removeLogininfor(rows.map((row) => row.infoId).join(',')); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('删除成功,即将刷新'); |
| | |
| | | Modal.confirm({ |
| | | title: '删除', |
| | | content: '确定删除该项吗?', |
| | | okText: '确认', |
| | | cancelText: '取消', |
| | | onOk: async () => { |
| | | const success = await handleRemoveOne(record); |
| | | const success = await handleRemove([record]); |
| | | if (success) { |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | |
| | | })} |
| | | actionRef={actionRef} |
| | | formRef={formTableRef} |
| | | rowKey="infoId" |
| | | rowKey="id" |
| | | key="logininforList" |
| | | search={{ |
| | | labelWidth: 120, |
| | | }} |
| | | toolBarRender={() => [ |
| | | <Button |
| | | key="remove" |
| | | danger |
| | | hidden={selectedRows?.length === 0} |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '是否确认删除所选数据项?', |
| | | icon: <ExclamationCircleOutlined />, |
| | | content: '请谨慎操作', |
| | | async onOk() { |
| | | const success = await handleRemove(selectedRows); |
| | | if (success) { |
| | | setSelectedRows([]); |
| | | actionRef.current?.reloadAndRest?.(); |
| | | } |
| | | }, |
| | | onCancel() { }, |
| | | }); |
| | | }} |
| | | > |
| | | <DeleteOutlined /> |
| | | <FormattedMessage id="pages.searchTable.delete" defaultMessage="删除" /> |
| | | </Button>, |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | |
| | | } |
| | | columns={columns} |
| | | rowSelection={{ |
| | | onChange: (_, selectedRows) => { |
| | | setSelectedRows(selectedRows); |
| | | }, |
| | | onChange: (ids, rows) => { |
| | | setSelectedRows(rows); |
| | | } |
| | | }} |
| | | /> |
| | | </div> |
| | |
| | | > |
| | | <Button |
| | | key="remove" |
| | | danger |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '删除', |