import PropTypes from "prop-types" import React from "react" import style from "./index.less" import TemplateItem from './TemplateItem' import check_circle from './TemplateItem/img/check-circle.png'; import delIcon from '@common/images/del_nor.png'; import check_right from './TemplateItem/img/check-right.png'; import tempTip from './TemplateItem/img/tempTip.png'; import tempTrd from './TemplateItem/img/tempTrd.png'; import tmpAllCircle from './TemplateItem/img/tmpAllCircle.png'; import tmpAllRight from './TemplateItem/img/tmpAllRight.png'; import floderR from './TemplateItem/img/floderR.png'; import floderD from './TemplateItem/img/floderD.png'; import Empty from '@components/Empty'; import $ from 'jquery'; import {windowEventHandler,getWindowInnerHeight} from '@utils/tools' class TemplateItems extends React.Component { constructor(props) { super(props); this.state = { msg:'还没有保存模板', val:'', height:'', showTipContent:false } this.$cont = React.createRef(); this.$conts = React.createRef(); this.$search = React.createRef(); this.genItems = this.genItems.bind(this); this.templateSearch = this.templateSearch.bind(this); this.handleEnter = this.handleEnter.bind(this); this.handleChange = this.handleChange.bind(this); this.clear = this.clear.bind(this); this.showTipContent = this.showTipContent.bind(this); this.getFloderLis = this.getFloderLis.bind(this); } componentDidMount(){ const height = getWindowInnerHeight()-195; this.setState({ height:height }) windowEventHandler('resize', ()=>{ if(this.$conts.current){ const height = getWindowInnerHeight()-195; this.setState({ height:height }) } }); $(document).click((event) => { let _del = $('#floderAction')[0]; // 弹窗 let _dels = $(event.target).attr("id"); // 触发弹窗列表 if (_del) {//onMousedown的目标为滚动条时,删除弹窗不关闭 if (!event.target.isEqualNode(_del) && event.target.parentNode != _del &&_dels != 'floderActionBtn') { this.floderAction(false,'none') } } }) } showTipContent(){ let show = this.state.showTipContent this.setState({ showTipContent:!show }) } floderSlide(e,item){ const {floderSlide} = this.props if(!item.templateInfo){ return; } $(e.target).next().slideToggle() let domLis = $(e.target).parent().siblings() for(let i = 0;i < domLis.length;i++){ let tmpD = domLis[i] $(tmpD).children().eq(1).slideUp() } floderSlide(item.id) } floderAction(e,id){ e&&e.stopPropagation() const {floderAction} = this.props; floderAction(id) } genItems(items,flg) { const Items = []; const {admin,checkItems,allCheckShow,handleContentClick,handleTemplateDel,handleTitleChange,checkItemsAdmin,allCheckShowAdmin} = this.props; items.forEach((v,idx) => { Items.push( ); }); return Items; } floderRename(e){ e.stopPropagation() this.props.floderAction(false,'none') this.props.floderRename() } floderDelete(e){ e.stopPropagation() this.props.floderAction(false,'none') this.props.floderDelete() } genAdminItems(items,flg) { const Floder=[],Items = []; const {admin,checkItemsAdmin} = this.props; for(let i = 0;i < items.length;i++){ let tmpItm = items[i] Floder.push(
this.floderSlide(e,tmpItm)}> {tmpItm.name} {this.floderAction(e,tmpItm.id)}}>... {tmpItm.action == 1&&

{this.floderRename(e)}}>重命名文件夹

{this.floderDelete(e)}}>删除文件夹

}
{ tmpItm.templateInfo&&tmpItm.templateInfo.length>0&&
{ this.getFloderLis(tmpItm.templateInfo,flg) }
}
) } return Floder } getFloderLis(items,flg){//文件夹内的模板明细 const Items = []; const {admin,checkItemsAdmin} = this.props; items.forEach((v,idx) => { Items.push( ); }); return Items; } getCheckIcon() { const {admin,checkItems,items,checkItemsAdmin,adminItems} = this.props; if(admin){ if (adminItems.length == checkItemsAdmin.length && checkItemsAdmin.length != 0) { return check_right; } else { return check_circle; } } if (items.length == checkItems.length && checkItems.length != 0) { return tmpAllRight; } else { return tmpAllCircle; } } templateSearch(){ const {templateSearch} = this.props templateSearch((this.$search.current.value).trim()) if(this.$search.current.value.trim()){ this.setState({ msg:'暂无模板信息' }) }else{ this.setState({ msg:'还没有保存模板' }) } } handleEnter(e){ if(e.keyCode==13){ this.templateSearch(); } } handleChange(){ const value = (this.$search.current.value).substring(0,30); // this.$search.current.value = value setTimeout(() => { this.setState({ val: value }); }, 30); } clear(){ this.$search.current.value = ''; this.setState({ val:'' }); this.$search.current.focus(); this.templateSearch(); } clickTabChange(){ } componentWillReceiveProps(next){ //点清空恢复初始状态 if(this.props.clearSearch!==next.clearSearch){ this.clear(); } } render() { const {selectTemp,whichTemp, checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props; const {height,showTipContent} = this.state return (
{//管理员操作 adminItems&&admin ? (allCheckShowAdmin ?
全选 完成 { checkItemsAdmin.length>0?删除: 删除 }
:
{this.state.val?清空:''}
搜索
{ adminItems.length > 0&&管理 }
) : null } {//个人 items&&!admin ?
{this.state.val?清空:''}
搜索
: null } {
{//个人 allCheckShow ?
whichTemp(1)}>
全选 完成 {checkItems.length>0&&删除} {/* { checkItems.length>0?删除: 删除 } */}
:null } {
{ !allCheckShow&&
whichTemp(1)}> 个人模板 { items.length > 0&&管理 }
} { !admin?!allCheckShowAdmin&&
{whichTemp(2);allCheckShow&&handleMangerTemplate()}} >标准模板 {selectTemp==2&&} { showTipContent&&

1. 标准模版中的科室,对应的是经朗通医疗团队整理的,符合临床医学意义的科室。

2.只有特定的“管理员”账号,可对“标准模板”进行修改,普通账号仅可进行“引用”;

}
:'' }
} {
{ selectTemp==1&&this.genItems(items).length > 0?this.genItems(items):selectTemp==2&&this.genAdminItems(adminItems,true).length > 0?this.genAdminItems(adminItems,true): }
}
{ admin&&
{this.genAdminItems(adminItems,true).length > 0?this.genAdminItems(adminItems,true): }
}
} {/*
{ this.genItems().length > 0?this.genItems(): } {//注释掉的暂时没有分也功能 hasMore?

handleClickGetMore(current)} className={style.loadMore}>点击查看更多

:null }
*/}
) } } export default TemplateItems; TemplateItems.propTypes = { items: PropTypes.arrayOf(PropTypes.object), handleContentClick: PropTypes.func, handleUpdate: PropTypes.func, handleTemplateDel: PropTypes.func, handleTitleChange: PropTypes.func };