Browse Source

默认值配置bug修改

zhouna 5 years ago
parent
commit
0f1e708368
2 changed files with 22 additions and 13 deletions
  1. 15 8
      src/components/SpreadDrop/index.jsx
  2. 7 5
      src/containers/SpreadDrop.js

+ 15 - 8
src/components/SpreadDrop/index.jsx

@@ -169,9 +169,10 @@ class SpreadDrop extends Component{
     });
   }
   getInitExclu(){
-    const {defaulted,labelDefault,data,value} = this.props;
+    const {defaulted,data,value} = this.props;
     let excluId = '',excName='';
-    if(labelDefault&&defaulted&&value===undefined){
+    let showDefaulted = this.ifDefault();
+    if(showDefaulted&&defaulted&&value===undefined){
       const it = data[0];
       excluId = it.exclusionType===1?it.questionDetailList[0].id:'';
       excName = it.exclusionType===1?it.questionDetailList[0].name:'';
@@ -340,21 +341,26 @@ class SpreadDrop extends Component{
     });
   }
   getClass(){
-    const {isImports,show,value,isExtBlue,defaulted,labelDefault} = this.props;
+    const {isImports,show,value,isExtBlue,defaulted} = this.props;
     const blueBorder = this.state.editable?style['blue-border']:'';
     const orgBorder = isImports&&!value?style['orange-border']:'';
     const ext = isExtBlue?style['ext']:'';
+    let showDefaulted = this.ifDefault();
     if(show){
       $(this.$div.current).addClass(style['borderd']);
     }else{
       $(this.$div.current).removeClass(style['borderd']);
     }
-    if(value||(labelDefault&&value===undefined&&defaulted)){
+    if(value||(showDefaulted&&value===undefined&&defaulted)){
       return classNames(style['selected-tag'],blueBorder);
     }
     return classNames(style['tag'],orgBorder,ext);
   }
-
+  ifDefault(){
+    const {type,otherDefault,curDefault} = this.props;
+    const showDefaulted = (type=='2'&&curDefault)||(type=='3'&&otherDefault);
+    return showDefaulted;
+  }
   componentDidMount(){
     if(isIE()){
       $(this.$div.current).onIe8Input(function(e){
@@ -363,9 +369,10 @@ class SpreadDrop extends Component{
     }
   }
   render(){
-    const {placeholder,value,show,data,order,type,tagType,ikey,pos,defaulted,labelDefault,showVal} = this.props;
+    const {placeholder,value,show,data,order,type,tagType,pos,defaulted,showVal} = this.props;
     const {tmpDom,left} = this.state;
-    let showV = labelDefault&&value===undefined?showVal:value;       //未选中过值时展示默认选中
+    let showDefaulted = this.ifDefault();
+    let showV = showDefaulted&&value===undefined?showVal:value;       //未选中过值时展示默认选中
     if(!show&&tmpDom){
       $(tmpDom).parent().prev().attr({"contentEditable":true})
     }
@@ -384,7 +391,7 @@ class SpreadDrop extends Component{
         onInput={this.onChange}
         onkeydown={handleEnter}
         >{showV||placeholder}</div>
-          <ListItems parDiv={this.$list} defaulted={labelDefault&&defaulted} pos={pos} data={data} order={order} left={left} boxMark={type} tagType={tagType}
+          <ListItems parDiv={this.$list} defaulted={showDefaulted&&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>
   }

+ 7 - 5
src/containers/SpreadDrop.js

@@ -15,15 +15,17 @@ import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText,ch
 import config from '@config/index.js';
 
 function mapStateToProps(state) {//console.log(state);
-  const {typeConfig,mainSuit,homePage} = state;
-  const hasReadMode = typeConfig.readConfig!==-1&&typeConfig.readConfig[2]!==null;
-  const docOtherMode = typeConfig.typeConfig[2];
-  const curOtherMode =hasReadMode?typeConfig.readConfig[2]:docOtherMode;
+  const {mainSuit,homePage} = state;
+  const {readConfig,typeConfig}=state.typeConfig;
+  const hasReadMode = readConfig!==-1;
+  const curOtherMode =hasReadMode&&readConfig[2]!==null?readConfig[2]:typeConfig[2];
+  const curMode =hasReadMode&&readConfig[1]!==null?readConfig[1]:typeConfig[1];
   return {
     mainSaveText:mainSuit.saveText,
     mainData:mainSuit.data,
     windowWidth:homePage.windowWidth,
-    labelDefault:+curOtherMode===1,
+    otherDefault:+curOtherMode===1,
+    curDefault:+curMode===1,
   }
 }