import React from 'react';
import { SearchOption, Calendar, ConfirmModal, Notify, Add ,DelToast} from '@commonComp';
import styles from './index.less';
import $ from 'jquery';
import Textarea from './Textarea';
import AssistName from './AssistName';
import { getPageCoordinate,getCurrentDate,setPosition, setFontColorSize } from '@utils/tools';
import ScrollArea from 'react-scrollbar';
class AddAssistCheck extends React.Component {
constructor(props) {
super(props);
this.state = {
show: false,
date: false,
dateTime: "",
active: '',
visible: false,
pageTop:'',
id: null,
activeName:''
}
this.handleShowDate = this.handleShowDate.bind(this)
this.getSearchList = this.getSearchList.bind(this)
this.getAssistLabel = this.getAssistLabel.bind(this)
this.handleDelClick = this.handleDelClick.bind(this)
this.delConfirm = this.delConfirm.bind(this)
this.handleCancel = this.handleCancel.bind(this)
this.timeSure = this.timeSure.bind(this)
}
componentDidMount() {
$(document).click((event) => {
let _con = $('#searchWrapAssist'); // 设置目标区域
let _cons = $('#datePick'); // 设置目标区域
// let _conClick = $('#assistCheck'); // 点击的按钮
let _del = document.getElementById("delBox"); // 删除弹窗
let _close = document.getElementById("assiClose"); // 删除icon
let _closeTil = $('#delTit')[0]; // 弹窗标题
if(!this.isBar) {//onMousedown的目标为滚动条时,子项弹窗不关闭)
if (_con && searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
if (this.state.show) {
this.props.setHighter(48)
}
this.setState({show: false});
}
if (!_cons.is(event.target) && _cons.has(event.target).length === 0 || event.target.isEqualNode(_close)) { // Mark 1
this.setState({date: false});
}
if($(event.target).attr("contenteditable")||event.target.textContent == '报告描述或意见'){
this.setState({date: false});
}
if(_del){
if($(event.target).attr('id') != 'assiClose' &&!event.target.isEqualNode(_close) && !event.target.isEqualNode(_del) && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)){
this.setState({
visible: false,
id: null,
activeName:''
})
}
}
}
});
const that = this;
document.addEventListener('mousedown',function(e){
//onMousedown的目标为滚动条时,标签填写单不关闭
if(e.target.className=='scrollbar'){
that.isBar = true;
}else{
that.isBar = false;
}
});
getCurrentDate(1);
}
handleDelClick(id,item) {
this.setState({
visible: true,
id: id,
activeName:item.name
})
}
delConfirm(type) {
const { handleDelAssist, handlePush } = this.props;
const { id,activeName } = this.state;
$(".TextareaRsize").css({marginTop:0});
handleDelAssist && handleDelAssist(id,activeName,type);
handlePush && handlePush(); //右侧推送
this.setState({
visible: false,
id: null,
activeName:''
})
Notify.success("删除成功");
}
handleCancel() {
this.setState({
visible: false,
id: null,
activeName:''
})
}
handleSearchShow(e) {
let tmpShow = this.state.show;
this.setState({ show: !tmpShow,pageTop:getPageCoordinate(e).boxTop })
// e.stopPropagation();
if(tmpShow){
this.props.setHighter(48)
}else{
setPosition(e,"#searchOption",this.props.setHighter)
}
}
handleShowDate(idx) {
this.setState({
date: !this.state.date,
active: idx
})
}
getSearchList(list) { //搜索列表
const { handleSign } = this.props;
const contStyle={
opacity:'0.4',
right:'0',
top:'1px',
zIndex:'15',
width:'14px',
background:'#f1f1f1'};
const barStyle={background:'#777',width:'100%'};
return
{
list && list.map((item, idx) => {
return
报告日期:{item.time || this.state.dateTime}
this.handleShowDate(idx)}>报告日期:{item.time || this.state.dateTime}
this.handleShowDate(idx)}> {/* { this.handleDelClick(idx,item) }}>暂无筛选项
)} { (list && list.length>0) || (assistVal != '') || (assistList&&assistList.length==0)?'':常用辅检项
{assistList.length>6?