luolei 5 years atrás
parent
commit
cc145db78b
1 changed files with 30 additions and 2 deletions
  1. 30 2
      src/components/TemplateItems/index.jsx

+ 30 - 2
src/components/TemplateItems/index.jsx

@@ -13,6 +13,8 @@ import floderR from './TemplateItem/img/floderR.png';
 import floderD from './TemplateItem/img/floderD.png';
 import Empty from '@components/Empty';
 import $ from 'jquery';
+import store from '@store';
+import { initCommonItemList,findTemplateNorms,getFloderListAll } from '@store/async-actions/tabTemplate';
 import {windowEventHandler,getWindowInnerHeight} from '@utils/tools'
 
 class TemplateItems extends React.Component {
@@ -36,6 +38,7 @@ class TemplateItems extends React.Component {
         this.clear = this.clear.bind(this);
         this.showTipContent = this.showTipContent.bind(this);
         this.getFloderLis = this.getFloderLis.bind(this);
+        this.whichTemp = this.whichTemp.bind(this);
     }  
     componentDidMount(){
         const height = getWindowInnerHeight()-195;
@@ -238,8 +241,22 @@ class TemplateItems extends React.Component {
     }
     
     handleChange(){
+        const {admin,selectTemp} = this.props;
         const value = (this.$search.current.value).substring(0,30);
         // this.$search.current.value = value
+        if(!admin&&selectTemp==1&&value == ''){
+            store.dispatch(initCommonItemList(1,""))
+        }else if(!admin&&selectTemp==2&&value == ''){
+            this.setState({
+                hasSearch:false
+            })
+            store.dispatch(findTemplateNorms(''))
+        }else if(admin){
+            this.setState({
+                hasSearch:false
+            })
+            store.dispatch(getFloderListAll(''))
+        }
         setTimeout(() => {
             this.setState({
                 val: value
@@ -248,7 +265,7 @@ class TemplateItems extends React.Component {
     }
 
     clear(){
-        const {clearTemplateSearch} = this.props
+        const {clearTemplateSearch,selectTemp,admin} = this.props
         this.$search.current.value = '';
         this.setState({
             val:''
@@ -259,6 +276,9 @@ class TemplateItems extends React.Component {
             hasSearch: false
         })
         clearTemplateSearch&&clearTemplateSearch()
+        if(!admin){
+            store.dispatch(initCommonItemList(1,""))
+        }
     }
     clickTabChange(){
 
@@ -269,6 +289,14 @@ class TemplateItems extends React.Component {
         this.clear();
       }
     }
+    whichTemp(num,val){
+        this.props.whichTemp(num,val)
+        if(val){
+            this.setState({
+                hasSearch:true
+            })
+        }
+    }
     render() {
         const {selectTemp,whichTemp, checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore,templateNormsSearchList } = this.props;
 
@@ -342,7 +370,7 @@ class TemplateItems extends React.Component {
                                     {
                                         !admin?!allCheckShowAdmin&&<div 
                                             className={`${style.personalTmp} ${style.personalTmpStatand} ${selectTemp==2?style.personalTmpOwn:''}`} 
-                                            onClick={()=>{whichTemp(2,(this.state.val).trim());allCheckShow&&handleMangerTemplate(2)}}
+                                            onClick={()=>{this.whichTemp(2,(this.state.val).trim());allCheckShow&&handleMangerTemplate(2)}}
                                             >标准模板 {selectTemp==2&&<img src={tempTip} className={style.tempTip} alt="" onMouseEnter={this.showTipContent} onMouseLeave={this.showTipContent}/>}
                                             {
                                                 showTipContent&&<div className={style.tempTipContent}>