zy-asrs-flow/src/pages/system/user/components/assignRole.jsx | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-flow/src/pages/system/user/index.jsx | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
zy-asrs-flow/src/pages/system/user/components/assignRole.jsx
New file @@ -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; 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> );