提交 90a77338 作者: ZhangLingKun

优化:成员管理角色

上级 fec30f6b
流水线 #8892 已通过 于阶段
in 1 分 5 秒
...@@ -360,3 +360,11 @@ export type getUserAddressInfoType = InterFunction< ...@@ -360,3 +360,11 @@ export type getUserAddressInfoType = InterFunction<
id: number; id: number;
} }
>; >;
// 获取角色列表
export type getRolesListType = InterFunction<
NonNullable<unknown>,
{
id: number;
roleName: string;
}[]
>;
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
deleteRoleInfoType, deleteRoleInfoType,
editAddressType, editAddressType,
getCompanyInfoByIdType, getCompanyInfoByIdType,
getRolesListType,
getSecondDistrictInfo, getSecondDistrictInfo,
getUserAddressInfoType, getUserAddressInfoType,
insertBAccountType, insertBAccountType,
...@@ -123,4 +124,8 @@ export class SystemManageAPI { ...@@ -123,4 +124,8 @@ export class SystemManageAPI {
// 地址管理-根据地址id查找 // 地址管理-根据地址id查找
static getUserAddressInfo: getUserAddressInfoType = (params) => static getUserAddressInfo: getUserAddressInfoType = (params) =>
axios.get('/oms/user-address/getUserAddressInfo', { params }); axios.get('/oms/user-address/getUserAddressInfo', { params });
// 获取角色列表
static getRolesList: getRolesListType = (params) =>
axios.get('/userapp/user-account/getRolesList', { params });
} }
import { FC, useState } from 'react'; import { FC, useState } from 'react';
import { Form, message, Modal, ModalProps, Select } from 'antd'; import { Form, message, Modal, ModalProps, Select, SelectProps } from 'antd';
import { CommonAPI, SystemManageAPI } from '~/api'; import { CommonAPI, SystemManageAPI } from '~/api';
interface selfProps { interface selfProps {
onOk: () => void; onOk: () => void;
companyInfoId: number; companyInfoId: number;
roleList: SelectProps['options'];
} }
const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, companyInfoId }) => { const AddPeopleModal: FC<ModalProps & selfProps> = ({
open,
onCancel,
onOk,
companyInfoId,
roleList,
}) => {
const [form] = Form.useForm<{ userAccountId: number }>(); const [form] = Form.useForm<{ userAccountId: number }>();
const [options, setOptions] = useState<{ label: string; value: number; key: string }[]>([]); const [options, setOptions] = useState<{ label: string; value: number; key: string }[]>([]);
// 确认事件
const handleOk = () => { const handleOk = () => {
form.validateFields().then((values) => { form.validateFields().then((values) => {
SystemManageAPI.bindingCompanyMember({ ...values, companyInfoId }).then(({ code }) => { SystemManageAPI.bindingCompanyMember({ ...values, companyInfoId }).then(({ code }) => {
if (code === '200') { if (code === '200') {
message.success('绑定成功'); message.success('绑定成功').then();
onOk(); onOk();
form.resetFields(); form.resetFields();
} }
...@@ -32,7 +40,6 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp ...@@ -32,7 +40,6 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp
setOptions(list); setOptions(list);
}); });
}; };
return ( return (
<Modal open={open} title='添加成员' onOk={handleOk} onCancel={onCancel}> <Modal open={open} title='添加成员' onOk={handleOk} onCancel={onCancel}>
<Form form={form}> <Form form={form}>
...@@ -51,6 +58,9 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp ...@@ -51,6 +58,9 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp
options={options} options={options}
></Select> ></Select>
</Form.Item> </Form.Item>
<Form.Item label='角色' name='leader' rules={[{ required: true, message: '请选择角色' }]}>
<Select placeholder='请输入成员手机号码' options={roleList}></Select>
</Form.Item>
</Form> </Form>
</Modal> </Modal>
); );
......
...@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; ...@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { SystemManageAPI } from '~/api'; import { SystemManageAPI } from '~/api';
import { InterDataType, PaginationProps } from '~/api/interface'; import { InterDataType, PaginationProps } from '~/api/interface';
import { listCompanyMembersType } from '~/api/interface/systemManageType'; import { listCompanyMembersType } from '~/api/interface/systemManageType';
import { Button, message, Modal, Table } from 'antd'; import { Button, message, Modal, SelectProps, Table } from 'antd';
import '~/pages/systemManage/companyManage/companyDetail/index.scss'; import '~/pages/systemManage/companyManage/companyDetail/index.scss';
import { ColumnsType } from 'antd/es/table'; import { ColumnsType } from 'antd/es/table';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
...@@ -15,58 +15,8 @@ type companyMembersType = InterDataType<listCompanyMembersType>['list']; ...@@ -15,58 +15,8 @@ type companyMembersType = InterDataType<listCompanyMembersType>['list'];
const CompanyMemberView = () => { const CompanyMemberView = () => {
const { userInfo } = useSelector((state: any) => state.UserInfo); const { userInfo } = useSelector((state: any) => state.UserInfo);
// 角色列表
const tableColumns: ColumnsType<companyMembersType[0]> = [ const [roleList, setRoleList] = useState<SelectProps['options']>();
{
title: 'uid',
align: 'center',
dataIndex: 'uid',
},
{
title: '姓名',
align: 'center',
dataIndex: 'userName',
},
{
title: '角色',
align: 'center',
dataIndex: 'leader',
render: (text: number) => (text ? '单位管理员' : '普通员工'),
},
{
title: '手机号',
align: 'center',
dataIndex: 'phoneNum',
},
{
title: '操作',
width: '15%',
onHeaderCell: () => ({
style: {
textAlign: 'center',
},
}),
render: (_text: string, record) => (
<>
<Button
type='link'
disabled={!userInfo.companyInfoVO.leader || !record.leader}
onClick={() => transferLeaderClick(record)}
>
转让
</Button>
<Button
type='link'
disabled={!userInfo.companyInfoVO.leader || !!record.leader}
onClick={() => unbindCompanyClick(record)}
>
解绑
</Button>
</>
),
},
];
const [companyId, setCompanyId] = useState<number>(-1); const [companyId, setCompanyId] = useState<number>(-1);
const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({ const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({
pageNo: 1, pageNo: 1,
...@@ -139,6 +89,15 @@ const CompanyMemberView = () => { ...@@ -139,6 +89,15 @@ const CompanyMemberView = () => {
}, },
}); });
}; };
// 获取角色列表
const getRoleList = async () => {
const res = await SystemManageAPI.getRolesList();
if (res && res.code === '200') {
setRoleList(
res.result?.map((i) => ({ label: i?.roleName, value: i?.id, disabled: i?.id === 1 })),
);
}
};
useEffect(() => { useEffect(() => {
if (!userInfo?.companyInfoVO?.id) { if (!userInfo?.companyInfoVO?.id) {
message.warning('暂无单位').then(); message.warning('暂无单位').then();
...@@ -146,8 +105,63 @@ const CompanyMemberView = () => { ...@@ -146,8 +105,63 @@ const CompanyMemberView = () => {
} }
setCompanyId(Number(userInfo?.companyInfoVO?.id)); setCompanyId(Number(userInfo?.companyInfoVO?.id));
getListCompanyMembers(Number(userInfo?.companyInfoVO?.id)); getListCompanyMembers(Number(userInfo?.companyInfoVO?.id));
getRoleList().then();
}, []); }, []);
const tableColumns: ColumnsType<companyMembersType[0]> = [
{
title: 'uid',
align: 'center',
dataIndex: 'uid',
},
{
title: '姓名',
align: 'center',
dataIndex: 'userName',
render: (text, record) => text || record?.nickName,
},
{
title: '角色',
align: 'center',
dataIndex: 'leader',
render: (text) => roleList?.find((i) => i?.value === text)?.label || text,
},
{
title: '手机号',
align: 'center',
dataIndex: 'phoneNum',
},
{
title: '操作',
width: '15%',
onHeaderCell: () => ({
style: {
textAlign: 'center',
},
}),
render: (_text: string, record) => (
<>
<Button
type='link'
disabled={
userInfo.companyInfoVO.leader !== 1 || userInfo.companyInfoVO.leader === record.leader
}
onClick={() => transferLeaderClick(record)}
>
转让
</Button>
<Button
type='link'
disabled={
userInfo.companyInfoVO.leader !== 1 || userInfo.companyInfoVO.leader === record.leader
}
onClick={() => unbindCompanyClick(record)}
>
解绑
</Button>
</>
),
},
];
return ( return (
<div className='company-detail'> <div className='company-detail'>
<div className='company-detail-people'> <div className='company-detail-people'>
...@@ -183,6 +197,7 @@ const CompanyMemberView = () => { ...@@ -183,6 +197,7 @@ const CompanyMemberView = () => {
onCancel={addPeopleModalCancel} onCancel={addPeopleModalCancel}
onOk={addPeopleModalOk} onOk={addPeopleModalOk}
companyInfoId={companyId} companyInfoId={companyId}
roleList={roleList}
/> />
{/*转让管理员*/} {/*转让管理员*/}
<TransferLeaderModal <TransferLeaderModal
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论