import React, { Component } from "react"; import style from "../index.less"; import deleteIcon from '@common/images/delete.png'; import allTableIcon from '@common/images/all-table.png'; import level1 from "@common/images/级别1.png"; 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"; /** * 来源于页面选择 * * **/ class ScaleItem extends Component { constructor(props) { super(props); this.$area = React.createRef(); this.state = { scaleId:'', scaleName:'', parentId:'', showScale:false, optionId:'', radioVal:props.radioVal||{}, formulaId:'', text:props.text, formulaData:{}, //计算公式值 }; this.getItems = this.getItems.bind(this); this.getDetailItems = this.getDetailItems.bind(this); this.showOption = this.showOption.bind(this); this.closeOption = this.closeOption.bind(this); this.closeFormula = this.closeFormula.bind(this); this.handleInputformula =this.handleInputformula.bind(this); } showOption(id){ this.setState({ optionId:id }) } closeOption(){ this.setState({ optionId:null }) } confirmOption(parentId){ const {handleRes} = this.props; const {radioVal,possible} = this.state; handleRes&&handleRes(parentId,{ possible:Object.assign({},possible,radioVal), radioVal:Object.assign({},possible,radioVal),//不设置radioVal只有最近一次选中的值 }); this.closeOption(); } handleShowScale(item,parentId){console.log(item,parentId) const {showScaleFn,closeAssess} = this.props; closeAssess&&closeAssess(); //关闭评估弹窗 showScaleFn&&showScaleFn(item,parentId); //显示量表 } handleRadio(item,parent,pIndex){ let {radioVal} = this.props; this.setState({ radioVal:Object.assign({},radioVal,{[pIndex]:item.detailName}) }) } handleForRadio(id,idd, ind){ const {formulaData} = this.state; const obj = JSON.parse(JSON.stringify(formulaData)); const data = obj&&obj[id]; if (data) { for(let z = 0; z < data.content.details[idd].details.length; z++) { data.content.details[idd].details[z].state = 0; } data.content.details[idd].details[ind].state = 1; }; this.setState({ formulaData:obj }); } showFormula(id,it){ const {formulaData} = this.state; const obj = JSON.parse(JSON.stringify(formulaData)||{}); obj[id] = it; this.setState({ formulaId:id, formulaData:obj }); } confirmFormula(){ this.closeFormula(); } closeFormula(){ this.setState({ formulaId:null }) } calcuFormula(j, v, i) { //计算公式计算 const { calcuFormula } = this.props; const {formulaId,formulaData} = this.state; const it =formulaData&&formulaData[formulaId]; let allHasInfo = true for (let i = 0; i < it.content.details.length; i++) { if(it.content.details[i].controlType == 2) { //输入框类型的有没有填值 if(!it.content.details[i].value) { allHasInfo = false } } else if(it.content.details[i].controlType == 1) { let hasSelect = false for( let z = 0; z { if(indexs[i]&&indexs[i].includes(j)){ let it=null; if(its.type==1){ //量表 it=deepClone(its); temp =this.handleShowScale(it.content,item.id)}>【{it.content.name}】; }else if(its.type==2){ //计算公式 it=formulaData[formulaId]||deepClone(its); temp =
计算公式: 请选择 {it.content.details.map((item1,idd)=>{ if(item1.controlType==1){//单选 return }else if(item1.controlType==2){//输入框 return } })}
{'请选择'+item1.name+':'} {item1.details.map((ii,ind)=>{ return
>
})}
{'请输入'+item1.name+':'} this.handleInputformula(item.id,idd,e.target.value)}/> {item1.uint}
计算
{it.content.result && Array.isArray(it.content.result) &&it.content.result.map((itemResult, resultIndex) => { return })}
{itemResult.name+':'} {itemResult.text}
}else if(its.type==3){ it=deepClone(its); temp =
可能结果: {possible&&possible[i]?possible[i]:'请选择'}
{it.content.name?it.content.name+':':''} {it.content.details&&it.content.details.map((lis,ind)=>{ return
})}
; } arr.push(
  • {item.name}:
    {temp}
    this.props.handleRemove(i,j)}>
  • ); } }); return arr; } getItems(){ const { data } = this.props; return data&&data.map((it,i)=>{ return this.getDetailItems(it,i); }); } handleInput(e){ const text = e.target.value; this.setState({ text }); } render() { const {title,handleInp,disabled,isRecommend} = this.props; return
    {isRecommend?'':

    {title}

    }
      { this.getItems() } {isRecommend?'':
    • 评估描述:{this.state.text}
    • }
    ; } } export default ScaleItem;