From 16dc3116794c57231768552f999040df4ca3c0f8 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 23 二月 2024 11:27:38 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/system/user/index.jsx                 |   37 +++++++++++++++---
 zy-asrs-flow/src/pages/system/user/components/assignRole.jsx |   74 +++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-flow/src/pages/system/user/components/assignRole.jsx b/zy-asrs-flow/src/pages/system/user/components/assignRole.jsx
new file mode 100644
index 0000000..6f2d08a
--- /dev/null
+++ b/zy-asrs-flow/src/pages/system/user/components/assignRole.jsx
@@ -0,0 +1,74 @@
+import React, { useState, useRef, useEffect } from 'react';
+import {
+    ProForm,
+    ProFormDigit,
+    ProFormSelect,
+} from '@ant-design/pro-components';
+import { Form, Modal } from 'antd';
+import Http from '@/utils/http';
+
+const AssignRole = (props) => {
+    const [form] = Form.useForm();
+    const { } = props;
+
+    useEffect(() => {
+        form.resetFields();
+        form.setFieldsValue({
+            ...props.values
+        })
+    }, [form, props])
+
+    const handleCancel = () => {
+        props.onCancel();
+    };
+
+    const handleOk = () => {
+        form.submit();
+    }
+
+    const handleFinish = async (values) => {
+        props.onSubmit({ ...values });
+    }
+
+    return (
+        <>
+            <Modal
+                title="Assign Role"
+                width={600}
+                forceRender
+                destroyOnClose
+                open={props.open}
+                onCancel={handleCancel}
+                onOk={handleOk}
+            >
+                <ProForm
+                    form={form}
+                    submitter={false}
+                    onFinish={handleFinish}
+                    layout="horizontal"
+                    grid={true}
+                >
+                    <ProFormDigit
+                        name="id"
+                        disabled
+                        hidden={true}
+                    />
+                    <ProFormSelect
+                        name="roleIds"
+                        mode="multiple"
+                        label="瑙掕壊"
+                        colProps={{ md: 24, xl: 24 }}
+                        placeholder="璇烽�夋嫨"
+                        rules={[{ required: true, type: 'array', message: '瑙掕壊涓嶈兘涓虹┖!' }]}
+                        request={async ({ keyWords }) => {
+                            const resp = await Http.doPostForm('api/role/query', { condition: keyWords });
+                            return resp.data;
+                        }}
+                    />
+                </ProForm>
+            </Modal>
+        </>
+    )
+}
+
+export default AssignRole;
diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 8c07081..c7d0fe6 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -1,4 +1,3 @@
-
 import React, { useState, useRef, useEffect } from 'react';
 import { Button, message, Modal, Row, Col, Card, Tree, Input, Tag, Skeleton } from 'antd';
 import {
@@ -12,6 +11,7 @@
 import Http from '@/utils/http';
 import Edit from './components/edit'
 import Pwd from './components/pwd'
+import AssignRole from './components/assignRole'
 import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
 import { transformTreeData, getTreeAllKeys } from '@/utils/tree-util'
 import { statusMap } from '@/utils/enum-util'
@@ -124,6 +124,8 @@
     const [deptExpandedKeys, setDeptExpandedKeys] = useState([]);
 
     const [pwdModalVisible, setPwdModalVisible] = useState(false);
+
+    const [assignModalVisible, setAssignModalVisible] = useState(false);
 
     const loadDeptTreeData = (param) => {
         setDeptTreeLoading(true);
@@ -508,16 +510,13 @@
                     key="actionGroup"
                     name="dropdown"
                     onSelect={(key) => {
-                        if (key === 'pwd') {
-                            setPwdModalVisible(true);
+                        if (key === 'assign') {
+                            setAssignModalVisible(true);
                             setCurrentRow(record);
-                        }
-                        else if (key === 'authRole') {
                         }
                     }}
                     menus={[
-                        // { key: 'pwd', name: '瀵嗙爜閲嶇疆' },
-                        { key: 'authRole', name: '鍒嗛厤瑙掕壊' },
+                        { key: 'assign', name: '鍒嗛厤瑙掕壊' },
                     ]}
                 />,
             ],
@@ -722,6 +721,30 @@
                     }
                     }
                 />
+
+                <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>
         </PageContainer>
     );

--
Gitblit v1.9.1