Browse Source

Merge remote-tracking branch 'origin/ChronicMag' into ChronicMag

zhouna 6 years ago
parent
commit
9611eff953

+ 16 - 3
src/common/components/InlineTag/index.jsx

@@ -21,7 +21,7 @@ class InlineTag extends Component {
     this.$span = React.createRef();
     this.state = {
       editable:false,
-      value:props.value
+      value:props.value||''
     };
     this.changeToEdit = this.changeToEdit.bind(this);
     this.changeToClick = this.changeToClick.bind(this);
@@ -47,17 +47,30 @@ class InlineTag extends Component {
     });
   }
   handleInput(e){       //输入时保存临时值,在修改灰显为黑色时判断用
+    const {handleInput,ikey,prefix,suffix} = this.props;
     const text = e.target.innerText || e.target.innerHTML;
+    // 内容全部删除时,要把空值存到store,否则会遗留最后一个字且为灰色无法删除
+    if(!text){
+      this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML='');      //修改生成文字变成输入的2倍bug
+      handleInput&&handleInput({text:text,ikey,prefix,suffix});
+      this.setState({
+        value:" "
+      });
+      return
+    }
     this.setState({
       value:text
     });
-   // e.target.innerText = text;
+   // e.target.innerText = text;  
   }
   handleBlur(e){         //鼠标离开是保存值到store中
     const {value} = this.state;
     const {handleInput,ikey,prefix,suffix} = this.props;
     this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML='');      //修改生成文字变成输入的2倍bug
-    handleInput&&handleInput({text:value,ikey,prefix,suffix});
+    handleInput&&handleInput({text:value.trim(),ikey,prefix,suffix});
+    this.setState({
+      value:value.trim()
+    });
   }
   handleFocus(e){
     e.stopPropagation();

+ 12 - 3
src/components/ChronicInfo/index.jsx

@@ -116,9 +116,18 @@ class ChronicInfo extends React.Component{
     })
   }
   closeOption(){
-    this.setState({
-      optionId:null
-    })
+    // 关闭-有可能结果则保持与结果一致,没有就保持最新选择的内容
+    let {possible,radioVal} = this.state;
+    if(JSON.stringify(possible)=='{}'){
+      this.setState({
+        optionId:null
+      })
+    }else{
+      this.setState({
+        radioVal:Object.assign({},radioVal,possible),
+        optionId:null,
+      });
+    } 
   }
   showTable(it,parentId,parentIndex){
     const {formulaResult,scaleInfo} = this.props;

+ 6 - 6
src/components/NumberDrop/index.jsx

@@ -39,7 +39,7 @@ class NumberDrop extends Component{
     this.handleNumFocus = this.handleNumFocus.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
     this.changeToEdit = this.changeToEdit.bind(this);
-    //this.handleKeyDowm = this.handleKeyDowm.bind(this);
+    // this.handleKeyDowm = this.handleKeyDowm.bind(this);
     this.beyondArea = this.beyondArea.bind(this);
   }
   select(text){        //选中键盘上数字事件
@@ -191,17 +191,17 @@ class NumberDrop extends Component{
     const {handleHide} = this.props;
     handleHide&&handleHide();
   }
-  /*handleKeyDowm(e){
-    handleEnter();
+  // handleKeyDowm(e){
+    // handleEnter();
     //只能输入数字
-    const key = e.key;
+    /*const key = e.key;
     const ctrlOn = e.ctrlKey;
     const isCopyPaste = ctrlOn&&(key=='v'||key=='c');
     if((!/[0-9|.|~|\/]/.test(key)&&key.length==1&&!isCopyPaste)){
       e.preventDefault();
       return false;
-    }
-  }*/
+    }*/
+  // }
   getClasses(){         //整个标签是否有值的状态
     const {hideTag,placeholder,value,isImports} = this.props;
     const $span = this.$span.current;

+ 5 - 1
src/store/actions/checkBody.js

@@ -425,7 +425,11 @@ export function setInputLabel(state,action){
       item.value=text;
     }
   }
-  res.saveText[i] = prefix+text+suffix;//console.log(res)
+  if(text){
+    res.saveText[i] = prefix+text+suffix;
+  }else{//删除完要清空
+    res.saveText[i] = "";
+  }
   res.update = Math.random();
   return res;
 }

+ 5 - 1
src/store/actions/currentIll.js

@@ -871,7 +871,11 @@ export function setInputLabel(state,action){
       item.value=text;
     }
   }
-  res.saveText[i] = prefix+text+suffix;
+  if(text){
+    res.saveText[i] = prefix+text+suffix;
+  }else{//删除完要清空
+    res.saveText[i] = "";
+  }
   res.update = Math.random();
   return res;
 }

+ 5 - 1
src/store/actions/mainSuit.js

@@ -741,7 +741,11 @@ export function setInputLabel(state,action){
       item.value=text;
     }
   }
-  res.saveText[i] = prefix+text+suffix;//console.log(res)
+  if(text){
+    res.saveText[i] = prefix+text+suffix;
+  }else{//删除完要清空
+    res.saveText[i] = "";
+  }
   res.update = Math.random();
   return res;
 }

+ 5 - 1
src/store/actions/otherHistory.js

@@ -216,7 +216,11 @@ export function setOtherInput(state,action){
   if(res.data[i]){
     res.data[i].value=text;
   }
-  res.saveText[i] = prefix+text+suffix;
+  if(text){
+    res.saveText[i] = prefix+text+suffix;
+  }else{//删除完要清空
+    res.saveText[i] = "";
+  }
   res.update = Math.random();
   return res;
 }