From ac4341ea6b66ae02427d39d35f41d42d78b2eb2e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 14 二月 2025 10:08:32 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/system/menu/index.jsx |  124 ++++++++++++++++++-----------------------
 1 files changed, 55 insertions(+), 69 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/menu/index.jsx b/zy-asrs-flow/src/pages/system/menu/index.jsx
index c3edfea..3c83f35 100644
--- a/zy-asrs-flow/src/pages/system/menu/index.jsx
+++ b/zy-asrs-flow/src/pages/system/menu/index.jsx
@@ -7,6 +7,7 @@
     ProTable,
     LightFilter,
 } from '@ant-design/pro-components';
+import { FormattedMessage, useIntl } from '@umijs/max';
 import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
 import Http from '@/utils/http';
 import Edit from './components/edit'
@@ -14,86 +15,89 @@
 import { transformTreeData } from '@/utils/tree-util'
 import { createIcon } from '@/utils/icon-util'
 import { statusMap } from '@/utils/enum-util'
+import { repairBug } from '@/utils/common-util';
+
+const TABLE_KEY = "pro-table-menu";
 
 const typeMap = {
     0: {
-        color: 'blue',
+        color: 'success',
         text: '鑿滃崟',
     },
     1: {
-        color: '',
+        color: 'default',
         text: '鎸夐挳',
     },
 };
 
-const handleSave = async (val) => {
-    const hide = message.loading('姝e湪娣诲姞');
+const handleSave = async (val, intl) => {
+    const hide = message.loading(intl.formatMessage({ id: 'page.adding', defaultMessage: '姝e湪娣诲姞' }));
     try {
         const resp = await Http.doPost('api/menu/save', val);
         if (resp.code === 200) {
-            message.success('娣诲姞鎴愬姛');
+            message.success(intl.formatMessage({ id: 'page.add.success', defaultMessage: '娣诲姞鎴愬姛' }));
             return true;
         } else {
             message.error(resp.msg);
             return false;
         }
     } catch (error) {
-        message.error('娣诲姞澶辫触璇烽噸璇曪紒');
+        message.error(intl.formatMessage({ id: 'page.add.fail', defaultMessage: '娣诲姞澶辫触璇烽噸璇曪紒' }));
         return false;
     } finally {
         hide();
     }
 };
 
-const handleUpdate = async (val) => {
-    const hide = message.loading('姝e湪鏇存柊');
+const handleUpdate = async (val, intl) => {
+    const hide = message.loading(intl.formatMessage({ id: 'page.updating', defaultMessage: '姝e湪鏇存柊' }));
     try {
         const resp = await Http.doPost('api/menu/update', val);
         if (resp.code === 200) {
-            message.success('鏇存柊鎴愬姛');
+            message.success(intl.formatMessage({ id: 'page.update.success', defaultMessage: '鏇存柊鎴愬姛' }));
             return true;
         } else {
             message.error(resp.msg);
             return false;
         }
     } catch (error) {
-        message.error('閰嶇疆澶辫触璇烽噸璇曪紒');
+        message.error(intl.formatMessage({ id: 'page.update.fail', defaultMessage: '鏇存柊澶辫触璇烽噸璇曪紒' }));
         return false;
     } finally {
         hide();
     }
 };
 
-const handleRemove = async (rows) => {
+const handleRemove = async (rows, intl) => {
     if (!rows) return true;
-    const hide = message.loading('姝e湪鍒犻櫎');
+    const hide = message.loading(intl.formatMessage({ id: 'page.deleting', defaultMessage: '姝e湪鍒犻櫎' }));
     try {
         const resp = await Http.doPost('api/menu/remove/' + rows.map((row) => row.id).join(','));
         if (resp.code === 200) {
-            message.success('鍒犻櫎鎴愬姛');
+            message.success(intl.formatMessage({ id: 'page.delete.success', defaultMessage: '鍒犻櫎鎴愬姛' }));
             return true;
         } else {
             message.error(resp.msg);
             return false;
         }
     } catch (error) {
-        message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
+        message.error(intl.formatMessage({ id: 'page.delete.fail', defaultMessage: '鍒犻櫎澶辫触锛岃閲嶈瘯锛�' }));
         return false;
     } finally {
         hide();
     }
 };
 
-const handleExport = async () => {
-    const hide = message.loading('姝e湪瀵煎嚭');
+const handleExport = async (intl) => {
+    const hide = message.loading(intl.formatMessage({ id: 'page.exporting', defaultMessage: '姝e湪瀵煎嚭' }));
     try {
         const resp = await Http.doPostBlob('api/menu/export');
         const blob = new Blob([resp], { type: 'application/vnd.ms-excel' });
         window.location.href = window.URL.createObjectURL(blob);
-        message.success('瀵煎嚭鎴愬姛');
+        message.success(intl.formatMessage({ id: 'page.export.success', defaultMessage: '瀵煎嚭鎴愬姛' }));
         return true;
     } catch (error) {
-        message.error('瀵煎嚭澶辫触锛岃閲嶈瘯');
+        message.error(intl.formatMessage({ id: 'page.export.fail', defaultMessage: '瀵煎嚭澶辫触锛岃閲嶈瘯' }));
         return false;
     } finally {
         hide();
@@ -102,6 +106,7 @@
 
 
 const Main = () => {
+    const intl = useIntl();
     const formTableRef = useRef();
     const actionRef = useRef();
     const [selectedRows, setSelectedRows] = useState([]);
@@ -143,36 +148,10 @@
             />,
         },
         {
-            title: '涓婄骇鑿滃崟鍚�',
-            dataIndex: 'parentName',
-            valueType: 'text',
-            hidden: true,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='parentName'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
             title: '鍏宠仈璺緞',
-            dataIndex: 'path',
-            valueType: 'text',
-            hidden: true,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='path'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
-            title: '鍏宠仈璺緞鍚�',
             dataIndex: 'pathName',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='pathName'
@@ -198,7 +177,7 @@
             title: '椤甸潰缁勪欢',
             dataIndex: 'component',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='component'
@@ -211,7 +190,7 @@
             title: '绠�杩�',
             dataIndex: 'brief',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='brief'
@@ -224,7 +203,7 @@
             title: '鏍囪瘑',
             dataIndex: 'code',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='code'
@@ -291,7 +270,7 @@
             title: '鍏冧俊鎭�',
             dataIndex: 'meta',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='meta'
@@ -325,7 +304,7 @@
             title: '娣诲姞鏃堕棿',
             dataIndex: 'createTime$',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <DatetimeRangeFilter
                 name='createTime'
@@ -338,7 +317,7 @@
             title: '娣诲姞浜哄憳',
             dataIndex: 'createBy$',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <LinkFilter
                 name='createBy'
@@ -379,7 +358,7 @@
             title: '澶囨敞',
             dataIndex: 'memo',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='memo'
@@ -403,7 +382,7 @@
                         setCurrentRow(record);
                     }}
                 >
-                    缂栬緫
+                    <FormattedMessage id='page.edit' defaultMessage='缂栬緫' />
                 </Button>,
                 <Button
                     type="link"
@@ -411,10 +390,10 @@
                     key="batchRemove"
                     onClick={async () => {
                         Modal.confirm({
-                            title: '鍒犻櫎',
-                            content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
+                            title: intl.formatMessage({ id: 'page.delete', defaultMessage: '鍒犻櫎' }),
+                            content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '纭畾鍒犻櫎璇ラ」鍚楋紵' }),
                             onOk: async () => {
-                                const success = await handleRemove([record]);
+                                const success = await handleRemove([record], intl);
                                 if (success) {
                                     if (actionRef.current) {
                                         actionRef.current.reload();
@@ -424,7 +403,7 @@
                         });
                     }}
                 >
-                    鍒犻櫎
+                    <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
                 </Button>,
             ],
         },
@@ -474,16 +453,16 @@
                                 }}
                             >
                                 <PlusOutlined />
-                                娣诲姞
+                                <FormattedMessage id='page.add' defaultMessage='娣诲姞' />
                             </Button>,
                             <Button
                                 key="export"
                                 onClick={async () => {
-                                    handleExport();
+                                    handleExport(intl);
                                 }}
                             >
                                 <ExportOutlined />
-                                瀵煎嚭
+                                <FormattedMessage id='page.export' defaultMessage='瀵煎嚭' />
                             </Button>,
                         ],
                     }}
