customInstructions.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import Vue from 'vue'
  2. import { getSessionStorage } from '@/utils/auth'
  3. Vue.directive('power', {
  4. inserted(el, type) {
  5. const powerList = getSessionStorage('buttons') || []
  6. const [one, two] = type.value.split(':')
  7. if (one && !powerList.includes(one)) {
  8. if (two === 'tab') {
  9. const idAttr = el.getAttribute('aria-labelledby')
  10. setTimeout(() => {
  11. document.getElementById(idAttr).style.display = 'none'
  12. }, 100)
  13. } else {
  14. el.remove()
  15. // el.style.display = 'none'
  16. }
  17. }
  18. }
  19. })
  20. Vue.directive('mobile-dropdown', {
  21. inserted(el) {
  22. if (window.screen.width < 768) {
  23. el.addEventListener('click', function(event) {
  24. const list = document.querySelectorAll('.el-select-dropdown')
  25. const dom = list[list.length - 1] // console.log(el.offsetLeft, 'offsetLeft') // console.log(event.pageX - event.offsetX +  document.body.scrollLeft, 'total')
  26. const total = event.pageX - event.offsetX + document.body.scrollLeft
  27. dom.style.left = total + 'px'
  28. })
  29. }
  30. }
  31. })