|
@@ -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);
|
|
|
}
|