From 7e7dac82d82f3273cb709e404aa179787d561011 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 20 二月 2024 13:02:48 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/system/role/index.jsx |  120 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 77 insertions(+), 43 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/role/index.jsx b/zy-asrs-flow/src/pages/system/role/index.jsx
index 00837be..6352839 100644
--- a/zy-asrs-flow/src/pages/system/role/index.jsx
+++ b/zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,20 +1,21 @@
 
 import React, { useState, useRef, useEffect } from 'react';
-import { useIntl, FormattedMessage } from '@umijs/max';
 import { Button, message, Modal } from 'antd';
 import {
-    FooterToolbar, PageContainer, ProTable, LightFilter,
-    ProFormDatePicker,
+    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湪娣诲姞');
     try {
         const resp = await Http.doPost('api/role/save', val);
-        hide();
         if (resp.code === 200) {
             message.success('娣诲姞鎴愬姛');
             return true;
@@ -23,9 +24,10 @@
             return false;
         }
     } catch (error) {
-        hide();
         message.error('娣诲姞澶辫触璇烽噸璇曪紒');
         return false;
+    } finally {
+        hide();
     }
 };
 
@@ -33,7 +35,6 @@
     const hide = message.loading('姝e湪鏇存柊');
     try {
         const resp = await Http.doPost('api/role/update', val);
-        hide();
         if (resp.code === 200) {
             message.success('鏇存柊鎴愬姛');
             return true;
@@ -42,9 +43,10 @@
             return false;
         }
     } catch (error) {
-        hide();
         message.error('閰嶇疆澶辫触璇烽噸璇曪紒');
         return false;
+    } finally {
+        hide();
     }
 };
 
@@ -53,7 +55,6 @@
     const hide = message.loading('姝e湪鍒犻櫎');
     try {
         const resp = await Http.doPost('api/role/remove/' + rows.map((row) => row.id).join(','));
-        hide();
         if (resp.code === 200) {
             message.success('鍒犻櫎鎴愬姛');
             return true;
@@ -62,25 +63,29 @@
             return false;
         }
     } catch (error) {
-        hide();
         message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
         return false;
+    } finally {
+        hide();
     }
 };
 
 const handleExport = async () => {
     const hide = message.loading('姝e湪瀵煎嚭');
     try {
-        await Http.doPost('api/role/export');
-        hide();
+        const resp = await Http.doPostBlob('api/role/export');
+        const blob = new Blob([resp], { type: 'application/vnd.ms-excel' });
+        window.location.href = window.URL.createObjectURL(blob);
         message.success('瀵煎嚭鎴愬姛');
         return true;
     } catch (error) {
-        hide();
         message.error('瀵煎嚭澶辫触锛岃閲嶈瘯');
         return false;
+    } finally {
+        hide();
     }
 };
+
 
 const Main = () => {
     const formTableRef = useRef();
@@ -89,8 +94,6 @@
     const [modalVisible, setModalVisible] = useState(false);
     const [currentRow, setCurrentRow] = useState();
     const [searchParam, setSearchParam] = useState({});
-
-    const intl = useIntl();
 
     useEffect(() => {
 
@@ -108,16 +111,66 @@
             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'
+                major='host'
+                {...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: '鎿嶄綔',
             dataIndex: 'option',
-            width: '220px',
+            width: 140,
             valueType: 'option',
             render: (_, record) => [
                 <Button
@@ -166,8 +219,10 @@
                     columns={columns}
                     cardBordered
                     dateFormatter="string"
+                    pagination={{ pageSize: 20 }}
                     search={false}
                     toolbar={{
+                        multipleLine: true,
                         search: {
                             onSearch: (value) => {
                                 setSearchParam(prevState => ({
@@ -178,8 +233,10 @@
                             },
                         },
                         filter: (
-                            <LightFilter>
-                                <ProFormDatePicker name="startdate" label="鍝嶅簲鏃ユ湡" />
+                            <LightFilter
+                                onValuesChange={(val) => {
+                                }}
+                            >
                             </LightFilter>
                         ),
                         actions: [
@@ -204,31 +261,8 @@
                             </Button>,
                         ],
                     }}
-                    // toolBarRender={() => [
-                    //     <Button
-                    //         type="primary"
-                    //         key="save"
-                    //         onClick={async () => {
-                    //             setModalVisible(true)
-                    //         }}
-                    //     >
-                    //         <PlusOutlined />
-                    //         娣诲姞
-                    //     </Button>,
-                    //     <Button
-                    //         key="export"
-                    //         onClick={async () => {
-                    //             handleExport();
-                    //         }}
-                    //     >
-                    //         <ExportOutlined />
-                    //         瀵煎嚭
-                    //     </Button>,
-                    // ]}
                     request={(params, sorter, filter) =>
                         Http.doPostPromise('/api/role/page', { ...params, ...searchParam }, (res) => {
-                            console.log({ ...params, ...searchParam });
-                            console.log(filter);
                             return {
                                 data: res.data.records,
                                 total: res.data.total,
@@ -257,9 +291,9 @@
                 <FooterToolbar
                     extra={
                         <div>
-                            <FormattedMessage id="pages.searchTable.chosen" defaultMessage="宸查�夋嫨" />
+                            宸查�夋嫨
                             <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
-                            <FormattedMessage id="pages.searchTable.item" defaultMessage="椤�" />
+                            椤�
                         </div>
                     }
                 >
@@ -280,7 +314,7 @@
                             });
                         }}
                     >
-                        <FormattedMessage id="pages.searchTable.batchDeletion" defaultMessage="鎵归噺鍒犻櫎" />
+                        鎵归噺鍒犻櫎
                     </Button>
                 </FooterToolbar>
             )}

--
Gitblit v1.9.1