|
@@ -2,6 +2,7 @@ import classNames from "classnames";
|
|
import {Component} from "react";
|
|
import {Component} from "react";
|
|
import ScrollArea from 'react-scrollbar';
|
|
import ScrollArea from 'react-scrollbar';
|
|
import {getIds} from '@utils/tools.js';
|
|
import {getIds} from '@utils/tools.js';
|
|
|
|
+import LiItem from '@common/components/LiItem';
|
|
import style from './index.less';
|
|
import style from './index.less';
|
|
|
|
|
|
class ListItem extends Component{
|
|
class ListItem extends Component{
|
|
@@ -10,7 +11,7 @@ class ListItem extends Component{
|
|
this.getData = this.getData.bind(this);
|
|
this.getData = this.getData.bind(this);
|
|
this.getLis = this.getLis.bind(this);
|
|
this.getLis = this.getLis.bind(this);
|
|
}
|
|
}
|
|
- handleClick(e,item,i){
|
|
|
|
|
|
+ handleClick(item,i,e){
|
|
e.stopPropagation();
|
|
e.stopPropagation();
|
|
// window.event? window.event.cancelBubble = true : e.stopPropagation();
|
|
// window.event? window.event.cancelBubble = true : e.stopPropagation();
|
|
const {handleClick,isExclu,isRadio,data,exists,noneIds,withs,joint,listIndex} = this.props;
|
|
const {handleClick,isExclu,isRadio,data,exists,noneIds,withs,joint,listIndex} = this.props;
|
|
@@ -61,16 +62,35 @@ class ListItem extends Component{
|
|
return '';
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- getLis(datas,isSpecialPos){
|
|
|
|
|
|
+ getLis(){
|
|
|
|
+ const {exclusion,noneIds,exists,withs,ban,isSpecialPos,datas} = this.props;
|
|
|
|
+ let type=''; //选中样式类型
|
|
|
|
+ let selected = false; //是否选中
|
|
|
|
+ const list = Object.keys(ban).length>0?[...exists,...withs,ban]:[...exists,...withs];
|
|
|
|
+ const arrs = [...noneIds,...getIds(list)]; //非无殊选中项id集合
|
|
return datas&&datas.map((it,i)=>{
|
|
return datas&&datas.map((it,i)=>{
|
|
if(isSpecialPos){
|
|
if(isSpecialPos){
|
|
- return <li onClick={(e)=>this.handleClick(e,it,i)} className={this.getClass(it.id)}>{it.name}</li>
|
|
|
|
|
|
+ //无殊部分,非无殊项有选中,则无殊项灰显(仍可点,选中非无殊项取消选中,反之亦然)
|
|
|
|
+ selected = exclusion===it.id;
|
|
|
|
+ return <LiItem handleClick={this.handleClick.bind(this,it,i)}
|
|
|
|
+ selected={selected}
|
|
|
|
+ noDot={true}
|
|
|
|
+ disabled={(exclusion&&!selected)||arrs.length>0}
|
|
|
|
+ type='check'
|
|
|
|
+ >{it.name}</LiItem>
|
|
}
|
|
}
|
|
- return <li onClick={(e)=>this.handleClick(e,it,i)} className={this.getClass(it.id)} title={it.name.length>8?it.name:''}>{it.name&&it.name.length>8?it.name.slice(0,8)+'...':it.name}</li>
|
|
|
|
|
|
+ //非无殊项,有无殊项被选中,则灰显,“无”选中黑√随后选中的项也黑√选中,
|
|
|
|
+ type = noneIds.includes(it.id)?'noneCheck':'check';
|
|
|
|
+ selected = arrs.includes(it.id);
|
|
|
|
+ return <LiItem handleClick={this.handleClick.bind(this,it,i)}
|
|
|
|
+ type={type}
|
|
|
|
+ selected={selected}
|
|
|
|
+ disabled={exclusion}
|
|
|
|
+ title={it.name.length>8?it.name:''}>{it.name&&it.name.length>8?it.name.slice(0,8)+'...':it.name}</LiItem>
|
|
})
|
|
})
|
|
}
|
|
}
|
|
getData(){
|
|
getData(){
|
|
- const {datas,isSpecialPos} = this.props;
|
|
|
|
|
|
+ const {datas} = this.props;
|
|
const contStyle={
|
|
const contStyle={
|
|
opacity:'0.4',
|
|
opacity:'0.4',
|
|
right:'0',
|
|
right:'0',
|
|
@@ -82,7 +102,7 @@ class ListItem extends Component{
|
|
if(!datas||datas.length===0){
|
|
if(!datas||datas.length===0){
|
|
return <li className={style['no-push-data']}>暂无推送</li>
|
|
return <li className={style['no-push-data']}>暂无推送</li>
|
|
}
|
|
}
|
|
- const liArr = this.getLis(datas,isSpecialPos);
|
|
|
|
|
|
+ const liArr = this.getLis();
|
|
if(datas&&datas.length>11){
|
|
if(datas&&datas.length>11){
|
|
//超过最多显示条数,添加自定义滚动条,不能全部添加,不需要滚动条时不能阻止外部滚动条滚动事件
|
|
//超过最多显示条数,添加自定义滚动条,不能全部添加,不需要滚动条时不能阻止外部滚动条滚动事件
|
|
return <ScrollArea speed={0.8}
|
|
return <ScrollArea speed={0.8}
|
|
@@ -100,17 +120,19 @@ class ListItem extends Component{
|
|
}
|
|
}
|
|
|
|
|
|
getMainData(){//主诉添加症状-带搜索框
|
|
getMainData(){//主诉添加症状-带搜索框
|
|
- const {datas,isSpecialPos} = this.props;
|
|
|
|
|
|
+ const {exists,withs,ban,datas} = this.props;
|
|
if(!datas||datas.length===0){
|
|
if(!datas||datas.length===0){
|
|
return <li className={style['no-push-data']}>暂无推送数据,可通过搜索查找更多内容~ </li>
|
|
return <li className={style['no-push-data']}>暂无推送数据,可通过搜索查找更多内容~ </li>
|
|
}
|
|
}
|
|
|
|
+ const arrs = getIds([...exists,...withs,ban]); //非无殊选中项id集合
|
|
return datas&&datas.map((it,i)=>{
|
|
return datas&&datas.map((it,i)=>{
|
|
- return <li onClick={(e)=>this.handleClick(e,it,i)}
|
|
|
|
- className={this.getClass(it.id)}
|
|
|
|
|
|
+ return <LiItem handleClick={this.handleClick.bind(this,it,i)}
|
|
|
|
+ selected={arrs.includes(it.id)}
|
|
|
|
+ noDot={true}
|
|
title={it.name.length>4?it.name:''}
|
|
title={it.name.length>4?it.name:''}
|
|
style={{'width':'55px','display':'inline-block'}}>
|
|
style={{'width':'55px','display':'inline-block'}}>
|
|
{it.name&&it.name.length>4?it.name.slice(0,4)+'...':it.name}
|
|
{it.name&&it.name.length>4?it.name.slice(0,4)+'...':it.name}
|
|
- </li>
|
|
|
|
|
|
+ </LiItem>
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|