From b634547771ae3dea26c2e7df8c26bd10e41ccc0b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 13 二月 2024 16:42:53 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/system/role/index.jsx | 331 +++++++++++++++++++++++++++++++++++++++-
zy-asrs-flow/src/pages/system/user/index.jsx | 114 +++++++-------
2 files changed, 375 insertions(+), 70 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/role/index.jsx b/zy-asrs-flow/src/pages/system/role/index.jsx
index 5081bb7..52d09c5 100644
--- a/zy-asrs-flow/src/pages/system/role/index.jsx
+++ b/zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,16 +1,319 @@
-import React from 'react';
-import {
- PageContainer,
-} from '@ant-design/pro-components';
-const User = () => {
- return (
- <>
- <PageContainer>
- <h1>Hello world</h1>
- </PageContainer>
- </>
- )
-}
+import React, { useState, useRef, useEffect } from 'react';
+import { useIntl, FormattedMessage, useAccess } 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 DictTag from '@/components/DictTag';
+import { getDictValueEnum } from '@/services/system/dict';
-export default User;
+/**
+ * 鍒犻櫎鑺傜偣
+ *
+ * @param selectedRows
+ */
+const handleRemove = async (selectedRows) => {
+ const hide = message.loading('姝e湪鍒犻櫎');
+ if (!selectedRows) return true;
+ try {
+ const resp = await removeLogininfor(selectedRows.map((row) => row.infoId).join(','));
+ hide();
+ if (resp.code === 200) {
+ message.success('鍒犻櫎鎴愬姛锛屽嵆灏嗗埛鏂�');
+ } else {
+ message.error(resp.msg);
+ }
+ return true;
+ } 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('姝e湪瑙i攣');
+ try {
+ const resp = await unlockLogininfor(userName);
+ hide();
+ if (resp.code === 200) {
+ message.success('瑙i攣鎴愬姛锛屽嵆灏嗗埛鏂�');
+ } else {
+ message.error(resp.msg);
+ }
+ return true;
+ } catch (error) {
+ hide();
+ message.error('瑙i攣澶辫触锛岃閲嶈瘯');
+ return false;
+ }
+};
+
+/**
+ * 瀵煎嚭鏁版嵁
+ *
+ * @param id
+ */
+const handleExport = async () => {
+ const hide = message.loading('姝e湪瀵煎嚭');
+ try {
+ await exportLogininfor();
+ hide();
+ message.success('瀵煎嚭鎴愬姛');
+ return true;
+ } catch (error) {
+ hide();
+ message.error('瀵煎嚭澶辫触锛岃閲嶈瘯');
+ return false;
+ }
+};
+
+
+const LogininforTableList = () => {
+ const formTableRef = useRef();
+
+ const actionRef = useRef();
+ const [selectedRows, setSelectedRows] = useState([]);
+ const [statusOptions, setStatusOptions] = useState([]);
+
+ const access = useAccess();
+
+ /** 鍥介檯鍖栭厤缃� */
+ const intl = useIntl();
+
+ useEffect(() => {
+ getDictValueEnum('sys_common_status', true).then((data) => {
+ setStatusOptions(data);
+ });
+ }, []);
+
+ const columns = [
+ {
+ 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 (
+ <PageContainer>
+ <div style={{ width: '100%', float: 'right' }}>
+ <ProTable
+ headerTitle={intl.formatMessage({
+ id: 'pages.searchTable.title',
+ defaultMessage: '淇℃伅',
+ })}
+ actionRef={actionRef}
+ formRef={formTableRef}
+ rowKey="infoId"
+ key="logininforList"
+ search={{
+ labelWidth: 120,
+ }}
+ toolBarRender={() => [
+ <Button
+ key="remove"
+ danger
+ hidden={selectedRows?.length === 0 || !access.hasPerms('monitor:logininfor:remove')}
+ 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="clean"
+ danger
+ hidden={selectedRows?.length === 0 || !access.hasPerms('monitor:logininfor:remove')}
+ 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 || !access.hasPerms('monitor:logininfor:unlock')}
+ onClick={async () => {
+ Modal.confirm({
+ title: '鏄惁纭瑙i攣璇ョ敤鎴风殑鏁版嵁椤�?',
+ 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="瑙i攣" />
+ </Button>,
+ <Button
+ type="primary"
+ key="export"
+ hidden={!access.hasPerms('monitor:logininfor:export')}
+ onClick={async () => {
+ handleExport();
+ }}
+ >
+ <PlusOutlined />
+ <FormattedMessage id="pages.searchTable.export" defaultMessage="瀵煎嚭" />
+ </Button>,
+ ]}
+ request={(params) =>
+ getLogininforList({ ...params }).then((res) => {
+ const result = {
+ data: res.rows,
+ total: res.total,
+ success: true,
+ };
+ return result;
+ })
+ }
+ columns={columns}
+ rowSelection={{
+ onChange: (_, selectedRows) => {
+ setSelectedRows(selectedRows);
+ },
+ }}
+ />
+ </div>
+ {selectedRows?.length > 0 && (
+ <FooterToolbar
+ extra={
+ <div>
+ <FormattedMessage id="pages.searchTable.chosen" defaultMessage="宸查�夋嫨" />
+ <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
+ <FormattedMessage id="pages.searchTable.item" defaultMessage="椤�" />
+ </div>
+ }
+ >
+ <Button
+ key="remove"
+ hidden={!access.hasPerms('monitor:logininfor:remove')}
+ onClick={async () => {
+ Modal.confirm({
+ title: '鍒犻櫎',
+ content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
+ okText: '纭',
+ cancelText: '鍙栨秷',
+ onOk: async () => {
+ const success = await handleRemove(selectedRows);
+ if (success) {
+ setSelectedRows([]);
+ actionRef.current?.reloadAndRest?.();
+ }
+ },
+ });
+ }}
+ >
+ <FormattedMessage id="pages.searchTable.batchDeletion" defaultMessage="鎵归噺鍒犻櫎" />
+ </Button>
+ </FooterToolbar>
+ )}
+ </PageContainer>
+ );
+};
+
+export default LogininforTableList;
diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 096a38a..7dfe2c5 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -111,63 +111,65 @@
return (
<>
<PageContainer>
- <ProTable
- columns={columns}
- request={(params, sorter, filter) => {
- // 琛ㄥ崟鎼滅储椤逛細浠� params 浼犲叆锛屼紶閫掔粰鍚庣鎺ュ彛銆�
- console.log(params, sorter, filter);
- return Promise.resolve({
- data: tableListDataSource,
- success: true,
- });
- }}
- rowKey="key"
- pagination={{
- showQuickJumper: true,
- }}
- search={{
- layout: 'vertical',
- defaultCollapsed: false,
- }}
- dateFormatter="string"
- toolbar={{
- title: '楂樼骇琛ㄦ牸',
- tooltip: '杩欐槸涓�涓爣棰樻彁绀�',
- }}
- toolBarRender={() => [
- <Button key="danger" danger>
- 鍗遍櫓鎸夐挳
- </Button>,
- <Button key="show">鏌ョ湅鏃ュ織</Button>,
- <Button type="primary" key="primary">
- 鍒涘缓搴旂敤
- </Button>,
+ <div style={{ width: '100%', float: 'right' }}>
+ <ProTable
+ columns={columns}
+ request={(params, sorter, filter) => {
+ // 琛ㄥ崟鎼滅储椤逛細浠� params 浼犲叆锛屼紶閫掔粰鍚庣鎺ュ彛銆�
+ console.log(params, sorter, filter);
+ return Promise.resolve({
+ data: tableListDataSource,
+ success: true,
+ });
+ }}
+ rowKey="key"
+ pagination={{
+ showQuickJumper: true,
+ }}
+ search={{
+ layout: 'vertical',
+ defaultCollapsed: false,
+ }}
+ dateFormatter="string"
+ toolbar={{
+ title: '楂樼骇琛ㄦ牸',
+ tooltip: '杩欐槸涓�涓爣棰樻彁绀�',
+ }}
+ toolBarRender={() => [
+ <Button key="danger" danger>
+ 鍗遍櫓鎸夐挳
+ </Button>,
+ <Button key="show">鏌ョ湅鏃ュ織</Button>,
+ <Button type="primary" key="primary">
+ 鍒涘缓搴旂敤
+ </Button>,
- <Dropdown
- key="menu"
- menu={{
- items: [
- {
- label: '1st item',
- key: '1',
- },
- {
- label: '2nd item',
- key: '2',
- },
- {
- label: '3rd item',
- key: '3',
- },
- ],
- }}
- >
- <Button>
- <EllipsisOutlined />
- </Button>
- </Dropdown>,
- ]}
- />
+ <Dropdown
+ key="menu"
+ menu={{
+ items: [
+ {
+ label: '1st item',
+ key: '1',
+ },
+ {
+ label: '2nd item',
+ key: '2',
+ },
+ {
+ label: '3rd item',
+ key: '3',
+ },
+ ],
+ }}
+ >
+ <Button>
+ <EllipsisOutlined />
+ </Button>
+ </Dropdown>,
+ ]}
+ />
+ </div>
</PageContainer>
</>
);
--
Gitblit v1.9.1