test
This commit is contained in:
@@ -39,6 +39,16 @@ export function addProduct(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑产品/system/product/update
|
||||||
|
|
||||||
|
export function updateProduct(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/product/update',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//协议查询
|
//协议查询
|
||||||
|
|
||||||
export function getConnectTypes(params) {
|
export function getConnectTypes(params) {
|
||||||
@@ -68,6 +78,16 @@ export function getDataTypesApi(params) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除物模型system/devicemodel/delete/{id}
|
||||||
|
|
||||||
|
export function deleteModel(id) {
|
||||||
|
return request({
|
||||||
|
url: `/system/devicemodel/delete/${id}`,
|
||||||
|
method: 'delete',
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ 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, addProduct, getConnectTypes, getDataTypesApi, getDeviceModelList, getProductPage, updateDeviceModel } from '../../api/deviceAccess.ts';
|
import { addDeviceModel, addProduct, deleteModel, getConnectTypes, getDataTypesApi, getDeviceModelList, getProductPage, updateDeviceModel } from '../../api/deviceAccess.ts';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const { TabPane } = Tabs;
|
const { TabPane } = Tabs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const modelDetailList: Record<number, {
|
const modelDetailList: Record<number, {
|
||||||
props: any[];
|
props: any[];
|
||||||
events: any[];
|
events: any[];
|
||||||
@@ -73,6 +74,7 @@ export default function DeviceAccessPage() {
|
|||||||
const [modalType, setModalType] = useState('');
|
const [modalType, setModalType] = useState('');
|
||||||
const [editData, setEditData] = useState<any>(null);
|
const [editData, setEditData] = useState<any>(null);
|
||||||
const [productList, setProductList] = useState([]);
|
const [productList, setProductList] = useState([]);
|
||||||
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
|
|
||||||
const [deviceProtocol, setDeviceProtocol] = useState('onvif');
|
const [deviceProtocol, setDeviceProtocol] = useState('onvif');
|
||||||
const [productProtocol, setProductProtocol] = useState('');
|
const [productProtocol, setProductProtocol] = useState('');
|
||||||
@@ -87,6 +89,8 @@ export default function DeviceAccessPage() {
|
|||||||
const [actionModal, setActionModal] = useState(false);
|
const [actionModal, setActionModal] = useState(false);
|
||||||
const [currentAction, setCurrentAction] = useState<any>(null);
|
const [currentAction, setCurrentAction] = useState<any>(null);
|
||||||
const [paramList, setParamList] = useState<any[]>([]);
|
const [paramList, setParamList] = useState<any[]>([]);
|
||||||
|
const [dataTypeList, setDataTypeList] = useState([]);
|
||||||
|
|
||||||
|
|
||||||
// 字段映射
|
// 字段映射
|
||||||
const [mappingList, setMappingList] = useState(mappingInitList);
|
const [mappingList, setMappingList] = useState(mappingInitList);
|
||||||
@@ -121,14 +125,14 @@ export default function DeviceAccessPage() {
|
|||||||
// 删除物模型
|
// 删除物模型
|
||||||
const handleDeleteModel = (id) => {
|
const handleDeleteModel = (id) => {
|
||||||
// 这里替换成你的真实删除接口
|
// 这里替换成你的真实删除接口
|
||||||
//deleteDeviceModel(id).then(res => {
|
deleteModel(id).then(res => {
|
||||||
// if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
// message.success('删除成功');
|
messageApi.success('删除成功');
|
||||||
// getModel(); // 删除后刷新列表
|
getModel(); // 删除后刷新列表
|
||||||
// } else {
|
} else {
|
||||||
// message.error('删除失败:' + res.msg);
|
messageApi.error('删除失败:' + res.msg);
|
||||||
// }
|
}
|
||||||
//}).catch(() => message.error('删除请求异常'));
|
}).catch(() => messageApi.error('删除请求异常'));
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
@@ -231,7 +235,9 @@ export default function DeviceAccessPage() {
|
|||||||
};
|
};
|
||||||
const getDataTypes = () => {
|
const getDataTypes = () => {
|
||||||
getDataTypesApi("").then(res => {
|
getDataTypesApi("").then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
setDataTypeList(res.data || []);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +302,7 @@ export default function DeviceAccessPage() {
|
|||||||
// 编辑:调用 updateDeviceModel,自动带 id
|
// 编辑:调用 updateDeviceModel,自动带 id
|
||||||
updateDeviceModel(submitData).then(res => {
|
updateDeviceModel(submitData).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('编辑成功');
|
messageApi.success('编辑成功');
|
||||||
getModel();
|
getModel();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -305,7 +311,7 @@ export default function DeviceAccessPage() {
|
|||||||
// 新增
|
// 新增
|
||||||
addDeviceModel(submitData).then(res => {
|
addDeviceModel(submitData).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('新增成功');
|
messageApi.success('新增成功');
|
||||||
getModel();
|
getModel();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -343,7 +349,7 @@ export default function DeviceAccessPage() {
|
|||||||
|
|
||||||
addProduct(submitData).then(res => {
|
addProduct(submitData).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
message.success('新增产品成功');
|
messageApi.success('新增产品成功');
|
||||||
getProductList()
|
getProductList()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -385,10 +391,10 @@ 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('修改成功');
|
messageApi.success('修改成功');
|
||||||
} else {
|
} else {
|
||||||
newList.push({ ...val, id: Date.now() });
|
newList.push({ ...val, id: Date.now() });
|
||||||
message.success('新增成功');
|
messageApi.success('新增成功');
|
||||||
}
|
}
|
||||||
setMappingList(newList);
|
setMappingList(newList);
|
||||||
setMappingModal(false);
|
setMappingModal(false);
|
||||||
@@ -397,7 +403,7 @@ export default function DeviceAccessPage() {
|
|||||||
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);
|
||||||
message.success('删除成功');
|
messageApi.success('删除成功');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
|
||||||
@@ -497,6 +503,7 @@ export default function DeviceAccessPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-5 bg-[#f5f7fa] min-h-screen">
|
<div className="p-5 bg-[#f5f7fa] min-h-screen">
|
||||||
|
{contextHolder}
|
||||||
<Card className="mb-4">
|
<Card className="mb-4">
|
||||||
<Tabs activeKey={activeTab} onChange={setActiveTab}>
|
<Tabs activeKey={activeTab} onChange={setActiveTab}>
|
||||||
<TabPane tab={<span><VideoCameraOutlined />设备管理</span>} key="device" />
|
<TabPane tab={<span><VideoCameraOutlined />设备管理</span>} key="device" />
|
||||||
@@ -892,10 +899,11 @@ export default function DeviceAccessPage() {
|
|||||||
<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>
|
{dataTypeList.map(item => (
|
||||||
<Option value="float">float</Option>
|
<Option key={item.code} value={item.code}>
|
||||||
<Option value="string">string</Option>
|
{item.name}
|
||||||
<Option value="bool">bool</Option>
|
</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>
|
||||||
@@ -937,10 +945,12 @@ export default function DeviceAccessPage() {
|
|||||||
style={{ width: 100 }}
|
style={{ width: 100 }}
|
||||||
onChange={v => setParamList([{ ...paramList[0], type: v }])}
|
onChange={v => setParamList([{ ...paramList[0], type: v }])}
|
||||||
>
|
>
|
||||||
<Option value="int">int</Option>
|
{/* 👇 接口数据渲染 */}
|
||||||
<Option value="string">string</Option>
|
{dataTypeList.map(item => (
|
||||||
<Option value="float">float</Option>
|
<Option key={item.code} value={item.code}>
|
||||||
<Option value="bool">bool</Option>
|
{item.code}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
<Input
|
<Input
|
||||||
placeholder="描述"
|
placeholder="描述"
|
||||||
|
|||||||
Reference in New Issue
Block a user