|
@@ -5,7 +5,7 @@
|
|
-->
|
|
-->
|
|
<template>
|
|
<template>
|
|
<transition name="bounceModalFrame" @afterLeave="unmount">
|
|
<transition name="bounceModalFrame" @afterLeave="unmount">
|
|
- <div v-show="show" class="modalFrame" :class="props.className" @click="handleMaskClose">
|
|
|
|
|
|
+ <div v-show="show" class="h-modalFrame" :class="props.className" @click="handleMaskClose">
|
|
<div class="animationBox">
|
|
<div class="animationBox">
|
|
<div ref="modalFrameBoxDom" class="modalFrameBox" :style="modalFrameStyle" @click.stop>
|
|
<div ref="modalFrameBoxDom" class="modalFrameBox" :style="modalFrameStyle" @click.stop>
|
|
<div ref="modalFrameTitleDom" class="modalFrameTitle" :class="{ noMove: !props.draggable }">
|
|
<div ref="modalFrameTitleDom" class="modalFrameTitle" :class="{ noMove: !props.draggable }">
|
|
@@ -13,7 +13,6 @@
|
|
<el-icon class="icon" @click="close"><Close /></el-icon>
|
|
<el-icon class="icon" @click="close"><Close /></el-icon>
|
|
</div>
|
|
</div>
|
|
<div class="frameBox" :class="{ frameBtnNone: !filterBtnShow }">
|
|
<div class="frameBox" :class="{ frameBtnNone: !filterBtnShow }">
|
|
- <!-- 这里有个异常bug,系统默认上传文件取消时候,不知道为啥会触发cancel,所以这里将cancel,close,ok改为onCancel,onClose,onOk -->
|
|
|
|
<component :is="props.template" ref="templateModal" @onCancel="cancel" @onClose="close" @onOk="ok" :modal-data="props.modalData" />
|
|
<component :is="props.template" ref="templateModal" @onCancel="cancel" @onClose="close" @onOk="ok" :modal-data="props.modalData" />
|
|
</div>
|
|
</div>
|
|
<div v-if="filterBtnShow" class="frameBtn">
|
|
<div v-if="filterBtnShow" class="frameBtn">
|
|
@@ -34,6 +33,7 @@
|
|
import { Close } from "@element-plus/icons-vue"
|
|
import { Close } from "@element-plus/icons-vue"
|
|
import { addClass, removeClass } from "@/libs/tools"
|
|
import { addClass, removeClass } from "@/libs/tools"
|
|
import { ref, computed, onMounted, DefineComponent, ComponentPublicInstance, App } from "vue"
|
|
import { ref, computed, onMounted, DefineComponent, ComponentPublicInstance, App } from "vue"
|
|
|
|
+import { baseSize, baseWidth, size } from "@/libs/rem"
|
|
|
|
|
|
interface modalFrameDataType {
|
|
interface modalFrameDataType {
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -62,11 +62,11 @@ const props = withDefaults(defineProps<modalFrameDataType>(), {
|
|
btnShow: () => [true, true], //是否显示按钮,[true,false],可以控制按钮的显示隐藏
|
|
btnShow: () => [true, true], //是否显示按钮,[true,false],可以控制按钮的显示隐藏
|
|
btnTit: () => ["确认", "取消"], // 按钮的文字,["确认"]
|
|
btnTit: () => ["确认", "取消"], // 按钮的文字,["确认"]
|
|
maskClose: false, //点击遮罩关闭
|
|
maskClose: false, //点击遮罩关闭
|
|
- draggable: true //是否可以拖动
|
|
|
|
|
|
+ draggable: false //是否可以拖动
|
|
})
|
|
})
|
|
|
|
|
|
const bodyDom = document.querySelector("body"),
|
|
const bodyDom = document.querySelector("body"),
|
|
- name = "modalFrameBody"
|
|
|
|
|
|
+ name = "h-modalFrameBody"
|
|
const show = ref(false) //控制动画显示隐藏
|
|
const show = ref(false) //控制动画显示隐藏
|
|
const vm = ref<ComponentPublicInstance>()
|
|
const vm = ref<ComponentPublicInstance>()
|
|
const vmApp = ref<App<Element>>()
|
|
const vmApp = ref<App<Element>>()
|
|
@@ -84,7 +84,7 @@ const modalFrameStyle = computed(() => {
|
|
width = convertValue(props.width)
|
|
width = convertValue(props.width)
|
|
const posWidth = computePos("width", width)
|
|
const posWidth = computePos("width", width)
|
|
const posHeight = computePos("height", height)
|
|
const posHeight = computePos("height", height)
|
|
- return `transform:translate(${posWidth.pos}px,${posHeight.pos}px);width:${posWidth.unit};height:${posHeight.unit};`
|
|
|
|
|
|
+ return `transform:translate(${posWidth.pos}rem,${posHeight.pos}px);width:${posWidth.unit};height:${posHeight.unit};`
|
|
})
|
|
})
|
|
|
|
|
|
function convertValue(strNum: string | number) {
|
|
function convertValue(strNum: string | number) {
|
|
@@ -99,15 +99,19 @@ function convertValue(strNum: string | number) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function computePos(type: "width" | "height", value: number | string) {
|
|
function computePos(type: "width" | "height", value: number | string) {
|
|
- const clientNum = document.documentElement[type == "width" ? "clientWidth" : "clientHeight"]
|
|
|
|
|
|
+ //const clientNum = document.documentElement[type == "width" ? "clientWidth" : "clientHeight"]
|
|
|
|
+ const clientNum = type == "width" ? baseWidth : document.documentElement.clientHeight
|
|
return typeof value === "string"
|
|
return typeof value === "string"
|
|
? {
|
|
? {
|
|
- pos: (clientNum - (parseInt(value) / 100) * clientNum) / 2,
|
|
|
|
|
|
+ pos:
|
|
|
|
+ type == "width"
|
|
|
|
+ ? ((clientNum - (parseInt(value) / 100) * clientNum) / 2 / baseSize).toFixed(5)
|
|
|
|
+ : (clientNum - (parseInt(value) / 100) * clientNum) / 2,
|
|
unit: value
|
|
unit: value
|
|
}
|
|
}
|
|
: {
|
|
: {
|
|
- pos: (clientNum - value) / 2,
|
|
|
|
- unit: value + "px"
|
|
|
|
|
|
+ pos: type == "width" ? ((clientNum - value) / 2 / baseSize).toFixed(5) : (clientNum - value * (size / baseSize)) / 2,
|
|
|
|
+ unit: (value / baseSize).toFixed(5) + "rem"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
@@ -115,6 +119,8 @@ onMounted(() => {
|
|
props.draggable && drag(modalFrameTitleDom.value!)
|
|
props.draggable && drag(modalFrameTitleDom.value!)
|
|
window.addEventListener("resize", refreshPos)
|
|
window.addEventListener("resize", refreshPos)
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+/* 拖拽还没有兼容rem */
|
|
function drag(el: HTMLElement) {
|
|
function drag(el: HTMLElement) {
|
|
function mousedown(e: MouseEvent) {
|
|
function mousedown(e: MouseEvent) {
|
|
const parentElement = modalFrameBoxDom.value!
|
|
const parentElement = modalFrameBoxDom.value!
|
|
@@ -148,7 +154,7 @@ function refreshPos() {
|
|
const posWidth = computePos("width", props.width)
|
|
const posWidth = computePos("width", props.width)
|
|
const posHeight = computePos("height", props.height)
|
|
const posHeight = computePos("height", props.height)
|
|
if (modalFrameBoxDom.value) {
|
|
if (modalFrameBoxDom.value) {
|
|
- modalFrameBoxDom.value.style.transform = `translate(${posWidth.pos}px, ${posHeight.pos}px)`
|
|
|
|
|
|
+ modalFrameBoxDom.value.style.transform = `translate(${posWidth.pos}rem, ${posHeight.pos}px)`
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//取消按钮
|
|
//取消按钮
|
|
@@ -193,12 +199,10 @@ function unmount() {
|
|
}
|
|
}
|
|
defineExpose({ vm, vmApp, remove, show })
|
|
defineExpose({ vm, vmApp, remove, show })
|
|
</script>
|
|
</script>
|
|
-
|
|
|
|
-<style lang="scss" scoped>
|
|
|
|
-@import "./modalFrame.scss";
|
|
|
|
-</style>
|
|
|
|
|
|
+<!-- 取消scoped 减少属性权重 外部添加class可以修改里面的样式 -->
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
-body.modalFrameBody {
|
|
|
|
|
|
+@import "./modalFrame.scss";
|
|
|
|
+body.h-modalFrameBody {
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|