|
@@ -2,9 +2,9 @@ import react from "react";
|
|
|
import style from "./index.less";
|
|
|
import $ from 'jquery';
|
|
|
import classNames from 'classnames';
|
|
|
-import {handleEnter,isIE,filterArr,deepClone,filterDataArr} from '@utils/tools.js';
|
|
|
+import {handleEnter,isIE,filterArr,deepClone,filterDataArr,getPageCoordinate} from '@utils/tools.js';
|
|
|
import {Notify} from '@commonComp';
|
|
|
-import ReactDom from "react-dom";
|
|
|
+import SlideItem from "./SlideItem";
|
|
|
import config from '@config/index.js';
|
|
|
/**
|
|
|
单列多选组件(tagtype=1,controlType=2)
|
|
@@ -28,7 +28,9 @@ class Multiple extends react.Component{
|
|
|
seleData:seleData||"",
|
|
|
seleId:seleId||[],
|
|
|
boxLeft:null,
|
|
|
- boxTop:null
|
|
|
+ boxTop:null,
|
|
|
+ tmpScroll:null,
|
|
|
+ tmpTop:null
|
|
|
}
|
|
|
this.$div = React.createRef();
|
|
|
this.handleShow = this.handleShow.bind(this);
|
|
@@ -37,7 +39,6 @@ class Multiple extends react.Component{
|
|
|
this.onChange = this.onChange.bind(this);
|
|
|
this.handleBlur = this.handleBlur.bind(this);
|
|
|
this.handleClear = this.handleClear.bind(this);
|
|
|
- this.handleComfirn = this.handleComfirn.bind(this);
|
|
|
}
|
|
|
|
|
|
getClass(){
|
|
@@ -74,8 +75,16 @@ class Multiple extends react.Component{
|
|
|
const ht = e.target.offsetHeight; //如杂音选中文字有多行时,写死会遮挡
|
|
|
let boxTop = offsetTop + ht +2 + 'px';
|
|
|
this.setState({
|
|
|
- boxLeft:boxLeft,
|
|
|
- boxTop:boxTop
|
|
|
+ boxLeft:getPageCoordinate(e).boxLeft,
|
|
|
+ boxTop:getPageCoordinate(e).boxTop,
|
|
|
+ tmpScroll: $("#addScrollEvent")[0].scrollTop,
|
|
|
+ tmpTop:getPageCoordinate(e).boxTop
|
|
|
+ })
|
|
|
+ $("#addScrollEvent").scroll(()=>{
|
|
|
+ let scrollYs = $("#addScrollEvent")[0].scrollTop;
|
|
|
+ this.setState({
|
|
|
+ boxTop:this.state.tmpTop - scrollYs + this.state.tmpScroll
|
|
|
+ })
|
|
|
})
|
|
|
this.setStateInit();
|
|
|
const {ikey,handleShow,placeholder,flag,id,value,tagType,type} = this.props;
|
|
@@ -182,14 +191,6 @@ class Multiple extends react.Component{
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- handleComfirn(e){
|
|
|
- e&&e.stopPropagation();
|
|
|
- const {handleConfirm,ikey,order,mainSaveText,value,handleHide,type} = this.props;
|
|
|
- const params = Object.assign({},this.state,{ikey,order,mainSaveText,value,type});
|
|
|
- handleConfirm&&handleConfirm(params);
|
|
|
- handleHide&&handleHide();
|
|
|
- }
|
|
|
-
|
|
|
componentDidMount(){
|
|
|
if(isIE()){
|
|
|
$(this.$div.current).onIe8Input(function(e){
|
|
@@ -197,21 +198,10 @@ class Multiple extends react.Component{
|
|
|
},this);
|
|
|
}
|
|
|
}
|
|
|
- getStyle(){
|
|
|
- const {left,top,show} = this.props;
|
|
|
- return {
|
|
|
- left:left?left+'px':'0',
|
|
|
- top:top?top+'px':'0',
|
|
|
- display:show?'table':'none' //table onBlur阻止冒泡是为了修复multSpread中数字键盘点击触发最外层数字组件onBlur事件
|
|
|
- }
|
|
|
- }
|
|
|
render(){
|
|
|
- const {placeholder,value,show,data} = this.props;
|
|
|
- console.log(placeholder,'name')
|
|
|
+ const {placeholder,value,show,data,handleConfirm,ikey,order,mainSaveText,handleHide,type} = this.props;
|
|
|
const {editable,boxTop,boxLeft} = this.state;
|
|
|
- const domNode = document.getElementById('root');
|
|
|
- return ReactDom.createPortal(<div className={style["container"]}>
|
|
|
- {/* return <div className={style["container"]}> */}
|
|
|
+ return <div className={style["container"]}>
|
|
|
<div className={this.getClass()}
|
|
|
ref={this.$div}
|
|
|
onClick={this.handleShow}
|
|
@@ -220,18 +210,20 @@ class Multiple extends react.Component{
|
|
|
onInput={this.onChange}
|
|
|
onkeydown={handleEnter}
|
|
|
contentEditable={editable}>{value||placeholder}</div>
|
|
|
- <div className={this.getListClass()} style={{top:boxTop,left:boxLeft}} contentEditable="false">
|
|
|
- <ul>
|
|
|
- {data&&data.map((it)=>{
|
|
|
- return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getSeleStyle(it.id)} title={it.name.length>8?it.name:''}>{it.name&&it.name.length>8?it.name.slice(0,8)+'...':it.name}</li>
|
|
|
- })}
|
|
|
- <li onClick={this.handleClear} className={style['mClear']}>清空选项</li>
|
|
|
- <li onClick={this.handleComfirn} className={style['mConfirm']}>确定</li>
|
|
|
- </ul>
|
|
|
-
|
|
|
+ <div className={this.getListClass()} contentEditable="false">
|
|
|
+ <SlideItem
|
|
|
+ show={show}
|
|
|
+ left={boxLeft}
|
|
|
+ top={boxTop}
|
|
|
+ data={data}
|
|
|
+ handleConfirm={handleConfirm}
|
|
|
+ ikey={ikey}
|
|
|
+ order={order}
|
|
|
+ mainSaveText={mainSaveText}
|
|
|
+ handleHide={handleHide}
|
|
|
+ type={type}></SlideItem>
|
|
|
</div>
|
|
|
- {/* </div> */}
|
|
|
- </div>,domNode)
|
|
|
+ </div>
|
|
|
}
|
|
|
|
|
|
}
|