BaseContextMenu.vue 2.28 KB
Newer Older
wanli's avatar
wanli committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
<template>
  <div class="context-module" v-show="contextVisible" @click="closeContextMenu">
    <div class="context-wrap">
      <el-popover
        v-model="contextVisible"
        placement="right-start"
        width="200"
        trigger="manual"
        transition="el-zoom-in-left"
        popover-class="content-popover-area"
      >
        <div @click="handleGetBig">大图标</div>
        <div @click="handleGetMedium">中等图标</div>
        <div @click="handleGetSmall">小图标</div>
        <div
          slot="reference"
          class="context-module-button"
          :style="{
            left: eventPosition.left + 'px',
            top: eventPosition.top + 'px',
          }"
        ></div>
      </el-popover>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    contextVisible: {
      type: Boolean,
    },
    eventPosition: {
      type: Object,
    },
  },
  mounted() {
    console.log("this.contextVisible", this.contextVisible);
  },
  data() {
    return {
      labelPosition: "right",
    };
  },
  methods: {
    closeContextMenu() {
      console.log("关闭");
      this.$emit("changeVisible", false);
    },
    handleGetBig() {
      console.log("大图标关闭");
      this.$emit("changeSize", "300");
      this.$emit("changeVisible", false);
    },
    handleGetMedium() {
      console.log("中等图标关闭");
      this.$emit("changeSize", "200");
      this.$emit("changeVisible", false);
    },
    handleGetSmall() {
      console.log("小图标关闭");
      this.$emit("changeSize", "100");
      this.$emit("changeVisible", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.context-module {
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  .context-wrap {
    position: relative;
    width: 100%;
    height: 100%;
  }
  .context-module-button {
    position: absolute;
    width: 1px;
    height: 1px;
  }
}

.content-popover-area {
  transform-origin: 0 0 !important;
}
.content-popover-area > div {
  font-size: 12px;
  cursor: pointer;
  line-height: 26px;
  &:hover {
    color: skyblue;
  }
}
</style>
<style lang="scss">
.el-popover {
  background-color: skyblue;
  div {
    font-size: 12px;
    cursor: pointer;
    line-height: 26px;
    &:hover {
      color: #fff;
    }
  }
}
</style>