index.jsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React, { Component } from "react";
  2. import style from "./index.less";
  3. import { Radio } from '@commonComp';
  4. import ChooseItem from "./ChooseItem";
  5. import ScaleItem from "./ScaleItem";
  6. import Information from '../Information'
  7. import ChartItem from "./ChartItem";
  8. import Notify from '@commonComp/Notify';
  9. import {readyKeepHistory} from '@utils/tools';
  10. class AssessResult extends Component {
  11. constructor(props) {
  12. super(props);
  13. const chooseSelecteds = JSON.parse(JSON.stringify(props.chooseSelecteds));
  14. const wholeIndexs = JSON.parse(JSON.stringify(props.wholeIndexs)); //深度复制,Object.assgin为浅复制,下下级会同源
  15. this.state={
  16. chooseSelecteds:chooseSelecteds, //大数据选择模块
  17. chartTimeTypes:{}, //图表模块
  18. wholeAssessItems:wholeIndexs, //整体评估模块
  19. wholeAssessText:props.wholeAssessText||'' //整体评估补充说明
  20. }
  21. this.handleChooseChange = this.handleChooseChange.bind(this);
  22. this.handleScaleDel = this.handleScaleDel.bind(this);
  23. this.handleScaleText = this.handleScaleText.bind(this);
  24. }
  25. componentWillMount(){
  26. //获取评估
  27. this.props.getAssess();
  28. }
  29. handleScaleText(text){
  30. this.setState({
  31. wholeAssessText:text
  32. })
  33. }
  34. handleScaleDel(i,j){
  35. const items = Object.assign({},this.state.wholeAssessItems);
  36. const inx = items[i].findIndex(x=>x==j);
  37. items[i].splice(inx,1);
  38. this.setState({
  39. wholeAssessItems: items
  40. });
  41. }
  42. handleChooseChange(i,selects){
  43. const {chooseSelecteds} = this.state;
  44. this.setState({
  45. chooseSelecteds: Object.assign(chooseSelecteds,{[i]:selects})
  46. });
  47. }
  48. handleChartChange(i,selects){
  49. const {chartTimeTypes} = this.state;
  50. this.setState({
  51. chartTimeTypes:Object.assign(chartTimeTypes,{[i]:selects})
  52. });
  53. }
  54. componentWillUnmount(){
  55. //点确定关闭弹窗时把参数传到父组件去
  56. const {handleSave,isAssessConfirm,clearChartData} = this.props;
  57. clearChartData&&clearChartData();
  58. if(isAssessConfirm && readyKeepHistory() == 1){
  59. Notify.error("主诉不能为空");
  60. }else if(isAssessConfirm && readyKeepHistory() == 2){
  61. Notify.info('诊断不能为空');
  62. }
  63. isAssessConfirm&&handleSave(this.state,readyKeepHistory());
  64. }
  65. handoutTypes(item,i){
  66. const {getIndexData,indexData,timeTypes,wholeAssessData,scaleInfo,getScaleInfo,possible,radioVal} =this.props;
  67. const {chooseSelecteds,wholeAssessItems,wholeAssessText,chartTimeTypes} = this.state;
  68. const chartData = indexData;
  69. const name = item.regionName+":";
  70. const list = item.data&&item.data.rows;
  71. switch (+item.regionType){
  72. case 0: //数据来源与右侧手动添加
  73. return <ScaleItem title={name}
  74. data={wholeAssessData}
  75. handleRemove={this.handleScaleDel}
  76. handleInp={this.handleScaleText}
  77. text={wholeAssessText}
  78. indexs={wholeAssessItems}
  79. scaleInfo={scaleInfo}
  80. possible={possible}
  81. radioVal={radioVal}
  82. getScaleData={getScaleInfo}></ScaleItem>;
  83. case 1: //数据来源于大数据
  84. return <ChooseItem title={name}
  85. data={list}
  86. handleChange={this.handleChooseChange.bind(this,i)}
  87. selecteds={chooseSelecteds[i]} ></ChooseItem>;
  88. case 10: //数据来源于后台
  89. return <ChartItem title={name}
  90. data={chartData||{}}
  91. timeTypes={JSON.stringify(chartTimeTypes)=='{}'?timeTypes&&timeTypes[i]:chartTimeTypes[i]}
  92. pindex={i}
  93. initFn={getIndexData}
  94. handleChange={this.handleChartChange.bind(this,i)}></ChartItem>;
  95. default:
  96. return '';
  97. }
  98. }
  99. render() {
  100. const { onClose, data } = this.props;
  101. return <div className={style['assess-cont']} id="AssistResult">
  102. <div className={style['printShow']}>
  103. <Information></Information>
  104. </div>
  105. {data && data.map((it, i) => {
  106. return this.handoutTypes(it, i);
  107. })}
  108. </div>;
  109. }
  110. }
  111. export default AssessResult;