|
@@ -1,22 +1,24 @@
|
|
/*
|
|
/*
|
|
* @Author: your name
|
|
* @Author: your name
|
|
* @Date: 2021-07-26 10:13:13
|
|
* @Date: 2021-07-26 10:13:13
|
|
- * @LastEditTime: 2021-08-02 18:27:21
|
|
|
|
|
|
+ * @LastEditTime: 2021-08-03 17:32:25
|
|
* @LastEditors: Please set LastEditors
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
|
|
* @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
|
|
*/
|
|
*/
|
|
|
|
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
-import { Button, Popconfirm, message, Input, Modal } from 'antd';
|
|
|
|
-import React, { useState, useRef, useEffect } from 'react';
|
|
|
|
-import { useIntl, FormattedMessage,useModel } from 'umi';
|
|
|
|
-import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
|
|
|
|
|
|
+import { Button, Popconfirm} from 'antd';
|
|
|
|
+import React, { useState, useRef } from 'react';
|
|
|
|
+import { PageContainer } from '@ant-design/pro-layout';
|
|
import ProTable from '@ant-design/pro-table';
|
|
import ProTable from '@ant-design/pro-table';
|
|
-import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form';
|
|
|
|
|
|
+import { ModalForm, ProFormText } from '@ant-design/pro-form';
|
|
import UpdateForm from './updateForm';
|
|
import UpdateForm from './updateForm';
|
|
|
|
+import DrawerContent from './component/drawer';
|
|
|
|
+import { getRoleList, roleBindUser, addList, editList, delList,roleBindMenu } from './service';
|
|
|
|
+import { getUserList } from '@/pages/UserMana/service';
|
|
|
|
|
|
-import { getRoleList, addUser, editUser, delUser } from './service';
|
|
|
|
|
|
+import { getMenuList } from '@/pages/platformMana/menuManage/service';
|
|
|
|
|
|
const UserMana = () => {
|
|
const UserMana = () => {
|
|
const columns = [
|
|
const columns = [
|
|
@@ -41,16 +43,18 @@ const UserMana = () => {
|
|
title: '变更日期',
|
|
title: '变更日期',
|
|
dataIndex: 'modifyTime',
|
|
dataIndex: 'modifyTime',
|
|
key: 'modifyTime',
|
|
key: 'modifyTime',
|
|
|
|
+ valueType: 'date',
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title:'操作',
|
|
|
|
|
|
+ title: '操作',
|
|
dataIndex: 'option',
|
|
dataIndex: 'option',
|
|
valueType: 'option',
|
|
valueType: 'option',
|
|
render: (_, record) => [
|
|
render: (_, record) => [
|
|
<a
|
|
<a
|
|
key="config"
|
|
key="config"
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- handleUpdateModalVisible(true);
|
|
|
|
|
|
+ setEditRoleBindUsers(true);
|
|
|
|
+ setDrawerVisible(true);
|
|
setCurrentRow(record);
|
|
setCurrentRow(record);
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -59,7 +63,8 @@ const UserMana = () => {
|
|
<a
|
|
<a
|
|
key="config"
|
|
key="config"
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- handleUpdateModalVisible(true);
|
|
|
|
|
|
+ setEditRoleBindUsers(false);
|
|
|
|
+ setDrawerVisible(true);
|
|
setCurrentRow(record);
|
|
setCurrentRow(record);
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -78,7 +83,6 @@ const UserMana = () => {
|
|
key="subscribeAlert"
|
|
key="subscribeAlert"
|
|
title="是否确定删除?"
|
|
title="是否确定删除?"
|
|
onConfirm={() => {
|
|
onConfirm={() => {
|
|
- setCurrentRow(record);
|
|
|
|
delUserHandler(record);
|
|
delUserHandler(record);
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -88,16 +92,55 @@ const UserMana = () => {
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ const DrawerTableUsersColumns = [
|
|
|
|
+ {
|
|
|
|
+ title: 'Id',
|
|
|
|
+ dataIndex: 'id',
|
|
|
|
+ key: 'id',
|
|
|
|
+ hideInSearch: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '姓名',
|
|
|
|
+ dataIndex: 'name',
|
|
|
|
+ key: 'name',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '用户名',
|
|
|
|
+ dataIndex: 'account',
|
|
|
|
+ key: 'account',
|
|
|
|
+ hideInSearch: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '在职状态',
|
|
|
|
+ dataIndex: 'hospitalStatus',
|
|
|
|
+ key: 'hospitalStatus',
|
|
|
|
+ hideInSearch: true,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ const DrawerTableMenusColumns = [
|
|
|
|
+ {
|
|
|
|
+ title: 'Id',
|
|
|
|
+ dataIndex: 'menuId',
|
|
|
|
+ key: 'menuId',
|
|
|
|
+ hideInSearch: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '菜单名称',
|
|
|
|
+ dataIndex: 'name',
|
|
|
|
+ key: 'name',
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+
|
|
const [createModalVisible, handleModalVisible] = useState(false);
|
|
const [createModalVisible, handleModalVisible] = useState(false);
|
|
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
|
|
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
|
|
const actionRef = useRef();
|
|
const actionRef = useRef();
|
|
const [currentRow, setCurrentRow] = useState({});
|
|
const [currentRow, setCurrentRow] = useState({});
|
|
-
|
|
|
|
|
|
+ const [editRoleBindUsers, setEditRoleBindUsers] = useState(false);
|
|
|
|
+ const [drawerVisible, setDrawerVisible] = useState(false);
|
|
|
|
|
|
// const [shareParamsSetting,setShareParamsSetting] = useState(false); //是否分摊参数设置
|
|
// const [shareParamsSetting,setShareParamsSetting] = useState(false); //是否分摊参数设置
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param {Boolean} bool 弹窗展示状态
|
|
* @param {Boolean} bool 弹窗展示状态
|
|
@@ -117,19 +160,40 @@ const UserMana = () => {
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ //获取Drawer用户列表
|
|
|
|
+ const getUsers = async (params = {}, sort, filter) => {
|
|
|
|
+ const res = await getUserList(params);
|
|
|
|
+ return {
|
|
|
|
+ data: res.data.list,
|
|
|
|
+ total: res.data.totalCount,
|
|
|
|
+ success: res.success,
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //获取Drawer菜单列表
|
|
|
|
+ const getMenus = async (params = {}, sort, filter) => {
|
|
|
|
+ const res = await getMenuList(params);
|
|
|
|
+ return {
|
|
|
|
+ data: res.data.list,
|
|
|
|
+ total: res.data.totalCount,
|
|
|
|
+ success: res.success,
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param {Object} value 删除项数据
|
|
* @param {Object} value 删除项数据
|
|
*/
|
|
*/
|
|
const delUserHandler = async (value) => {
|
|
const delUserHandler = async (value) => {
|
|
- const resp = await delUser(value);
|
|
|
|
- if(resp.msg){
|
|
|
|
|
|
+ const ids = [value.roleId];
|
|
|
|
+ const resp = await delList({ ids });
|
|
|
|
+ if (resp.status == 200) {
|
|
if (actionRef.current) {
|
|
if (actionRef.current) {
|
|
actionRef.current.reload();
|
|
actionRef.current.reload();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<PageContainer>
|
|
<PageContainer>
|
|
<ProTable
|
|
<ProTable
|
|
@@ -148,7 +212,6 @@ const UserMana = () => {
|
|
>
|
|
>
|
|
新增
|
|
新增
|
|
</Button>,
|
|
</Button>,
|
|
-
|
|
|
|
]}
|
|
]}
|
|
pagination={{
|
|
pagination={{
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
@@ -160,18 +223,17 @@ const UserMana = () => {
|
|
/>
|
|
/>
|
|
|
|
|
|
<ModalForm
|
|
<ModalForm
|
|
- title="新增角度"
|
|
|
|
|
|
+ title="新增角色"
|
|
width="800px"
|
|
width="800px"
|
|
labelCol={{ span: 5, offset: 3 }}
|
|
labelCol={{ span: 5, offset: 3 }}
|
|
layout={'horizontal'}
|
|
layout={'horizontal'}
|
|
visible={createModalVisible}
|
|
visible={createModalVisible}
|
|
onVisibleChange={handleModalVisible}
|
|
onVisibleChange={handleModalVisible}
|
|
onFinish={async (value) => {
|
|
onFinish={async (value) => {
|
|
- const success = await addUser(value);
|
|
|
|
|
|
+ const success = await addList(value);
|
|
// console.log({ success });
|
|
// console.log({ success });
|
|
if (success) {
|
|
if (success) {
|
|
handleModalVisible(false);
|
|
handleModalVisible(false);
|
|
-
|
|
|
|
if (actionRef.current) {
|
|
if (actionRef.current) {
|
|
actionRef.current.reload();
|
|
actionRef.current.reload();
|
|
}
|
|
}
|
|
@@ -183,7 +245,7 @@ const UserMana = () => {
|
|
rules={[
|
|
rules={[
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
- message:'角色名是必填项!',
|
|
|
|
|
|
+ message: '角色名是必填项!',
|
|
},
|
|
},
|
|
]}
|
|
]}
|
|
width="sm"
|
|
width="sm"
|
|
@@ -194,20 +256,20 @@ const UserMana = () => {
|
|
rules={[
|
|
rules={[
|
|
{
|
|
{
|
|
required: false,
|
|
required: false,
|
|
- message:'',
|
|
|
|
|
|
+ message: '',
|
|
},
|
|
},
|
|
]}
|
|
]}
|
|
width="sm"
|
|
width="sm"
|
|
name="remark"
|
|
name="remark"
|
|
/>
|
|
/>
|
|
-
|
|
|
|
</ModalForm>
|
|
</ModalForm>
|
|
|
|
|
|
{/* 更新 */}
|
|
{/* 更新 */}
|
|
<UpdateForm
|
|
<UpdateForm
|
|
onSubmit={async (value) => {
|
|
onSubmit={async (value) => {
|
|
// console.log({value});
|
|
// console.log({value});
|
|
- const success = await editUser(value);
|
|
|
|
|
|
+ const { roleId, roleName, remark } = value;
|
|
|
|
+ const success = await editList({ roleId, roleName, remark });
|
|
|
|
|
|
if (success) {
|
|
if (success) {
|
|
handleUpdateModalVisible(false);
|
|
handleUpdateModalVisible(false);
|
|
@@ -227,7 +289,56 @@ const UserMana = () => {
|
|
values={currentRow || {}}
|
|
values={currentRow || {}}
|
|
/>
|
|
/>
|
|
|
|
|
|
-
|
|
|
|
|
|
+ {editRoleBindUsers ? (
|
|
|
|
+ //编辑用户
|
|
|
|
+ <DrawerContent
|
|
|
|
+ columns={DrawerTableUsersColumns}
|
|
|
|
+ visible={drawerVisible}
|
|
|
|
+ currentRow={currentRow}
|
|
|
|
+ defaultSelected={[98, 87]}
|
|
|
|
+ onVisibleChange={(bool) => setDrawerVisible(bool)}
|
|
|
|
+ renderListFunc={getUsers}
|
|
|
|
+ config={{tableSearch:true}}
|
|
|
|
+ onFinishFunc={async (value, selectedRowKeys) => {
|
|
|
|
+ // console.log({value,selectedRowKeys});
|
|
|
|
+ const { roleId } = currentRow;
|
|
|
|
+ const resp = await roleBindUser({ roleId, userIds: selectedRowKeys });
|
|
|
|
+ const { status } = resp;
|
|
|
|
+ if (status == 200) {
|
|
|
|
+ setDrawerVisible(false);
|
|
|
|
+ setCurrentRow(undefined);
|
|
|
|
+ if (actionRef.current) {
|
|
|
|
+ actionRef.current.reload();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ ) : (
|
|
|
|
+ //编辑权限
|
|
|
|
+ <DrawerContent
|
|
|
|
+ columns={DrawerTableMenusColumns}
|
|
|
|
+ visible={drawerVisible}
|
|
|
|
+ currentRow={currentRow}
|
|
|
|
+ defaultSelected={[98, 87]}
|
|
|
|
+ onVisibleChange={(bool) => setDrawerVisible(bool)}
|
|
|
|
+ renderListFunc={getMenus}
|
|
|
|
+ config={{rowKeys:'menuId',tableSearch:false}}
|
|
|
|
+ tableSearch={false}
|
|
|
|
+ onFinishFunc={async (value, selectedRowKeys) => {
|
|
|
|
+ // console.log({value,selectedRowKeys});
|
|
|
|
+ const { roleId } = currentRow;
|
|
|
|
+ const resp = await roleBindMenu({ roleId, menuIds: selectedRowKeys });
|
|
|
|
+ const { status } = resp;
|
|
|
|
+ if (status == 200) {
|
|
|
|
+ setDrawerVisible(false);
|
|
|
|
+ setCurrentRow(undefined);
|
|
|
|
+ if (actionRef.current) {
|
|
|
|
+ actionRef.current.reload();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ )}
|
|
</PageContainer>
|
|
</PageContainer>
|
|
);
|
|
);
|
|
};
|
|
};
|