import React, { Component } from 'react'; import style from './index.less'; import {ConfirmModal} from '@commonComp'; import Notify from '@commonComp/Notify'; class DiagnosticItem extends Component{ constructor(props){ super(props); this.state = { visible: false } this.addDiagodal = this.addDiagodal.bind(this); this.chooseDiagodal = this.chooseDiagodal.bind(this); this.confirm = this.confirm.bind(this); this.cancel = this.cancel.bind(this) this.close = this.close.bind(this) } confirm() { this.close(); const diagType = 1; this.addDiagodal(diagType) } cancel() { this.close(); const diagType = 2; this.addDiagodal(diagType) } close(){ this.setState({ visible: false }) } chooseDiagodal(item) { const { diagnosticList,getTips } = this.props; getTips && getTips(item); for (let i = 0; i < diagnosticList.length; i++) { if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) { Notify.info('该诊断已存在'); return } } this.setState({ visible: true }) } addDiagodal(diagType){ const {item} = this.props; item.type = diagType; // setTimeout(()=>{ // this.setState({ // visible: false, // },()=>{ const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props; for (let i = 0; i < diagnosticList.length; i++) { if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) { Notify.info('该诊断已存在'); return } } addDiagnostic&&addDiagnostic(item); clearInput&&clearInput(); hideSearch&&hideSearch() // }) // }, 0) } render(){ const { visible } = this.state const { item, title } = this.props return ( {this.chooseDiagodal(item)}}> {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
确定选择“{item.name}”为
) } } export default DiagnosticItem;