Commit 623735d3 authored by suhuiguang's avatar suhuiguang

1.修改缺陷757

parent 876bde88
...@@ -796,13 +796,10 @@ class View3D extends Component { ...@@ -796,13 +796,10 @@ class View3D extends Component {
//选中区域变化 //选中区域变化
selectItemChange = (selectArea) => { selectItemChange = (selectArea) => {
this.a3dRef.changeDrawState(PEN_STATE.CLEARED);//清除当前路径 this.a3dRef.changeDrawState(PEN_STATE.CLEARED);//清除当前路径
// 结束绘制
this.setState({
drawing: false
});
this.setState({ this.setState({
selectArea, selectArea: { ...selectArea },
rightHeight: JSON.parse(selectArea.routePath).regionHeigth, drawing: false,// 结束绘制
rightHeight: selectArea.routePath ? JSON.parse(selectArea.routePath).regionHeigth : 10,
showRightPanel: true showRightPanel: true
}); });
} }
...@@ -848,7 +845,6 @@ class View3D extends Component { ...@@ -848,7 +845,6 @@ class View3D extends Component {
this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={item.routePath ? JSON.parse(item.routePath).routePath : ''} onCreated={(e) => {this.onRegionCreated(e,item);}} />); this.areas.push(<PolygonRegion {...this.areaStyles.normal} points={item.routePath ? JSON.parse(item.routePath).routePath : ''} onCreated={(e) => {this.onRegionCreated(e,item);}} />);
{this.getAreas(item.children);} {this.getAreas(item.children);}
} }
} else { } else {
if (dragItem) { if (dragItem) {
if ( dragItem && dragItem.parentId && dragItem.parentId === item.id) { if ( dragItem && dragItem.parentId && dragItem.parentId === item.id) {
...@@ -862,7 +858,6 @@ class View3D extends Component { ...@@ -862,7 +858,6 @@ class View3D extends Component {
} }
} }
} else { } else {
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
this.getAreas(item.children); this.getAreas(item.children);
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Connect, Tree, Search, Button } from 'amos-framework'; import { Tree, Search, Button } from 'amos-framework';
import imgStatic from '../../consts/imgStatic'; import imgStatic from '../../consts/imgStatic';
const moduleEditIcon = imgStatic.moduleEditIcon; const moduleEditIcon = imgStatic.moduleEditIcon;
const eventConnect = Connect.eventConnect;
const TreeNode = Tree.TreeNode; const TreeNode = Tree.TreeNode;
const getParentKey = (key, tree) => { const getParentKey = (key, tree) => {
let parentKey; let parentKey;
for (let i = 0; i < tree.length; i++) { for (let i = 0; i < tree.length; i++) {
const node = tree[i]; const node = tree[i];
if (node.children && node.children.length >0) { if (node.children && node.children.length > 0) {
if (node.children.some(item => item.id === key)) { if (node.children.some(item => item.id === key)) {
parentKey = node.id; parentKey = node.id;
} else if (getParentKey(key, node.children)) { } else if (getParentKey(key, node.children)) {
...@@ -21,7 +20,9 @@ const getParentKey = (key, tree) => { ...@@ -21,7 +20,9 @@ const getParentKey = (key, tree) => {
return parentKey; return parentKey;
}; };
@eventConnect /**
* 区域绑定树
*/
class AreaLeftTree extends Component { class AreaLeftTree extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -36,42 +37,32 @@ class AreaLeftTree extends Component { ...@@ -36,42 +37,32 @@ class AreaLeftTree extends Component {
treeDataList: [], treeDataList: [],
searchValue: '' searchValue: ''
}; };
} }
componentDidMount() { componentWillMount() {
let {treeData,pointTypeArr,treeDataList} = this.props; const { treeData, pointTypeArr, treeDataList } = this.props;
this.setState({ this.setState({
treeData, treeData,
treeDataList, treeDataList,
pointTypeArr, pointTypeArr,
pointType: pointTypeArr[0]?pointTypeArr[0].code:'' pointType: pointTypeArr[0] ? pointTypeArr[0].code : ''
}) });
} }
componentWillUnmount() {
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(nextProps) console.log(nextProps);
let {treeData,pointTypeArr,pageType,treeDataList} = nextProps; const { treeData, pointTypeArr, treeDataList } = nextProps;
this.setState({ this.setState({
treeData, treeData,
pointTypeArr, pointTypeArr,
treeDataList, treeDataList,
pointType: pointTypeArr[0]?pointTypeArr[0].code:'' pointType: pointTypeArr[0] ? pointTypeArr[0].code : ''
}) });
} }
// onSelectChange = (value, item) =>{
// console.log(value, item);
// this.state.pointType = value;
// this.props.pointTypeChange(value);
// }
onSearchChange = e => { onSearchChange = e => {
const {treeDataList,treeData} = this.state const { treeDataList, treeData } = this.state;
const value = e.target.value; const value = e.target.value;
const expandedKeys = treeDataList const expandedKeys = treeDataList
.map(item => { .map(item => {
...@@ -85,131 +76,106 @@ class AreaLeftTree extends Component { ...@@ -85,131 +76,106 @@ class AreaLeftTree extends Component {
expandedKeys, expandedKeys,
searchValue: value, searchValue: value,
autoExpandParent: true autoExpandParent: true
}); });
} };
onExpand = (expandedKeys) => { onExpand = expandedKeys => {
//console.log('onExpand', arguments);
// if not set autoExpandParent to false, if children expanded, parent can not collapse. // if not set autoExpandParent to false, if children expanded, parent can not collapse.
// or, you can remove all expanded children keys. // or, you can remove all expanded children keys.
this.setState({ this.setState({
expandedKeys, expandedKeys,
autoExpandParent: false autoExpandParent: false
}); });
} };
// onCheck = (checkedKeys,e) => {
// console.log('onCheck', checkedKeys);
// // console.log('onCheck', e);
// let currentKey = checkedKeys.checked[0]?checkedKeys.checked[checkedKeys.checked.length-1]:'';
// if (checkedKeys.checked.length<2) {
// currentKey = checkedKeys.checked[0]
// } else {
// if (checkedKeys.checked[0] == this.state.checkedKeys[0]) {
// currentKey = checkedKeys.checked[1]
// } else {
// currentKey = checkedKeys.checked[0]
// }
// }
// // checkedKeys[0] = checkedKeys[checkedKeys.length - 1]
// this.setState({ checkedKeys: currentKey?[currentKey]:[] });
// this.props.selectItemChange(currentKey);
// if (currentKey) {
// this.props.startDrow(currentKey);
// }else {
// this.props.stopDrowing()
// }
// }
drowArea = (editItem) => {
}
onTreeSelect = (selectedKeys, info) => { onTreeSelect = (selectedKeys, info) => {
console.log('onSelect', info); console.log('onSelect', info);
let selectItem = info.node.props.dataRef; let selectItem = info.node.props.dataRef;
this.setState({ selectedKeys }); this.setState({
selectedKeys
});
this.props.selectItemChange(selectItem); this.props.selectItemChange(selectItem);
} };
// onClick={(e)=>{e.nativeEvent.stopImmediatePropagation();e.stopPropagation();console.log(123123);}}
renderTreeNodes = (data) => { renderTreeNodes = data => {
let {searchValue} =this.state const { searchValue } = this.state;
// console.log(data); if (data.length > 0) {
if (data.length>0) { return data.map(item => {
return data.map((item) => {
const index = item.name.indexOf(searchValue); const index = item.name.indexOf(searchValue);
const beforeStr = item.name.substr(0, index); const beforeStr = item.name.substr(0, index);
const afterStr = item.name.substr(index + searchValue.length); const afterStr = item.name.substr(index + searchValue.length);
const title = const title =
index > -1 ? ( index > -1 ? (
<span> <span>
{beforeStr} {' '}
<span style={{ color: '#f50' }}>{searchValue}</span> {beforeStr}{' '}
{afterStr} <span
style={{
color: '#f50'
}}
>
{' '}
{searchValue}{' '}
</span>{' '}
{afterStr}{' '}
</span> </span>
) : ( ) : (
<span>{item.name}</span> <span> {item.name} </span>
); );
if (item.children) { if (item.children) {
return ( return (
<TreeNode <TreeNode
title={ title={
<div> <div>
{' '}
{ {
<span > <span>
{title} {' '}
<span className='icon'> {title}{' '}
{ <span className="icon">
item.isBind ? '' : {' '}
{item.isBind ? '' :
<img <img
src={moduleEditIcon.editBtn} src={moduleEditIcon.editBtn}
onClick={(e) => { alt=""
onClick={e => {
e.nativeEvent.stopImmediatePropagation(); e.nativeEvent.stopImmediatePropagation();
e.stopPropagation(); e.stopPropagation();
this.props.startDrow(item); this.props.startDrow(item);
}} }}
/> />
} }{' '}
{ {item.isBind ? <img src={moduleEditIcon.bindedTip} alt="" /> : item.routePath ? <img src={moduleEditIcon.noSaveTip} alt="" /> : <img src={moduleEditIcon.noSaveTip} alt="" />}{' '}
item.isBind ? <img src={moduleEditIcon.bindedTip} alt='' /> : </span>{' '}
item.routePath ? <img src={moduleEditIcon.noSaveTip} alt='' /> :
<img src={moduleEditIcon.noSaveTip} alt='' />
}
</span> </span>
</span> }{' '}
}
</div> </div>
} }
key={item.id} key={item.id}
dataRef={item} dataRef={item}
> >
{this.renderTreeNodes(item.children)} {this.renderTreeNodes(item.children)}{' '}
</TreeNode> </TreeNode>
); );
} }
}); });
} }
};
}
render() { render() {
let { treeData, checkedKeys,pointTypeArr,pointType} = this.state; const { treeData } = this.state;
let { pageType } = this.props;
return ( return (
<div className="leftTree"> <div className="leftTree">
<div className='leftContainer'> <div className="leftContainer">
<div className='topForm'> <div className="topForm">
<Search className='leftSearch' icon="search" onChange={this.onSearchChange} onIconClick={this.onSearchChange} /> <Search className="leftSearch" icon="search" onChange={this.onSearchChange} onIconClick={this.onSearchChange} />
</div> </div>
<div className='treeBox'> <div className="treeBox">
<Tree <Tree
// checkable selectable
// checkStrictly
selectable={true}
onExpand={this.onExpand} onExpand={this.onExpand}
expandedKeys={this.state.expandedKeys} expandedKeys={this.state.expandedKeys}
autoExpandParent={true} autoExpandParent
// onCheck={this.onCheck}
// checkedKeys={checkedKeys}
onSelect={this.onTreeSelect} onSelect={this.onTreeSelect}
selectedKeys={this.state.selectedKeys} selectedKeys={this.state.selectedKeys}
blockNode blockNode
...@@ -217,28 +183,31 @@ class AreaLeftTree extends Component { ...@@ -217,28 +183,31 @@ class AreaLeftTree extends Component {
{this.renderTreeNodes(treeData)} {this.renderTreeNodes(treeData)}
</Tree> </Tree>
</div> </div>
<div className='bottomBtns'> <div className="bottomBtns">
<Button <Button
className='sureBtn' className="sureBtn"
onClick={() => { onClick={() => this.props.saveAreaData()}
this.props.saveAreaData() />
}} ></Button>
<Button <Button
className='deleteBtn' className="deleteBtn"
onClick={() => { onClick={() => this.props.deleteAreaBind()}
this.props.deleteAreaBind() />
}} ></Button>
</div> </div>
</div> </div>
</div> </div>
); );
} }
} }
AreaLeftTree.propTypes = { AreaLeftTree.propTypes = {
subscribe: PropTypes.func, treeData: PropTypes.array,
trigger: PropTypes.func pointTypeArr: PropTypes.array,
treeDataList: PropTypes.array,
saveAreaData: PropTypes.func,
deleteAreaBind: PropTypes.func,
pageType: PropTypes.string,
startDrow: PropTypes.func,
selectItemChange: PropTypes.func
}; };
export default AreaLeftTree; export default AreaLeftTree;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment