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