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/dept/index.jsx |  188 ++++++++++++++++++++++++-----------------------
 1 files changed, 96 insertions(+), 92 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/dept/index.jsx b/zy-asrs-flow/src/pages/system/dept/index.jsx
index bc080e3..717e854 100644
--- a/zy-asrs-flow/src/pages/system/dept/index.jsx
+++ b/zy-asrs-flow/src/pages/system/dept/index.jsx
@@ -7,91 +7,85 @@
     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'
 import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
 import { transformTreeData } from '@/utils/tree-util'
+import { statusMap } from '@/utils/enum-util'
+import { repairBug } from '@/utils/common-util';
 
-const statusMap = {
-    1: {
-        color: 'green',
-        text: '姝e父',
-    },
-    0: {
-        color: 'red',
-        text: '绂佺敤',
-    },
-};
+const TABLE_KEY = "pro-table-dept";
 
-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/dept/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/dept/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/dept/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/dept/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();
@@ -100,6 +94,7 @@
 
 
 const Main = () => {
+    const intl = useIntl();
     const formTableRef = useRef();
     const actionRef = useRef();
     const [selectedRows, setSelectedRows] = useState([]);
@@ -120,12 +115,12 @@
             valueType: 'text',
             hidden: false,
             width: 240,
-            filterDropdown: (props) => <TextFilter
-                name='name'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            // filterDropdown: (props) => <TextFilter
+            //     name='name'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
         },
         {
             title: '涓婄骇閮ㄩ棬',
@@ -144,7 +139,7 @@
             title: '鍏ㄧО',
             dataIndex: 'fullName',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='fullName'
@@ -157,7 +152,7 @@
             title: '绠�杩�',
             dataIndex: 'brief',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='brief'
@@ -170,7 +165,7 @@
             title: '鏍囪瘑',
             dataIndex: 'code',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='code'
@@ -183,7 +178,7 @@
             title: '绫诲瀷',
             dataIndex: 'type',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='type'
@@ -198,18 +193,18 @@
             valueType: 'text',
             hidden: false,
             width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='leader'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            // filterDropdown: (props) => <TextFilter
+            //     name='leader'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
         },
         {
             title: '鏁伴噺',
             dataIndex: 'count',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='count'
@@ -224,12 +219,12 @@
             valueType: 'text',
             hidden: false,
             width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='sort'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            // filterDropdown: (props) => <TextFilter
+            //     name='sort'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
             render: (_, record) => {
                 return <span style={{ fontWeight: "bold" }}>{_}</span>
             }
@@ -240,16 +235,16 @@
             valueType: 'text',
             hidden: false,
             width: 140,
-            filterDropdown: (props) => <SelectFilter
-                name='status'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-                data={[
-                    { label: '姝e父', value: 1 },
-                    { label: '绂佺敤', value: 0 },
-                ]}
-            />,
+            // filterDropdown: (props) => <SelectFilter
+            //     name='status'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            //     data={[
+            //         { label: '姝e父', value: 1 },
+            //         { label: '绂佺敤', value: 0 },
+            //     ]}
+            // />,
             render: (_, record) => {
                 const status = statusMap[record.status]
                 return <Tag color={status.color}>{status.text}</Tag>
@@ -261,12 +256,12 @@
             valueType: 'text',
             hidden: false,
             width: 140,
-            filterDropdown: (props) => <DatetimeRangeFilter
-                name='updateTime'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            // filterDropdown: (props) => <DatetimeRangeFilter
+            //     name='updateTime'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
         },
         {
             title: '淇敼浜哄憳',
@@ -274,19 +269,19 @@
             valueType: 'text',
             hidden: false,
             width: 140,
-            filterDropdown: (props) => <LinkFilter
-                name='updateBy'
-                major='user'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            // filterDropdown: (props) => <LinkFilter
+            //     name='updateBy'
+            //     major='user'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
         },
         {
             title: '澶囨敞',
             dataIndex: 'memo',
             valueType: 'text',
-            hidden: true,
+            hidden: false,
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='memo'
@@ -310,7 +305,7 @@
                         setCurrentRow(record);
                     }}
                 >
-                    缂栬緫
+                    <FormattedMessage id='page.edit' defaultMessage='缂栬緫' />
                 </Button>,
                 <Button
                     type="link"
@@ -318,10 +313,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();
@@ -331,14 +326,18 @@
                         });
                     }}
                 >
-                    鍒犻櫎
+                    <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
                 </Button>,
             ],
         },
     ];
 
     return (
-        <PageContainer>
+        <PageContainer
+            header={{
+                breadcrumb: {},
+            }}
+        >
             <div style={{ width: '100%', float: 'right' }}>
                 <ProTable
                     key="dept"
@@ -349,7 +348,7 @@
                     cardBordered
                     scroll={{ x: 1300 }}
                     dateFormatter="string"
-                    pagination={{ pageSize: 20 }}
+                    pagination={{ pageSize: 100 }}
                     search={false}
                     toolbar={{
                         search: {
@@ -377,16 +376,16 @@
                                 }}
                             >
                                 <PlusOutlined />
-                                娣诲姞
+                                <FormattedMessage id='page.add' defaultMessage='娣诲姞' />
                             </Button>,
                             <Button
                                 key="export"
                                 onClick={async () => {
-                                    handleExport();
+                                    handleExport(intl);
                                 }}
                             >
                                 <ExportOutlined />
-                                瀵煎嚭
+                                <FormattedMessage id='page.export' defaultMessage='瀵煎嚭' />
                             </Button>,
                         ],
                     }}
@@ -409,9 +408,15 @@
                         }
                     }}
                     columnsState={{
-                        persistenceKey: 'pro-table-dept',
+                        persistenceKey: TABLE_KEY,
                         persistenceType: 'localStorage',
                         defaultValue: {
+                            fullName: { show: repairBug(TABLE_KEY, 'fullName', false) },
+                            brief: { show: repairBug(TABLE_KEY, 'brief', false) },
+                            code: { show: repairBug(TABLE_KEY, 'code', false) },
+                            type: { show: repairBug(TABLE_KEY, 'type', false) },
+                            count: { show: repairBug(TABLE_KEY, 'count', false) },
+                            memo: { show: repairBug(TABLE_KEY, 'memo', false) },
                             option: { fixed: 'right', disable: true },
                         },
                         onChange(value) {
@@ -424,9 +429,8 @@
                 <FooterToolbar
                     extra={
                         <div>
-                            宸查�夋嫨
                             <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
-                            椤�
+                            <FormattedMessage id='page.selected' defaultMessage=' 椤瑰凡閫夋嫨' />
                         </div>
                     }
                 >
@@ -435,10 +439,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?.();
@@ -447,7 +451,7 @@
                             });
                         }}
                     >
-                        鎵归噺鍒犻櫎
+                        <FormattedMessage id='page.delete.batch' defaultMessage='鎵归噺鍒犻櫎' />
                     </Button>
                 </FooterToolbar>
             )}
@@ -465,9 +469,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