2021-03-05 16:07:44 +08:00
|
|
|
import permission from '@/directive/Permission'
|
2022-03-29 11:46:48 +08:00
|
|
|
import { setLayout } from '@/utils/LayoutUtil'
|
2021-03-05 16:07:44 +08:00
|
|
|
|
2021-03-16 17:53:43 +08:00
|
|
|
export const left2RightDrag = {
|
|
|
|
inserted(el, binding) {
|
2022-03-29 11:46:48 +08:00
|
|
|
const value = binding.value
|
2021-03-16 17:53:43 +08:00
|
|
|
el.onmousedown = function(e) {
|
|
|
|
const init = e.clientX
|
|
|
|
const parent = el.parentNode
|
|
|
|
const initWidth = parent.offsetWidth
|
|
|
|
document.onmousemove = function(e) {
|
|
|
|
const end = e.clientX
|
|
|
|
const newWidth = end - init + initWidth
|
|
|
|
if (newWidth < document.body.clientWidth - 10 && newWidth > 10) {
|
|
|
|
parent.style.width = newWidth + 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.onmouseup = function() {
|
2022-03-29 11:46:48 +08:00
|
|
|
value && setLayout(value, parent.style.width)
|
|
|
|
|
2021-03-16 17:53:43 +08:00
|
|
|
document.onmousemove = document.onmouseup = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const right2LeftDrag = {
|
|
|
|
inserted(el, binding) {
|
|
|
|
el.onmousedown = function(e) {
|
|
|
|
const init = e.clientX
|
|
|
|
const parent = el.parentNode
|
|
|
|
const initWidth = parent.offsetWidth
|
|
|
|
document.onmousemove = function(e) {
|
|
|
|
const end = e.clientX
|
|
|
|
const newWidth = initWidth - (end - init)
|
|
|
|
if (newWidth < document.body.clientWidth - 10 && newWidth > 10) {
|
|
|
|
parent.style.width = newWidth + 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.onmouseup = function() {
|
|
|
|
document.onmousemove = document.onmouseup = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const bottom2TopDrag = {
|
|
|
|
inserted(el, binding) {
|
|
|
|
el.onmousedown = function(e) {
|
|
|
|
const init = e.clientY
|
|
|
|
const parent = el.parentNode
|
|
|
|
const initHeight = parent.offsetHeight
|
|
|
|
document.onmousemove = function(e) {
|
|
|
|
const end = e.clientY
|
|
|
|
const newHeight = initHeight - (end - init)
|
|
|
|
if (newHeight < document.body.clientHeight - 10 && newHeight > 10) {
|
|
|
|
parent.style.height = newHeight + 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.onmouseup = function() {
|
|
|
|
document.onmousemove = document.onmouseup = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 18:32:19 +08:00
|
|
|
const closePress = {
|
|
|
|
inserted: function (el) {
|
|
|
|
el.querySelector('.el-drawer__close-btn').onmousedown = function (e) {
|
|
|
|
e.currentTarget.style.background = '#d2d3d4';
|
|
|
|
}
|
|
|
|
el.querySelector('.el-drawer__close-btn').onmouseup = function (e) {
|
|
|
|
e.currentTarget.style.background = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-26 18:03:31 +08:00
|
|
|
const btnPress = {
|
|
|
|
update: function (el, binding) {
|
|
|
|
el.onmousedown = function (e) {
|
|
|
|
e.currentTarget.style.setProperty('background', binding.value || '#EFF0F1', 'important');
|
|
|
|
}
|
|
|
|
el.onmouseup = function (e) {
|
|
|
|
e.currentTarget.style.background = 'none';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2022-07-25 18:32:19 +08:00
|
|
|
|
|
|
|
|
2021-03-05 16:07:44 +08:00
|
|
|
export default {
|
|
|
|
install(Vue) {
|
2021-05-18 16:07:19 +08:00
|
|
|
// Vue.directive('data-permission', dataPermission)
|
2021-03-05 16:07:44 +08:00
|
|
|
Vue.directive('permission', permission)
|
2021-03-16 17:53:43 +08:00
|
|
|
Vue.directive('left-to-right-drag', left2RightDrag)
|
|
|
|
Vue.directive('right-to-left-drag', right2LeftDrag)
|
|
|
|
Vue.directive('bottom-to-top-drag', bottom2TopDrag)
|
2022-07-25 18:32:19 +08:00
|
|
|
Vue.directive('closePress', closePress)
|
2022-07-26 18:03:31 +08:00
|
|
|
Vue.directive('btnPress', btnPress)
|
2021-03-05 16:07:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|