用户角色概览
This commit is contained in:
@@ -59,6 +59,9 @@ import {
|
||||
import dayjs from 'dayjs';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getRoleList } from '@/api/role';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import { getUser } from '@/api/user';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
@@ -66,6 +69,11 @@ const BasicSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
const [roles, setRoles] = useState<any[]>([]);
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { currentStation, stationId } = useSelector((state: RootState) => state.station);
|
||||
const [userList, setUserList] = useState<any[]>([]);
|
||||
|
||||
|
||||
|
||||
// 响应式字体大小
|
||||
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||
@@ -136,7 +144,7 @@ const BasicSettings = () => {
|
||||
title: t('systemSetting.fixed2OM'),
|
||||
users: 5,
|
||||
perms: 18,
|
||||
tags: ["处理工单","处理任务"],
|
||||
tags: ["处理工单", "处理任务"],
|
||||
color: '#52c41a',
|
||||
bg: '#f6ffed',
|
||||
icon: <Wrench size={20} color="#52c41a" />
|
||||
@@ -156,7 +164,7 @@ const BasicSettings = () => {
|
||||
title: t('systemSetting.s322'),
|
||||
users: 3,
|
||||
perms: 15,
|
||||
tags: ['管理自己场站', '报表查看','告警处理'],
|
||||
tags: ['管理自己场站', '报表查看', '告警处理'],
|
||||
color: '#722ed1',
|
||||
bg: '#f9f0ff',
|
||||
icon: <LineChart size={20} color="#722ed1" />
|
||||
@@ -174,6 +182,26 @@ const BasicSettings = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const getUserData = () => {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
orgId: userInfo?.roleKey == "manager" ? userInfo?.orgId : currentStation?.orgId,
|
||||
...(userInfo?.roleKey == "manager"
|
||||
? {}
|
||||
: { siteId: stationId }
|
||||
)
|
||||
};
|
||||
|
||||
getUser(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setUserList(res.rows || []);
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 设备状态
|
||||
const deviceStatuses = [
|
||||
{ name: t('home.inverter'), count: '5/5', status: t('roles.normal') },
|
||||
@@ -197,6 +225,7 @@ const BasicSettings = () => {
|
||||
|
||||
useEffect(() => {
|
||||
getRoleData();
|
||||
getUserData();
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -373,39 +402,37 @@ const BasicSettings = () => {
|
||||
|
||||
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
|
||||
columns={[
|
||||
{ title: t('systemSetting.s36'), dataIndex: 'name', key: 'name', fixed: 'left', width: 80 },
|
||||
{ title: t('systemSetting.s36'), dataIndex: 'userName', key: 'userName', fixed: 'left', },
|
||||
{
|
||||
title: t('users.role'),
|
||||
dataIndex: 'role',
|
||||
key: 'role',
|
||||
width: 100,
|
||||
render: (role) => {
|
||||
const config: any = {
|
||||
'超级管理员': { color: '#1677ff', bg: '#e6f4ff' },
|
||||
'运维工程师': { color: '#52c41a', bg: '#f6ffed' },
|
||||
'巡检主管': { color: '#fa8c16', bg: '#fff7e6' },
|
||||
'数据分析师': { color: '#722ed1', bg: '#f9f0ff' },
|
||||
};
|
||||
const s = config[role] || { color: '#8c8c8c', bg: '#f5f5f5' };
|
||||
return <Tag bordered={false} style={{ color: s.color, background: s.bg, fontSize: 10, margin: 0 }}>{role}</Tag>;
|
||||
render: (_val, record) => {
|
||||
const roleList = record.roles || [];
|
||||
return <>
|
||||
{roleList.map((rItem: any) => {
|
||||
//const conf = getRoleConfByKey(rItem.roleKey);
|
||||
return <Tag key={rItem.roleId}>{rItem.roleKey == "manager" ? t('systemSetting.fixed2Inspection2') : rItem.roleKey == "siteManager" ? t('systemSetting.s322') : t('systemSetting.fixed2OM')}</Tag>
|
||||
})}
|
||||
</>
|
||||
}
|
||||
},
|
||||
{ title: t('users.phone'), dataIndex: 'phone', key: 'phone', width: 110 },
|
||||
{ title: t('users.phone'), dataIndex: 'phonenumber', key: 'phonenumber', },
|
||||
{ title: t('users.email'), dataIndex: 'email', key: 'email', ellipsis: true },
|
||||
{
|
||||
title: t('roles.status'),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 70,
|
||||
render: (status) => (
|
||||
<Space size={4}>
|
||||
<div style={{ width: 6, height: 6, borderRadius: '50%', background: status === t('devices.online') ? '#52c41a' : '#bfbfbf' }} />
|
||||
<span style={{ fontSize: 10 }}>{status}</span>
|
||||
<span style={{ fontSize: 10 }}>{status == 1 ? "在线" : "离线"}</span>
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: t('roles.actions'), key: 'action', width: 60, render: () => <Button
|
||||
title: t('roles.actions'), key: 'action', render: () => <Button
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EyeOutlined />}
|
||||
@@ -413,12 +440,7 @@ const BasicSettings = () => {
|
||||
>{t('common.view')}</Button>, fixed: 'right'
|
||||
},
|
||||
]}
|
||||
dataSource={[
|
||||
{ name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsmart.com', status: t('devices.online') },
|
||||
]}
|
||||
dataSource={userList}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
|
||||
@@ -237,7 +237,7 @@ const zh = {
|
||||
|
||||
failedFixed2: '❌ 工单生成接口调用失败',
|
||||
solarPanel: "组件阵列",
|
||||
weatherStation: "气象站",
|
||||
WeatherStation: "气象站",
|
||||
environmentalSensor: "环境传感器",
|
||||
distributable: "可调度",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user