<template>
  <div class="panel">
    <div class="left">
      <div class="title">{{ currentTab }}</div>
      <div class="left-content">
        <InsertNote
          ref="InsertNote"
          @insertText="handleInsertText"
          @handleOpenAddUpdateDialog="handleOpenAddUpdateDialog"
        />
        <!-- <AutoCheck v-if="currentTab == '自动检查'" />
        <AutoClose v-if="currentTab == '自动补全'" /> -->
      </div>
    </div>
    <!-- <div class="right">
      <div class="tabs">
        <div
          @click="handleClickTab(item)"
          :class="{ 'tab-item': true, active: currentTab == item }"
          v-for="(item, index) in tabs"
          :key="index"
        >
          {{ item }}
        </div>
      </div>
    </div> -->
    <div class="close">
      <i class="el-icon-close"></i>
    </div>
  </div>
</template>

<script>
import InsertNote from "./insertNote.vue";
import AutoCheck from "./autoCheck.vue";
import AutoClose from "./autoClose.vue";
export default {
  name: "rightPanel",
  components: {
    InsertNote,
    AutoCheck,
    AutoClose,
  },
  data() {
    return {
      // 当前选中的tab
      currentTab: "插入笔记",
      //右侧tabs
      tabs: ["插入笔记", "自动检查", "自动补全"],
    };
  },
  methods: {
    handleClickTab(tab) {
      this.currentTab = tab;
    },
    // 获取笔记
    loadNoteData() {
      console.log("获取笔记loadData");
      this.$refs.InsertNote.loadData();
    },
    //插入文字
    handleInsertText(value) {
      this.$emit("handleInsertText", value);
    },
    // 打开编辑笔记对话框
    handleOpenAddUpdateDialog(item) {
      this.$emit("handleOpenAddUpdateDialog", item);
    },
  },
};
</script>

<style lang="scss" scoped>
.panel {
  display: flex;
  padding: 40px 0 20px;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  .left {
    padding-right: 16px;
    width: 100%;
    .title {
      font-weight: bold;
      display: flex;
      justify-content: center;
      margin-bottom: 16px;
    }
    .left-content {
    }
  }
  .right {
    margin-top: 20px;
    width: 66px;
    .tabs {
      .tab-item {
        text-align: center;
        padding: 14px;
        background-color: #eee;
        color: #666;
        cursor: pointer;
        transition: all ease 0.3s;
        &:hover {
          background-color: $theme-blue;
          color: #fff;
        }
      }
      .active {
        background-color: $theme-blue;
        color: #fff;
      }
    }
  }
  .close {
    position: absolute;
    right: 20px;
    top: 20px;
    i {
      font-size: 24px;
    }
  }
}
</style>
