New file |
| | |
| | | import React, { useEffect, useState } from 'react'; |
| | | import { |
| | | ProForm, |
| | | ProFormDigit, |
| | | ProFormText, |
| | | ProFormRadio, |
| | | ProFormTextArea, |
| | | } from '@ant-design/pro-components'; |
| | | import { Form, Modal } from 'antd'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | |
| | | const Edit = (props) => { |
| | | const [form] = Form.useForm(); |
| | | const { } = props; |
| | | const intl = useIntl(); |
| | | |
| | | useEffect(() => { |
| | | form.resetFields(); |
| | | form.setFieldsValue({ |
| | | ...props.values |
| | | }) |
| | | }, [form, props]) |
| | | |
| | | const handleCancel = () => { |
| | | props.onCancel(); |
| | | }; |
| | | |
| | | const handleOk = () => { |
| | | form.submit(); |
| | | } |
| | | |
| | | const handleFinish = async (values) => { |
| | | props.onSubmit({ ...values }); |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Modal |
| | | title="Edit" |
| | | width={640} |
| | | forceRender |
| | | destroyOnClose |
| | | open={props.open} |
| | | onCancel={handleCancel} |
| | | onOk={handleOk} |
| | | > |
| | | <ProForm |
| | | form={form} |
| | | submitter={false} |
| | | onFinish={handleFinish} |
| | | layout="horizontal" |
| | | grid={true} |
| | | > |
| | | <ProFormText |
| | | name="name" |
| | | label="角色名称" |
| | | placeholder="请输入" |
| | | rules={[ |
| | | { |
| | | required: true, |
| | | message: "请输入角色名称!", |
| | | }, |
| | | ]} |
| | | /> |
| | | <ProFormText |
| | | name="code" |
| | | label="角色标识" |
| | | placeholder="请输入" |
| | | rules={[ |
| | | { |
| | | required: true, |
| | | message: "请输入角色标识!", |
| | | }, |
| | | ]} |
| | | /> |
| | | </ProForm> |
| | | </Modal> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default Edit; |
| | |
| | | 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} from '@/services/monitor/logininfor'; |
| | | import Http from '@/utils/http' |
| | | import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import { getLogininforList, removeLogininfor, exportLogininfor } from '@/services/monitor/logininfor'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | | try { |
| | | const resp = await Http.doPost('api/role/save', val); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('添加成功'); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('添加失败请重试!'); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 删除节点 |
| | | * |
| | | * @param selectedRows |
| | | */ |
| | | const handleUpdate = async (val) => { |
| | | const hide = message.loading('正在更新'); |
| | | try { |
| | | const resp = await updateRole(val); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('更新成功'); |
| | | } else { |
| | | message.error(resp.msg); |
| | | } |
| | | return true; |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('配置失败请重试!'); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | const handleRemove = async (selectedRows) => { |
| | | if (!selectedRows) return true; |
| | | const hide = message.loading('正在删除'); |
| | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * |
| | | * @param id |
| | | */ |
| | | const handleExport = async () => { |
| | | const hide = message.loading('正在导出'); |
| | | try { |
| | |
| | | |
| | | |
| | | const LogininforTableList = () => { |
| | | |
| | | const formTableRef = useRef(); |
| | | |
| | | const actionRef = useRef(); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [statusOptions, setStatusOptions] = useState([]); |
| | | const [modalVisible, setModalVisible] = useState(false); |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | |
| | | /** 国际化配置 */ |
| | | const intl = useIntl(); |
| | | |
| | | useEffect(() => { |
| | |
| | | dataIndex: 'code', |
| | | valueType: 'text', |
| | | }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.info_id" defaultMessage="访问编号" />, |
| | | // dataIndex: 'infoId', |
| | | // valueType: 'text', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.user_name" defaultMessage="用户账号" />, |
| | | // dataIndex: 'userName', |
| | | // valueType: 'text', |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.ipaddr" defaultMessage="登录IP地址" />, |
| | | // dataIndex: 'ipaddr', |
| | | // valueType: 'text', |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.login_location" defaultMessage="登录地点" />, |
| | | // dataIndex: 'loginLocation', |
| | | // valueType: 'text', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.browser" defaultMessage="浏览器类型" />, |
| | | // dataIndex: 'browser', |
| | | // valueType: 'text', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.os" defaultMessage="操作系统" />, |
| | | // dataIndex: 'os', |
| | | // valueType: 'text', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.status" defaultMessage="登录状态" />, |
| | | // dataIndex: 'status', |
| | | // valueType: 'select', |
| | | // valueEnum: statusOptions, |
| | | // // render: (_, record) => { |
| | | // // return (<DictTag enums={statusOptions} value={record.status} />); |
| | | // // }, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.msg" defaultMessage="提示消息" />, |
| | | // dataIndex: 'msg', |
| | | // valueType: 'text', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: <FormattedMessage id="monitor.logininfor.login_time" defaultMessage="访问时间" />, |
| | | // dataIndex: 'loginTime', |
| | | // valueType: 'dateTime', |
| | | // }, |
| | | ]; |
| | | |
| | | return ( |
| | |
| | | </Button>, |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | 添加 |
| | | </Button>, |
| | | <Button |
| | | key="export" |
| | | onClick={async () => { |
| | | handleExport(); |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | <FormattedMessage id="pages.searchTable.export" defaultMessage="导出" /> |
| | | <ExportOutlined /> |
| | | 导出 |
| | | </Button>, |
| | | ]} |
| | | request={(params) => |
| | | Http.doPost('/api/role/page', params, (res) => { |
| | | Http.doPostPromise('/api/role/page', params, (res) => { |
| | | return { |
| | | data: res.data.records, |
| | | total: res.data.total, |
| | |
| | | </Button> |
| | | </FooterToolbar> |
| | | )} |
| | | |
| | | <Edit |
| | | open={modalVisible} |
| | | values={currentRow || {}} |
| | | onCancel={ |
| | | () => { |
| | | setModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | } |
| | | } |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handleUpdate({...values}) |
| | | } else { |
| | | ok = await handleSave({...values}) |
| | | } |
| | | if (ok) { |
| | | setModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /> |
| | | </PageContainer> |
| | | ); |
| | | }; |
| | |
| | | import { request } from '@umijs/max'; |
| | | import { message, Modal } from 'antd'; |
| | | |
| | | const doGet = (url, params, fn) => { |
| | | const doGet = async (url, params) => { |
| | | const res = await request(url, { |
| | | method: 'GET', |
| | | params |
| | | }); |
| | | if (res.code === 200) { |
| | | return res; |
| | | } |
| | | message.error(res.msg) |
| | | } |
| | | |
| | | const doGetPromise = (url, params, fn) => { |
| | | return request(url, { |
| | | method: 'GET', |
| | | params |
| | |
| | | }); |
| | | } |
| | | |
| | | const doGetSync = async (url, params) => { |
| | | const doPost = async (url, params, fn) => { |
| | | const res = await request(url, { |
| | | method: 'GET', |
| | | params |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | }, |
| | | data: { ...params } |
| | | }); |
| | | if (res.code === 200) { |
| | | return res; |
| | | if (fn) { |
| | | fn(res); |
| | | } |
| | | message.error(res.msg) |
| | | return res; |
| | | } |
| | | |
| | | const doPost = (url, params, fn) => { |
| | | const doPostPromise = (url, params, fn) => { |
| | | return request(url, { |
| | | method: 'POST', |
| | | headers: { |
| | |
| | | }); |
| | | } |
| | | |
| | | const doPostSync = async (url, params) => { |
| | | const res = await request(url, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | }, |
| | | data: { ...params } |
| | | }); |
| | | if (res.code === 200) { |
| | | return res; |
| | | } |
| | | message.error(res.msg) |
| | | } |
| | | |
| | | const Http = { doGet, doGetSync, doPost, doPostSync } |
| | | const Http = { doGet, doGetPromise, doPost, doPostPromise } |
| | | |
| | | export default Http; |