import React from 'react'; import style from './index.less'; // import mocks from '../../mock/chronicTable.js' import { Radio,CheckBtn ,Notify} from '@commonComp'; import Information from '../Information'; import {deepClone} from '@utils/tools.js'; import {getFormulaResult} from '@store/async-actions/fetchModules.js'; /** *量表 具体信息页面 *title:量表标题/scaleName *data:量表内容:scaleName量表标题,calculate量表计算结果,group分组, * * **/ class ScaleTable extends React.Component{ constructor(props){ super(props); this.state={ selecteds:{}, //当前页面的选中标识,保存后使用select标识 valueData:{}, start:false, //点击计算 scaleResult1:null } this.handleFormula = this.handleFormula.bind(this); } handleRadio(groupName,name,item,indexId){ const {selecteds,valueData} = this.state; const value = item.detailName; this.setState({ selecteds:Object.assign({},selecteds,{[name]:value}) }) const datas = JSON.parse(JSON.stringify(valueData)); const group = datas.group; let rows; let details; for(let i=0; ii==value); if(index!=-1){ selecteds[name].splice(index,1); }else{ selecteds[name].push(value); } this.setState({ selecteds:selecteds }); const datas = JSON.parse(JSON.stringify(valueData)); const group = datas.group; let rows; let details; for(let i=0; i{return !it.isSelect})).length>0){ // 必填项下有一项选中既可 if(rows[j].required==1&& (rows[j].row.filter((it,i)=>{return it.isSelect})).length==0){ unfinish = true; break; } } } if(unfinish){ Notify.info("请先将量表内容选择完整"); return } // 将计算结果存在state,防止页面跳动问题 const params = { type:1, data:valueData, pId:parentId, id:tableId, pIndex:parentIndex } const that = this; getFormulaResult(params).then((res)=>{ if(+res.data.code==0){ that.setState({ scaleResult1:res.data.data }) }else{ Notify.error(res.data.msg||'计算没有结果返回'); } }) } filterScale(data){//type=1为表格内容 let scale = {}; for(let i=0; i{ return

{v.groupName}

{v.rows&&v.rows.map((it,ind)=>{ return
{it.row.map((item,index)=>{ if(item.controlType==0){ return

{item.name}

{item.details&&item.details.map((vv,ii)=>{ return
{vv.state==1?(智能推荐):''}
})}
}else{ return

{item.name}

{item.details&&item.details.map((vv,ii)=>{ return
{vv.state==1?(智能推荐):''}
})}
} })}
})} {v.groupCalculate.isShow==1?

计分: {/*{v.groupCalculate.result.value}*/} {scaleResult&&scaleResult.group.map((m,ii)=>{ if(m.groupName==v.groupName){ return m.groupCalculate.result.value; } })}

:''}
}) return content; } render(){ const {title,scaleInfo,tableId,formulaResult} = this.props; const data = scaleInfo[tableId]; let {selecteds,scaleResult1} = this.state; const scale = data && this.filterScale(data); const datas = scale && scale.content && JSON.parse(scale.content); const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果 return

{datas?datas.scaleName:''}

{data && data.map((v,i)=>{ if(v.type==0){ return
}else{ return
{this.getContent()} {datas&&datas.Calc==1?
总分: {scaleResult&&scaleResult.calcalculate&&scaleResult.calcalculate.result&&scaleResult.calcalculate.result.value +' '+ (scaleResult.calcalculate.result.text?scaleResult.calcalculate.result.text:'')} 得分
:''}
} })}
} } export default ScaleTable;