提交 90a77338 作者: ZhangLingKun

优化:成员管理角色

上级 fec30f6b
流水线 #8892 已通过 于阶段
in 1 分 5 秒
......@@ -360,3 +360,11 @@ export type getUserAddressInfoType = InterFunction<
id: number;
}
>;
// 获取角色列表
export type getRolesListType = InterFunction<
NonNullable<unknown>,
{
id: number;
roleName: string;
}[]
>;
......@@ -6,6 +6,7 @@ import {
deleteRoleInfoType,
editAddressType,
getCompanyInfoByIdType,
getRolesListType,
getSecondDistrictInfo,
getUserAddressInfoType,
insertBAccountType,
......@@ -123,4 +124,8 @@ export class SystemManageAPI {
// 地址管理-根据地址id查找
static getUserAddressInfo: getUserAddressInfoType = (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 { Form, message, Modal, ModalProps, Select } from 'antd';
import { Form, message, Modal, ModalProps, Select, SelectProps } from 'antd';
import { CommonAPI, SystemManageAPI } from '~/api';
interface selfProps {
onOk: () => void;
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 [options, setOptions] = useState<{ label: string; value: number; key: string }[]>([]);
// 确认事件
const handleOk = () => {
form.validateFields().then((values) => {
SystemManageAPI.bindingCompanyMember({ ...values, companyInfoId }).then(({ code }) => {
if (code === '200') {
message.success('绑定成功');
message.success('绑定成功').then();
onOk();
form.resetFields();
}
......@@ -32,7 +40,6 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp
setOptions(list);
});
};
return (
<Modal open={open} title='添加成员' onOk={handleOk} onCancel={onCancel}>
<Form form={form}>
......@@ -51,6 +58,9 @@ const AddPeopleModal: FC<ModalProps & selfProps> = ({ open, onCancel, onOk, comp
options={options}
></Select>
</Form.Item>
<Form.Item label='角色' name='leader' rules={[{ required: true, message: '请选择角色' }]}>
<Select placeholder='请输入成员手机号码' options={roleList}></Select>
</Form.Item>
</Form>
</Modal>
);
......
......@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { SystemManageAPI } from '~/api';
import { InterDataType, PaginationProps } from '~/api/interface';
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 { ColumnsType } from 'antd/es/table';
import { PlusOutlined } from '@ant-design/icons';
......@@ -15,58 +15,8 @@ type companyMembersType = InterDataType<listCompanyMembersType>['list'];
const CompanyMemberView = () => {
const { userInfo } = useSelector((state: any) => state.UserInfo);
const tableColumns: ColumnsType<companyMembersType[0]> = [
{
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 [roleList, setRoleList] = useState<SelectProps['options']>();
const [companyId, setCompanyId] = useState<number>(-1);
const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({
pageNo: 1,
......@@ -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(() => {
if (!userInfo?.companyInfoVO?.id) {
message.warning('暂无单位').then();
......@@ -146,8 +105,63 @@ const CompanyMemberView = () => {
}
setCompanyId(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 (
<div className='company-detail'>
<div className='company-detail-people'>
......@@ -183,6 +197,7 @@ const CompanyMemberView = () => {
onCancel={addPeopleModalCancel}
onOk={addPeopleModalOk}
companyInfoId={companyId}
roleList={roleList}
/>
{/*转让管理员*/}
<TransferLeaderModal
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论