Parcourir la source

模板搜索为空显示搜索框

luolei il y a 5 ans
Parent
commit
a453568129

+ 14 - 5
src/components/TemplateItems/index.jsx

@@ -57,11 +57,11 @@ class TemplateItems extends React.Component {
     }
     render() {
         const { allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props;
-        // console.log(hasMore,current,7877877)
+        console.log(allCheckShow,7877877)
         return (
             <div className={style.wrapper}>
                 {
-                    items && items.length > 0 ? (allCheckShow ?
+                    items ? (allCheckShow ?
                         <div className={style.wrapperTop}>
                             <div className={style['check-wrap']} onClick={handleAllCheckbox}>
                                 <img className={`${style['fl-element']} ${style['check-box']}`} src={this.getCheckIcon()} />
@@ -78,13 +78,22 @@ class TemplateItems extends React.Component {
                                 <input ref={this.$search} type="text" />
                                 <div className={style.search} onClick={this.templateSearch}>检索</div>
                             </div>
-                            <span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplate}>管理</span>
+                            {
+                                items.length > 0&&<span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplate}>管理</span>
+                            }
                     </div>) : <div style={{height:'36px'}}></div>
+                    // <div className={style.emptyWrap}>
+                    //     <div className={`${style.templateSearch}`}>
+                    //         <input ref={this.$search} type="text" />
+                    //         <div className={style.search} onClick={this.templateSearch}>检索</div>
+                            
+                    //     </div>
+                    //     <span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplate}>管理</span>
+                    // </div>
                 }
                 <div className={style.tempLists} ref={this.$cont}>
                     {
-                        this.genItems().length > 0?this.genItems():
-                        <Empty message={'还没有保存模板'}></Empty>
+                        this.genItems().length > 0?this.genItems(): <Empty message={'还没有保存模板'}></Empty>
                     }
                     {/* {//注释掉的暂时没有分也功能
                       hasMore?<p onClick={()=>handleClickGetMore(current)} className={style.loadMore}>点击查看更多</p>:null

+ 11 - 0
src/components/TemplateItems/index.less

@@ -11,6 +11,17 @@
         background-color: #fff;
         margin-top: 15px;
     }
+    .emptyWrap {
+        padding: 0 20px;
+        margin-top: 15px;
+        .fr-element {
+            float: right;
+            color: #3B9ED0;
+            display: inline-block;
+            height: 36px;
+            line-height: 36px;
+        }
+    }
     .wrapperTop {
         height: 36px;
         padding: 0 20px;

+ 6 - 0
src/store/reducers/tabTemplate.js

@@ -36,6 +36,9 @@ export default (state = initDataList, action) => {
     let tempArr = newState.items;
     tempArr.splice(tempArr.findIndex(item => item.id == action.id), 1)
     newState.items = [...tempArr];
+    // if(tempArr.length == 0){
+    //   newState.allCheckShow = false
+    // }
     return newState;
   }
   if (action.type === BATCH_DEL_ITEMS) {
@@ -46,6 +49,9 @@ export default (state = initDataList, action) => {
       tempArr.splice(tempArr.findIndex(item => item.id == currentId), 1)
     }
     newState.items = [...tempArr];
+    // if(tempArr.length == 0){
+    //   newState.allCheckShow = false
+    // }
     newState.checkItems = [];
     return newState;
   }