Pārlūkot izejas kodu

模板展开限制为一个

Luolei 6 gadi atpakaļ
vecāks
revīzija
388a8fefd3

+ 12 - 53
src/components/TemplateItems/TemplateItem/index.jsx

@@ -10,7 +10,6 @@ import edit_icon from './img/edit_grey.png';
 import editing_icon from './img/edit_blue.png';
 import check_circle from './img/check-circle.png';
 import check_right from './img/check-right.png';
-import Notify from '@commonComp/Notify';
 import store from '@store'
 import {checkItems} from '@store/actions/tabTemplate';
 import $ from 'jquery';
@@ -19,72 +18,28 @@ class TemplateItem extends React.Component {
     constructor() {
         super();
         this.content = null;
-        this.isAnimate = false;
         this.state = {
             isOpen: false,
             delHover: false,
             editHover: false,
             checkBox:false,
-            bgColor:false
+            bgColor:false,
         };
         this.titleDOM = null;
         this.isConfirmClick = false;
         this.timer = null;
-    }
-    genContent() {
-        const {preview} = this.props;
-        this.title = '';
-        let DesItems = [];
-        for(var a in previewJson){
-            DesItems.push(<DesItem preview={preview} des={a} />);            
-        }
-        // if(previewJson){
-        //     console.log(previewJson,1000)
-        //     previewJson.forEach((v, i) => {
-        //         DesItems.push(<DesItem des={v} key={i} />);
-        //         this.title += `${v}\n`;
-        //     });
-        // }
-        return DesItems;
+        this.handleTitleClick = this.handleTitleClick.bind(this)
     }
 
     getArrow() {
         return this.state.isOpen ? arrow_down_icon : arrow_icon;
     }
 
-    getContentStyle() {
-        return {
-            display: this.state.isOpen ? 'block' : 'none'
-        }
-    }
-
     handleContentClick(e,sex) {
         e.stopPropagation();
         this.props.handleContentClick(this.props.id,sex);
     }
 
-    handleTitleClick() {
-        if (this.isAnimate) {
-            return;
-        }
-        this.isAnimate = true;
-        if (this.state.isOpen) {
-            $(this.content).slideUp(() => {
-                this.isAnimate = false;
-                this.setState({
-                    isOpen: false
-                });
-            });
-            // console.log($(this.content).parent().siblings().find('.content'))
-            return;
-        }
-        $(this.content).slideDown(() => {
-            this.isAnimate = false;
-            this.setState({
-                isOpen: true
-            });
-        });
-    }
     handleCheckboxClick(e,id){          //点击复选框
         e.stopPropagation();
         let tempCheck = this.state.checkBox;
@@ -157,6 +112,15 @@ class TemplateItem extends React.Component {
         this.titleDOM.innerHTML = this.props.title;
     }
 
+    handleTitleClick(e) {
+      $(e.target).next().slideToggle() 
+      let tmpDomLis = $(e.target).parent().siblings()
+      for(let i = 0;i < tmpDomLis.length;i++){
+        let tmpDiv = tmpDomLis[i]
+        $(tmpDiv).children().eq(1).slideUp()
+      }
+    }
+
     render() {
         const { allCheckShow,id,name,preview,sex } = this.props;
         let previewJson = JSON.parse(preview);
@@ -167,7 +131,7 @@ class TemplateItem extends React.Component {
                     allCheckShow?
                     `${style["title-wrapper"]} ${style["clearfix"]} ${style[this.getCheckIcon()[1]]}`:
                     `${style["title-wrapper"]} ${style["clearfix"]}`} 
-                    onClick={() => this.handleTitleClick()}
+                    onClick={this.handleTitleClick}
                 >
                     {
                         allCheckShow?<div className={style['check-wrap']} onClick={(e)=>{this.handleCheckboxClick(e,id)}}>
@@ -204,7 +168,6 @@ class TemplateItem extends React.Component {
                     ref={(content) => this.content = content}
                     className={style.content}
                     title={this.title}
-                    style={this.getContentStyle()}
                 >
                     {
                         previewJson?<DesItem preview={previewJson}></DesItem>:<p>暂无数据</p>
@@ -215,10 +178,6 @@ class TemplateItem extends React.Component {
         )
     }
 
-    componentDidUpdate() {
-        this.isAnimate = false;
-    }
-
     componentWillUnmount() {
         clearTimeout(this.timer);
     }

+ 2 - 0
src/components/TemplateItems/TemplateItem/index.less

@@ -14,6 +14,7 @@
 //   margin-bottom: 5px;
   border: 1px solid #fff;
   &:hover{
+    border: 1px solid @blue-background-color;
     border: 1px solid @blue-background-color;
     .title{
       color:@blue-background-color;
@@ -131,5 +132,6 @@
     width: 100%;
     box-sizing: border-box;
     cursor: pointer;
+    display: none;
   }
 }

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

@@ -27,11 +27,12 @@ class TemplateItems extends React.Component {
     }
     genItems() {
         const Items = [];
-        this.props.items.forEach((v) => {
+        this.props.items.forEach((v,idx) => {
             Items.push(
                 <TemplateItem
                     {...v}
                     key={v.id}
+                    idx={idx}
                     checkItems={this.props.checkItems}
                     allCheckShow={this.props.allCheckShow}
                     handleContentClick={this.props.handleContentClick}

+ 1 - 1
src/store/actions/checkBody.js

@@ -496,7 +496,7 @@ export function delSingleLable(state,action){
   return res;
 }
 //查体推送高亮标签
-export function setImportCheckbodyLabel(state,action) {console.log(action)
+export function setImportCheckbodyLabel(state,action) {//console.log(action)
   let res = Object.assign({},state);
   res.importLabel = action.labels;
   res.update = Math.random();