|
@@ -4,6 +4,7 @@ import mocks from '../../mock/chronicTable.js'
|
|
import { Radio,CheckBtn ,Notify} from '@commonComp';
|
|
import { Radio,CheckBtn ,Notify} from '@commonComp';
|
|
import Information from '../Information';
|
|
import Information from '../Information';
|
|
import {deepClone} from '@utils/tools.js';
|
|
import {deepClone} from '@utils/tools.js';
|
|
|
|
+ import {getFormulaResult} from '@store/async-actions/fetchModules.js';
|
|
/**
|
|
/**
|
|
*量表 具体信息页面
|
|
*量表 具体信息页面
|
|
*title:量表标题/scaleName
|
|
*title:量表标题/scaleName
|
|
@@ -18,6 +19,7 @@ class ScaleTable extends React.Component{
|
|
selecteds:{}, //当前页面的选中标识,保存后使用select标识
|
|
selecteds:{}, //当前页面的选中标识,保存后使用select标识
|
|
valueData:{},
|
|
valueData:{},
|
|
start:false, //点击计算
|
|
start:false, //点击计算
|
|
|
|
+ scaleResult1:null
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -146,10 +148,20 @@ class ScaleTable extends React.Component{
|
|
pIndex:parentIndex
|
|
pIndex:parentIndex
|
|
}
|
|
}
|
|
// 替换表格内容
|
|
// 替换表格内容
|
|
- let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
|
|
|
|
- allDatas[1].content = JSON.stringify(valueData);
|
|
|
|
|
|
+ // let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
|
|
|
|
+ // allDatas[1].content = JSON.stringify(valueData);
|
|
// 计算接口
|
|
// 计算接口
|
|
- getResult&&getResult({params,allDatas});
|
|
|
|
|
|
+ // getResult&&getResult({params,allDatas});
|
|
|
|
+
|
|
|
|
+ // 将计算结果存在state,防止页面跳动问题
|
|
|
|
+ const that = this;
|
|
|
|
+ getFormulaResult(params).then((res)=>{
|
|
|
|
+ if(+res.data.code==0){
|
|
|
|
+ that.setState({
|
|
|
|
+ scaleResult1:res.data.data
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
componentWillReceiveProps(nextProps){
|
|
componentWillReceiveProps(nextProps){
|
|
const {tableId} = this.props;
|
|
const {tableId} = this.props;
|
|
@@ -167,13 +179,27 @@ class ScaleTable extends React.Component{
|
|
// valueData:scaleInfo[tableId].length?mocks.newData:JSON.parse(scaleInfo[tableId].content)
|
|
// valueData:scaleInfo[tableId].length?mocks.newData:JSON.parse(scaleInfo[tableId].content)
|
|
valueData:JSON.parse(scaleInfo[tableId][1].content)
|
|
valueData:JSON.parse(scaleInfo[tableId][1].content)
|
|
})
|
|
})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ componentWillUnmount(){
|
|
|
|
+ // 储存计算结果和选择后的data
|
|
|
|
+ const {tableId,getResult,parentId,parentIndex,scaleInfo} = this.props;
|
|
|
|
+ const {valueData,scaleResult1} = this.state;
|
|
|
|
+ // 替换表格内容
|
|
|
|
+ let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
|
|
|
|
+ allDatas[1].content = JSON.stringify(valueData);
|
|
|
|
+ const params = {
|
|
|
|
+ type:1,
|
|
|
|
+ data:scaleResult1,
|
|
|
|
+ id:tableId,
|
|
|
|
+ pIndex:parentIndex
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ getResult&&getResult({params,allDatas});
|
|
}
|
|
}
|
|
getContent(){
|
|
getContent(){
|
|
- let {selecteds,valueData,start} = this.state;
|
|
|
|
|
|
+ let {selecteds,valueData,start,scaleResult1} = this.state;
|
|
const {tableId,formulaResult} = this.props;
|
|
const {tableId,formulaResult} = this.props;
|
|
- const scaleResult = formulaResult&&formulaResult[tableId]; //量表计算结果
|
|
|
|
|
|
+ const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果
|
|
// const datas = valueData&&valueData.group?valueData:mocks.newData;
|
|
// const datas = valueData&&valueData.group?valueData:mocks.newData;
|
|
const datas = valueData&&valueData.group?valueData:'';
|
|
const datas = valueData&&valueData.group?valueData:'';
|
|
let content = datas&&datas.group&&datas.group.map((v,i)=>{
|
|
let content = datas&&datas.group&&datas.group.map((v,i)=>{
|
|
@@ -232,12 +258,12 @@ class ScaleTable extends React.Component{
|
|
render(){
|
|
render(){
|
|
const {title,scaleInfo,tableId,formulaResult} = this.props;
|
|
const {title,scaleInfo,tableId,formulaResult} = this.props;
|
|
const data = scaleInfo[tableId];
|
|
const data = scaleInfo[tableId];
|
|
- let {selecteds} = this.state;
|
|
|
|
|
|
+ let {selecteds,scaleResult1} = this.state;
|
|
const content = data && data[1].content;//表格内容
|
|
const content = data && data[1].content;//表格内容
|
|
const preContent = data && data[0].content;//表前文字
|
|
const preContent = data && data[0].content;//表前文字
|
|
const footContent = data && data[2].content; //表后文字
|
|
const footContent = data && data[2].content; //表后文字
|
|
const datas = content && JSON.parse(content);
|
|
const datas = content && JSON.parse(content);
|
|
- const scaleResult = formulaResult&&formulaResult[tableId]; //量表计算结果
|
|
|
|
|
|
+ const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果
|
|
return <div className={style['tableBox']} id="printcontent">
|
|
return <div className={style['tableBox']} id="printcontent">
|
|
<div className={style['printShow']}>
|
|
<div className={style['printShow']}>
|
|
<Information></Information>
|
|
<Information></Information>
|
|
@@ -248,7 +274,7 @@ class ScaleTable extends React.Component{
|
|
{this.getContent()}
|
|
{this.getContent()}
|
|
{datas&&datas.noCalc==0?<div className={style['total']}>
|
|
{datas&&datas.noCalc==0?<div className={style['total']}>
|
|
<span>总分:</span>
|
|
<span>总分:</span>
|
|
- <span>{scaleResult&&scaleResult.calcalculate.result&&scaleResult.calcalculate.result.value||''}</span>
|
|
|
|
|
|
+ <span>{scaleResult&&scaleResult.calcalculate.result&&scaleResult.calcalculate.result.value +' '+ scaleResult.calcalculate.result.text||''}</span>
|
|
<span className={style['totalBtn']} onClick={this.handleFormula.bind(this)}>得分</span>
|
|
<span className={style['totalBtn']} onClick={this.handleFormula.bind(this)}>得分</span>
|
|
</div>:''}
|
|
</div>:''}
|
|
</div>
|
|
</div>
|