设备接入
This commit is contained in:
@@ -7,14 +7,11 @@ import {
|
||||
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
|
||||
AppstoreOutlined, SwapOutlined, VideoCameraOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { addDeviceModel, addProduct, deleteModel, getConnectTypes, getDataTypesApi, getDeviceModelList, getProductPage, updateDeviceModel } from '../../api/deviceAccess.ts';
|
||||
import { addDeviceModel, addProduct, deleteModel, getConnectTypes, getDataTypesApi, getDeviceModelList, getProductPage, updateDeviceModel, updateProduct } from '../../api/deviceAccess.ts';
|
||||
|
||||
const { Option } = Select;
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
|
||||
|
||||
|
||||
const modelDetailList: Record<number, {
|
||||
props: any[];
|
||||
events: any[];
|
||||
@@ -66,7 +63,6 @@ const deviceList = [
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
export default function DeviceAccessPage() {
|
||||
const [activeTab, setActiveTab] = useState('device');
|
||||
const [form] = Form.useForm();
|
||||
@@ -91,14 +87,13 @@ export default function DeviceAccessPage() {
|
||||
const [paramList, setParamList] = useState<any[]>([]);
|
||||
const [dataTypeList, setDataTypeList] = useState([]);
|
||||
|
||||
|
||||
// 字段映射
|
||||
const [mappingList, setMappingList] = useState(mappingInitList);
|
||||
const [mappingModal, setMappingModal] = useState(false);
|
||||
const [mappingForm] = Form.useForm();
|
||||
const [protocolList, setProtocolList] = useState([]);
|
||||
const [propertyList, setPropertyList] = useState([]); // 物模型属性列表
|
||||
const [selectedModelId, setSelectedModelId] = useState(''); // 选中的模型ID
|
||||
const [propertyList, setPropertyList] = useState([]);
|
||||
const [selectedModelId, setSelectedModelId] = useState('');
|
||||
|
||||
// 筛选条件
|
||||
const [filterForm] = Form.useForm();
|
||||
@@ -124,11 +119,10 @@ export default function DeviceAccessPage() {
|
||||
|
||||
// 删除物模型
|
||||
const handleDeleteModel = (id) => {
|
||||
// 这里替换成你的真实删除接口
|
||||
deleteModel(id).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('删除成功');
|
||||
getModel(); // 删除后刷新列表
|
||||
getModel();
|
||||
} else {
|
||||
messageApi.error('删除失败:' + res.msg);
|
||||
}
|
||||
@@ -140,11 +134,12 @@ export default function DeviceAccessPage() {
|
||||
setModalType(type);
|
||||
setEditData(record);
|
||||
form.resetFields();
|
||||
setSelectedModelId('');
|
||||
setPropertyList([]);
|
||||
|
||||
if (record) {
|
||||
form.setFieldsValue(record);
|
||||
if (type === 'model') {
|
||||
// 接口数据 → 前端格式转换
|
||||
const props = record.supportProperties?.map(p => ({
|
||||
id: p.id,
|
||||
code: p.propertyKey,
|
||||
@@ -168,27 +163,36 @@ export default function DeviceAccessPage() {
|
||||
}
|
||||
if (type === 'product') {
|
||||
setProductProtocol(record?.protocolCode || '');
|
||||
// 编辑回显
|
||||
const modelId = Object.keys(record?.thingsModels || {})[0] || '';
|
||||
const limitConfig = record?.thingsModels?.[modelId] || {};
|
||||
const targetModel = filteredModelList.find(m => m.id == modelId);
|
||||
form.setFieldsValue({
|
||||
...record,
|
||||
modelId: modelId,
|
||||
limitConfig: limitConfig,
|
||||
propertyList: targetModel?.supportProperties || []
|
||||
});
|
||||
setVisible(true);
|
||||
const modelId = record.thingsModels ? Object.keys(record.thingsModels)[0] : null;
|
||||
const limitConfig = modelId ? record.thingsModels[modelId] : {};
|
||||
if (modelId) {
|
||||
const targetModel = thinsModelList.find(m => m.id == modelId);
|
||||
setSelectedModelId(Number(modelId)); // 让选中值生效
|
||||
setPropertyList(targetModel?.supportProperties || []);
|
||||
|
||||
form.setFieldsValue({
|
||||
...record,
|
||||
modelId: modelId,
|
||||
limitConfig: limitConfig
|
||||
});
|
||||
setTimeout(() => {
|
||||
form.setFieldsValue({ modelId });
|
||||
}, 100);
|
||||
} else {
|
||||
form.setFieldsValue(record);
|
||||
setSelectedModelId('');
|
||||
setPropertyList([]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (type === 'device') { setDeviceProtocol('onvif'); setModelDetail({ props: [] }); }
|
||||
else if (type === 'product') { setProductProtocol(''); setPropertyList([]) }
|
||||
else if (type === 'product') { setProductProtocol(''); setPropertyList([]); }
|
||||
else setModelDetail({ props: [], events: [], actions: [] });
|
||||
}
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 获取物模型列表(带分页 + 筛选)
|
||||
// 获取物模型列表
|
||||
const getModel = () => {
|
||||
const values = filterForm.getFieldsValue();
|
||||
const params = {
|
||||
@@ -206,15 +210,10 @@ export default function DeviceAccessPage() {
|
||||
};
|
||||
|
||||
const getModelAll = () => {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 999999,
|
||||
|
||||
};
|
||||
const params = { pageNum: 1, pageSize: 999999 };
|
||||
getDeviceModelList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setThingsModelList(res.rows);
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -223,7 +222,7 @@ export default function DeviceAccessPage() {
|
||||
const handleFilter = () => {
|
||||
setPagination(prev => ({ ...prev, current: 1 }));
|
||||
if (activeTab === 'model') getModel();
|
||||
if (activeTab === 'product') getProductList(); // 产品列表
|
||||
if (activeTab === 'product') getProductList();
|
||||
};
|
||||
|
||||
// 重置
|
||||
@@ -233,13 +232,14 @@ export default function DeviceAccessPage() {
|
||||
if (activeTab === 'model') getModel();
|
||||
if (activeTab === 'product') getProductList();
|
||||
};
|
||||
|
||||
const getDataTypes = () => {
|
||||
getDataTypesApi("").then(res => {
|
||||
if (res.code === 200) {
|
||||
setDataTypeList(res.data || []);
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 分页切换
|
||||
const handleTableChange = (pag) => {
|
||||
@@ -247,7 +247,8 @@ export default function DeviceAccessPage() {
|
||||
if (activeTab === 'model') getModel();
|
||||
if (activeTab === 'product') getProductList();
|
||||
};
|
||||
// ====================== 获取产品列表 ======================
|
||||
|
||||
// 获取产品列表
|
||||
const getProductList = () => {
|
||||
const values = filterForm.getFieldsValue();
|
||||
const params = {
|
||||
@@ -264,7 +265,6 @@ export default function DeviceAccessPage() {
|
||||
status: values.status ?? '',
|
||||
};
|
||||
|
||||
// 这里调用你的【产品列表接口】
|
||||
getProductPage(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setProductList(res.rows);
|
||||
@@ -273,7 +273,7 @@ export default function DeviceAccessPage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ===================== 物模型提交 =====================
|
||||
// 提交
|
||||
const handleSubmit = () => {
|
||||
form.validateFields().then(values => {
|
||||
if (modalType === 'model') {
|
||||
@@ -299,21 +299,24 @@ export default function DeviceAccessPage() {
|
||||
}))
|
||||
};
|
||||
if (editData) {
|
||||
// 编辑:调用 updateDeviceModel,自动带 id
|
||||
updateDeviceModel(submitData).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('编辑成功');
|
||||
getModel();
|
||||
setVisible(false);
|
||||
} else {
|
||||
messageApi.error(res.msg);
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
addDeviceModel(submitData).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('新增成功');
|
||||
getModel();
|
||||
setVisible(false);
|
||||
} else {
|
||||
messageApi.error(res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -324,9 +327,6 @@ export default function DeviceAccessPage() {
|
||||
const newValues = form.getFieldsValue();
|
||||
const { modelId, limitConfig, ...params } = newValues;
|
||||
|
||||
// ======================
|
||||
// 👇 强制给默认值 0 ~ 100
|
||||
// ======================
|
||||
const finalLimitConfig = {};
|
||||
if (limitConfig) {
|
||||
Object.keys(limitConfig).forEach(key => {
|
||||
@@ -339,26 +339,47 @@ export default function DeviceAccessPage() {
|
||||
|
||||
const thingsModels = {};
|
||||
if (modelId) {
|
||||
thingsModels[modelId] = finalLimitConfig; // 👈 用处理后的
|
||||
thingsModels[modelId] = finalLimitConfig;
|
||||
}
|
||||
|
||||
const submitData = {
|
||||
...params,
|
||||
thingsModels: thingsModels,
|
||||
id: editData?.id,
|
||||
};
|
||||
|
||||
addProduct(submitData).then(res => {
|
||||
if (res.code == 200) {
|
||||
messageApi.success('新增产品成功');
|
||||
getProductList()
|
||||
}
|
||||
})
|
||||
// ======================
|
||||
// 产品:判断新增 / 编辑
|
||||
// ======================
|
||||
if (editData) {
|
||||
// 编辑
|
||||
updateProduct(submitData).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('产品编辑成功');
|
||||
getProductList();
|
||||
setVisible(false);
|
||||
} else {
|
||||
messageApi.error(res.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
addProduct(submitData).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('产品新增成功');
|
||||
getProductList();
|
||||
setVisible(false);
|
||||
} else {
|
||||
messageApi.error(res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
setVisible(false);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// 属性编辑
|
||||
// 属性
|
||||
const openItemModal = (type: 'props' | 'events' | 'actions', record?: any) => {
|
||||
setItemType(type);
|
||||
itemForm.resetFields();
|
||||
@@ -405,6 +426,9 @@ export default function DeviceAccessPage() {
|
||||
setMappingList(newList);
|
||||
messageApi.success('删除成功');
|
||||
};
|
||||
const handleDeleteProduct = (data) => {
|
||||
|
||||
}
|
||||
|
||||
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
||||
|
||||
@@ -441,60 +465,35 @@ export default function DeviceAccessPage() {
|
||||
{
|
||||
title: '操作', render: r => (
|
||||
<Space>
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => openModal('product', r)}>编辑</Button>
|
||||
<Button type="text" icon={<SwapOutlined />} onClick={() => openModal('product', r)}>字段映射</Button>
|
||||
<Button type="text" style={{ color: '#1677ff' }} icon={<EditOutlined />} onClick={() => openModal('product', r)}>编辑</Button>
|
||||
<Button type="text" icon={<SwapOutlined />} onClick={() => openMappingModal()}>字段映射</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
// ====================== 已增加属性列 + 指令列 ======================
|
||||
const modelColumns = [
|
||||
{ title: '模型名称', dataIndex: 'name' },
|
||||
{ title: '连接协议', dataIndex: 'connectType' },
|
||||
{
|
||||
title: '属性列表',
|
||||
width: 300,
|
||||
render: (record) => {
|
||||
title: '属性列表', width: 300, render: (record) => {
|
||||
const list = record.supportProperties || [];
|
||||
if (list.length === 0) return <span style={{ color: '#999' }}>无属性</span>;
|
||||
return (
|
||||
<Space size={[4, 4]} wrap>
|
||||
{list.map(item => (
|
||||
<Tag key={item.id} color="blue">{item.propertyName}</Tag>
|
||||
))}
|
||||
</Space>
|
||||
);
|
||||
return <Space size={[4, 4]} wrap>{list.map(item => <Tag key={item.id} color="blue">{item.propertyName}</Tag>)}</Space>;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '指令列表',
|
||||
width: 300,
|
||||
render: (record) => {
|
||||
title: '指令列表', width: 300, render: (record) => {
|
||||
const list = record.supportActions || [];
|
||||
if (list.length === 0) return <span style={{ color: '#999' }}>无指令</span>;
|
||||
return (
|
||||
<Space size={[4, 4]} wrap>
|
||||
{list.map(item => (
|
||||
<Tag key={item.id} color="green">{item.actionName}</Tag>
|
||||
))}
|
||||
</Space>
|
||||
);
|
||||
return <Space size={[4, 4]} wrap>{list.map(item => <Tag key={item.id} color="green">{item.actionName}</Tag>)}</Space>;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
render: r => (
|
||||
title: '操作', render: r => (
|
||||
<Space>
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button>
|
||||
|
||||
{/* 增加删除按钮 + 确认框 */}
|
||||
<Popconfirm
|
||||
title="确定要删除该物模型吗?"
|
||||
onConfirm={() => handleDeleteModel(r.id)}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Popconfirm title="确定要删除该物模型吗?" onConfirm={() => handleDeleteModel(r.id)} okText="确定" cancelText="取消">
|
||||
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
@@ -515,7 +514,6 @@ 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 === 'product' && (
|
||||
<Card>
|
||||
{/* ====================== 产品筛选表单 ====================== */}
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between', alignItems: 'end' }}>
|
||||
<Form
|
||||
form={filterForm}
|
||||
@@ -562,47 +560,57 @@ export default function DeviceAccessPage() {
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* ====================== 产品表格 ====================== */}
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={[
|
||||
{ title: '产品编码', dataIndex: 'code', width: 120 },
|
||||
{ title: '产品名称', dataIndex: 'name', width: 160 },
|
||||
{ title: '生产厂家', dataIndex: 'manufacturer', width: 130 },
|
||||
{ title: '分类ID', dataIndex: 'categoryId', width: 90 },
|
||||
{ title: '协议', dataIndex: 'protocolCode', width: 100 },
|
||||
{ title: '传输方式', dataIndex: 'transport', width: 100 },
|
||||
{ title: '上报Topic', dataIndex: 'uploadTopic', ellipsis: true },
|
||||
{ title: '订阅Topic', dataIndex: 'subscribeTopic', ellipsis: true },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (s) => <Tag color={s === 1 ? 'green' : 'red'}>{s === 1 ? '启用' : '禁用'}</Tag>
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
render: (r) => (
|
||||
<Space>
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => openModal('product', r)}>编辑</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
]}
|
||||
dataSource={productList}
|
||||
pagination={{
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total) => `共 ${total} 条`
|
||||
}}
|
||||
onChange={handleTableChange}
|
||||
/>
|
||||
{/* 包一层横向滚动容器 */}
|
||||
<div style={{ overflowX: 'auto', width: '100%' }}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={[
|
||||
{ title: '产品编码', dataIndex: 'code', width: 120 },
|
||||
{ title: '产品名称', dataIndex: 'name', width: 160 },
|
||||
{ title: '生产厂家', dataIndex: 'manufacturer', width: 130 },
|
||||
{ title: '分类ID', dataIndex: 'categoryId', width: 90 },
|
||||
{ title: '协议', dataIndex: 'protocolCode', width: 100 },
|
||||
{ title: '传输方式', dataIndex: 'transport', width: 100 },
|
||||
{ title: '上报Topic', dataIndex: 'uploadTopic', ellipsis: true },
|
||||
{ title: '订阅Topic', dataIndex: 'subscribeTopic', ellipsis: true },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (s) => <Tag color={s === 1 ? 'green' : 'red'}>{s === 1 ? '启用' : '禁用'}</Tag>
|
||||
},
|
||||
{
|
||||
title: '操作', width: 180, render: (r) => (
|
||||
<Space>
|
||||
<Button type="text" style={{ color: '#1677ff' }} icon={<EditOutlined />} onClick={() => openModal('product', r)}>编辑</Button>
|
||||
<Button type="text" icon={<SwapOutlined />} onClick={() => openMappingModal()}>字段映射</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除该产品吗?"
|
||||
onConfirm={() => handleDeleteProduct(r.id)}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
]}
|
||||
dataSource={productList}
|
||||
pagination={{
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total) => `共 ${total} 条`
|
||||
}}
|
||||
onChange={handleTableChange}
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
{/* 物模型 + 筛选 + 分页 */}
|
||||
|
||||
{activeTab === 'model' && (
|
||||
<Card>
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
@@ -625,13 +633,7 @@ export default function DeviceAccessPage() {
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('model')}>新增物模型</Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={modelColumns}
|
||||
dataSource={filteredModelList}
|
||||
pagination={pagination}
|
||||
onChange={handleTableChange}
|
||||
/>
|
||||
<Table rowKey="id" columns={modelColumns} dataSource={filteredModelList} pagination={pagination} onChange={handleTableChange} />
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -644,7 +646,6 @@ export default function DeviceAccessPage() {
|
||||
<Form.Item label="设备名称" name="name" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item label="设备SN" name="sn" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item label="关联产品" name="productId" rules={[{ required: true }]}><Select>{productList.map(p => <Option key={p.id} value={p.id}>{p.name}</Option>)}</Select></Form.Item>
|
||||
{/*<Form.Item label="关联物模型" name="modelId" rules={[{ required: true }]}><Select onChange={val => setModelDetail(modelDetailList[val] || { props: [] })}>{modelList.map(m => <Option key={m.id} value={m.id}>{m.name}</Option>)}</Select></Form.Item>*/}
|
||||
</TabPane>
|
||||
<TabPane tab="协议配置" key="protocol">
|
||||
<Form.Item label="设备协议类型" name="protocolType" rules={[{ required: true }]}>
|
||||
@@ -691,7 +692,6 @@ export default function DeviceAccessPage() {
|
||||
)}
|
||||
|
||||
{modalType === 'product' && (
|
||||
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="产品编号" name="code" rules={[{ required: true }]}>
|
||||
@@ -733,18 +733,22 @@ export default function DeviceAccessPage() {
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
{/* ============ 物模型选择(直接放在基础信息里) ============ */}
|
||||
<Divider>物模型属性配置</Divider>
|
||||
<Form.Item label="绑定物模型">
|
||||
<Select
|
||||
placeholder="请选择要绑定的物模型"
|
||||
style={{ width: '100%' }}
|
||||
value={selectedModelId}
|
||||
onChange={(modelId) => {
|
||||
const model = thinsModelList.find(item => item.id === modelId);
|
||||
console.log(model.supportProperties, "物模型")
|
||||
if (model) {
|
||||
setSelectedModelId(modelId);
|
||||
setPropertyList(model.supportProperties || []); // 👈 用 state 立刻刷新
|
||||
setSelectedModelId(Number(modelId));
|
||||
setPropertyList(model.supportProperties || []);
|
||||
const defaultLimit = {};
|
||||
model.supportProperties?.forEach(attr => {
|
||||
defaultLimit[attr.propertyKey] = { min: 0, max: 100 };
|
||||
});
|
||||
form.setFieldsValue({ limitConfig: defaultLimit });
|
||||
} else {
|
||||
setSelectedModelId('');
|
||||
setPropertyList([]);
|
||||
@@ -759,45 +763,23 @@ export default function DeviceAccessPage() {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
{/* 隐藏字段存储数据 */}
|
||||
<Form.Item name="modelId" hidden ><Input /></Form.Item>
|
||||
<Form.Item name="propertyList" hidden ><Input /></Form.Item>
|
||||
|
||||
{/* ============ 自动渲染属性 + min/max输入框 ============ */}
|
||||
{/* ============ 自动渲染属性 + min/max输入框 ============ */}
|
||||
<div style={{ marginTop: 12 }}>
|
||||
{/* 👇 这里从 state 取,同步秒刷新 */}
|
||||
{propertyList?.map((item) => (
|
||||
<div key={item.id} style={{
|
||||
padding: '12px 16px',
|
||||
border: '1px solid #eee',
|
||||
borderRadius: 8,
|
||||
marginBottom: 8
|
||||
}}>
|
||||
<div key={item.id} style={{ padding: '12px 16px', border: '1px solid #eee', borderRadius: 8, marginBottom: 8 }}>
|
||||
<div style={{ marginBottom: 8, fontWeight: 500 }}>
|
||||
{item.propertyName}({item.propertyKey})
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Form.Item
|
||||
label="最小值"
|
||||
name={['limitConfig', item.propertyKey, 'min']}
|
||||
style={{ flex: 1 }}
|
||||
|
||||
>
|
||||
<InputNumber style={{ width: '100%' }} placeholder="最小值" initialValue={0}
|
||||
/>
|
||||
<Form.Item label="最小值" name={['limitConfig', item.propertyKey, 'min']} style={{ flex: 1 }}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder="最小值" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="最大值"
|
||||
name={['limitConfig', item.propertyKey, 'max']}
|
||||
style={{ flex: 1 }}
|
||||
>
|
||||
<InputNumber style={{ width: '100%' }} placeholder="最大值" initialValue={100} />
|
||||
<Form.Item label="最大值" name={['limitConfig', item.propertyKey, 'max']} style={{ flex: 1 }}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder="最大值" />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{(!propertyList || propertyList.length === 0) && (
|
||||
<div style={{ color: '#999', textAlign: 'center', padding: 10 }}>
|
||||
请选择物模型以显示属性
|
||||
@@ -805,7 +787,6 @@ export default function DeviceAccessPage() {
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
|
||||
)}
|
||||
|
||||
{modalType === 'model' && (
|
||||
@@ -900,9 +881,7 @@ export default function DeviceAccessPage() {
|
||||
<Form.Item label="类型" name="type">
|
||||
<Select>
|
||||
{dataTypeList.map(item => (
|
||||
<Option key={item.code} value={item.code}>
|
||||
{item.name}
|
||||
</Option>
|
||||
<Option key={item.code} value={item.code}>{item.name}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
@@ -933,40 +912,16 @@ export default function DeviceAccessPage() {
|
||||
<Input placeholder="指令名称" value={currentAction?.actionName} onChange={e => setCurrentAction({ ...currentAction, actionName: e.target.value })} style={{ flex: 1 }} />
|
||||
</div>
|
||||
<Divider>指令参数</Divider>
|
||||
|
||||
<div className="flex gap-2 items-center">
|
||||
<Input
|
||||
placeholder="参数名"
|
||||
value={paramList[0]?.paramKey || ''}
|
||||
onChange={e => setParamList([{ ...paramList[0], paramKey: e.target.value }])}
|
||||
/>
|
||||
<Select
|
||||
value={paramList[0]?.type || 'int'}
|
||||
style={{ width: 100 }}
|
||||
onChange={v => setParamList([{ ...paramList[0], type: v }])}
|
||||
>
|
||||
{/* 👇 接口数据渲染 */}
|
||||
<Input placeholder="参数名" value={paramList[0]?.paramKey || ''} onChange={e => setParamList([{ ...paramList[0], paramKey: e.target.value }])} />
|
||||
<Select value={paramList[0]?.type || 'int'} style={{ width: 100 }} onChange={v => setParamList([{ ...paramList[0], type: v }])}>
|
||||
{dataTypeList.map(item => (
|
||||
<Option key={item.code} value={item.code}>
|
||||
{item.code}
|
||||
</Option>
|
||||
<Option key={item.code} value={item.code}>{item.code}</Option>
|
||||
))}
|
||||
</Select>
|
||||
<Input
|
||||
placeholder="描述"
|
||||
value={paramList[0]?.desc || ''}
|
||||
onChange={e => setParamList([{ ...paramList[0], desc: e.target.value }])}
|
||||
/>
|
||||
<Input
|
||||
placeholder="默认值"
|
||||
value={paramList[0]?.defaultValue || ''}
|
||||
onChange={e => setParamList([{ ...paramList[0], defaultValue: e.target.value }])}
|
||||
/>
|
||||
<Input
|
||||
placeholder="枚举(,分隔)"
|
||||
value={(paramList[0]?.enum || []).join(',')}
|
||||
onChange={e => setParamList([{ ...paramList[0], enum: e.target.value.split(',').map(s => s.trim()) }])}
|
||||
/>
|
||||
<Input placeholder="描述" value={paramList[0]?.desc || ''} onChange={e => setParamList([{ ...paramList[0], desc: e.target.value }])} />
|
||||
<Input placeholder="默认值" value={paramList[0]?.defaultValue || ''} onChange={e => setParamList([{ ...paramList[0], defaultValue: e.target.value }])} />
|
||||
<Input placeholder="枚举(,分隔)" value={(paramList[0]?.enum || []).join(',')} onChange={e => setParamList([{ ...paramList[0], enum: e.target.value.split(',').map(s => s.trim()) }])} />
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user