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/user/index.jsx |  280 +++++++++++++++++++++++++------------------------------
 1 files changed, 128 insertions(+), 152 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 2066b4e..dd0f2f9 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -7,6 +7,7 @@
     LightFilter,
     TableDropdown
 } from '@ant-design/pro-components';
+import { FormattedMessage, useIntl } from '@umijs/max';
 import { PlusOutlined, ExportOutlined, DownOutlined, DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
 import Http from '@/utils/http';
 import Edit from './components/edit'
@@ -19,93 +20,93 @@
 
 const TABLE_KEY = "pro-table-user";
 
-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/user/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/user/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/user/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/user/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();
     }
 };
 
-const handlePwd = async (val) => {
-    const hide = message.loading('姝e湪閲嶇疆');
+const handlePwd = async (val, intl) => {
+    const hide = message.loading(intl.formatMessage({ id: 'page.resetting', defaultMessage: '姝e湪閲嶇疆' }));
     try {
         const resp = await Http.doPost('api/user/reset/pwd', val);
         if (resp.code === 200) {
-            message.success('閲嶇疆鎴愬姛');
+            message.success(intl.formatMessage({ id: 'page.reset.success', defaultMessage: '閲嶇疆鎴愬姛' }));
             return true;
         } else {
             message.error(resp.msg);
             return false;
         }
     } catch (error) {
-        message.error('閲嶇疆澶辫触璇烽噸璇曪紒');
+        message.error(intl.formatMessage({ id: 'page.reset.fail', defaultMessage: '閲嶇疆澶辫触璇烽噸璇曪紒' }));
         return false;
     } finally {
         hide();
@@ -114,6 +115,7 @@
 
 
 const Main = () => {
+    const intl = useIntl();
     const formTableRef = useRef();
     const actionRef = useRef();
     const [selectedRows, setSelectedRows] = useState([]);
@@ -142,6 +144,7 @@
             const treeAllKeys = getTreeAllKeys(treeData);
             setDeptExpandedKeys(treeAllKeys);
         }).catch((err) => {
+            console.error(err);
             setDeptTreeLoading(false);
         })
     }
@@ -158,17 +161,19 @@
 
     const columns = [
         {
-            title: 'No',
+            title: intl.formatMessage({
+                id: 'page.table.no',
+                defaultMessage: 'No'
+            }),
             dataIndex: 'index',
             valueType: 'indexBorder',
-            width: 30,
+            width: 48,
         },
         {
             title: '閮ㄩ棬',
             dataIndex: 'deptId$',
             valueType: 'text',
             hidden: false,
-            width: 100,
             render: (_, record) => {
                 if (_ && _ !== '-') {
                     return <Tag color={""}>{_}</Tag>
@@ -190,7 +195,6 @@
             valueType: 'text',
             hidden: false,
             copyable: true,
-            width: 100,
             filterDropdown: (props) => <TextFilter
                 name='username'
                 {...props}
@@ -206,7 +210,6 @@
             dataIndex: 'nickname',
             valueType: 'text',
             hidden: false,
-            width: 100,
             filterDropdown: (props) => <TextFilter
                 name='nickname'
                 {...props}
@@ -222,7 +225,6 @@
             dataIndex: 'password',
             valueType: 'password',
             hidden: false,
-            width: 100,
             filterDropdown: (props) => <TextFilter
                 name='password'
                 {...props}
@@ -235,7 +237,6 @@
             dataIndex: 'avatar',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='avatar'
                 {...props}
@@ -248,7 +249,6 @@
             dataIndex: 'code',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='code'
                 {...props}
@@ -261,7 +261,6 @@
             dataIndex: 'sex$',
             valueType: 'text',
             hidden: false,
-            width: 80,
             filterDropdown: (props) => <SelectFilter
                 name='sex'
                 {...props}
@@ -279,7 +278,6 @@
             dataIndex: 'phone',
             valueType: 'text',
             hidden: false,
-            width: 100,
             filterDropdown: (props) => <TextFilter
                 name='phone'
                 {...props}
@@ -292,7 +290,6 @@
             dataIndex: 'email',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='email'
                 {...props}
@@ -305,7 +302,6 @@
             dataIndex: 'emailVerified$',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <SelectFilter
                 name='emailVerified'
                 {...props}
@@ -317,27 +313,11 @@
                 ]}
             />,
         },
-        // {
-        //     title: '瑙掕壊',
-        //     valueType: 'text',
-        //     hidden: false,
-        //     width: 100,
-        //     render: (_, record) => {
-        //         if (record.roleIds && record.roleIds.length > 0) {
-        //             Http.doGetPromise('api/role/list/name/' + record.roleIds.join(','), null, (res) => {
-        //                 return '-'
-        //             });
-        //         } else {
-        //             return '-'
-        //         }
-        //     },
-        // },
         {
             title: '鐪熷疄濮撳悕',
             dataIndex: 'realName',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='realName'
                 {...props}
@@ -350,7 +330,6 @@
             dataIndex: 'idCard',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='idCard'
                 {...props}
@@ -363,7 +342,6 @@
             dataIndex: 'birthday',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='birthday'
                 {...props}
@@ -376,7 +354,6 @@
             dataIndex: 'introduction',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='introduction'
                 {...props}
@@ -389,7 +366,6 @@
             dataIndex: 'status$',
             valueType: 'text',
             hidden: false,
-            width: 80,
             render: (_, record) => {
                 const status = statusMap[record.status]
                 return <Tag color={status.color}>{status.text}</Tag>
@@ -410,7 +386,6 @@
             dataIndex: 'createTime$',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <DatetimeRangeFilter
                 name='createTime'
                 {...props}
@@ -423,7 +398,6 @@
             dataIndex: 'updateTime$',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <DatetimeRangeFilter
                 name='updateTime'
                 {...props}
@@ -436,7 +410,6 @@
             dataIndex: 'updateBy$',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <LinkFilter
                 name='updateBy'
                 major='user'
@@ -450,7 +423,6 @@
             dataIndex: 'memo',
             valueType: 'text',
             hidden: false,
-            width: 140,
             filterDropdown: (props) => <TextFilter
                 name='memo'
                 {...props}
@@ -462,8 +434,8 @@
         {
             title: '鎿嶄綔',
             dataIndex: 'option',
-            width: 120,
             valueType: 'option',
+            width: 180,
             render: (_, record) => [
                 <Button
                     type="link"
@@ -474,7 +446,7 @@
                         setCurrentRow(record);
                     }}
                 >
-                    缂栬緫
+                    <FormattedMessage id='page.edit' defaultMessage='缂栬緫' />
                 </Button>,
                 <Button
                     type="link"
@@ -485,7 +457,7 @@
                         setCurrentRow(record);
                     }}
                 >
-                    閲嶇疆瀵嗙爜
+                    <FormattedMessage id='page.reset.pwd' defaultMessage='閲嶇疆瀵嗙爜' />
                 </Button>,
                 <Button
                     type="link"
@@ -494,10 +466,10 @@
                     key="remove"
                     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();
@@ -507,7 +479,7 @@
                         });
                     }}
                 >
