index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <!-- 菜单下载/预览/删除 -->
  3. <div class="menuPopover" :class="menuStyle" @mouseover="mouseover" @mouseout="mouseout">
  4. <el-popover placement="top-start" title="" trigger="hover" popper-class="popperClass"
  5. >
  6. <div class="menuList" >
  7. <div v-for="item in menuList" :key="item.value" @click="menuBtn(item)" class="menuListLi" v-show="item.show">
  8. <i :class="item.icon"></i><span>{{item.label}}</span>
  9. </div>
  10. </div>
  11. <div slot="reference" class="menu-button">
  12. <div class="line-box">
  13. <div class="line"></div>
  14. <div class="line"></div>
  15. <div class="line"></div>
  16. </div>
  17. </div>
  18. </el-popover>
  19. </div>
  20. </template>
  21. <script>
  22. import { File } from './mixins'
  23. export default {
  24. props: {
  25. data: {
  26. type: Object,
  27. default: () => {
  28. return {}
  29. }
  30. },
  31. deleted: {
  32. type: Boolean,
  33. default:true
  34. }
  35. },
  36. mixins: [File],
  37. data() {
  38. return {
  39. menuStyle: 'menu-box',
  40. active: false,
  41. menuList: [
  42. {value:'downLoad',label:'下载',icon:'el-icon-download',show:true},
  43. {value:'preview',label:'预览',icon:'el-icon-view',show:true},
  44. {value:'delFile',label:'删除',icon:'el-icon-delete',show:this.deleted},
  45. ]
  46. }
  47. },
  48. watch: {
  49. deleted(val) {
  50. this.menuList.forEach(item => {
  51. if (item.value == 'delFile') {
  52. item.show = val
  53. return false
  54. }
  55. })
  56. }
  57. },
  58. methods: {
  59. menuBtn(item) {
  60. var data =this.data
  61. switch (item.value) {
  62. case 'downLoad':
  63. this.downLoad(data)
  64. break;
  65. case 'preview':
  66. this.preview(data)
  67. break;
  68. case 'delFile':
  69. this.delFile(data)
  70. break;
  71. default:
  72. break;
  73. }
  74. },
  75. mouseover() {
  76. this.menuStyle = 'active'
  77. this.active = true
  78. },
  79. mouseout() {
  80. this.menuStyle = ''
  81. this.active = false
  82. },
  83. }
  84. }
  85. </script>
  86. <style >
  87. .el-popover.popperClass {
  88. min-width: 80px ;
  89. border: 1px solid #ACA9A9;
  90. }
  91. .el-popper[x-placement^=top] .popper__arrow::after{
  92. border-top-color: #7f7f7f;
  93. bottom: 0px;
  94. }
  95. </style>
  96. <style lang="scss" scoped>
  97. .menuList :first-child{
  98. padding-top: 0px;
  99. }
  100. .menuList :hover{
  101. color: #5c67ff;
  102. cursor: pointer;
  103. }
  104. .menuListLi{
  105. border-bottom: 1px solid #e6e6e6;
  106. padding: 10px 0 3px 0;
  107. }
  108. .menuListLi :first-child{
  109. padding-right: 5px;
  110. }
  111. .menu-button {
  112. width: 25px;
  113. height: 25px;
  114. background-color: white;
  115. border-radius: 50%;
  116. // box-shadow: 0 0 0 4px rgba(92,103,255,0.3);
  117. color: #fff;
  118. display: flex;
  119. justify-content: center;
  120. align-items: center;
  121. position: relative;
  122. cursor: pointer;
  123. transition: 0.2s ease-in;
  124. }
  125. .menu-button:hover {
  126. background-color: white;
  127. z-index: 999;
  128. // box-shadow: 0 0 0 8px rgba(92,103,255,0.3);
  129. }
  130. .menu-button .line-box {
  131. width: 10px;
  132. height: 10px;
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: space-between;
  136. cursor: pointer;
  137. transition: transform 0.3s ease-out;
  138. }
  139. .menu-button .line {
  140. background-color: black;
  141. width: 100%;
  142. height: 2px;
  143. border-radius: 2px;
  144. }
  145. .menu-button .line:first-child {
  146. width: 50%;
  147. transform-origin: right;
  148. transition: transform 0.3s ease-in-out;
  149. }
  150. .menu-button .line:last-child {
  151. width: 50%;
  152. align-self: flex-end;
  153. transform-origin: left;
  154. transition: transform 0.3s ease-in-out;
  155. }
  156. // .menu-list1 {
  157. // padding: 6px;
  158. // transition: 0.3s ease;
  159. // transition: delay 0.3s;
  160. // }
  161. // .menu-list1 li {
  162. // display: flex;
  163. // justify-content: center;
  164. // align-items: center;
  165. // padding: 10px;
  166. // color: #343470;
  167. // cursor: pointer;
  168. // position: relative;
  169. // opacity: 1;
  170. // transform: translateX(-10px);
  171. // transition: 0.2s ease-in;
  172. // }
  173. // .menu-list1 li:hover {
  174. // color: #5c67ff;
  175. // }
  176. .menu-list1 li::before {
  177. content: '';
  178. width: calc(100% - 24px);
  179. height: 1px;
  180. background-color: rgba(92, 103, 255, 0.1);
  181. position: absolute;
  182. bottom: 0;
  183. left: 12px;
  184. }
  185. .menu-list1 li:last-child::before {
  186. display: none;
  187. }
  188. // .menu-list1 .fa {
  189. // font-size: 18px;
  190. // width: 18px;
  191. // height: 18px;
  192. // display: flex;
  193. // justify-content: center;
  194. // align-items: center;
  195. // }
  196. // .menu-list1 span {
  197. // font-size: 14px;
  198. // margin-left: 8px;
  199. // }
  200. .active {
  201. position: relative;
  202. }
  203. .active .line-box {
  204. transform: rotate(-45deg);
  205. }
  206. .active .line-box .line:first-child {
  207. transform: rotate(-90deg) translateX(1px);
  208. }
  209. .active .line-box .line:last-child {
  210. transform: rotate(-90deg) translateX(-1px);
  211. }
  212. .active .menu-list {
  213. margin: 0;
  214. opacity: 1;
  215. transform: scale(1);
  216. }
  217. .active .menu-list li {
  218. animation: fade-in-item 0.4s linear forwards;
  219. }
  220. .active .menu-list li:nth-child(1) {
  221. animation-delay: 0.1s;
  222. }
  223. .active .menu-list li:nth-child(2) {
  224. animation-delay: 0.2s;
  225. }
  226. .active .menu-list li:nth-child(3) {
  227. animation-delay: 0.3s;
  228. }
  229. @keyframes fade-in-item {
  230. 100% {
  231. transform: translateX(0);
  232. opacity: 1;
  233. }
  234. }</style>