@@ -505,9 +484,17 @@
                         }
                     }}
                     columnsState={{
-                        persistenceKey: 'pro-table-menu',
+                        persistenceKey: TABLE_KEY,
                         persistenceType: 'localStorage',
                         defaultValue: {
+                            pathName: { show: repairBug(TABLE_KEY, 'pathName', false) },
+                            component: { show: repairBug(TABLE_KEY, 'component', false) },
+                            brief: { show: repairBug(TABLE_KEY, 'brief', false) },
+                            code: { show: repairBug(TABLE_KEY, 'code', false) },
+                            meta: { show: repairBug(TABLE_KEY, 'meta', false) },
+                            createTime$: { show: repairBug(TABLE_KEY, 'createTime$', false) },
+                            createBy$: { show: repairBug(TABLE_KEY, 'createBy$', false) },
+                            memo: { show: repairBug(TABLE_KEY, 'memo', false) },
                             option: { fixed: 'right', disable: true },
                         },
                         onChange(value) {
@@ -520,9 +507,8 @@
                 <FooterToolbar
                     extra={
                         <div>
-                            宸查�夋嫨
                             <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
-                            椤�
+                            <FormattedMessage id='page.selected' defaultMessage=' 椤瑰凡閫夋嫨' />
                         </div>
                     }
                 >
@@ -531,10 +517,10 @@
                         danger
                         onClick={async () => {
                             Modal.confirm({
-                                title: '鍒犻櫎',
-                                content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
+                                title: intl.formatMessage({ id: 'page.delete', defaultMessage: '鍒犻櫎' }),
+                                content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '纭畾鍒犻櫎璇ラ」鍚楋紵' }),
                                 onOk: async () => {
-                                    const success = await handleRemove(selectedRows);
+                                    const success = await handleRemove(selectedRows, intl);
                                     if (success) {
                                         setSelectedRows([]);
                                         actionRef.current?.reloadAndRest?.();
@@ -543,7 +529,7 @@
                             });
                         }}
                     >
-                        鎵归噺鍒犻櫎
+                        <FormattedMessage id='page.delete.batch' defaultMessage='鎵归噺鍒犻櫎' />
                     </Button>
                 </FooterToolbar>
             )}
@@ -561,9 +547,9 @@
                 onSubmit={async (values) => {
                     let ok = false;
                     if (values.id) {
-                        ok = await handleUpdate({ ...values })
+                        ok = await handleUpdate({ ...values }, intl)
                     } else {
-                        ok = await handleSave({ ...values })
+                        ok = await handleSave({ ...values }, intl)
                     }
                     if (ok) {
                         setModalVisible(false);

--
Gitblit v1.9.1