<template>
  <div class="templateEditBtnBox" @click="openComponentListWindow" v-if="this.$store.state.template.previewStatus==false">
    <i class="el-icon-scissors"></i>
  </div>
</template>

<script>
export default {
  props: {
    id: {
      type:Number,
      default:0
    },
    dataSort: {
      type:Number,
      default:0
    },
    sort:{
      type:Number,
      default:0
    },
    type:{
      type:Number,
      default:0
    }
  },
  data() {
    return {
      
    };
  },
  methods: {
    openComponentListWindow(){
      //判断编辑的是哪个页面的组件style
      let style = 0;
      if(this.$store.state.template.pageStatus==1){
        style = this.$store.state.template.pageData.index[this.dataSort].content.componentList[this.sort].component_style;
      }
      if(this.$store.state.template.pageStatus==2){}
      if(this.$store.state.template.pageStatus==3){
        style = this.$store.state.template.pageData.list[this.dataSort].content.componentList[this.sort].component_style;
      }
      if(this.$store.state.template.pageStatus==4){
        style = this.$store.state.template.pageData.article[this.dataSort].content.componentList[this.sort].component_style;
      }
      if(this.$store.state.template.pageStatus==5){}
      if(this.$store.state.template.pageStatus==6){}
      if(this.$store.state.template.pageStatus==7){}

      let data = {
        id:this.id,
        dataSort:this.dataSort,
        sort:this.sort,
        type:this.type,
        style:style
      }
      console.log(data);
      this.$store.commit('template/setComponentStyleStatus',data);
    }
  },
  mounted() {
    
  },
};
</script>

<style scoped lang="less">
  .templateEditBtnBox {
    position: absolute;
    top: 0;
    left: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 5px;
    color: #666;
    background: rgba(255,255,255,0.5);
    border-radius: 5px;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    font-size: 30px;
    transition: all 0.3s;
    z-index: 999;
    &:hover {
      color: #333;
    }
  }
</style>
