设备管理
This commit is contained in:
@ -1,21 +1,25 @@
|
||||
import { Form, Input, Modal, Spin } from "antd"
|
||||
import { Form, Input, Modal, Select, Spin } from "antd"
|
||||
import React, { useEffect, useState } from "react"
|
||||
import { getDeviceById } from "./service";
|
||||
|
||||
import { SnowflakeID } from "@/services/untilService";
|
||||
|
||||
import { trim } from "@/utils/CommonUtils";
|
||||
|
||||
interface DeviceFormProps {
|
||||
modalVisible: boolean;
|
||||
titleName: string;
|
||||
onCancel: () => void;
|
||||
status: string;//状态 0-新建 1-编辑 2-查看
|
||||
type: string;
|
||||
tpId: string;
|
||||
deviceId: string;
|
||||
|
||||
}
|
||||
|
||||
const deviceTypeEnum = {
|
||||
'resource_door': { text: '门禁点' },
|
||||
'resource_camera': { text: '监控点' },
|
||||
'resource_nvr': { text: 'nvr' },
|
||||
'resource_encodeDevice': { text: '编码设备' },
|
||||
'resource_oneMachine': { text: '门禁一体机' },
|
||||
}
|
||||
const layout = {
|
||||
labelCol: { span: 7 },
|
||||
wrapperCol: { span: 10 },
|
||||
@ -26,13 +30,12 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
|
||||
const [spinning, setSping] = useState<boolean>();//加载遮罩
|
||||
const [editInformation, setEditInformation] = useState<boolean>(false);//是否可编
|
||||
const [form] = Form.useForm();
|
||||
|
||||
//窗口状态 0-新建 1-编辑 2-查看
|
||||
const [modalStatus, setModalStatus] = useState<string | undefined>(status);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
SnowflakeID().then(res => {
|
||||
Int();
|
||||
});
|
||||
Int();
|
||||
form.resetFields();//清除form中数据
|
||||
}, [type, deviceId]);
|
||||
const Int = () => {
|
||||
@ -44,21 +47,20 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
|
||||
setEditInformation(false);//可编辑
|
||||
|
||||
} else if (type == "edit") {//=========================================================修改
|
||||
|
||||
|
||||
console.log(deviceId);
|
||||
getDeviceById(deviceId).then(res => {
|
||||
if (res.code == 200) {
|
||||
const data = res.data;
|
||||
let defPak = [];
|
||||
for (const item of data.sections) {
|
||||
defPak.push(item.bsId);
|
||||
}
|
||||
|
||||
form.setFieldsValue({
|
||||
"documentName": data.documentName,
|
||||
"documentSetId": data.documentSetId,
|
||||
"sectionIds": defPak,
|
||||
"id": data.id,
|
||||
"deviceName": data.deviceName,
|
||||
"deviceManagementIp": data.deviceManagementIp,
|
||||
"deviceCode": data.deviceCode,
|
||||
"devicePlatform": data.devicePlatform,
|
||||
"placeId": data.placeId,
|
||||
"areaId": data.areaId,
|
||||
});
|
||||
|
||||
setSping(false);
|
||||
setEditInformation(false);//可编辑
|
||||
|
||||
@ -70,17 +72,15 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
|
||||
getDeviceById(deviceId).then(res => {
|
||||
if (res.code == 200) {
|
||||
const data = res.data;
|
||||
let thisData1 = [];
|
||||
let defPak = [];
|
||||
for (const item of data.sections) {
|
||||
thisData1.push({ "label": item.bsName, "value": item.bsId })
|
||||
defPak.push(item.bsId);
|
||||
}
|
||||
|
||||
form.setFieldsValue({
|
||||
"documentName": data.documentName,
|
||||
"documentSetId": data.documentSetId,
|
||||
"sectionIds": defPak,
|
||||
"id": data.id,
|
||||
"deviceName": data.deviceName,
|
||||
"deviceManagementIp": data.deviceManagementIp,
|
||||
"deviceCode": data.deviceCode,
|
||||
"devicePlatform": data.devicePlatform,
|
||||
"placeId": data.placeId,
|
||||
"areaId": data.areaId,
|
||||
})
|
||||
|
||||
setSping(false);
|
||||
@ -114,21 +114,44 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
|
||||
name="basic"
|
||||
form={form}
|
||||
>
|
||||
<Form.Item
|
||||
label="文件名称"
|
||||
name="documentName"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '当前项不可为空',
|
||||
},
|
||||
]}
|
||||
normalize={(value) => trim(value)}
|
||||
>
|
||||
<Input maxLength={200} readOnly={editInformation} />
|
||||
</Form.Item>
|
||||
<Form.Item name="id" label="设备id" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item name="placeId" label="评标场所" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="评标场所" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="areaId" label="评标区域" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="评标区域" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="devicePlatform" label="管理平台" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="管理平台" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="deviceType" label="设备类型" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Select
|
||||
placeholder="选择设备类型"
|
||||
allowClear
|
||||
disabled={modalStatus == "2"}
|
||||
>
|
||||
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="deviceName" label="设备名称" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="设备名称" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="deviceManagementIp" label="网络IP" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="网络IP" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="deviceCode" label="设备标识" rules={[{ required: !(modalStatus == "2") }]}>
|
||||
<Input placeholder="设备标识" disabled={modalStatus == "2"} maxLength={50} />
|
||||
</Form.Item>
|
||||
|
||||
</Form>
|
||||
|
||||
</Spin>
|
||||
|
@ -66,9 +66,10 @@ const Index: React.FC<{}> = () => {
|
||||
setUpdateVisible(true);
|
||||
|
||||
}
|
||||
const toEdit = (props: any) => {
|
||||
const toEdit = (dId: String) => {
|
||||
setUpdateChange('修改设备');
|
||||
setDeviceId(props.id)
|
||||
console.log(dId)
|
||||
setDeviceId(dId)
|
||||
setType("edit");
|
||||
setUpdateVisible(true);
|
||||
}
|
||||
@ -152,23 +153,23 @@ const Index: React.FC<{}> = () => {
|
||||
search: true,
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
width: '7%',
|
||||
search: false,
|
||||
render: (text: any, record: any) => {
|
||||
return (
|
||||
<>
|
||||
<Button type="text" onClick={() => {toEdit(record.id)}} danger>
|
||||
编辑
|
||||
</Button>
|
||||
<Button type="text" onClick={() => {}} danger>
|
||||
删除
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: '操作',
|
||||
// width: '7%',
|
||||
// search: false,
|
||||
// render: (text: any, record: any) => {
|
||||
// return (
|
||||
// <>
|
||||
// <Button type="text" onClick={() => {toEdit(record.id)}} danger>
|
||||
// 编辑
|
||||
// </Button>
|
||||
// <Button type="text" onClick={() => {}} danger>
|
||||
// 删除
|
||||
// </Button>
|
||||
// </>
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
];
|
||||
|
||||
return (
|
||||
@ -237,9 +238,9 @@ const Index: React.FC<{}> = () => {
|
||||
>
|
||||
{searchConfig?.searchText}
|
||||
</Button>,
|
||||
<Button key="toCreate" onClick={() => toAdd()}>
|
||||
新建
|
||||
</Button>,
|
||||
// <Button key="toCreate" onClick={() => toAdd()}>
|
||||
// 新建
|
||||
// </Button>,
|
||||
];
|
||||
},
|
||||
}}
|
||||
@ -252,11 +253,11 @@ const Index: React.FC<{}> = () => {
|
||||
/>
|
||||
</ProCard>
|
||||
</ProCard>
|
||||
{updateVisible ? (
|
||||
{/* {updateVisible ? (
|
||||
<DeviceForm key={Math.random()} titleName={updateChange}
|
||||
type={type} deviceId={deviceId} onCancel={() => setUpdateVisible(false)}
|
||||
type={type} deviceId={deviceId} status={'2'} onCancel={() => setUpdateVisible(false)}
|
||||
modalVisible={updateVisible} tpId={''} />
|
||||
) : null}
|
||||
) : null} */}
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
|
@ -34,7 +34,7 @@ export async function getplaceareaList() {
|
||||
}
|
||||
|
||||
export async function getDeviceById(id: any) {
|
||||
return request('/v1/elec/eval/placearea/list/'+`${id}`, {
|
||||
return request('/v1/eval/device/query/'+`${id}`, {
|
||||
method: 'get',
|
||||
params: {}
|
||||
});
|
||||
|
Reference in New Issue
Block a user