<template>
  <div class="panel">
    <div class="left">
      <div class="title">插入笔记</div>
      <div class="left-content">
        <InsertNote
          ref="InsertNote"
          @insertText="handleInsertText"
          @handleOpenAddUpdateDialog="handleOpenAddUpdateDialog"
        />
      </div>
    </div>
    <div
      :title="visible?'收起面板':'插入笔记'"
      :class="['close', !visible ? 'hidden' : '']"
      @click="handleToggleNotePanel"
    >
      <i :class="visible ? 'el-icon-arrow-right' : 'el-icon-edit'"></i>
    </div>
  </div>
</template>

<script>
import InsertNote from "./insertNote.vue";
export default {
  name: "rightPanel",
  components: {
    InsertNote,
  },
  data() {
    return {
      visible: false, //面板的可见性，用于控制按钮是否是悬浮
    };
  },
  methods: {
    // 获取笔记
    loadNoteData() {
      this.$refs.InsertNote.loadData();
    },
    //插入文字
    handleInsertText(value) {
      this.$emit("handleInsertText", value);
    },
    // 打开编辑笔记对话框
    handleOpenAddUpdateDialog(item) {
      this.$emit("handleOpenAddUpdateDialog", item);
    },
    // 关闭笔记弹窗
    handleToggleNotePanel() {
      this.visible = !this.visible;
      this.$emit("handleToggleNotePanel");
    },
  },
};
</script>

<style lang="scss" scoped>
.panel {
  display: flex;
  padding: 20px 0;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  border-left: 1px solid #e6ebf5;
  background-color: #fff;
  .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;
    left: 0;
    top: 45%;
    cursor: pointer;
    background-color: #fff;
    transform: translate(-50%, -50%);
    box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px,
      rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    i {
      font-size: 22px;
      color: #d3d3d3;
      transition: all ease 0.5s;
    }
  }
  // 当面板不可见时会显示
  .hidden {
    left: -100px;
    width: 68px;
    height: 68px;
    i {
      color: $theme-blue;
      font-size: 42px;
    }
  }
}
</style>
