Skip to content

Commit 003751a

Browse files
committed
fix: dialog
1 parent 4417dc8 commit 003751a

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

src/components/Dialog/src/Dialog.vue

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script lang="ts" setup>
22
import { propTypes } from '@/utils/propTypes'
33
import { isNumber } from '@/utils/is'
4-
5-
// eslint-disable-next-line vue/no-reserved-component-names
64
defineOptions({ name: 'Dialog' })
75
86
const slots = useSlots()
@@ -13,7 +11,7 @@ const props = defineProps({
1311
fullscreen: propTypes.bool.def(true),
1412
width: propTypes.oneOfType([String, Number]).def('40%'),
1513
scroll: propTypes.bool.def(false), // 是否开启滚动条。如果是的话,按照 maxHeight 设置最大高度
16-
maxHeight: propTypes.oneOfType([String, Number]).def('300px')
14+
maxHeight: propTypes.oneOfType([String, Number]).def('400px')
1715
})
1816
1917
const getBindValue = computed(() => {
@@ -39,7 +37,6 @@ const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : pr
3937
watch(
4038
() => isFullscreen.value,
4139
async (val: boolean) => {
42-
// 计算最大高度
4340
await nextTick()
4441
if (val) {
4542
const windowHeight = document.documentElement.offsetHeight
@@ -62,61 +59,80 @@ const dialogStyle = computed(() => {
6259

6360
<template>
6461
<ElDialog
62+
v-bind="getBindValue"
6563
:close-on-click-modal="true"
6664
:fullscreen="isFullscreen"
6765
:width="width"
6866
destroy-on-close
69-
draggable
7067
lock-scroll
71-
v-bind="getBindValue"
68+
draggable
69+
top="0"
70+
:show-close="false"
7271
>
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">
7574
<slot name="title">
7675
{{ title }}
7776
</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>
8596
</div>
8697
</template>
8798

88-
<!-- 情况一:如果 scroll 为 true,说明开启滚动条 -->
8999
<ElScrollbar v-if="scroll" :style="dialogStyle">
90100
<slot></slot>
91101
</ElScrollbar>
92-
<!-- 情况二:如果 scroll 为 false,说明关闭滚动条滚动条 -->
93102
<slot v-else></slot>
94-
95103
<template v-if="slots.footer" #footer>
96104
<slot name="footer"></slot>
97105
</template>
98106
</ElDialog>
99107
</template>
100108

101109
<style lang="scss">
110+
.#{$elNamespace}-overlay-dialog {
111+
display: flex;
112+
justify-content: center;
113+
align-items: center;
114+
}
115+
102116
.#{$elNamespace}-dialog {
117+
margin: 0 !important;
118+
103119
&__header {
120+
height: 54px;
121+
padding: 0;
104122
margin-right: 0 !important;
105123
border-bottom: 1px solid var(--el-border-color);
106124
}
107125
108126
&__body {
109-
padding: 0 !important;
127+
padding: 15px !important;
110128
}
111129
112130
&__footer {
113131
border-top: 1px solid var(--el-border-color);
114132
}
115-
}
116133
117-
.is-hover {
118-
&:hover {
119-
color: var(--el-color-primary) !important;
134+
&__headerbtn {
135+
top: 0;
120136
}
121137
}
122138
</style>

src/views/mall/product/spu/addForm.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const getDetail = async () => {
101101
if ('ProductSpuDetail' === name) {
102102
isDetail.value = true
103103
}
104-
const id = params.spuId as number
104+
const id = params.spuId as unknown as number
105105
if (id) {
106106
formLoading.value = true
107107
try {
@@ -155,15 +155,15 @@ const submitForm = async () => {
155155
item.subCommissionSecondPrice = convertToInteger(item.subCommissionSecondPrice)
156156
})
157157
// 处理轮播图列表
158-
const newSliderPicUrls = []
159-
deepCopyFormData.sliderPicUrls.forEach((item) => {
158+
const newSliderPicUrls: any[] = []
159+
deepCopyFormData.sliderPicUrls.forEach((item: any) => {
160160
// 如果是前端选的图
161161
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
162162
})
163163
deepCopyFormData.sliderPicUrls = newSliderPicUrls
164164
// 校验都通过后提交表单
165165
const data = deepCopyFormData as ProductSpuApi.Spu
166-
const id = params.spuId as number
166+
const id = params.spuId as unknown as number
167167
if (!id) {
168168
await ProductSpuApi.createSpu(data)
169169
message.success(t('common.createSuccess'))

0 commit comments

Comments
 (0)