index.jsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, { Component } from "react";
  2. import style from "../index.less";
  3. import deleteIcon from '@common/images/delete.png';
  4. /**
  5. * 来源于页面选择
  6. *
  7. * **/
  8. class ScaleItem extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state={
  12. supplement:''
  13. };
  14. this.getItems = this.getItems.bind(this);
  15. this.getDetailItems = this.getDetailItems.bind(this);
  16. }
  17. getDetailItems(item,i){
  18. let arr = [],temp='';
  19. const {indexs} = this.props;
  20. item.details.map((it,j)=>{
  21. if(indexs[i]&&indexs[i].includes(j)){
  22. if(it.type==1){ //量表
  23. temp =<span className={style['scale']}>【{it.content.name}】</span>;
  24. }else if(it.type==2){ //计算公式
  25. temp = <span>计算公式</span>
  26. }else if(it.type==3){
  27. temp = <span>可能结果</span>
  28. }
  29. arr.push(<li>
  30. <span>{item.name}:</span>
  31. <div className={style['row']}>{temp}</div>
  32. <div className={style["recommend"]} onClick={()=>this.props.handleRemove(i,j)}>
  33. <img src={deleteIcon} />
  34. </div>
  35. </li>);
  36. }
  37. });
  38. return arr;
  39. }
  40. getItems(){
  41. const { data } = this.props;
  42. return data.map((it,i)=>{
  43. return this.getDetailItems(it,i);
  44. });
  45. }
  46. render() {
  47. const {title,handleInp} = this.props;
  48. return <div className={style['assess-item']}>
  49. <h2>{title}</h2>
  50. <div className={style['item-content']}>
  51. <ul>
  52. {
  53. this.getItems()
  54. }
  55. <li>
  56. <textarea className={style['edit-row']} name="supplement" rows="6" placeholder='评估描述' onInput={(e)=>handleInp(e.target.value)}></textarea>
  57. </li>
  58. </ul>
  59. </div>
  60. </div>;
  61. }
  62. }
  63. export default ScaleItem;