|
@@ -1,9 +1,8 @@
|
|
|
<template>
|
|
|
- <div class="ui-drag-modal-box-hide" v-if="isBody">
|
|
|
- <Teleport to="#app" :disabled="!isBody">
|
|
|
- <div class="ui-drag-modal-box"
|
|
|
+ <div v-if="isBody" class="ui-drag-modal-box-hide">
|
|
|
+ <Teleport :disabled="!isBody" to="#app">
|
|
|
+ <div :id="'drag-modal-' + uuid"
|
|
|
:class="[isModalShow?'ui-drag-modal-show':'']"
|
|
|
- :id="'drag-modal-' + uuid"
|
|
|
:style="{
|
|
|
left: dragModalLeft + 'px',
|
|
|
top: dragModalTop + 'px',
|
|
@@ -11,19 +10,20 @@
|
|
|
height: heightVal + 'px',
|
|
|
zIndex: isModalShow ? zIndex: -1
|
|
|
}"
|
|
|
+ class="ui-drag-modal-box"
|
|
|
@click.capture="dragModalCapture">
|
|
|
- <div class="ui-drag-modal-dialog shadow-xl" :class="[bg,ui]"
|
|
|
- :style="{width: widthVal + 'px', height: heightVal + 'px'}"
|
|
|
+ <div :class="[bg,ui]" :style="{width: widthVal + 'px', height: heightVal + 'px'}"
|
|
|
+ class="ui-drag-modal-dialog shadow-xl"
|
|
|
@mousedown="dragModalMouseDown">
|
|
|
- <div class="ui-drag-modal-dialog-header" :class="titleBorder?'border-bottom':''">
|
|
|
- <div class="ui-drag-modal-dialog-title text-lg" :class="titleUi">
|
|
|
- <span v-if="title">{{title}}</span>
|
|
|
+ <div :class="titleBorder?'border-bottom':''" class="ui-drag-modal-dialog-header">
|
|
|
+ <div :class="titleUi" class="ui-drag-modal-dialog-title text-lg">
|
|
|
+ <span v-if="title">{{ title }}</span>
|
|
|
</div>
|
|
|
<div class="ui-drag-modal-dialog-extra">
|
|
|
<div class="dialog-icon" @click="_fullscreenClick()">
|
|
|
<HcIcon :name="isFullscreen?'fullscreen-exit':'fullscreen'"/>
|
|
|
</div>
|
|
|
- <div class="dialog-icon" v-if="closeIcon" @click="_closeClick()">
|
|
|
+ <div v-if="closeIcon" class="dialog-icon" @click="_closeClick()">
|
|
|
<HcIcon name="close"/>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -39,9 +39,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref,nextTick,watch } from "vue"
|
|
|
+import {ref, nextTick, watch} from "vue"
|
|
|
import {deepClone, getRandom} from "vue-utils-plus"
|
|
|
import {useAppStore} from "~src/store";
|
|
|
+
|
|
|
const useAppState = useAppStore()
|
|
|
//参数
|
|
|
const props = defineProps({
|
|
@@ -54,7 +55,7 @@ const props = defineProps({
|
|
|
default: ''
|
|
|
},
|
|
|
widths: {
|
|
|
- type: [Number,String],
|
|
|
+ type: [Number, String],
|
|
|
default: 340
|
|
|
},
|
|
|
title: {
|
|
@@ -62,7 +63,7 @@ const props = defineProps({
|
|
|
default: ''
|
|
|
},
|
|
|
titleUi: {
|
|
|
- type: [String,Object,Array],
|
|
|
+ type: [String, Object, Array],
|
|
|
default: ''
|
|
|
},
|
|
|
titleBorder: {
|
|
@@ -78,15 +79,15 @@ const props = defineProps({
|
|
|
default: false
|
|
|
},
|
|
|
lefts: {
|
|
|
- type: [Number,String],
|
|
|
+ type: [Number, String],
|
|
|
default: 0
|
|
|
},
|
|
|
tops: {
|
|
|
- type: [Number,String],
|
|
|
+ type: [Number, String],
|
|
|
default: 0
|
|
|
},
|
|
|
height: {
|
|
|
- type: [Number,String],
|
|
|
+ type: [Number, String],
|
|
|
default: 440
|
|
|
},
|
|
|
//是否排序置顶
|
|
@@ -95,7 +96,7 @@ const props = defineProps({
|
|
|
default: false
|
|
|
},
|
|
|
eid: {
|
|
|
- type: [Number,String],
|
|
|
+ type: [Number, String],
|
|
|
default: ''
|
|
|
},
|
|
|
//关闭时销毁
|
|
@@ -128,7 +129,7 @@ watch(() => [
|
|
|
], ([sortTopList]) => {
|
|
|
dragModalSortTopList.value = sortTopList
|
|
|
setModalIndex(sortTopList)
|
|
|
-}, { deep: true })
|
|
|
+}, {deep: true})
|
|
|
|
|
|
//设置窗口层级
|
|
|
const zIndex = ref(8000)
|
|
@@ -140,13 +141,13 @@ const setModalIndex = (sortTopList) => {
|
|
|
}
|
|
|
|
|
|
//页面渲染完成
|
|
|
-nextTick(()=> {
|
|
|
+nextTick(() => {
|
|
|
//页面渲染完成后,再让 vue3 的 Teleport,把弹出框挂载到外部节点上。
|
|
|
isBody.value = true
|
|
|
if (props.isSortTop) {
|
|
|
const sortTopList = dragModalSortTopList.value
|
|
|
let index = sortTopList.indexOf(uuid)
|
|
|
- if(index === -1) {
|
|
|
+ if (index === -1) {
|
|
|
sortTopList.push(uuid)
|
|
|
index = sortTopList.length - 1
|
|
|
}
|
|
@@ -209,13 +210,13 @@ const dragModalResizeMouseDown = (event) => {
|
|
|
let offsetWidth = dom.offsetWidth, clientHeight = dom.clientHeight;
|
|
|
document.onmousemove = (e) => {
|
|
|
//拖拽时为了对宽和高 限制一下范围,定义两个变量
|
|
|
- let W = e.clientX - clientX + offsetWidth;
|
|
|
- let H = e.clientY - clientY + clientHeight;
|
|
|
+ let W = e.clientX - clientX + offsetWidth;
|
|
|
+ let H = e.clientY - clientY + clientHeight;
|
|
|
|
|
|
- if(body.offsetWidth - e.clientX < 0){
|
|
|
+ if (body.offsetWidth - e.clientX < 0) {
|
|
|
W = body.offsetWidth - parseInt(dom.style.marginLeft);
|
|
|
}
|
|
|
- if(body.offsetHeight - e.clientY < 0){
|
|
|
+ if (body.offsetHeight - e.clientY < 0) {
|
|
|
H = body.offsetHeight - parseInt(dom.style.marginTop);
|
|
|
}
|
|
|
|
|
@@ -281,11 +282,11 @@ const dragModalCapture = () => {
|
|
|
if (props.isSortTop) {
|
|
|
const sortTopList = dragModalSortTopList.value
|
|
|
const index = sortTopList.indexOf(uuid)
|
|
|
- if(index === -1) {
|
|
|
+ if (index === -1) {
|
|
|
//检查是否已经存在,不存在则添加
|
|
|
sortTopList.push(uuid)
|
|
|
useAppState.setDragModalSortTop(sortTopList)
|
|
|
- } else if(index !== sortTopList.length - 1) {
|
|
|
+ } else if (index !== sortTopList.length - 1) {
|
|
|
//检查是否在最上层,不在则置顶,可以解决多次点击时,频繁更改全局状态的问题
|
|
|
sortTopList.splice(index, 1)
|
|
|
sortTopList.push(uuid)
|
|
@@ -300,7 +301,7 @@ const destroyModal = () => {
|
|
|
if (props.isSortTop) {
|
|
|
const sortTopList = dragModalSortTopList.value
|
|
|
const index = sortTopList.indexOf(uuid)
|
|
|
- if(index !== -1) {
|
|
|
+ if (index !== -1) {
|
|
|
sortTopList.splice(index, 1)
|
|
|
}
|
|
|
}
|