监控、工单报表清洗在线用户页面
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber,
|
||||
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty
|
||||
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
|
||||
AppstoreOutlined, SwapOutlined, VideoCameraOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { addDeviceModel } from '../../api/deviceAccess.ts';
|
||||
|
||||
const { Option } = Select;
|
||||
const { TabPane } = Tabs;
|
||||
@@ -40,24 +41,24 @@ const modelDetailList: Record<number, {
|
||||
}> = {
|
||||
10: {
|
||||
props: [
|
||||
{ id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false },
|
||||
{ id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false },
|
||||
{ id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null },
|
||||
{ id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null },
|
||||
],
|
||||
events: [{ id: 1, code: 'alarm_perimeter', name: '周界入侵告警' }],
|
||||
actions: [{ actionId: 'take_snapshot', actionName: '截图', params: {} }]
|
||||
},
|
||||
11: {
|
||||
props: [
|
||||
{ id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true },
|
||||
{ id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true },
|
||||
{ id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true, unit: '℃', required: true, defaultValue: null },
|
||||
{ id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null },
|
||||
],
|
||||
events: [{ id: 1, code: 'temp_over', name: '超温告警' }],
|
||||
actions: []
|
||||
},
|
||||
12: {
|
||||
props: [
|
||||
{ id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true },
|
||||
{ id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true },
|
||||
{ id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null },
|
||||
{ id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true, unit: 'V', required: true, defaultValue: null },
|
||||
],
|
||||
events: [{ id: 1, code: 'low_power', name: '低电量告警' }],
|
||||
actions: []
|
||||
@@ -101,12 +102,12 @@ export default function DeviceAccessPage() {
|
||||
const [itemType, setItemType] = useState<'props' | 'events' | 'actions'>('props');
|
||||
const [itemForm] = Form.useForm();
|
||||
|
||||
// 指令 + 参数 新增状态
|
||||
// 指令 + 参数 + 枚举
|
||||
const [actionModal, setActionModal] = useState(false);
|
||||
const [currentAction, setCurrentAction] = useState<any>(null);
|
||||
const [paramList, setParamList] = useState<any[]>([]);
|
||||
|
||||
// 字段映射(实时增删改查,实时保存)
|
||||
// 字段映射
|
||||
const [mappingList, setMappingList] = useState(mappingInitList);
|
||||
const [mappingModal, setMappingModal] = useState(false);
|
||||
const [mappingForm] = Form.useForm();
|
||||
@@ -133,35 +134,45 @@ export default function DeviceAccessPage() {
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 提交
|
||||
// ===================== 物模型提交(完全匹配你的JSON) =====================
|
||||
const handleSubmit = () => {
|
||||
form.validateFields().then(values => {
|
||||
if (modalType === 'model') {
|
||||
const submitData = {
|
||||
name: values.name,
|
||||
connectType: values.connectType,
|
||||
version: "1.0",
|
||||
version: '1.0',
|
||||
deviceType: values.deviceType,
|
||||
supportProperties: modelDetail.props.map(p => ({
|
||||
propertyKey: p.code,
|
||||
propertyName: p.name,
|
||||
dataType: p.type,
|
||||
unit: p.unit || "",
|
||||
required: true,
|
||||
defaultValue: null
|
||||
unit: p.unit || '',
|
||||
required: p.required ?? true,
|
||||
defaultValue: p.defaultValue ?? null,
|
||||
isAlarm: p.isAlarm ?? false
|
||||
})),
|
||||
supportActions: modelDetail.actions
|
||||
supportActions: modelDetail.actions.map(act => ({
|
||||
actionId: act.actionId,
|
||||
actionName: act.actionName,
|
||||
params: act.params || {}
|
||||
}))
|
||||
};
|
||||
console.log("最终提交物模型:", submitData);
|
||||
message.success("物模型保存成功");
|
||||
addDeviceModel(submitData).then(res => {
|
||||
if (res.code === 200) {
|
||||
message.success('物模型保存成功');
|
||||
}
|
||||
});
|
||||
console.log('✅ 最终提交物模型(完全匹配接口)', submitData);
|
||||
message.success('物模型保存成功');
|
||||
} else {
|
||||
message.success("保存成功");
|
||||
message.success('保存成功');
|
||||
}
|
||||
setVisible(false);
|
||||
});
|
||||
};
|
||||
|
||||
// 属性/事件 编辑
|
||||
// 属性编辑
|
||||
const openItemModal = (type: 'props' | 'events' | 'actions', record?: any) => {
|
||||
setItemType(type);
|
||||
itemForm.resetFields();
|
||||
@@ -181,7 +192,7 @@ export default function DeviceAccessPage() {
|
||||
setModelDetail({ ...modelDetail, [type]: list });
|
||||
};
|
||||
|
||||
// ===================== 字段映射:增删改 立即保存 =====================
|
||||
// 字段映射
|
||||
const openMappingModal = (record?: any) => {
|
||||
mappingForm.resetFields();
|
||||
if (record) mappingForm.setFieldsValue(record);
|
||||
@@ -211,7 +222,6 @@ export default function DeviceAccessPage() {
|
||||
message.success('字段映射删除成功');
|
||||
};
|
||||
|
||||
// 获取告警属性
|
||||
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
||||
|
||||
// 表格列
|
||||
@@ -243,7 +253,6 @@ export default function DeviceAccessPage() {
|
||||
|
||||
const modelColumns = [
|
||||
{ title: '模型名称', dataIndex: 'name' },
|
||||
{ title: '描述', dataIndex: 'desc' },
|
||||
{ title: '操作', render: r => <Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button> }
|
||||
];
|
||||
|
||||
@@ -261,7 +270,7 @@ export default function DeviceAccessPage() {
|
||||
{activeTab === 'product' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('product')}>新增产品</Button></Space><Table rowKey="id" columns={productColumns} dataSource={productList} /></Card>}
|
||||
{activeTab === 'model' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('model')}>新增物模型</Button></Space><Table rowKey="id" columns={modelColumns} dataSource={modelList} /></Card>}
|
||||
|
||||
<Modal open={visible} width={850} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose
|
||||
<Modal open={visible} width={900} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose
|
||||
title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}>
|
||||
<Form form={form} layout="vertical">
|
||||
{modalType === 'device' && (
|
||||
@@ -344,15 +353,28 @@ export default function DeviceAccessPage() {
|
||||
<Divider>属性列表</Divider>
|
||||
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openItemModal('props')} className="mb-2">新增属性</Button>
|
||||
<Table size="small" dataSource={modelDetail.props} pagination={false} columns={[
|
||||
{ title: '编码', dataIndex: 'code' }, { title: '名称', dataIndex: 'name' }, { title: '类型', dataIndex: 'type' },
|
||||
{ title: '编码', dataIndex: 'code' },
|
||||
{ title: '名称', dataIndex: 'name' },
|
||||
{ title: '类型', dataIndex: 'type' },
|
||||
{ title: '单位', dataIndex: 'unit' },
|
||||
{ title: '默认值', dataIndex: 'defaultValue' },
|
||||
{ title: '告警', render: r => <Switch checked={r.isAlarm} disabled size="small" /> },
|
||||
{ title: '操作', render: r => <Space><Button type="text" icon={<EditOutlined />} onClick={() => openItemModal('props', r)}>编辑</Button><Popconfirm onConfirm={() => deleteItem('props', r.id)}><Button type="text" danger icon={<DeleteOutlined />}>删除</Button></Popconfirm></Space> }
|
||||
{
|
||||
title: '操作', render: r => (
|
||||
<Space>
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => openItemModal('props', r)}>编辑</Button>
|
||||
<Popconfirm onConfirm={() => deleteItem('props', r.id)}>
|
||||
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
]} />
|
||||
|
||||
<Divider>指令列表</Divider>
|
||||
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => {
|
||||
setCurrentAction({ actionId: '', actionName: '', params: {} });
|
||||
setParamList([]);
|
||||
setParamList([{ paramKey: '', type: 'int', desc: '', defaultValue: '', enum: [] }]);
|
||||
setActionModal(true);
|
||||
}} className="mb-2">新增指令</Button>
|
||||
<Table size="small" dataSource={modelDetail.actions} pagination={false} columns={[
|
||||
@@ -388,16 +410,28 @@ export default function DeviceAccessPage() {
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal open={itemModal} width={520} zIndex={1001} destroyOnClose onCancel={() => setItemModal(false)} onOk={saveItem} title="编辑">
|
||||
{/* 属性弹窗:完整字段 */}
|
||||
<Modal open={itemModal} width={580} zIndex={1001} destroyOnClose onCancel={() => setItemModal(false)} onOk={saveItem} title="配置属性">
|
||||
<Form form={itemForm} layout="vertical">
|
||||
<Form.Item name="id" hidden><Input /></Form.Item>
|
||||
<Form.Item label="编码" name="code" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item label="名称" name="name" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
{itemType === 'props' && <><Form.Item label="数据类型" name="type"><Select><Option value="int">int</Option><Option value="float">float</Option><Option value="string">string</Option></Select></Form.Item><Form.Item label="作为告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item></>}
|
||||
<Form.Item label="属性编码" name="code" rules={[{ required: true }]}><Input placeholder="如 temperature" /></Form.Item>
|
||||
<Form.Item label="属性名称" name="name" rules={[{ required: true }]}><Input placeholder="如 温度" /></Form.Item>
|
||||
<Form.Item label="数据类型" name="type">
|
||||
<Select>
|
||||
<Option value="int">int</Option>
|
||||
<Option value="float">float</Option>
|
||||
<Option value="string">string</Option>
|
||||
<Option value="bool">bool</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="单位" name="unit"><Input placeholder="如 ℃、%、V" /></Form.Item>
|
||||
{/*<Form.Item label="是否必填" name="required" valuePropName="checked"><Switch /></Form.Item>*/}
|
||||
<Form.Item label="默认值" name="defaultValue"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item label="是否作为告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 指令 + 参数 弹窗 */}
|
||||
{/* 指令 + 参数 + 枚举 */}
|
||||
<Modal
|
||||
title="配置指令"
|
||||
open={actionModal}
|
||||
@@ -407,7 +441,8 @@ export default function DeviceAccessPage() {
|
||||
obj[item.paramKey] = {
|
||||
type: item.type,
|
||||
description: item.desc || '',
|
||||
default: item.defaultValue
|
||||
default: item.defaultValue,
|
||||
...(item.enum?.length ? { enum: item.enum } : {})
|
||||
};
|
||||
return obj;
|
||||
}, {});
|
||||
@@ -419,68 +454,69 @@ export default function DeviceAccessPage() {
|
||||
};
|
||||
|
||||
const exists = modelDetail.actions.some(x => x.actionId === currentAction.actionId);
|
||||
let newActions = [];
|
||||
if (exists) {
|
||||
newActions = modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x);
|
||||
} else {
|
||||
newActions = [...modelDetail.actions, action];
|
||||
}
|
||||
|
||||
setModelDetail({ ...modelDetail, actions: newActions });
|
||||
setModelDetail({
|
||||
...modelDetail,
|
||||
actions: exists
|
||||
? modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x)
|
||||
: [...modelDetail.actions, action]
|
||||
});
|
||||
setActionModal(false);
|
||||
message.success('保存成功');
|
||||
}}
|
||||
width={700}
|
||||
width={750}
|
||||
>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ marginBottom: 16, display: 'flex', gap: 8 }}>
|
||||
<Input
|
||||
placeholder="指令编码 如 restart"
|
||||
value={currentAction?.actionId}
|
||||
onChange={(e) => setCurrentAction({ ...currentAction, actionId: e.target.value })}
|
||||
style={{ width: '48%', marginRight: '4%' }}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
<Input
|
||||
placeholder="指令名称 如 重启设备"
|
||||
value={currentAction?.actionName}
|
||||
onChange={(e) => setCurrentAction({ ...currentAction, actionName: e.target.value })}
|
||||
style={{ width: '48%' }}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Divider>指令参数</Divider>
|
||||
<Divider>指令参数(支持枚举)</Divider>
|
||||
|
||||
{paramList.map((item, index) => (
|
||||
<div key={index} style={{ display: 'flex', gap: 8, marginBottom: 10, alignItems: 'center' }}>
|
||||
<Input placeholder="参数名" value={item.paramKey} onChange={(e) => {
|
||||
{/* 只保留 1 个参数,不支持新增多行 */}
|
||||
{paramList.length > 0 && (
|
||||
<div key={0} style={{ display: 'flex', gap: 8, marginBottom: 10, alignItems: 'center' }}>
|
||||
<Input placeholder="参数名" value={paramList[0].paramKey} onChange={(e) => {
|
||||
const arr = [...paramList];
|
||||
arr[index].paramKey = e.target.value;
|
||||
arr[0].paramKey = e.target.value;
|
||||
setParamList(arr);
|
||||
}} />
|
||||
<Select value={item.type} style={{ width: 100 }} onChange={(v) => {
|
||||
<Select value={paramList[0].type} style={{ width: 100 }} onChange={(v) => {
|
||||
const arr = [...paramList];
|
||||
arr[index].type = v;
|
||||
arr[0].type = v;
|
||||
setParamList(arr);
|
||||
}}>
|
||||
<Select.Option value="int">int</Select.Option>
|
||||
<Select.Option value="string">string</Select.Option>
|
||||
</Select>
|
||||
<Input placeholder="描述" value={item.desc} onChange={(e) => {
|
||||
<Input placeholder="描述" value={paramList[0].desc} onChange={(e) => {
|
||||
const arr = [...paramList];
|
||||
arr[index].desc = e.target.value;
|
||||
arr[0].desc = e.target.value;
|
||||
setParamList(arr);
|
||||
}} />
|
||||
<Input placeholder="默认值" value={item.defaultValue} onChange={(e) => {
|
||||
<Input placeholder="默认值" value={paramList[0].defaultValue} onChange={(e) => {
|
||||
const arr = [...paramList];
|
||||
arr[index].defaultValue = e.target.value;
|
||||
arr[0].defaultValue = e.target.value;
|
||||
setParamList(arr);
|
||||
}} />
|
||||
<Input placeholder="枚举,逗号分隔" value={paramList[0].enum?.join(',')} onChange={(e) => {
|
||||
const arr = [...paramList];
|
||||
arr[0].enum = e.target.value.split(',').map(s => s.trim());
|
||||
setParamList(arr);
|
||||
}} />
|
||||
<Button danger size="small" onClick={() => setParamList(paramList.filter((_, i) => i !== index))}>删</Button>
|
||||
</div>
|
||||
))}
|
||||
)}
|
||||
|
||||
|
||||
<Button size="small" type="dashed" block onClick={() => {
|
||||
setParamList([...paramList, { paramKey: '', type: 'int', desc: '', defaultValue: '' }])
|
||||
}}>+ 添加参数</Button>
|
||||
</Modal>
|
||||
|
||||
<Modal open={mappingModal} width={600} zIndex={1002} destroyOnClose onCancel={() => setMappingModal(false)} onOk={saveMapping} title="字段映射配置">
|
||||
|
||||
160
src/components/SystemSetting/OnlineUser.tsx
Normal file
160
src/components/SystemSetting/OnlineUser.tsx
Normal file
@@ -0,0 +1,160 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Input, Button, Table, message, Space, Tabs, Card
|
||||
} from 'antd';
|
||||
import { SearchOutlined, ReloadOutlined } from '@ant-design/icons';
|
||||
|
||||
const { Search } = Input;
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
// 模拟在线用户数据
|
||||
const mockOnlineUsers = [
|
||||
{
|
||||
id: 1,
|
||||
sessionId: 'c85c6fe7-2e70-47...',
|
||||
loginName: 'admin',
|
||||
dept: '研发部门',
|
||||
host: '127.0.0.1',
|
||||
location: '内网IP',
|
||||
os: 'Linux',
|
||||
browser: 'Firefox 136.0',
|
||||
loginTime: '2026-05-08 09:46:08'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
sessionId: '9f6c7d73-f684-4e...',
|
||||
loginName: 'admin',
|
||||
dept: '研发部门',
|
||||
host: '127.0.0.1',
|
||||
location: '内网IP',
|
||||
os: 'Windows >=10',
|
||||
browser: 'Edge 147',
|
||||
loginTime: '2026-05-08 10:11:27'
|
||||
}
|
||||
];
|
||||
|
||||
const OnlineUserPage = () => {
|
||||
const [activeTab, setActiveTab] = useState('onlineUser'); // 默认选中在线用户
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dataSource, setDataSource] = useState(mockOnlineUsers);
|
||||
const [searchParams, setSearchParams] = useState({
|
||||
loginAddress: '',
|
||||
userName: ''
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
setLoading(true);
|
||||
// 模拟接口请求
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
message.success('搜索完成');
|
||||
}, 500);
|
||||
};
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
setSearchParams({ loginAddress: '', userName: '' });
|
||||
setDataSource(mockOnlineUsers);
|
||||
message.info('已重置搜索条件');
|
||||
};
|
||||
|
||||
// 强退用户
|
||||
const handleForceLogout = (record) => {
|
||||
message.info(`已向会话 ${record.sessionId} 发送强退指令`);
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{ title: '序号', dataIndex: 'id', width: 60 },
|
||||
{ title: '会话编号', dataIndex: 'sessionId', ellipsis: true },
|
||||
{ title: '登录名称', dataIndex: 'loginName' },
|
||||
{ title: '所属部门', dataIndex: 'dept' },
|
||||
{ title: '主机', dataIndex: 'host' },
|
||||
{ title: '登录地点', dataIndex: 'location' },
|
||||
{ title: '操作系统', dataIndex: 'os' },
|
||||
{ title: '浏览器', dataIndex: 'browser' },
|
||||
{ title: '登录时间', dataIndex: 'loginTime' },
|
||||
{
|
||||
title: '操作', width: 100,
|
||||
render: (_, record) => (
|
||||
<Button type="link" onClick={() => handleForceLogout(record)} style={{ color: '#1890ff' }}>
|
||||
强退
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
{/* ====================== 顶部 Tabs ====================== */}
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
style={{ marginBottom: 20 }}
|
||||
>
|
||||
<TabPane tab="在线用户" key="onlineUser" />
|
||||
<TabPane tab="其他监控" key="other" />
|
||||
</Tabs>
|
||||
|
||||
{/* ====================== Tab 1:在线用户 ====================== */}
|
||||
{activeTab === 'onlineUser' && (
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
{/* 搜索栏 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 20 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span>登录地址</span>
|
||||
<Input
|
||||
placeholder="请输入登录地址"
|
||||
value={searchParams.loginAddress}
|
||||
onChange={(e) => setSearchParams({ ...searchParams, loginAddress: e.target.value })}
|
||||
style={{ width: 200 }}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span>用户名称</span>
|
||||
<Input
|
||||
placeholder="请输入用户名称"
|
||||
value={searchParams.userName}
|
||||
onChange={(e) => setSearchParams({ ...searchParams, userName: e.target.value })}
|
||||
style={{ width: 200 }}
|
||||
/>
|
||||
</div>
|
||||
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>
|
||||
搜索
|
||||
</Button>
|
||||
<Button icon={<ReloadOutlined />} onClick={handleReset}>
|
||||
重置
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 在线用户表格 */}
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={dataSource}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
total: 2,
|
||||
pageSize: 10,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total) => `共 ${total} 条`,
|
||||
showQuickJumper: true
|
||||
}}
|
||||
bordered={false}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */}
|
||||
{activeTab === 'other' && (
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
|
||||
<h2>其他监控内容</h2>
|
||||
<p>这里可以放服务状态、CPU监控、内存监控、接口监控等内容</p>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OnlineUserPage;
|
||||
@@ -23,7 +23,7 @@ export default function StationManage() {
|
||||
|
||||
// 组织列表
|
||||
const [orgList, setOrgList] = useState([]);
|
||||
// 🔥 新增:选中的组织ID(用于筛选)
|
||||
// 🔥 选中的组织ID(用于筛选)
|
||||
const [selectedOrgId, setSelectedOrgId] = useState<number | undefined>(undefined);
|
||||
|
||||
// 获取当前登录用户信息
|
||||
@@ -50,7 +50,7 @@ export default function StationManage() {
|
||||
total: 0
|
||||
});
|
||||
|
||||
// ====================== 获取组织列表(根据 userId 过滤) ======================
|
||||
// ====================== 获取组织列表 ======================
|
||||
const getOrgData = () => {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
@@ -64,14 +64,12 @@ export default function StationManage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 获取场站列表(分页 + 组织筛选) ======================
|
||||
// ====================== 获取场站列表 ======================
|
||||
const getStationData = () => {
|
||||
const params = {
|
||||
pageNum: pagination.pageNum,
|
||||
pageSize: pagination.pageSize,
|
||||
orgId: userInfo?.orgId,
|
||||
// 🔥 把选中的组织ID传进去
|
||||
filterOrgId: selectedOrgId,
|
||||
orgId: selectedOrgId, // 🔥 最终使用的筛选 orgId
|
||||
};
|
||||
getStationList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -93,26 +91,37 @@ export default function StationManage() {
|
||||
});
|
||||
};
|
||||
|
||||
// 🔥 组织筛选变化
|
||||
// 组织筛选变化
|
||||
const handleOrgChange = (value: number) => {
|
||||
setSelectedOrgId(value);
|
||||
setPagination({ ...pagination, pageNum: 1 }); // 筛选重置页码
|
||||
setPagination({ ...pagination, pageNum: 1 });
|
||||
};
|
||||
|
||||
// 🔥 重置筛选
|
||||
// 重置筛选
|
||||
const handleReset = () => {
|
||||
setSelectedOrgId(undefined);
|
||||
setPagination({ ...pagination, pageNum: 1 });
|
||||
};
|
||||
|
||||
// 初始化加载
|
||||
// ====================== 初始化加载 ======================
|
||||
useEffect(() => {
|
||||
getOrgData();
|
||||
}, []);
|
||||
|
||||
// 🔥 关键:如果 userInfo.orgId 存在,则默认选中
|
||||
useEffect(() => {
|
||||
if (userInfo?.orgId) {
|
||||
setSelectedOrgId(userInfo.orgId);
|
||||
}
|
||||
}, [userInfo]);
|
||||
|
||||
// 加载数据
|
||||
useEffect(() => {
|
||||
getStationData();
|
||||
getOrgData();
|
||||
}, [
|
||||
pagination.pageNum,
|
||||
pagination.pageSize,
|
||||
selectedOrgId // 🔥 监听筛选变化
|
||||
selectedOrgId
|
||||
]);
|
||||
|
||||
// ====================== 新增 / 编辑 场站 ======================
|
||||
@@ -247,28 +256,30 @@ export default function StationManage() {
|
||||
{contextHolder}
|
||||
|
||||
<Card title="场站管理" style={{ borderRadius: 8 }}>
|
||||
{/* 🔥 筛选栏 */}
|
||||
<div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
|
||||
<Select
|
||||
placeholder="请选择组织筛选"
|
||||
style={{ width: 220 }}
|
||||
value={selectedOrgId}
|
||||
onChange={handleOrgChange}
|
||||
allowClear
|
||||
>
|
||||
{orgList.map(item => (
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item.orgName}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
<Button onClick={handleReset}>重置</Button>
|
||||
|
||||
<div style={{ marginLeft: 'auto' }}>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增场站
|
||||
</Button>
|
||||
{/* 🔥 筛选栏:只有 userInfo 没有 orgId 时才显示 */}
|
||||
{!userInfo?.orgId && (
|
||||
<div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
|
||||
<Select
|
||||
placeholder="请选择组织筛选"
|
||||
style={{ width: 220 }}
|
||||
value={selectedOrgId}
|
||||
onChange={handleOrgChange}
|
||||
allowClear
|
||||
>
|
||||
{orgList.map(item => (
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item.orgName}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
<Button onClick={handleReset}>重置</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'end', marginBottom: 16 }}>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增场站
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
|
||||
@@ -2,7 +2,8 @@ import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Layout, Tabs, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message,
|
||||
Input, Popconfirm, Divider, InputNumber, Pagination, Table, Select,
|
||||
Tag, Checkbox, App
|
||||
Tag, Checkbox, App,
|
||||
Switch
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined, EditOutlined, DeleteOutlined, UserOutlined
|
||||
@@ -445,6 +446,12 @@ export default function UserRolePage() {
|
||||
? <Tag color="green">正常</Tag>
|
||||
: <Tag color="red">停用</Tag>
|
||||
},
|
||||
{
|
||||
title: '是否有设备权限', dataIndex: 'deviceOperatePerm', width: 80,
|
||||
render: (_, s) => s.deviceOperatePerm == true
|
||||
? <Tag color="green">有权限</Tag>
|
||||
: <Tag color="red">无权限</Tag>
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
@@ -719,7 +726,22 @@ export default function UserRolePage() {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
)}
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="deviceOperatePerm"
|
||||
label="设备操作权限"
|
||||
valuePropName="checked"
|
||||
initialValue={false}
|
||||
|
||||
>
|
||||
<Switch
|
||||
checkedChildren="有"
|
||||
unCheckedChildren="无"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user