提交设备管理部分代码

This commit is contained in:
袁帅
2022-09-27 10:54:00 +08:00
parent 6b3c05532b
commit 8337eae99a
4 changed files with 426 additions and 96 deletions

View File

@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from 'react';
import { Button, Spin, Tabs, Tree} from 'antd';
import { Button, message, Spin, Tabs, Tree} from 'antd';
import ProTable, { ActionType } from '@ant-design/pro-table';
import { deviceList, getplaceareaList, roomList } from './service';
import '@/assets/ld_style.less';
@ -38,15 +38,23 @@ const DeviceManage: React.FC<{}> = () => {
if (res.code == 200) {
let data: any = [];
if (res.data != undefined) {
res.data.map((item: any, index: any) => {
const title1 = item.placeName;
const key1 = item.id;
res.data.map((item1: any, index: any) => {
const title1 = item1.placeName;
const key1 = item1.id;
let children1: any = [];
if (item.roomList != undefined) {
const children = item.roomList.map((item: any, index: any) => {
if (item1.roomList != undefined) {
const children = item1.roomList.map((item: any, index: any) => {
const title2 = item.areaName;
const key2 = item.id;
return { title: title2, key: key2}
const obj = {
placeId:item1.platformList[0].placeId,
placeName: item1.placeName,
areaId: item.id,
areaName: item.areaName,
platformId: item1.platformList[0].platformId,
platformName: item1.platformList[0].platformName,
};
return { title: title2, key: key2, obj: obj}
});
children1 = children;
}
@ -61,10 +69,13 @@ const DeviceManage: React.FC<{}> = () => {
const toAdd = async (props?: any) => {
// spinSet(true);
setUpdateChange('新增设备');
setType("new");
setUpdateVisible(true);
if(currentNodeRef?.current){
setUpdateChange('新增设备');
setType("new");
setUpdateVisible(true);
}else{
message.error('请在评标区域下新增设备');
}
}
const toEdit = (dId: String) => {
setUpdateChange('修改设备');
@ -89,10 +100,13 @@ const DeviceManage: React.FC<{}> = () => {
//列表页loading
const [spinLoading, setSpinLoading] = useState<boolean>(false);
const currentNodeRef = useRef<any>();
const onSelect = (selectedKeys: any, info: any) => {
selectedKeys.length == 0 ? setTreeId(null) : setTreeId(selectedKeys[0])
console.log(selectedKeys)
if(info.node?.obj){
currentNodeRef.current = info.node?.obj;
}
}
const columns: any[] = [
//设备管理
@ -231,14 +245,14 @@ const DeviceManage: React.FC<{}> = () => {
</Button>,
<Button
key="searchText"
type="primary"
onClick={() => {
form?.submit();
}}
>
{searchConfig?.searchText}
</Button>,
<Button key="toCreate" onClick={() => toAdd()}>
<Button key="toCreate"
type="primary" onClick={() => toAdd()}>
</Button>,
];
@ -255,7 +269,7 @@ const DeviceManage: React.FC<{}> = () => {
</ProCard>
{updateVisible ? (
<DeviceForm key={Math.random()} titleName={updateChange}
type={type} deviceId={deviceId} status={'2'} onCancel={() => setUpdateVisible(false)}
type={type} deviceId={deviceId} deviceRel={currentNodeRef?.current} reload={()=>{checkRelationRef?.current?.reload();}} status={'2'} onCancel={() => setUpdateVisible(false)}
modalVisible={updateVisible} tpId={''} />
) : null}
</Spin>