contentMenu.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!--
  2. * @Descripttion: 组件右键菜单
  3. * @Author: qianlishi
  4. * @Date: 2021-6-25 14:48:27
  5. * @LastEditors: qianlishi
  6. * @LastEditTime: 2023-3-6 17:38:44
  7. -->
  8. <template>
  9. <div v-show="visible" class="contentmenu" :style="styleObj">
  10. <div class="contentmenu__item" @click="deleteLayer">
  11. <i class="iconfont iconguanbi"></i> 删除图层
  12. </div>
  13. <div class="contentmenu__item" @click="lockLayer">
  14. <i class="iconfont iconfuzhi1"></i> 锁定图层
  15. </div>
  16. <div class="contentmenu__item" @click="noLockLayer">
  17. <i class="iconfont iconfuzhi1"></i> 解除锁定
  18. </div>
  19. <div class="contentmenu__item" @click="copyLayer">
  20. <i class="iconfont iconfuzhi1"></i> 复制图层
  21. </div>
  22. <div class="contentmenu__item" @click="istopLayer">
  23. <i class="iconfont iconjinlingyingcaiwangtubiao01"></i> 置顶图层
  24. </div>
  25. <div class="contentmenu__item" @click="setlowLayer">
  26. <i class="iconfont iconleft-copy"></i> 置底图层
  27. </div>
  28. <div class="contentmenu__item" @click="moveupLayer">
  29. <i class="iconfont iconjinlingyingcaiwangtubiao01"></i> 上移一层
  30. </div>
  31. <div class="contentmenu__item" @click="movedownLayer">
  32. <i class="iconfont iconleft-copy"></i> 下移一层
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. export default {
  38. props: {
  39. styleObj: Object,
  40. visible: Boolean,
  41. },
  42. data() {
  43. return {};
  44. },
  45. watch: {
  46. visible(value) {
  47. if (value) {
  48. document.body.addEventListener("click", this.closeMenu);
  49. } else {
  50. document.body.removeEventListener("click", this.closeMenu);
  51. }
  52. },
  53. },
  54. methods: {
  55. closeMenu() {
  56. this.$emit("update:visible", false);
  57. },
  58. deleteLayer() {
  59. this.$confirm("是否删除所选图层?", "提示", {
  60. confirmButtonText: "确定",
  61. cancelButtonText: "取消",
  62. type: "warning",
  63. })
  64. .then(() => {
  65. this.$emit("deletelayer");
  66. this.$message({
  67. type: "success",
  68. message: "删除成功!",
  69. });
  70. })
  71. .catch(() => {
  72. this.$message({
  73. type: "info",
  74. message: "已取消删除",
  75. });
  76. });
  77. },
  78. lockLayer() {
  79. this.$emit("lockLayer");
  80. },
  81. noLockLayer() {
  82. this.$emit("noLockLayer");
  83. },
  84. copyLayer() {
  85. this.$emit("copylayer");
  86. },
  87. istopLayer() {
  88. this.$emit("istopLayer");
  89. },
  90. setlowLayer() {
  91. this.$emit("setlowLayer");
  92. },
  93. moveupLayer() {
  94. this.$emit("moveupLayer");
  95. },
  96. movedownLayer() {
  97. this.$emit("movedownLayer");
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .contentmenu {
  104. width: 160px;
  105. position: fixed;
  106. z-index: 99999;
  107. list-style: none;
  108. -webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  109. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  110. padding: 0;
  111. background: #27343e;
  112. color: #bcc9d4;
  113. .contentmenu__item {
  114. z-index: 10000;
  115. list-style: none;
  116. padding: 8px 12px;
  117. cursor: pointer;
  118. position: relative;
  119. font-size: 12px;
  120. }
  121. .iconfont {
  122. font-size: 12px;
  123. }
  124. }
  125. </style>