// 设备管理 导航条的右侧 import React, { useState, useEffect } from 'react'; import { Dropdown, Menu, Modal, message } from 'antd'; import Icon from '@/tenants-ui/Icon'; import { EllipsisOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; import styles from './index.less'; //import { equipImageMap } from '@/config/image.js'; import type { navigatorItem } from '@/pages/Environment/index'; import { projectId } from '@/config/api.js'; import { changeCurtain, changeAllAir, changeLight } from '@/pages/Equipment/equipmentControl'; export type topNavRightProps = { selNavObj: navigatorItem; navigatorList: navigatorItem[]; mapList: API.MapInfo[]; queryDeviceManage: () => Promise; }; const TopNavRight: React.FC = ({ selNavObj, navigatorList, mapList, queryDeviceManage, }) => { //const [modalvisible, setModalvisible] = useState(false); //去掉全部设备的 设备列表 const [deviceList, setDeviceList] = useState([]); useEffect(() => { setDeviceList(navigatorList.slice(1)); }, []); const allOpenClick = (key) => { //debugger; console.log('key', key); confirm({ title: '请确认', icon: , content: `确认要全部开启${selNavObj.name}吗?`, okText: '确认', cancelText: '取消', onOk() { console.log('mapListmapList', mapList); //筛选 没有开启的空间 // var filterSpaceArr = mapList.filter((item) => { // return item[selNavObj.id] !== 1; // }); var filterSpaceArr2 = mapList.filter((item) => { return item.localName == '火卫一' || item.localName == '火卫二'; }); console.log('开启filterSpaceArr', filterSpaceArr2); var flag = 1; function getDeviceStatus() { flag = flag + 1; queryDeviceManage().then((res) => { if (flag < 13) { setTimeout(() => { getDeviceStatus(); }, 800); } else { flag = 1; } }); } //如果是空调 //if (filterSpaceArr.length == 0) return; if (selNavObj.id == 'airConditioner') { changeAllAir(mapList, getDeviceStatus, '打开', projectId); } if (selNavObj.id == 'light') { changeLight('all', mapList, getDeviceStatus, '打开'); } if (selNavObj.id == 'curtain') { changeCurtain('all', mapList, getDeviceStatus, '打开'); // '关闭' : '打开'; } }, onCancel() { //console.log('Cancel'); }, }); }; const { confirm } = Modal; const allCloseClick = () => { console.log('showModal'); // setModalvisible(true); confirm({ title: '请确认', icon: , content: `确认要全部关闭${selNavObj.name}吗?`, okText: '确认', cancelText: '取消', onOk() { // var filterSpaceArr = mapList.filter((item) => { // return item[selNavObj.id] !== 0; // }); var filterSpaceArr2 = mapList.filter((item) => { return item.localName == '火卫一' || item.localName == '火卫二'; }); console.log('关闭filterSpaceArr', filterSpaceArr2); //return; var flag = 1; function getDeviceStatus() { flag = flag + 1; queryDeviceManage().then((res) => { if (flag < 13) { setTimeout(() => { getDeviceStatus(); }, 800); } else { flag = 1; } }); // setTimeout(() => { // console.log('setTimeout'); // clearInterval(interval); // }, 60000); } //如果是空调 if (selNavObj.id == 'airConditioner') { changeAllAir(mapList, getDeviceStatus, '关闭', projectId); } if (selNavObj.id == 'light') { changeLight('all', mapList, getDeviceStatus, '关闭'); } if (selNavObj.id == 'curtain') { changeCurtain('all', mapList, getDeviceStatus, '关闭'); } }, onCancel() { //console.log('Cancel'); }, }); }; return ( <> {/* 全部设备 */} {selNavObj.id === 'all' && (
运行中的设备
{deviceList.map(function (litem, index) { return (
{litem.num}
); })}
)} {/* 设备 */} {selNavObj.id !== 'all' && (
运行中的设备
{selNavObj.num}
{/* */} 全部关闭
{/* ...下拉菜单 */} allOpenClick(key)}> 全部开启 } >
)} {/*

确定全部开启吗

*/} ); }; export default TopNavRight;