|
@@ -7,7 +7,6 @@ import checkIcon from '@common/images/check.png';
|
|
|
import {ComplexModal,MiniToast,Radio} from '@commonComp';
|
|
|
import Notify from '@commonComp/Notify';
|
|
|
import {deepClone} from '@utils/tools';
|
|
|
-import $ from "jquery";
|
|
|
/**
|
|
|
* 来源于页面选择
|
|
|
*
|
|
@@ -16,13 +15,15 @@ class ScaleItem extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.$area = React.createRef();
|
|
|
+ const {result}= props;
|
|
|
+ let radioVal = result&&result.radioVal;
|
|
|
this.state = {
|
|
|
scaleId:'',
|
|
|
scaleName:'',
|
|
|
parentId:'',
|
|
|
showScale:false,
|
|
|
optionId:'',
|
|
|
- radioVal:props.radioVal||{},
|
|
|
+ radioVal:Object.assign({},radioVal)||{},
|
|
|
formulaId:'',
|
|
|
text:props.text,
|
|
|
formulaData:{}, //计算公式值
|
|
@@ -45,10 +46,10 @@ class ScaleItem extends Component {
|
|
|
optionId:null
|
|
|
})
|
|
|
}
|
|
|
- confirmOption(parentId){
|
|
|
+ confirmOption(){
|
|
|
const {handleRes} = this.props;
|
|
|
const {radioVal,possible} = this.state;
|
|
|
- handleRes&&handleRes(parentId,{
|
|
|
+ handleRes&&handleRes({
|
|
|
possible:Object.assign({},possible,radioVal),
|
|
|
radioVal:Object.assign({},possible,radioVal),//不设置radioVal只有最近一次选中的值
|
|
|
});
|
|
@@ -60,10 +61,11 @@ class ScaleItem extends Component {
|
|
|
showScaleFn&&showScaleFn(item,parentId); //显示量表
|
|
|
|
|
|
}
|
|
|
- handleRadio(item,parent,pIndex){
|
|
|
- let {radioVal} = this.props;
|
|
|
+ handleRadio(item,parent){
|
|
|
+ let {result} = this.props;
|
|
|
+ let radioVal = result&&result.radioVal;
|
|
|
this.setState({
|
|
|
- radioVal:Object.assign({},radioVal,{[pIndex]:item.detailName})
|
|
|
+ radioVal:Object.assign({},radioVal,{[parent.id]:item.detailName})
|
|
|
})
|
|
|
}
|
|
|
handleForRadio(id,idd, ind){
|
|
@@ -152,7 +154,7 @@ class ScaleItem extends Component {
|
|
|
let arr = [],temp='';
|
|
|
const {indexs,result,formulaResult} = this.props;
|
|
|
const {optionId,formulaId,radioVal,formulaData,isFormulaConfirm} = this.state;
|
|
|
- const possible=result&&result[item.id]&&result[item.id].possible;
|
|
|
+ const possible=result&&result.possible;
|
|
|
|
|
|
item.details.map((its,j)=>{
|
|
|
if(indexs[i]&&indexs[i].includes(j)){
|
|
@@ -167,10 +169,10 @@ class ScaleItem extends Component {
|
|
|
</span>;
|
|
|
}else if(its.type==2){ //计算公式
|
|
|
it=formulaData[formulaId]||deepClone(its);
|
|
|
- const result = it.content.result&&it.content.result[1]&&it.content.result[1].text;
|
|
|
+ const cresult = it.content.result&&it.content.result[1]&&it.content.result[1].text;
|
|
|
temp = <div className={style['results']}>
|
|
|
<span>计算公式:</span>
|
|
|
- <span className={style["blue"]} onClick={this.showFormula.bind(this,item.id,it)}>{result?result:'请选择'}</span>
|
|
|
+ <span className={style["blue"]} onClick={this.showFormula.bind(this,item.id,it)}>{cresult?cresult:'请选择'}</span>
|
|
|
<img src={level1} />
|
|
|
<MiniToast title={it.content.name}
|
|
|
icon={allTableIcon}
|
|
@@ -232,7 +234,7 @@ class ScaleItem extends Component {
|
|
|
it=deepClone(its);
|
|
|
temp = <div className={style['results']}>
|
|
|
<span>可能结果:</span>
|
|
|
- <span onClick={this.showOption.bind(this,item.id)} className={style["blue"]}>{possible&&possible[i]?possible[i]:'请选择'}</span>
|
|
|
+ <span onClick={this.showOption.bind(this,item.id)} className={style["blue"]}>{possible&&possible[item.id]?possible[item.id]:'请选择'}</span>
|
|
|
<img src={level1} />
|
|
|
<MiniToast title='结果选择'
|
|
|
icon={checkIcon}
|
|
@@ -245,7 +247,7 @@ class ScaleItem extends Component {
|
|
|
{it.content.details&&it.content.details.map((lis,ind)=>{
|
|
|
return <div className={style["chooseItem"]}>
|
|
|
<Radio label={lis.detailName}
|
|
|
- isSelect={radioVal&&radioVal[i]==lis.detailName}
|
|
|
+ isSelect={radioVal&&radioVal[item.id]==lis.detailName}
|
|
|
handleClick={this.handleRadio.bind(this,lis,item,i)}>
|
|
|
</Radio>
|
|
|
</div>
|
|
@@ -278,7 +280,7 @@ class ScaleItem extends Component {
|
|
|
});
|
|
|
}
|
|
|
render() {
|
|
|
- const {title,handleInp,disabled,isRecommend,formulaResult} = this.props;console.log(formulaResult)
|
|
|
+ const {title,handleInp,disabled,isRecommend,formulaResult} = this.props;
|
|
|
return <div className={style['assess-item']}>
|
|
|
{isRecommend?'':<h2>{title}</h2>}
|
|
|
<div className={style['item-content']}>
|