用户角色概览
This commit is contained in:
@@ -59,6 +59,9 @@ import {
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { getRoleList } from '@/api/role';
|
import { getRoleList } from '@/api/role';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '@/src/store';
|
||||||
|
import { getUser } from '@/api/user';
|
||||||
|
|
||||||
const { Text, Title } = Typography;
|
const { Text, Title } = Typography;
|
||||||
|
|
||||||
@@ -66,6 +69,11 @@ const BasicSettings = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [roles, setRoles] = useState<any[]>([]);
|
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)';
|
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||||
@@ -136,7 +144,7 @@ const BasicSettings = () => {
|
|||||||
title: t('systemSetting.fixed2OM'),
|
title: t('systemSetting.fixed2OM'),
|
||||||
users: 5,
|
users: 5,
|
||||||
perms: 18,
|
perms: 18,
|
||||||
tags: ["处理工单","处理任务"],
|
tags: ["处理工单", "处理任务"],
|
||||||
color: '#52c41a',
|
color: '#52c41a',
|
||||||
bg: '#f6ffed',
|
bg: '#f6ffed',
|
||||||
icon: <Wrench size={20} color="#52c41a" />
|
icon: <Wrench size={20} color="#52c41a" />
|
||||||
@@ -156,7 +164,7 @@ const BasicSettings = () => {
|
|||||||
title: t('systemSetting.s322'),
|
title: t('systemSetting.s322'),
|
||||||
users: 3,
|
users: 3,
|
||||||
perms: 15,
|
perms: 15,
|
||||||
tags: ['管理自己场站', '报表查看','告警处理'],
|
tags: ['管理自己场站', '报表查看', '告警处理'],
|
||||||
color: '#722ed1',
|
color: '#722ed1',
|
||||||
bg: '#f9f0ff',
|
bg: '#f9f0ff',
|
||||||
icon: <LineChart size={20} color="#722ed1" />
|
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 = [
|
const deviceStatuses = [
|
||||||
{ name: t('home.inverter'), count: '5/5', status: t('roles.normal') },
|
{ name: t('home.inverter'), count: '5/5', status: t('roles.normal') },
|
||||||
@@ -197,6 +225,7 @@ const BasicSettings = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getRoleData();
|
getRoleData();
|
||||||
|
getUserData();
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
@@ -373,39 +402,37 @@ const BasicSettings = () => {
|
|||||||
|
|
||||||
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
|
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
|
||||||
columns={[
|
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'),
|
title: t('users.role'),
|
||||||
dataIndex: 'role',
|
dataIndex: 'role',
|
||||||
key: 'role',
|
key: 'role',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (role) => {
|
render: (_val, record) => {
|
||||||
const config: any = {
|
const roleList = record.roles || [];
|
||||||
'超级管理员': { color: '#1677ff', bg: '#e6f4ff' },
|
return <>
|
||||||
'运维工程师': { color: '#52c41a', bg: '#f6ffed' },
|
{roleList.map((rItem: any) => {
|
||||||
'巡检主管': { color: '#fa8c16', bg: '#fff7e6' },
|
//const conf = getRoleConfByKey(rItem.roleKey);
|
||||||
'数据分析师': { color: '#722ed1', bg: '#f9f0ff' },
|
return <Tag key={rItem.roleId}>{rItem.roleKey == "manager" ? t('systemSetting.fixed2Inspection2') : rItem.roleKey == "siteManager" ? t('systemSetting.s322') : t('systemSetting.fixed2OM')}</Tag>
|
||||||
};
|
})}
|
||||||
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>;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ 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('users.email'), dataIndex: 'email', key: 'email', ellipsis: true },
|
||||||
{
|
{
|
||||||
title: t('roles.status'),
|
title: t('roles.status'),
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
key: 'status',
|
key: 'status',
|
||||||
width: 70,
|
|
||||||
render: (status) => (
|
render: (status) => (
|
||||||
<Space size={4}>
|
<Space size={4}>
|
||||||
<div style={{ width: 6, height: 6, borderRadius: '50%', background: status === t('devices.online') ? '#52c41a' : '#bfbfbf' }} />
|
<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>
|
</Space>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('roles.actions'), key: 'action', width: 60, render: () => <Button
|
title: t('roles.actions'), key: 'action', render: () => <Button
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
icon={<EyeOutlined />}
|
icon={<EyeOutlined />}
|
||||||
@@ -413,12 +440,7 @@ const BasicSettings = () => {
|
|||||||
>{t('common.view')}</Button>, fixed: 'right'
|
>{t('common.view')}</Button>, fixed: 'right'
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
dataSource={[
|
dataSource={userList}
|
||||||
{ 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') },
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
</AntdCard>
|
</AntdCard>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ const zh = {
|
|||||||
|
|
||||||
failedFixed2: '❌ 工单生成接口调用失败',
|
failedFixed2: '❌ 工单生成接口调用失败',
|
||||||
solarPanel: "组件阵列",
|
solarPanel: "组件阵列",
|
||||||
weatherStation: "气象站",
|
WeatherStation: "气象站",
|
||||||
environmentalSensor: "环境传感器",
|
environmentalSensor: "环境传感器",
|
||||||
distributable: "可调度",
|
distributable: "可调度",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user