/*
* @Author: your name
* @Date: 2022-04-11 17:19:22
* @Description:
* @FilePath: /zl-large-screen/src/components/LargeScreenSetting/index.tsx
*/
import React from 'react';
import LargeScreenTitle from '../LargeScreenTitle/index';
import LargeScreenSettingMain from './LargeScreenSettingMain/index';
import ControlBtn from '../Control-btn/index';
import LabelAlign from '../Unit/LabelAlign/index';
import Icon from '../Icon/index';
import LargeScreenLayerInput from '../LargeScreenLayer/LargeScreenLayerInput/index';
import Sortable from 'sortablejs';
import {
ILargeScreenSettingProps,
ILargeScreenSettingState
} from '../../type/LargeScreenSetting';
import { alignList } from '../../options/layout';
import { Dropdown, Menu, Popover } from 'antd';
import { gisChildLayer } from '../../options/layout';
class LargeScreenSetting extends React.Component<
ILargeScreenSettingProps,
ILargeScreenSettingState
> {
constructor(props: ILargeScreenSettingProps) {
super(props);
this.state = {
settingData: this.props.settingData,
collapseDefaultActiveKey: this.props.collapseDefaultActiveKey,
controlClass: '', //控制展开收起按钮样式
wrapClass: '', //控制展开收起按钮样式
iconType: 'icon-arrow-right-bold', ////控制展开收起按钮icon,
scenes: this.props.scenes, // 场景列表,用于交互
sceneSelectId: this.props.sceneSelectId, // 选中场景的页id
cockpitList: this.props.cockpitList, // 驾驶舱列表
GISChildren: this.props.GISChildren, //地图子组件
gisChildLayerMenuList: [
{
key: 'shangyi',
label: '上移一层',
icon:
},
{
key: 'xiayi',
label: '下移一层',
icon:
},
{ key: 'del', label: '删除', icon: },
{
key: 'rename',
label: '重命名',
icon:
}
],
isCurrentInput: -1,
isVisible: false, //开关
sortableRef: null,
dragRef: false
};
}
componentDidUpdate(prevProps, prevState) {
if (this.props.settingData !== prevProps.settingData) {
this.setState({ settingData: this.props.settingData });
}
if (
this.props.collapseDefaultActiveKey !== prevProps.collapseDefaultActiveKey
) {
this.setState({
collapseDefaultActiveKey: this.props.collapseDefaultActiveKey
});
}
if (this.props.scenes !== prevProps.scenes) {
this.setState({ scenes: this.props.scenes });
}
if (this.props.cockpitList !== prevProps.cockpitList) {
this.setState({ cockpitList: this.props.cockpitList });
}
if (this.props.GISChildren !== prevState.GISChildren) {
if (this.props.GISChildren?.length > 0 && this.refs.mapListRef) {
this.state.sortableRef && this.state.sortableRef.destroy();
this.initSort();
}
this.setState({ GISChildren: this.props.GISChildren });
}
document.addEventListener('mousedown', this.mousedown);
}
mousedown = (e) => {
if (
!(
this.elementContains(
document.querySelector('.zl-lagre-screen-add-gis-child-popover'),
e.target
) ||
this.elementContains(
document.querySelector('.zl-large-screen-setting'),
e.target
)
)
) {
this.setState({ isVisible: false });
}
};
// 判断父元素是否包含某个元素
elementContains = (parent, child) =>
parent !== child && parent?.contains(child);
//展开收起的样式
controlBtnClick = () => {
if (this.state.wrapClass) {
this.setState({
wrapClass: '',
controlClass: '',
iconType: 'icon-arrow-right-bold'
});
} else {
this.setState({
wrapClass: 'zl-component-com-siler-close',
controlClass: 'zl-right-control-up',
iconType: 'icon-arrow-left-bold'
});
}
this.props?.clickControlBtn('setting');
};
zoomMenu = (item, index) => {
let menu = [...this.state.gisChildLayerMenuList];
return (