From 3215e24a462ee364ead6709b0ef238b1f43015c4 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 21 二月 2024 16:15:14 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/system/user/index.jsx |   97 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 83 insertions(+), 14 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 5734465..70fe28f 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -1,6 +1,6 @@
 
 import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal, Row, Col, Card, Tree, Input } from 'antd';
+import { Button, message, Modal, Row, Col, Card, Tree, Input, Tag } from 'antd';
 import {
     FooterToolbar,
     PageContainer,
@@ -10,8 +10,10 @@
 import { PlusOutlined, ExportOutlined, DownOutlined } from '@ant-design/icons';
 import Http from '@/utils/http';
 import Edit from './components/edit'
+import Pwd from './components/pwd'
 import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
 import { transformTreeData, getTreeAllKeys } from '@/utils/tree-util'
+import { statusMap } from '@/utils/enum-util'
 
 const handleSave = async (val) => {
     const hide = message.loading('姝e湪娣诲姞');
@@ -87,6 +89,25 @@
     }
 };
 
+const handlePwd = async (val) => {
+    const hide = message.loading('姝e湪閲嶇疆');
+    try {
+        const resp = await Http.doPost('api/user/reset/pwd', val);
+        if (resp.code === 200) {
+            message.success('閲嶇疆鎴愬姛');
+            return true;
+        } else {
+            message.error(resp.msg);
+            return false;
+        }
+    } catch (error) {
+        message.error('閲嶇疆澶辫触璇烽噸璇曪紒');
+        return false;
+    } finally {
+        hide();
+    }
+};
+
 
 const Main = () => {
     const formTableRef = useRef();
@@ -98,6 +119,7 @@
     const [boxHeight, setBoxHeight] = useState();
     const [deptTreeData, setDeptTreeData] = useState([]);
     const [deptExpandedKeys, setDeptExpandedKeys] = useState([]);
+    const [pwdModalVisible, setPwdModalVisible] = useState(false);
 
     useEffect(() => {
         const handleResize = () => setBoxHeight(window.innerHeight - 368);
@@ -124,12 +146,11 @@
             width: 30,
         },
         {
-            title: '鏄电О',
+            title: '鍚嶇О',
             dataIndex: 'nickname',
             valueType: 'text',
             hidden: false,
             width: 100,
-            copyable: true,
             filterDropdown: (props) => <TextFilter
                 name='nickname'
                 {...props}
@@ -138,7 +159,7 @@
             />,
         },
         {
-            title: '璐﹀彿',
+            title: '鐧诲綍璐﹀彿',
             dataIndex: 'username',
             valueType: 'text',
             hidden: false,
@@ -256,13 +277,20 @@
             valueType: 'text',
             hidden: false,
             width: 100,
-            filterDropdown: (props) => <LinkFilter
-                name='deptId'
-                major='dept'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
+            render: (_, record) => {
+                if (_ && _ !== '-') {
+                    return <Tag color={""}>{_}</Tag>
+                } else {
+                    return '-'
+                }
+            },
+            // filterDropdown: (props) => <LinkFilter
+            //     name='deptId'
+            //     major='dept'
+            //     {...props}
+            //     actionRef={actionRef}
+            //     setSearchParam={setSearchParam}
+            // />,
         },
         {
             title: '鐪熷疄濮撳悕',
@@ -322,6 +350,10 @@
             valueType: 'text',
             hidden: false,
             width: 80,
+            render: (_, record) => {
+                const status = statusMap[record.status]
+                return <Tag color={status.color}>{status.text}</Tag>
+            },
             filterDropdown: (props) => <SelectFilter
                 name='status'
                 {...props}
@@ -390,7 +422,7 @@
         {
             title: '鎿嶄綔',
             dataIndex: 'option',
-            width: 100,
+            width: 150,
             valueType: 'option',
             render: (_, record) => [
                 <Button
@@ -402,6 +434,16 @@
                     }}
                 >
                     缂栬緫
+                </Button>,
+                <Button
+                    type="link"
+                    key="pwd"
+                    onClick={() => {
+                        setPwdModalVisible(true);
+                        setCurrentRow(record);
+                    }}
+                >
+                    閲嶇疆瀵嗙爜
                 </Button>,
                 <Button
                     type="link"
@@ -450,6 +492,7 @@
                             blockNode
                             defaultExpandAll    // 寮傛鍔犺浇澶辨晥
                             expandedKeys={deptExpandedKeys}
+                            onExpand={setDeptExpandedKeys} 
                             treeData={deptTreeData}
                             switcherIcon={<DownOutlined />}
                             onSelect={(selectedKeys, info) => {
@@ -471,7 +514,7 @@
                         formRef={formTableRef}
                         columns={columns}
                         cardBordered
-                        scroll={{y: boxHeight }}
+                        scroll={{ y: boxHeight }}
                         dateFormatter="string"
                         pagination={{ pageSize: 20 }}
                         search={false}
@@ -515,7 +558,7 @@
                             ],
                         }}
                         request={(params, sorter, filter) =>
-                            Http.doPostPromise('/api/user/page', { ...params, ...searchParam }, (res) => {
+                            Http.doPostPromise('/api/user/page1', { ...params, ...searchParam }, (res) => {
                                 return {
                                     data: res.data.records,
                                     total: res.data.total,
@@ -575,6 +618,7 @@
                 <Edit
                     open={modalVisible}
                     values={currentRow || {}}
+                    treeData={deptTreeData}
                     onCancel={
                         () => {
                             setModalVisible(false);
@@ -598,6 +642,31 @@
                     }
                     }
                 />
+
+                <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();
+                            }
+                        }
+                    }
+                    }
+                />
             </Row>
         </PageContainer>
     );

--
Gitblit v1.9.1