|
@@ -6,6 +6,7 @@ import RadioInpDrop from "@containers/RadioInpDrop";
|
|
|
import InlineTag from '@containers/InlineTag';
|
|
|
import Multiple from '@containers/Multiple';
|
|
|
import addIcon from '@images/addItem.png';
|
|
|
+import addIcon1 from '@images/addItem2.png';
|
|
|
import style from "./index.less";
|
|
|
import tools from '@utils/tools';
|
|
|
import NumberUnitDrop from '@containers/NumberUnitDrop';
|
|
@@ -33,8 +34,16 @@ class MultSpread extends Component{
|
|
|
constructor(props){
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- numDoms:[]
|
|
|
+ numDoms:[],
|
|
|
+ tall:0, //升高
|
|
|
+ weight:0, //体重
|
|
|
+ bmi:'', //BMI
|
|
|
+ wrBmi:false, //是否无效bmi值,是则要清空身高体重,不能用判断bmi是否为空来判断,因为初始就是为空
|
|
|
};
|
|
|
+ this.setBMIParam = this.setBMIParam.bind(this);
|
|
|
+ this.setBMI = this.setBMI.bind(this);
|
|
|
+ this.isBMIUseable = this.isBMIUseable.bind(this);
|
|
|
+ this.setBMIstate = this.setBMIstate.bind(this);
|
|
|
}
|
|
|
getClass(){
|
|
|
const {saveText,ikey,showAdd} = this.props;
|
|
@@ -70,8 +79,61 @@ class MultSpread extends Component{
|
|
|
const doms = this.state.numDoms;
|
|
|
doms[i+1]&&this.moveEnd(doms[i+1].current)
|
|
|
}
|
|
|
+ isBMIUseable(name,val){
|
|
|
+ const {tall,weight} = this.state;
|
|
|
+ //身高不能为0,否则分母为0,身高体重任何一个为空,则BMI清空
|
|
|
+ if((name==='tall'&&(!val||!weight))||(name==='weight'&&(!tall||!val))){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ setBMIParam(name,val){ //设置bmi相关数据,身高、体重
|
|
|
+ const {tall,weight} = this.state;
|
|
|
+ const useable = this.isBMIUseable(name,val);
|
|
|
+ this.setState({
|
|
|
+ [name]:val
|
|
|
+ });
|
|
|
+ if(useable){
|
|
|
+ const result = name==='tall'?weight/Math.pow(val/100,2):val/Math.pow(tall/100,2);
|
|
|
+ this.setState({
|
|
|
+ bmi:result.toFixed(1),
|
|
|
+ wrBmi:false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setState({
|
|
|
+ bmi:'',
|
|
|
+ wrBmi:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setBMI(val){
|
|
|
+ //手动修改BMI赋值,且身高体重清空
|
|
|
+ this.setState({
|
|
|
+ bmi:val,
|
|
|
+ wrBmi:true,
|
|
|
+ tall:0,
|
|
|
+ weight:0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ setBMIstate(item){
|
|
|
+ //回读时bmi相关state赋值
|
|
|
+ const map={
|
|
|
+ BMI_SG:'tall',
|
|
|
+ BMI_TZ:'weight',
|
|
|
+ BMI_RES:'bmi',
|
|
|
+ };
|
|
|
+ const st = this.state;
|
|
|
+ const key = map[item.formulaCode];
|
|
|
+ //回读BMI相关项有值时,state赋值
|
|
|
+ if(key&&st[key]!==item.value){
|
|
|
+ this.setState({
|
|
|
+ [key]:item.value
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
getLabels(){
|
|
|
- const {data,ikey,showArr,copyId,selecteds,boxMark} = this.props;
|
|
|
+ const {data,ikey,showArr,copyId,selecteds,boxMark,isExtBlue} = this.props;
|
|
|
+ const {wrBmi,bmi} = this.state;
|
|
|
let show = false;
|
|
|
let inx = '',count=0;
|
|
|
const list = data.map((it,i)=>{
|
|
@@ -84,6 +146,7 @@ class MultSpread extends Component{
|
|
|
const list = it.questionDetailList&&it.questionDetailList.length>0?it.questionDetailList:it.questionMapping;
|
|
|
return <RadioDrop data={list}
|
|
|
boxMark={boxMark}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
placeholder={it.name}
|
|
|
show={show}
|
|
|
value = {it.value}
|
|
@@ -96,6 +159,7 @@ class MultSpread extends Component{
|
|
|
return <Multiple data={dataList}
|
|
|
ikey={inx}
|
|
|
placeholder={it.name}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
value={it.value}
|
|
|
copyType={it.copyType}
|
|
|
selecteds={selecteds ?selecteds[i]:[]}
|
|
@@ -109,6 +173,7 @@ class MultSpread extends Component{
|
|
|
suffix={it.labelSuffix}
|
|
|
placeholder={it.name}
|
|
|
boxMark={ikey.substr(0,1)}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
id={it.id}
|
|
|
show={show}
|
|
|
ikey={inx}
|
|
@@ -119,18 +184,26 @@ class MultSpread extends Component{
|
|
|
return <InlineTag prefix={it.labelPrefix}
|
|
|
suffix={it.labelSuffix}
|
|
|
placeholder={it.name}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
value={it.value}
|
|
|
id={it.id}
|
|
|
ikey={inx} hideTag={true}></InlineTag>;
|
|
|
case +it.controlType===7:
|
|
|
const min = it.minValue;//!=null&&it.minValue!=undefined?it.minValue-1:undefined;
|
|
|
const max = it.maxValue;//!=null&&it.maxValue!=undefined?+it.maxValue+1:undefined;
|
|
|
+ this.setBMIstate(it);
|
|
|
return <NumberDrop prefix={it.labelPrefix}
|
|
|
suffix={it.labelSuffix}
|
|
|
placeholder={it.name}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
//inputRef = {this['$inp'+(count++)]}
|
|
|
saveDoms={this.saveDoms.bind(this)}
|
|
|
reFocus={this.setNextFocus.bind(this)}
|
|
|
+ setBMI={this.setBMI}
|
|
|
+ wrBmi={wrBmi}
|
|
|
+ bmi={bmi}
|
|
|
+ setBMIParam={this.setBMIParam}
|
|
|
+ formulaCode={it.formulaCode}
|
|
|
num = {count++}
|
|
|
min={min}
|
|
|
max={max}
|
|
@@ -148,6 +221,7 @@ class MultSpread extends Component{
|
|
|
show={showArr&&showArr[inx]}
|
|
|
value = {it.value}
|
|
|
boxMark={boxMark}
|
|
|
+ isExtBlue={isExtBlue}
|
|
|
id={it.id}
|
|
|
ikey={inx}
|
|
|
hideTag={true}></RadioInpDrop>;
|
|
@@ -168,21 +242,22 @@ class MultSpread extends Component{
|
|
|
}
|
|
|
}
|
|
|
getContClass(){
|
|
|
- const {isImports,ikey,saveText} = this.props;
|
|
|
+ const {isImports,ikey,saveText,isExtBlue} = this.props;
|
|
|
const labelInx = tools.getLabelIndex(ikey);
|
|
|
const text = saveText&&saveText[+labelInx];
|
|
|
+ const ext = !text&&isExtBlue?style['ext']:'';
|
|
|
const orgBorder = isImports&&!text?style['orange-border']:'';
|
|
|
- return classNames(orgBorder);
|
|
|
+ return classNames(orgBorder,ext);
|
|
|
}
|
|
|
render(){
|
|
|
- const {showAdd,addLabelItem,ikey,copyId,textPrefix,textSuffix} = this.props;
|
|
|
+ const {showAdd,addLabelItem,ikey,copyId,textPrefix,textSuffix,isExtBlue} = this.props;
|
|
|
return (<div className={this.getContClass()}
|
|
|
style={{display:'inline-block'}}>
|
|
|
{textPrefix?<span>{textPrefix}</span>:''}
|
|
|
<div className={this.getClass()}>
|
|
|
{this.getLabels()}
|
|
|
{textSuffix?<span>{textSuffix}</span>:''}
|
|
|
- {showAdd?<img src={addIcon} alt="添加血压项"
|
|
|
+ {showAdd?<img src={isExtBlue?addIcon1:addIcon} alt="复制该项"
|
|
|
className={style['add-icon']}
|
|
|
onClick={()=>addLabelItem({ikey,copyId})}/>:''}
|
|
|
</div>
|