|
@@ -32,16 +32,17 @@ class SpreadDrop extends Component{
|
|
|
constructor(props){
|
|
|
super(props);
|
|
|
const {nones,noneOn,noneIds,withOn,exists,nowOn,withs,exclusion,excluName} = deepClone(props.selecteds||[]);
|
|
|
+ const initEx = this.getInitExclu();
|
|
|
this.state = {
|
|
|
nones:nones||'', //无,字符串拼接
|
|
|
exists:exists||[], //主症状id
|
|
|
- excluName:excluName||'',
|
|
|
+ excluName:excluName||initEx.excName,
|
|
|
withs:withs||[], //伴随 id
|
|
|
noneIds:noneIds||[],
|
|
|
noneOn:noneOn||false, //无是否选中
|
|
|
withOn:withOn||false, //伴是否选中
|
|
|
nowOn:nowOn||'', //最近选中“无”还是“伴”
|
|
|
- exclusion:exclusion||'', //选中互斥项id
|
|
|
+ exclusion:exclusion||initEx.excluId, //选中互斥项id
|
|
|
timer:null, //延时,区分单击双击
|
|
|
ban:{}, //放'伴'字段
|
|
|
editable:false, //双击编辑
|
|
@@ -166,21 +167,33 @@ class SpreadDrop extends Component{
|
|
|
this.setState({
|
|
|
editable:false
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ getInitExclu(){
|
|
|
+ const {defaulted,data,value} = this.props;
|
|
|
+ let excluId = '',excName='';
|
|
|
+ if(defaulted&&value===undefined){
|
|
|
+ const it = data[0];
|
|
|
+ excluId = it.exclusionType===1?it.questionDetailList[0].id:'';
|
|
|
+ excName = it.exclusionType===1?it.questionDetailList[0].name:'';
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ excluId,
|
|
|
+ excName
|
|
|
+ }
|
|
|
}
|
|
|
setStateInit(){
|
|
|
const {nones,noneOn,noneIds,withOn,exists,nowOn,withs,exclusion,excluName,ban} = deepClone(this.props.selecteds||[]);
|
|
|
+ const initEx = this.getInitExclu();
|
|
|
this.setState({
|
|
|
nones:nones||'',
|
|
|
exists:exists||[],
|
|
|
- excluName:excluName||'',
|
|
|
+ excluName:excluName||initEx.excName,
|
|
|
withs:withs||[],
|
|
|
noneIds:noneIds||[],
|
|
|
noneOn:noneOn||false,
|
|
|
withOn:withOn||false,
|
|
|
nowOn:nowOn||'',
|
|
|
- exclusion:exclusion||'',
|
|
|
+ exclusion:exclusion||initEx.excluId,
|
|
|
ban:ban||{},
|
|
|
});
|
|
|
}
|
|
@@ -363,8 +376,8 @@ class SpreadDrop extends Component{
|
|
|
}
|
|
|
}*/
|
|
|
render(){
|
|
|
- const {placeholder,value,show,data,order,type,tagType,ikey,pos} = this.props;
|
|
|
- const {tmpDom,left} = this.state
|
|
|
+ const {placeholder,value,show,data,order,type,tagType,ikey,pos,defaulted} = this.props;
|
|
|
+ const {tmpDom,left} = this.state;
|
|
|
const clickIndx = ikey.split('-')[1];//展开下拉的index
|
|
|
if(!show&&tmpDom){
|
|
|
$(tmpDom).parent().prev().attr({"contentEditable":true})
|
|
@@ -384,7 +397,7 @@ class SpreadDrop extends Component{
|
|
|
onInput={this.onChange}
|
|
|
onkeydown={handleEnter}
|
|
|
>{value||placeholder}</div>
|
|
|
- <ListItems parDiv={this.$list} pos={pos} data={data} order={order} left={left} boxMark={type} tagType={tagType}
|
|
|
+ <ListItems parDiv={this.$list} defaulted={defaulted} pos={pos} data={data} order={order} left={left} boxMark={type} tagType={tagType}
|
|
|
show={show} handleSelect={this.handleSelect} handleConfirm={this.handleConfirm} handleClear={this.handleClear} {...this.state}></ListItems>
|
|
|
</div>
|
|
|
}
|