设备接入 和视频监测
This commit is contained in:
@@ -12,7 +12,7 @@ export function addDeviceModel(data) {
|
|||||||
//物模型列表export function addDeviceModel(data) {
|
//物模型列表export function addDeviceModel(data) {
|
||||||
export function getDeviceModelList(params) {
|
export function getDeviceModelList(params) {
|
||||||
return request({
|
return request({
|
||||||
url: ' /iot/deviceModel/list',
|
url: '/system/devicemodel/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params
|
params
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber,
|
Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber,
|
||||||
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox
|
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
|
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
|
||||||
AppstoreOutlined, SwapOutlined, VideoCameraOutlined
|
AppstoreOutlined, SwapOutlined, VideoCameraOutlined
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { addDeviceModel } from '../../api/deviceAccess.ts';
|
import { addDeviceModel, getDeviceModelList } from '../../api/deviceAccess.ts';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const { TabPane } = Tabs;
|
const { TabPane } = Tabs;
|
||||||
@@ -20,18 +20,18 @@ const productList = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2, name: '大华摄像头', code: 'dahua', protocolType: 'rtsp', manufacturer: '大华',
|
id: 2, name: '大华摄像头', code: 'dahua', protocolType: 'rtsp', manufacturer: '大华',
|
||||||
publishTopic: '/dahua/device/upload', subscribeTopic: '/dahua/device/cmd'
|
publishTopic: '/dahua/upload', subscribeTopic: '/dahua/cmd'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3, name: '通用MQTT设备', code: 'mqtt_device', protocolType: 'mqtt', manufacturer: '通用',
|
id: 3, name: '通用MQTT设备', code: 'mqtt_device', protocolType: 'mqtt', manufacturer: '通用',
|
||||||
publishTopic: '/iot/device/upload', subscribeTopic: '/iot/device/cmd'
|
publishTopic: '/iot/upload', subscribeTopic: '/iot/cmd'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const modelList = [
|
const modelList = [
|
||||||
{ id: 10, name: '通用视频监控设备', code: 'video_camera', desc: '摄像头、云台、告警' },
|
{ id: 10, name: '通用视频监控设备', code: 'video_camera', desc: '摄像头、云台、告警', connectType: 'MQTT' },
|
||||||
{ id: 11, name: '环境监测设备', code: 'env_sensor', desc: '温湿度、烟感' },
|
{ id: 11, name: '环境监测设备', code: 'env_sensor', desc: '温湿度、烟感', connectType: 'MQTT' },
|
||||||
{ id: 12, name: '电池供电设备', code: 'battery_device', desc: '电量、电压监测' },
|
{ id: 12, name: '电池供电设备', code: 'battery_device', desc: '电量、电压监测', connectType: 'HTTP' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const modelDetailList: Record<number, {
|
const modelDetailList: Record<number, {
|
||||||
@@ -112,6 +112,17 @@ export default function DeviceAccessPage() {
|
|||||||
const [mappingModal, setMappingModal] = useState(false);
|
const [mappingModal, setMappingModal] = useState(false);
|
||||||
const [mappingForm] = Form.useForm();
|
const [mappingForm] = Form.useForm();
|
||||||
|
|
||||||
|
// 筛选条件
|
||||||
|
const [filterForm] = Form.useForm();
|
||||||
|
const [filteredModelList, setFilteredModelList] = useState(modelList);
|
||||||
|
|
||||||
|
// ========== 物模型分页(只加这里) ==========
|
||||||
|
const [pagination, setPagination] = useState({
|
||||||
|
current: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: modelList.length,
|
||||||
|
});
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openModal = (type: string, record?: any) => {
|
const openModal = (type: string, record?: any) => {
|
||||||
setModalType(type);
|
setModalType(type);
|
||||||
@@ -134,7 +145,44 @@ export default function DeviceAccessPage() {
|
|||||||
setVisible(true);
|
setVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===================== 物模型提交(完全匹配你的JSON) =====================
|
// 获取物模型列表(带分页 + 筛选)
|
||||||
|
const getModel = () => {
|
||||||
|
const values = filterForm.getFieldsValue();
|
||||||
|
const params = {
|
||||||
|
pageNum: pagination.current,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
name: values.name || '',
|
||||||
|
connectType: values.connectType || '',
|
||||||
|
};
|
||||||
|
getDeviceModelList(params).then(res => {
|
||||||
|
// 接口返回格式自行替换:res.list / res.total
|
||||||
|
if (res.code === 200) {
|
||||||
|
// setFilteredModelList(res.data.list);
|
||||||
|
// setPagination(prev => ({ ...prev, total: res.data.total }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 筛选
|
||||||
|
const handleFilter = () => {
|
||||||
|
setPagination(prev => ({ ...prev, current: 1 }));
|
||||||
|
setTimeout(() => getModel(), 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const handleReset = () => {
|
||||||
|
filterForm.resetFields();
|
||||||
|
setPagination(prev => ({ ...prev, current: 1 }));
|
||||||
|
setTimeout(() => getModel(), 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 分页切换
|
||||||
|
const handleTableChange = (pag) => {
|
||||||
|
setPagination(pag);
|
||||||
|
getModel();
|
||||||
|
};
|
||||||
|
|
||||||
|
// ===================== 物模型提交 =====================
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
form.validateFields().then(values => {
|
form.validateFields().then(values => {
|
||||||
if (modalType === 'model') {
|
if (modalType === 'model') {
|
||||||
@@ -161,12 +209,10 @@ export default function DeviceAccessPage() {
|
|||||||
addDeviceModel(submitData).then(res => {
|
addDeviceModel(submitData).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('物模型保存成功');
|
message.success('物模型保存成功');
|
||||||
|
getModel(); // 保存后刷新列表
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('✅ 最终提交物模型(完全匹配接口)', submitData);
|
console.log('✅ 提交物模型', submitData);
|
||||||
message.success('物模型保存成功');
|
|
||||||
} else {
|
|
||||||
message.success('保存成功');
|
|
||||||
}
|
}
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
});
|
});
|
||||||
@@ -205,25 +251,29 @@ export default function DeviceAccessPage() {
|
|||||||
if (val.id) {
|
if (val.id) {
|
||||||
const index = newList.findIndex(x => x.id === val.id);
|
const index = newList.findIndex(x => x.id === val.id);
|
||||||
if (index >= 0) newList[index] = val;
|
if (index >= 0) newList[index] = val;
|
||||||
message.success('字段映射修改成功');
|
message.success('修改成功');
|
||||||
} else {
|
} else {
|
||||||
newList.push({ ...val, id: Date.now() });
|
newList.push({ ...val, id: Date.now() });
|
||||||
message.success('字段映射新增成功');
|
message.success('新增成功');
|
||||||
}
|
}
|
||||||
setMappingList(newList);
|
setMappingList(newList);
|
||||||
mappingInitList = newList;
|
|
||||||
setMappingModal(false);
|
setMappingModal(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const deleteMapping = (id: number) => {
|
const deleteMapping = (id: number) => {
|
||||||
const newList = mappingList.filter(x => x.id !== id);
|
const newList = mappingList.filter(x => x.id !== id);
|
||||||
setMappingList(newList);
|
setMappingList(newList);
|
||||||
mappingInitList = newList;
|
message.success('删除成功');
|
||||||
message.success('字段映射删除成功');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeTab === 'model') {
|
||||||
|
getModel();
|
||||||
|
}
|
||||||
|
}, [ pagination.pageSize, activeTab]);
|
||||||
|
|
||||||
// 表格列
|
// 表格列
|
||||||
const deviceColumns = [
|
const deviceColumns = [
|
||||||
{ title: '设备名称', dataIndex: 'name' },
|
{ title: '设备名称', dataIndex: 'name' },
|
||||||
@@ -253,6 +303,7 @@ export default function DeviceAccessPage() {
|
|||||||
|
|
||||||
const modelColumns = [
|
const modelColumns = [
|
||||||
{ title: '模型名称', dataIndex: 'name' },
|
{ title: '模型名称', dataIndex: 'name' },
|
||||||
|
{ title: '连接协议', dataIndex: 'connectType' },
|
||||||
{ title: '操作', render: r => <Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button> }
|
{ title: '操作', render: r => <Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button> }
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -268,7 +319,40 @@ export default function DeviceAccessPage() {
|
|||||||
|
|
||||||
{activeTab === 'device' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('device')}>新增设备</Button></Space><Table rowKey="id" columns={deviceColumns} dataSource={deviceList} /></Card>}
|
{activeTab === 'device' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('device')}>新增设备</Button></Space><Table rowKey="id" columns={deviceColumns} dataSource={deviceList} /></Card>}
|
||||||
{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 === '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>}
|
|
||||||
|
{/* 物模型 + 筛选 + 分页 */}
|
||||||
|
{activeTab === 'model' && (
|
||||||
|
<Card>
|
||||||
|
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||||
|
<Form form={filterForm} layout="inline">
|
||||||
|
<Form.Item name="name" label="模型名称">
|
||||||
|
<Input placeholder="名称" allowClear />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="connectType" label="连接协议">
|
||||||
|
<Select placeholder="协议" allowClear style={{ width: 160 }}>
|
||||||
|
<Option value="MQTT">MQTT</Option>
|
||||||
|
<Option value="HTTP">HTTP</Option>
|
||||||
|
<Option value="RTSP">RTSP</Option>
|
||||||
|
<Option value="ONVIF">ONVIF</Option>
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item>
|
||||||
|
<Button type="primary" onClick={handleFilter}>查询</Button>
|
||||||
|
<Button onClick={handleReset}>重置</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
<Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('model')}>新增物模型</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
columns={modelColumns}
|
||||||
|
dataSource={filteredModelList}
|
||||||
|
pagination={pagination}
|
||||||
|
onChange={handleTableChange}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
<Modal open={visible} width={900} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose
|
<Modal open={visible} width={900} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose
|
||||||
title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}>
|
title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}>
|
||||||
@@ -284,19 +368,43 @@ export default function DeviceAccessPage() {
|
|||||||
<TabPane tab="协议配置" key="protocol">
|
<TabPane tab="协议配置" key="protocol">
|
||||||
<Form.Item label="设备协议类型" name="protocolType" rules={[{ required: true }]}>
|
<Form.Item label="设备协议类型" name="protocolType" rules={[{ required: true }]}>
|
||||||
<Select value={deviceProtocol} onChange={setDeviceProtocol}>
|
<Select value={deviceProtocol} onChange={setDeviceProtocol}>
|
||||||
<Option value="onvif">ONVIF 协议</Option>
|
<Option value="onvif">ONVIF</Option>
|
||||||
<Option value="rtsp">RTSP 视频流</Option>
|
<Option value="rtsp">RTSP</Option>
|
||||||
<Option value="mqtt">MQTT 物联网协议</Option>
|
<Option value="mqtt">MQTT</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Divider />
|
<Divider />
|
||||||
{deviceProtocol === 'onvif' && <><Form.Item label="设备IP地址" name="ip"><Input /></Form.Item><Form.Item label="访问端口" name="port"><InputNumber className="w-full" /></Form.Item><Form.Item label="登录账号" name="username"><Input /></Form.Item><Form.Item label="登录密码" name="password"><Input.Password /></Form.Item></>}
|
{deviceProtocol === 'onvif' && (
|
||||||
{deviceProtocol === 'rtsp' && <Form.Item label="RTSP 完整流地址" name="rtspUrl"><Input /></Form.Item>}
|
<>
|
||||||
{deviceProtocol === 'mqtt' && <><Form.Item label="MQTT 服务地址" name="mqttServer"><Input /></Form.Item><Form.Item label="MQTT 端口" name="mqttPort"><InputNumber defaultValue={1883} /></Form.Item><Form.Item label="设备 ClientID" name="clientId"><Input /></Form.Item><Form.Item label="MQTT 用户名" name="mqttUsername"><Input /></Form.Item><Form.Item label="MQTT 密码" name="mqttPassword"><Input.Password /></Form.Item></>}
|
<Form.Item label="IP" name="ip"><Input /></Form.Item>
|
||||||
|
<Form.Item label="端口" name="port"><InputNumber className="w-full" /></Form.Item>
|
||||||
|
<Form.Item label="账号" name="username"><Input /></Form.Item>
|
||||||
|
<Form.Item label="密码" name="password"><Input.Password /></Form.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{deviceProtocol === 'rtsp' && <Form.Item label="RTSP地址" name="rtspUrl"><Input /></Form.Item>}
|
||||||
|
{deviceProtocol === 'mqtt' && (
|
||||||
|
<>
|
||||||
|
<Form.Item label="MQTT服务地址" name="mqttServer"><Input /></Form.Item>
|
||||||
|
<Form.Item label="端口" name="mqttPort"><InputNumber defaultValue={1883} /></Form.Item>
|
||||||
|
<Form.Item label="ClientID" name="clientId"><Input /></Form.Item>
|
||||||
|
<Form.Item label="用户名" name="mqttUsername"><Input /></Form.Item>
|
||||||
|
<Form.Item label="密码" name="mqttPassword"><Input.Password /></Form.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="报警阈值" key="alarm">
|
<TabPane tab="报警阈值" key="alarm">
|
||||||
{getAlarmProps().map(item => <div key={item.code}><Form.Item label={`${item.name} 上限`} name={['alarmConfig', `${item.code}Max`]}><InputNumber className="w-full" /></Form.Item><Form.Item label={`${item.name} 下限`} name={['alarmConfig', `${item.code}Min`]}><InputNumber className="w-full" /></Form.Item></div>)}
|
{getAlarmProps().map(item => (
|
||||||
{getAlarmProps().length === 0 && <Empty description="当前物模型无配置告警参数" />}
|
<div key={item.code} className="flex gap-2">
|
||||||
|
<Form.Item label={`${item.name}上限`} name={['alarmConfig', `${item.code}Max`]} style={{ flex: 1 }}>
|
||||||
|
<InputNumber className="w-full" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label={`${item.name}下限`} name={['alarmConfig', `${item.code}Min`]} style={{ flex: 1 }}>
|
||||||
|
<InputNumber className="w-full" />
|
||||||
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{getAlarmProps().length === 0 && <Empty description="无告警参数" />}
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
)}
|
)}
|
||||||
@@ -305,22 +413,28 @@ export default function DeviceAccessPage() {
|
|||||||
<Tabs defaultActiveKey="base">
|
<Tabs defaultActiveKey="base">
|
||||||
<TabPane tab="基础信息" key="base">
|
<TabPane tab="基础信息" key="base">
|
||||||
<Form.Item label="产品名称" name="name" rules={[{ required: true }]}><Input /></Form.Item>
|
<Form.Item label="产品名称" name="name" rules={[{ required: true }]}><Input /></Form.Item>
|
||||||
<Form.Item label="厂商名称" name="manufacturer"><Input /></Form.Item>
|
<Form.Item label="厂商" name="manufacturer"><Input /></Form.Item>
|
||||||
<Form.Item label="默认协议类型" name="protocolType"><Select value={productProtocol} onChange={setProductProtocol}><Option value="onvif">ONVIF</Option><Option value="rtsp">RTSP</Option><Option value="mqtt">MQTT</Option></Select></Form.Item>
|
<Form.Item label="协议" name="protocolType"><Select value={productProtocol} onChange={setProductProtocol}><Option value="onvif">ONVIF</Option><Option value="rtsp">RTSP</Option><Option value="mqtt">MQTT</Option></Select></Form.Item>
|
||||||
{productProtocol === 'mqtt' && <><Divider>MQTT 厂商级 Topic 配置</Divider><Form.Item label="设备上报 Topic" name="publishTopic"><Input /></Form.Item><Form.Item label="平台下发 Topic" name="subscribeTopic"><Input /></Form.Item></>}
|
{productProtocol === 'mqtt' && (
|
||||||
|
<>
|
||||||
|
<Divider>MQTT Topic</Divider>
|
||||||
|
<Form.Item label="上报Topic" name="publishTopic"><Input /></Form.Item>
|
||||||
|
<Form.Item label="订阅Topic" name="subscribeTopic"><Input /></Form.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="字段映射" key="mapping">
|
<TabPane tab="字段映射" key="mapping">
|
||||||
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openMappingModal()} className="mb-2">新增映射</Button>
|
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openMappingModal()} className="mb-2">新增</Button>
|
||||||
<Table size="small" dataSource={mappingList.filter(x => x.productId === editData?.id)} pagination={false}
|
<Table size="small" dataSource={mappingList.filter(x => x.productId === editData?.id)} pagination={false}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '标准字段', dataIndex: 'standardCode' },
|
{ title: '标准字段', dataIndex: 'standardCode' },
|
||||||
{ title: '厂商原始字段', dataIndex: 'sourceField' },
|
{ title: '厂商字段', dataIndex: 'sourceField' },
|
||||||
{ title: '转换规则', dataIndex: 'convertRule' },
|
{ title: '转换规则', dataIndex: 'convertRule' },
|
||||||
{
|
{
|
||||||
title: '操作', render: r => (
|
title: '操作', render: r => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button type="text" icon={<EditOutlined />} onClick={() => openMappingModal(r)}>编辑</Button>
|
<Button type="text" onClick={() => openMappingModal(r)}>编辑</Button>
|
||||||
<Popconfirm onConfirm={() => deleteMapping(r.id)} title="确定删除?"><Button type="text" danger icon={<DeleteOutlined />}>删除</Button></Popconfirm>
|
<Popconfirm onConfirm={() => deleteMapping(r.id)}><Button type="text" danger>删除</Button></Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -332,26 +446,20 @@ export default function DeviceAccessPage() {
|
|||||||
|
|
||||||
{modalType === 'model' && (
|
{modalType === 'model' && (
|
||||||
<>
|
<>
|
||||||
<div style={{ display: "flex", gap: 16, marginBottom: 16 }}>
|
<div className="flex gap-4 mb-4">
|
||||||
<div style={{ flex: 1 }}>
|
<div className="flex-1">
|
||||||
<Form.Item label="模型名称" name="name" rules={[{ required: true }]}>
|
<Form.Item label="模型名称" name="name" rules={[{ required: true }]}><Input /></Form.Item>
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: 1 }}>
|
<div className="flex-1">
|
||||||
<Form.Item label="连接协议" name="connectType" initialValue="MQTT">
|
<Form.Item label="连接协议" name="connectType" initialValue="MQTT"><Input /></Form.Item>
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: 1 }}>
|
<div className="flex-1">
|
||||||
<Form.Item label="设备类型" name="deviceType" initialValue={1}>
|
<Form.Item label="设备类型" name="deviceType" initialValue={1}><InputNumber style={{ width: '100%' }} /></Form.Item>
|
||||||
<InputNumber style={{ width: "100%" }} />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider>属性列表</Divider>
|
<Divider>属性</Divider>
|
||||||
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openItemModal('props')} className="mb-2">新增属性</Button>
|
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openItemModal('props')} className="mb-2">新增</Button>
|
||||||
<Table size="small" dataSource={modelDetail.props} pagination={false} columns={[
|
<Table size="small" dataSource={modelDetail.props} pagination={false} columns={[
|
||||||
{ title: '编码', dataIndex: 'code' },
|
{ title: '编码', dataIndex: 'code' },
|
||||||
{ title: '名称', dataIndex: 'name' },
|
{ title: '名称', dataIndex: 'name' },
|
||||||
@@ -362,43 +470,34 @@ export default function DeviceAccessPage() {
|
|||||||
{
|
{
|
||||||
title: '操作', render: r => (
|
title: '操作', render: r => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button type="text" icon={<EditOutlined />} onClick={() => openItemModal('props', r)}>编辑</Button>
|
<Button type="text" onClick={() => openItemModal('props', r)}>编辑</Button>
|
||||||
<Popconfirm onConfirm={() => deleteItem('props', r.id)}>
|
<Popconfirm onConfirm={() => deleteItem('props', r.id)}><Button type="text" danger>删除</Button></Popconfirm>
|
||||||
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
</Space>
|
</Space>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
<Divider>指令列表</Divider>
|
<Divider>指令</Divider>
|
||||||
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => {
|
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => {
|
||||||
setCurrentAction({ actionId: '', actionName: '', params: {} });
|
setCurrentAction({ actionId: '', actionName: '', params: {} });
|
||||||
setParamList([{ paramKey: '', type: 'int', desc: '', defaultValue: '', enum: [] }]);
|
setParamList([{ paramKey: '', type: 'int', desc: '', defaultValue: '', enum: [] }]);
|
||||||
setActionModal(true);
|
setActionModal(true);
|
||||||
}} className="mb-2">新增指令</Button>
|
}} className="mb-2">新增</Button>
|
||||||
<Table size="small" dataSource={modelDetail.actions} pagination={false} columns={[
|
<Table size="small" dataSource={modelDetail.actions} pagination={false} columns={[
|
||||||
{ title: '指令编码', dataIndex: 'actionId' },
|
{ title: '指令编码', dataIndex: 'actionId' },
|
||||||
{ title: '指令名称', dataIndex: 'actionName' },
|
{ title: '指令名称', dataIndex: 'actionName' },
|
||||||
{ title: '参数', render: r => Object.keys(r.params || {}).join(',') || '无' },
|
{ title: '参数', render: r => Object.keys(r.params || []).join(',') || '无' },
|
||||||
{
|
{
|
||||||
title: '操作', render: r => (
|
title: '操作', render: r => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button type="text" onClick={() => {
|
<Button type="text" onClick={() => {
|
||||||
setCurrentAction(r);
|
setCurrentAction(r);
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let k in r.params) {
|
for (let k in r.params) arr.push({ paramKey: k, ...r.params[k] });
|
||||||
arr.push({ paramKey: k, ...r.params[k] });
|
|
||||||
}
|
|
||||||
setParamList(arr);
|
setParamList(arr);
|
||||||
setActionModal(true);
|
setActionModal(true);
|
||||||
}}>编辑</Button>
|
}}>编辑</Button>
|
||||||
<Popconfirm onConfirm={() => {
|
<Popconfirm onConfirm={() => setModelDetail({ ...modelDetail, actions: modelDetail.actions.filter(x => x.actionId !== r.actionId) })}>
|
||||||
setModelDetail({
|
|
||||||
...modelDetail,
|
|
||||||
actions: modelDetail.actions.filter(x => x.actionId !== r.actionId)
|
|
||||||
})
|
|
||||||
}}>
|
|
||||||
<Button type="text" danger>删除</Button>
|
<Button type="text" danger>删除</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
@@ -410,13 +509,13 @@ export default function DeviceAccessPage() {
|
|||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
{/* 属性弹窗:完整字段 */}
|
{/* 属性弹窗 */}
|
||||||
<Modal open={itemModal} width={580} 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 form={itemForm} layout="vertical">
|
||||||
<Form.Item name="id" hidden><Input /></Form.Item>
|
<Form.Item name="id" hidden><Input /></Form.Item>
|
||||||
<Form.Item label="属性编码" name="code" rules={[{ required: true }]}><Input placeholder="如 temperature" /></Form.Item>
|
<Form.Item label="属性编码" name="code" rules={[{ required: true }]}><Input placeholder="如 temp" /></Form.Item>
|
||||||
<Form.Item label="属性名称" name="name" rules={[{ required: true }]}><Input placeholder="如 温度" /></Form.Item>
|
<Form.Item label="属性名称" name="name" rules={[{ required: true }]}><Input placeholder="如 温度" /></Form.Item>
|
||||||
<Form.Item label="数据类型" name="type">
|
<Form.Item label="类型" name="type">
|
||||||
<Select>
|
<Select>
|
||||||
<Option value="int">int</Option>
|
<Option value="int">int</Option>
|
||||||
<Option value="float">float</Option>
|
<Option value="float">float</Option>
|
||||||
@@ -424,105 +523,51 @@ export default function DeviceAccessPage() {
|
|||||||
<Option value="bool">bool</Option>
|
<Option value="bool">bool</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="单位" name="unit"><Input placeholder="如 ℃、%、V" /></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 /></Form.Item>
|
||||||
<Form.Item label="默认值" name="defaultValue"><Input placeholder="选填" /></Form.Item>
|
<Form.Item label="告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item>
|
||||||
<Form.Item label="是否作为告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item>
|
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
{/* 指令 + 参数 + 枚举 */}
|
{/* 指令弹窗 */}
|
||||||
<Modal
|
<Modal title="配置指令" open={actionModal} zIndex={1002} onCancel={() => setActionModal(false)}
|
||||||
title="配置指令"
|
|
||||||
open={actionModal}
|
|
||||||
onCancel={() => setActionModal(false)}
|
|
||||||
onOk={() => {
|
onOk={() => {
|
||||||
const params = paramList.reduce((obj, item) => {
|
const params = paramList.reduce((obj, item) => {
|
||||||
obj[item.paramKey] = {
|
obj[item.paramKey] = { type: item.type, description: item.desc, default: item.defaultValue, ...(item.enum?.length && { enum: item.enum }) };
|
||||||
type: item.type,
|
|
||||||
description: item.desc || '',
|
|
||||||
default: item.defaultValue,
|
|
||||||
...(item.enum?.length ? { enum: item.enum } : {})
|
|
||||||
};
|
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
const action = { actionId: currentAction.actionId, actionName: currentAction.actionName, params };
|
||||||
const action = {
|
|
||||||
actionId: currentAction.actionId,
|
|
||||||
actionName: currentAction.actionName,
|
|
||||||
params
|
|
||||||
};
|
|
||||||
|
|
||||||
const exists = modelDetail.actions.some(x => x.actionId === currentAction.actionId);
|
const exists = modelDetail.actions.some(x => x.actionId === currentAction.actionId);
|
||||||
setModelDetail({
|
setModelDetail({
|
||||||
...modelDetail,
|
...modelDetail,
|
||||||
actions: exists
|
actions: exists ? modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x) : [...modelDetail.actions, action]
|
||||||
? modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x)
|
|
||||||
: [...modelDetail.actions, action]
|
|
||||||
});
|
});
|
||||||
setActionModal(false);
|
setActionModal(false);
|
||||||
message.success('保存成功');
|
|
||||||
}}
|
}}
|
||||||
width={750}
|
width={750}>
|
||||||
>
|
<div className="flex gap-2 mb-4">
|
||||||
<div style={{ marginBottom: 16, display: 'flex', gap: 8 }}>
|
<Input placeholder="指令编码" value={currentAction?.actionId} onChange={e => setCurrentAction({ ...currentAction, actionId: e.target.value })} style={{ flex: 1 }} />
|
||||||
<Input
|
<Input placeholder="指令名称" value={currentAction?.actionName} onChange={e => setCurrentAction({ ...currentAction, actionName: e.target.value })} style={{ flex: 1 }} />
|
||||||
placeholder="指令编码 如 restart"
|
|
||||||
value={currentAction?.actionId}
|
|
||||||
onChange={(e) => setCurrentAction({ ...currentAction, actionId: e.target.value })}
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
placeholder="指令名称 如 重启设备"
|
|
||||||
value={currentAction?.actionName}
|
|
||||||
onChange={(e) => setCurrentAction({ ...currentAction, actionName: e.target.value })}
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<Divider>指令参数</Divider>
|
||||||
<Divider>指令参数(支持枚举)</Divider>
|
{paramList[0] && (
|
||||||
|
<div className="flex gap-2 items-center">
|
||||||
{/* 只保留 1 个参数,不支持新增多行 */}
|
<Input placeholder="参数名" value={paramList[0].paramKey} onChange={e => setParamList([{ ...paramList[0], paramKey: e.target.value }])} />
|
||||||
{paramList.length > 0 && (
|
<Select value={paramList[0].type} style={{ width: 100 }} onChange={v => setParamList([{ ...paramList[0], type: v }])}>
|
||||||
<div key={0} style={{ display: 'flex', gap: 8, marginBottom: 10, alignItems: 'center' }}>
|
<Option value="int">int</Option><Option value="string">string</Option>
|
||||||
<Input placeholder="参数名" value={paramList[0].paramKey} onChange={(e) => {
|
|
||||||
const arr = [...paramList];
|
|
||||||
arr[0].paramKey = e.target.value;
|
|
||||||
setParamList(arr);
|
|
||||||
}} />
|
|
||||||
<Select value={paramList[0].type} style={{ width: 100 }} onChange={(v) => {
|
|
||||||
const arr = [...paramList];
|
|
||||||
arr[0].type = v;
|
|
||||||
setParamList(arr);
|
|
||||||
}}>
|
|
||||||
<Select.Option value="int">int</Select.Option>
|
|
||||||
<Select.Option value="string">string</Select.Option>
|
|
||||||
</Select>
|
</Select>
|
||||||
<Input placeholder="描述" value={paramList[0].desc} onChange={(e) => {
|
<Input placeholder="描述" value={paramList[0].desc} onChange={e => setParamList([{ ...paramList[0], desc: e.target.value }])} />
|
||||||
const arr = [...paramList];
|
<Input placeholder="默认值" value={paramList[0].defaultValue} onChange={e => setParamList([{ ...paramList[0], defaultValue: e.target.value }])} />
|
||||||
arr[0].desc = e.target.value;
|
<Input placeholder="枚举(,分隔)" value={paramList[0].enum?.join(',')} onChange={e => setParamList([{ ...paramList[0], enum: e.target.value.split(',').map(s => s.trim()) }])} />
|
||||||
setParamList(arr);
|
|
||||||
}} />
|
|
||||||
<Input placeholder="默认值" value={paramList[0].defaultValue} onChange={(e) => {
|
|
||||||
const arr = [...paramList];
|
|
||||||
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);
|
|
||||||
}} />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal open={mappingModal} width={600} zIndex={1002} destroyOnClose onCancel={() => setMappingModal(false)} onOk={saveMapping} title="字段映射配置">
|
{/* 字段映射 */}
|
||||||
|
<Modal open={mappingModal} width={600} zIndex={1002} destroyOnClose onCancel={() => setMappingModal(false)} onOk={saveMapping} title="字段映射">
|
||||||
<Form form={mappingForm} layout="vertical">
|
<Form form={mappingForm} layout="vertical">
|
||||||
<Form.Item name="id" hidden /><Form.Item name="productId" hidden />
|
<Form.Item name="id" hidden /><Form.Item name="productId" hidden />
|
||||||
<Form.Item label="标准模型字段" name="standardCode" rules={[{ required: true }]}>
|
<Form.Item label="标准字段" name="standardCode" rules={[{ required: true }]}>
|
||||||
<Select>{modelDetail.props?.map(p => <Option key={p.code} value={p.code}>{p.name}</Option>)}</Select>
|
<Select>{modelDetail.props?.map(p => <Option key={p.code} value={p.code}>{p.name}</Option>)}</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="厂商原始字段" name="sourceField" rules={[{ required: true }]}><Input /></Form.Item>
|
<Form.Item label="厂商原始字段" name="sourceField" rules={[{ required: true }]}><Input /></Form.Item>
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ export default function VideoMonitorPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 bg-[#f5f7fa] min-h-screen">
|
<div className="p-6 bg-[#f5f7fa] min-h-screen">
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<Typography.Title level={4} style={{ margin: 0 }}>视频监控</Typography.Title>
|
||||||
|
<p style={{ color: '#666', margin: '4px 0 0' }}>实时视频监控、云台控制、录像回放与智能告警一体化管理</p>
|
||||||
|
</div>
|
||||||
{/* ========== 顶部统计卡片:统一高度 ========== */}
|
{/* ========== 顶部统计卡片:统一高度 ========== */}
|
||||||
<Row gutter={[16, 16]} style={{ marginBottom: 16, display: 'flex', alignItems: 'stretch' }}>
|
<Row gutter={[16, 16]} style={{ marginBottom: 16, display: 'flex', alignItems: 'stretch' }}>
|
||||||
<Col style={{ flex: 1 }}>
|
<Col style={{ flex: 1 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user