This commit is contained in:
maplemei
2019-12-18 18:10:56 +08:00
parent 036126d58c
commit 1af1f03195
12 changed files with 129 additions and 31 deletions

View File

@@ -246,6 +246,10 @@ class Framework extends Component{
//select框被点击
onClick(e){
if(this.props.model.type === 'relative'){
return ;
}
if(this.props.disabled){
this.state.show !== false && this.setState({ show: false });
return ;
@@ -382,7 +386,7 @@ class Framework extends Component{
<i class={ show ? 'xm-icon xm-icon-expand' : 'xm-icon' } />
{ sels.length === 0 && <div class="xm-tips">{ config.tips }</div> }
<Label { ...labelProps } />
<div class={ show ? 'xm-body' : 'xm-body dis' } ref={ ref => this.bodyView = ref}>
<div class={ ['xm-body', config.model.type, show ? '':'dis', ].join(' ') } ref={ ref => this.bodyView = ref}>
{ Body }
</div>
{ disabled && <div class="xm-select-disabled"></div> }
@@ -439,7 +443,12 @@ class Framework extends Component{
//此时页面又被重新渲染了
componentDidUpdate(){
let { direction } = this.props;
let { direction, model } = this.props;
if(model.type === 'relative'){
return ;
}
let rect = this.base.getBoundingClientRect();
if(direction === 'auto'){
//用于控制js获取下拉框的高度

View File

@@ -20,20 +20,24 @@ class Tree extends Component{
}
init(props){
const { tree, dataObj, prop } = props;
const { value } = prop
const { tree, dataObj, flatData, prop } = props;
const { value, optgroup } = prop
let keys = [];
tree.expandedKeys.forEach(key => {
keys.push(key);
if(tree.expandedKeys === true){
keys = flatData.filter(item => item[optgroup] === true).map(item => item[value])
}else{
tree.expandedKeys.forEach(key => {
keys.push(key);
let item = dataObj[key];
while(item){
let pkey = item[value];
keys.findIndex(k => k === pkey) === -1 && (keys.push(pkey))
item = item.__node.parent
}
});
let item = dataObj[key];
while(item){
let pkey = item[value];
keys.findIndex(k => k === pkey) === -1 && (keys.push(pkey))
item = item.__node.parent
}
});
}
this.setState({ expandedKeys: keys })
}

View File

@@ -138,7 +138,8 @@ export default function (lan = 'zn') {
}
},
},
icon: 'show',
icon: 'show',
type: 'absolute',
},
// 展开下拉框

View File

@@ -117,6 +117,7 @@ xm-select{
}
.xm-label-block > span{
white-space: unset;
height: 100%;
}
}
@@ -198,6 +199,17 @@ xm-select{
bottom: 42px;
}
&.relative{
position: relative;
display: block !important;
top: 0;
box-shadow: none;
border: none;
animation-name: none;
animation-duration: 0;
min-width: 100%;
}
.xm-group{
cursor: default;
&-item{