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 Empty from '@components/Empty'; import {windowEventHandler,getWindowInnerHeight} from '@utils/tools' class TemplateItems extends React.Component { constructor(props) { super(props); this.state = { msg:'还没有保存模板', val:'', height:'' } 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); } componentDidMount(){ const height = getWindowInnerHeight()-195; this.setState({ height:height }) windowEventHandler('resize', ()=>{ if(this.$conts.current){ const height = getWindowInnerHeight()-195; this.setState({ height:height }) } }); } genItems(items,flg) { const Items = []; const {admin,adminItems,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 check_right; } else { return check_circle; } } 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(); } componentWillReceiveProps(next){ //点清空恢复初始状态 if(this.props.clearSearch!==next.clearSearch){ this.clear(); } } render() { const { checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props; const {height} = this.state return (
{//管理员操作 adminItems&&admin ? (allCheckShowAdmin ?
全选 完成 { checkItemsAdmin.length>0?删除: 删除 }
:
{this.state.val?清空:''}
搜索
{ adminItems.length > 0&&管理 }
) : null } {//个人 items&&!admin ?
{this.state.val?清空:''}
搜索
: null } {
{//个人 allCheckShow&&!admin ?
全选 完成 { checkItems.length>0?删除: 删除 }
:null } { !allCheckShow&&
个人模板 { items.length > 0&&管理 }
} {
{this.genItems(items).length > 0?this.genItems(items): }
}
{ !admin?!allCheckShowAdmin&&
标准模板
:'' } {
{this.genItems(adminItems,true).length > 0?this.genItems(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 };