1
1
<script lang="ts" setup>
2
2
import { propTypes } from ' @/utils/propTypes'
3
3
import { isNumber } from ' @/utils/is'
4
-
5
- // eslint-disable-next-line vue/no-reserved-component-names
6
4
defineOptions ({ name: ' Dialog' })
7
5
8
6
const slots = useSlots ()
@@ -13,7 +11,7 @@ const props = defineProps({
13
11
fullscreen: propTypes .bool .def (true ),
14
12
width: propTypes .oneOfType ([String , Number ]).def (' 40%' ),
15
13
scroll: propTypes .bool .def (false ), // 是否开启滚动条。如果是的话,按照 maxHeight 设置最大高度
16
- maxHeight: propTypes .oneOfType ([String , Number ]).def (' 300px ' )
14
+ maxHeight: propTypes .oneOfType ([String , Number ]).def (' 400px ' )
17
15
})
18
16
19
17
const getBindValue = computed (() => {
@@ -39,7 +37,6 @@ const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : pr
39
37
watch (
40
38
() => isFullscreen .value ,
41
39
async (val : boolean ) => {
42
- // 计算最大高度
43
40
await nextTick ()
44
41
if (val ) {
45
42
const windowHeight = document .documentElement .offsetHeight
@@ -62,61 +59,80 @@ const dialogStyle = computed(() => {
62
59
63
60
<template >
64
61
<ElDialog
62
+ v-bind =" getBindValue"
65
63
:close-on-click-modal =" true"
66
64
:fullscreen =" isFullscreen"
67
65
:width =" width"
68
66
destroy-on-close
69
- draggable
70
67
lock-scroll
71
- v-bind =" getBindValue"
68
+ draggable
69
+ top =" 0"
70
+ :show-close =" false"
72
71
>
73
- <template #header >
74
- <div class =" flex justify-between" >
72
+ <template #header = " { close } " >
73
+ <div class =" flex justify-between items-center h-54px pl-15px pr-15px relative " >
75
74
<slot name =" title" >
76
75
{{ title }}
77
76
</slot >
78
- <Icon
79
- v-if =" fullscreen"
80
- :icon =" isFullscreen ? 'zmdi:fullscreen-exit' : 'zmdi:fullscreen'"
81
- class =" mr-22px cursor-pointer is-hover mt-2px z-10"
82
- color =" var(--el-color-info)"
83
- @click =" toggleFull"
84
- />
77
+ <div
78
+ class =" h-54px flex justify-between items-center absolute top-[50%] right-15px translate-y-[-50%]"
79
+ >
80
+ <Icon
81
+ v-if =" fullscreen"
82
+ class =" cursor-pointer is-hover mr-10px"
83
+ :icon =" isFullscreen ? 'radix-icons:exit-full-screen' : 'radix-icons:enter-full-screen'"
84
+ color =" var(--el-color-info)"
85
+ hover-color =" var(--el-color-primary)"
86
+ @click =" toggleFull"
87
+ />
88
+ <Icon
89
+ class =" cursor-pointer is-hover"
90
+ icon =" ep:close"
91
+ hover-color =" var(--el-color-primary)"
92
+ color =" var(--el-color-info)"
93
+ @click =" close"
94
+ />
95
+ </div >
85
96
</div >
86
97
</template >
87
98
88
- <!-- 情况一:如果 scroll 为 true,说明开启滚动条 -->
89
99
<ElScrollbar v-if =" scroll" :style =" dialogStyle" >
90
100
<slot ></slot >
91
101
</ElScrollbar >
92
- <!-- 情况二:如果 scroll 为 false,说明关闭滚动条滚动条 -->
93
102
<slot v-else ></slot >
94
-
95
103
<template v-if =" slots .footer " #footer >
96
104
<slot name =" footer" ></slot >
97
105
</template >
98
106
</ElDialog >
99
107
</template >
100
108
101
109
<style lang="scss">
110
+ .#{$elNamespace } -overlay-dialog {
111
+ display : flex ;
112
+ justify-content : center ;
113
+ align-items : center ;
114
+ }
115
+
102
116
.#{$elNamespace } -dialog {
117
+ margin : 0 !important ;
118
+
103
119
& __header {
120
+ height : 54px ;
121
+ padding : 0 ;
104
122
margin-right : 0 !important ;
105
123
border-bottom : 1px solid var (--el-border-color );
106
124
}
107
125
108
126
& __body {
109
- padding : 0 !important ;
127
+ padding : 15 px !important ;
110
128
}
111
129
112
130
& __footer {
113
131
border-top : 1px solid var (--el-border-color );
114
132
}
115
- }
116
133
117
- .is-hover {
118
- & :hover {
119
- color : var (--el-color-primary ) !important ;
134
+ & __headerbtn {
135
+ top : 0 ;
120
136
}
121
137
}
122
138
</style >
0 commit comments