-                    鍒犻櫎
+                    <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
                 </Button>,
                 <TableDropdown
                     key="actionGroup"
@@ -519,7 +491,7 @@
                         }
                     }}
                     menus={[
-                        { key: 'assign', name: '鍒嗛厤瑙掕壊' },
+                        { key: 'assign', name: intl.formatMessage({ id: 'page.assign.role', defaultMessage: '鍒嗛厤瑙掕壊' }) },
                     ]}
                 />,
             ],
@@ -534,10 +506,13 @@
         >
             <Row gutter={[16, 24]}>
                 <Col lg={6} md={24}>
-                    <Card title="閮ㄩ棬" style={{ width: '100%', height: 'calc(100vh - 160px)' }}>
+                    <Card
+                        title={intl.formatMessage({ id: 'system.dept', defaultMessage: '閮ㄩ棬' })}
+                        style={{ width: '100%', height: 'calc(100vh - 160px)' }}
+                    >
                         <Input
                             style={{ marginBottom: 10 }}
-                            placeholder="璇疯緭鍏�"
+                            placeholder={intl.formatMessage({ id: 'commont.enter', defaultMessage: '璇疯緭鍏�' })}
                             onChange={(e) => {
                                 const { value } = e.target;
                                 loadDeptTreeData({
@@ -579,9 +554,9 @@
                         columns={columns}
                         cardBordered
                         size='small'
-                        scroll={{ y: boxHeight }}
+                        // scroll={{ y: boxHeight }}
                         dateFormatter="string"
-                        pagination={{ pageSize: 20 }}
+                        pagination={{ pageSize: 12 }}
                         search={false}
                         toolbar={{
                             search: {
@@ -608,11 +583,11 @@
                                     hidden={selectedRows?.length === 0}
                                     onClick={async () => {
                                         Modal.confirm({
-                                            title: '鏄惁纭鍒犻櫎鎵�閫夋暟鎹」?',
+                                            title: intl.formatMessage({ id: 'page.delete', defaultMessage: '鍒犻櫎' }),
+                                            content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '纭畾鍒犻櫎璇ラ」鍚楋紵' }),
                                             icon: <ExclamationCircleOutlined />,
-                                            content: '璇疯皑鎱庢搷浣�',
                                             async onOk() {
-                                                const success = await handleRemove(selectedRows);
+                                                const success = await handleRemove(selectedRows, intl);
                                                 if (success) {
                                                     setSelectedRows([]);
                                                     actionRef.current.reload();
@@ -623,7 +598,7 @@
                                     }}
                                 >
                                     <DeleteOutlined />
-                                    鍒犻櫎
+                                    <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
                                 </Button>,
                                 <Button
                                     type="primary"
@@ -633,16 +608,16 @@
                                     }}
                                 >
                                     <PlusOutlined />
-                                    娣诲姞
+                                    <FormattedMessage id='page.add' defaultMessage='娣诲姞' />
                                 </Button>,
                                 <Button
                                     key="export"
                                     onClick={async () => {
-                                        handleExport();
+                                        handleExport(intl);
                                     }}
                                 >
                                     <ExportOutlined />
-                                    瀵煎嚭
+                                    <FormattedMessage id='page.export' defaultMessage='瀵煎嚭' />
                                 </Button>,
                             ],
                         }}
@@ -686,84 +661,85 @@
                         }}
                     />
                 </Col>
-
-                <Edit
-                    open={modalVisible}
-                    values={currentRow || {}}
-                    treeData={deptTreeData}
-                    onCancel={
-                        () => {
-                            setModalVisible(false);
-                            setCurrentRow(undefined);
-                        }
-                    }
-                    onSubmit={async (values) => {
-                        let ok = false;
-                        if (values.id) {
-                            ok = await handleUpdate({ ...values })
-                        } else {
-                            ok = await handleSave({ ...values })
-                        }
-                        if (ok) {
-                            setModalVisible(false);
-                            setCurrentRow(undefined);
-                            if (actionRef.current) {
-                                actionRef.current.reload();
-                            }
-                        }
-                    }
-                    }
-                />
-
-                <Pwd
-                    open={pwdModalVisible}
-                    values={currentRow || {}}
-                    onCancel={
-                        () => {
-                            setPwdModalVisible(false);
-                            setCurrentRow(undefined);
-                        }
-                    }
-                    onSubmit={async (values) => {
-                        let ok = false;
-                        if (values.id) {
-                            ok = await handlePwd({ ...values })
-                        }
-                        if (ok) {
-                            setPwdModalVisible(false);
-                            setCurrentRow(undefined);
-                            if (actionRef.current) {
-                                actionRef.current.reload();
-                            }
-                        }
-                    }
-                    }
-                />
-
-                <AssignRole
-                    open={assignModalVisible}
-                    values={currentRow || {}}
-                    onCancel={
-                        () => {
-                            setAssignModalVisible(false);
-                            setCurrentRow(undefined);
-                        }
-                    }
-                    onSubmit={async (values) => {
-                        let ok = false;
-                        if (values.id) {
-                            ok = await handleUpdate({ ...values })
-                        }
-                        if (ok) {
-                            setAssignModalVisible(false);
-                            setCurrentRow(undefined);
-                            if (actionRef.current) {
-                                actionRef.current.reload();
-                            }
-                        }
-                    }}
-                />
             </Row>
+
+            <Edit
+                open={modalVisible}
+                values={currentRow || {}}
+                treeData={deptTreeData}
+                onCancel={
+                    () => {
+                        setModalVisible(false);
+                        setCurrentRow(undefined);
+                    }
+                }
+                onSubmit={async (values) => {
+                    let ok = false;
+                    if (values.id) {
+                        ok = await handleUpdate({ ...values }, intl)
+                    } else {
+                        ok = await handleSave({ ...values }, intl)
+                    }
+                    if (ok) {
+                        setModalVisible(false);
+                        setCurrentRow(undefined);
+                        if (actionRef.current) {
+                            actionRef.current.reload();
+                        }
+                    }
+                }
+                }
+            />
+
+            <Pwd
+                open={pwdModalVisible}
+                values={currentRow || {}}
+                onCancel={
+                    () => {
+                        setPwdModalVisible(false);
+                        setCurrentRow(undefined);
+                    }
+                }
+                onSubmit={async (values) => {
+                    let ok = false;
+                    if (values.id) {
+                        ok = await handlePwd({ ...values }, intl)
+                    }
+                    if (ok) {
+                        setPwdModalVisible(false);
+                        setCurrentRow(undefined);
+                        if (actionRef.current) {
+                            actionRef.current.reload();
+                        }
+                    }
+                }
+                }
+            />
+
+            <AssignRole
+                open={assignModalVisible}
+                values={currentRow || {}}
+                onCancel={
+                    () => {
+                        setAssignModalVisible(false);
+                        setCurrentRow(undefined);
+                    }
+                }
+                onSubmit={async (values) => {
+                    let ok = false;
+                    if (values.id) {
+                        ok = await handleUpdate({ ...values }, intl)
+                    }
+                    if (ok) {
+                        setAssignModalVisible(false);
+                        setCurrentRow(undefined);
+                        if (actionRef.current) {
+                            actionRef.current.reload();
+                        }
+                    }
+                }}
+            />
+
         </PageContainer>
     );
 };

--
Gitblit v1.9.1