From 9589e0e1bfd14f2297563fa9a9b3bdcbc7723b74 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 16 二月 2024 21:12:52 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/system/role/index.jsx |  177 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 130 insertions(+), 47 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/role/index.jsx b/zy-asrs-flow/src/pages/system/role/index.jsx
index d78fa07..a34f947 100644
--- a/zy-asrs-flow/src/pages/system/role/index.jsx
+++ b/zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,12 +1,17 @@
 
 import React, { useState, useRef, useEffect } from 'react';
 import { useIntl, FormattedMessage } from '@umijs/max';
-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';
+import { Button, message, Modal } from 'antd';
+import {
+    FooterToolbar,
+    PageContainer,
+    ProTable,
+    LightFilter,
+} from '@ant-design/pro-components';
+import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
 import Http from '@/utils/http';
 import Edit from './components/edit'
+import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
 
 const handleSave = async (val) => {
     const hide = message.loading('姝e湪娣诲姞');
@@ -50,14 +55,15 @@
     if (!rows) return true;
     const hide = message.loading('姝e湪鍒犻櫎');
     try {
-        const resp = await removeLogininfor(rows.map((row) => row.infoId).join(','));
+        const resp = await Http.doPost('api/role/remove/' + rows.map((row) => row.id).join(','));
         hide();
         if (resp.code === 200) {
-            message.success('鍒犻櫎鎴愬姛锛屽嵆灏嗗埛鏂�');
+            message.success('鍒犻櫎鎴愬姛');
+            return true;
         } else {
             message.error(resp.msg);
+            return false;
         }
-        return true;
     } catch (error) {
         hide();
         message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
@@ -68,7 +74,7 @@
 const handleExport = async () => {
     const hide = message.loading('姝e湪瀵煎嚭');
     try {
-        await exportLogininfor();
+        await Http.doPost('api/role/export');
         hide();
         message.success('瀵煎嚭鎴愬姛');
         return true;
@@ -80,12 +86,13 @@
 };
 
 
-const LogininforTableList = () => {
+const Main = () => {
     const formTableRef = useRef();
     const actionRef = useRef();
     const [selectedRows, setSelectedRows] = useState([]);
     const [modalVisible, setModalVisible] = useState(false);
     const [currentRow, setCurrentRow] = useState();
+    const [searchParam, setSearchParam] = useState({});
 
     const intl = useIntl();
 
@@ -95,14 +102,70 @@
 
     const columns = [
         {
+            title: 'No',
+            dataIndex: 'index',
+            valueType: 'indexBorder',
+            width: 48,
+        },
+        {
             title: '濮撳悕',
             dataIndex: 'name',
             valueType: 'text',
+            copyable: true,
+            filterDropdown: (props) => <TextFilter
+                name='name'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
         },
         {
             title: '鏍囪瘑',
             dataIndex: 'code',
             valueType: 'text',
+            filterDropdown: (props) => <TextFilter
+                name='code'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: '鏈烘瀯',
+            dataIndex: 'hostId$',
+            valueType: 'text',
+            filterDropdown: (props) => <LinkFilter
+                name='hostId'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: '鐘舵��',
+            dataIndex: 'status$',
+            valueType: 'text',
+            filterDropdown: (props) => <SelectFilter
+                name='status'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+                data={[
+                    { label: '姝e父', value: 1 },
+                    { label: '绂佺敤', value: 0 },
+                ]}
+            />,
+        },
+        {
+            title: '淇敼鏃堕棿',
+            dataIndex: 'updateTime$',
+            valueType: 'text',
+            filterDropdown: (props) => <DatetimeRangeFilter
+                name='updateTime'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
         },
         {
             title: '鎿嶄綔',
@@ -112,7 +175,6 @@
             render: (_, record) => [
                 <Button
                     type="link"
-                    size="small"
                     key="edit"
                     onClick={() => {
                         setModalVisible(true);
@@ -123,7 +185,6 @@
                 </Button>,
                 <Button
                     type="link"
-                    size="small"
                     danger
                     key="batchRemove"
                     onClick={async () => {
@@ -151,40 +212,55 @@
         <PageContainer>
             <div style={{ width: '100%', float: 'right' }}>
                 <ProTable
-                    headerTitle={intl.formatMessage({
-                        id: 'pages.searchTable.title',
-                        defaultMessage: '淇℃伅',
-                    })}
+                    key="role"
+                    rowKey="id"
                     actionRef={actionRef}
                     formRef={formTableRef}
-                    rowKey="id"
-                    key="logininforList"
-                    search={{
-                        labelWidth: 120,
+                    columns={columns}
+                    cardBordered
+                    dateFormatter="string"
+                    search={false}
+                    toolbar={{
+                        search: {
+                            onSearch: (value) => {
+                                setSearchParam(prevState => ({
+                                    ...prevState,
+                                    condition: value
+                                }));
+                                actionRef.current?.reload();
+                            },
+                        },
+                        filter: (
+                            <LightFilter
+                                onValuesChange={(val) => {
+                                }}
+                            >
+                            </LightFilter>
+                        ),
+                        actions: [
+                            <Button
+                                type="primary"
+                                key="save"
+                                onClick={async () => {
+                                    setModalVisible(true)
+                                }}
+                            >
+                                <PlusOutlined />
+                                娣诲姞
+                            </Button>,
+                            <Button
+                                key="export"
+                                onClick={async () => {
+                                    handleExport();
+                                }}
+                            >
+                                <ExportOutlined />
+                                瀵煎嚭
+                            </Button>,
+                        ],
                     }}
-                    toolBarRender={() => [
-                        <Button
-                            type="primary"
-                            key="save"
-                            onClick={async () => {
-                                setModalVisible(true)
-                            }}
-                        >
-                            <PlusOutlined />
-                            娣诲姞
-                        </Button>,
-                        <Button
-                            key="export"
-                            onClick={async () => {
-                                handleExport();
-                            }}
-                        >
-                            <ExportOutlined />
-                            瀵煎嚭
-                        </Button>,
-                    ]}
-                    request={(params) =>
-                        Http.doPostPromise('/api/role/page', params, (res) => {
+                    request={(params, sorter, filter) =>
+                        Http.doPostPromise('/api/role/page', { ...params, ...searchParam }, (res) => {
                             return {
                                 data: res.data.records,
                                 total: res.data.total,
@@ -192,14 +268,23 @@
                             }
                         })
                     }
-                    columns={columns}
                     rowSelection={{
                         onChange: (ids, rows) => {
                             setSelectedRows(rows);
                         }
                     }}
+                    columnsState={{
+                        persistenceKey: 'pro-table-role',
+                        persistenceType: 'localStorage',
+                        defaultValue: {
+                            option: { fixed: 'right', disable: true },
+                        },
+                        onChange(value) {
+                        },
+                    }}
                 />
             </div>
+
             {selectedRows?.length > 0 && (
                 <FooterToolbar
                     extra={
@@ -217,8 +302,6 @@
                             Modal.confirm({
                                 title: '鍒犻櫎',
                                 content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
-                                okText: '纭',
-                                cancelText: '鍙栨秷',
                                 onOk: async () => {
                                     const success = await handleRemove(selectedRows);
                                     if (success) {
@@ -229,7 +312,7 @@
                             });
                         }}
                     >
-                        <FormattedMessage id="pages.searchTable.batchDeletion" defaultMessage="鎵归噺鍒犻櫎" />
+                        鎵归噺鍒犻櫎
                     </Button>
                 </FooterToolbar>
             )}
@@ -264,4 +347,4 @@
     );
 };
 
-export default LogininforTableList;
+export default Main;

--
Gitblit v1.9.1