fix: dialog
This commit is contained in:
parent
4417dc8700
commit
003751a41c
@ -1,8 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { isNumber } from '@/utils/is'
|
import { isNumber } from '@/utils/is'
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-reserved-component-names
|
|
||||||
defineOptions({ name: 'Dialog' })
|
defineOptions({ name: 'Dialog' })
|
||||||
|
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
@ -13,7 +11,7 @@ const props = defineProps({
|
|||||||
fullscreen: propTypes.bool.def(true),
|
fullscreen: propTypes.bool.def(true),
|
||||||
width: propTypes.oneOfType([String, Number]).def('40%'),
|
width: propTypes.oneOfType([String, Number]).def('40%'),
|
||||||
scroll: propTypes.bool.def(false), // 是否开启滚动条。如果是的话,按照 maxHeight 设置最大高度
|
scroll: propTypes.bool.def(false), // 是否开启滚动条。如果是的话,按照 maxHeight 设置最大高度
|
||||||
maxHeight: propTypes.oneOfType([String, Number]).def('300px')
|
maxHeight: propTypes.oneOfType([String, Number]).def('400px')
|
||||||
})
|
})
|
||||||
|
|
||||||
const getBindValue = computed(() => {
|
const getBindValue = computed(() => {
|
||||||
@ -39,7 +37,6 @@ const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : pr
|
|||||||
watch(
|
watch(
|
||||||
() => isFullscreen.value,
|
() => isFullscreen.value,
|
||||||
async (val: boolean) => {
|
async (val: boolean) => {
|
||||||
// 计算最大高度
|
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (val) {
|
if (val) {
|
||||||
const windowHeight = document.documentElement.offsetHeight
|
const windowHeight = document.documentElement.offsetHeight
|
||||||
@ -62,36 +59,47 @@ const dialogStyle = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ElDialog
|
<ElDialog
|
||||||
|
v-bind="getBindValue"
|
||||||
:close-on-click-modal="true"
|
:close-on-click-modal="true"
|
||||||
:fullscreen="isFullscreen"
|
:fullscreen="isFullscreen"
|
||||||
:width="width"
|
:width="width"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
draggable
|
|
||||||
lock-scroll
|
lock-scroll
|
||||||
v-bind="getBindValue"
|
draggable
|
||||||
|
top="0"
|
||||||
|
:show-close="false"
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header="{ close }">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between items-center h-54px pl-15px pr-15px relative">
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
</slot>
|
</slot>
|
||||||
<Icon
|
<div
|
||||||
v-if="fullscreen"
|
class="h-54px flex justify-between items-center absolute top-[50%] right-15px translate-y-[-50%]"
|
||||||
:icon="isFullscreen ? 'zmdi:fullscreen-exit' : 'zmdi:fullscreen'"
|
>
|
||||||
class="mr-22px cursor-pointer is-hover mt-2px z-10"
|
<Icon
|
||||||
color="var(--el-color-info)"
|
v-if="fullscreen"
|
||||||
@click="toggleFull"
|
class="cursor-pointer is-hover mr-10px"
|
||||||
/>
|
:icon="isFullscreen ? 'radix-icons:exit-full-screen' : 'radix-icons:enter-full-screen'"
|
||||||
|
color="var(--el-color-info)"
|
||||||
|
hover-color="var(--el-color-primary)"
|
||||||
|
@click="toggleFull"
|
||||||
|
/>
|
||||||
|
<Icon
|
||||||
|
class="cursor-pointer is-hover"
|
||||||
|
icon="ep:close"
|
||||||
|
hover-color="var(--el-color-primary)"
|
||||||
|
color="var(--el-color-info)"
|
||||||
|
@click="close"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 情况一:如果 scroll 为 true,说明开启滚动条 -->
|
|
||||||
<ElScrollbar v-if="scroll" :style="dialogStyle">
|
<ElScrollbar v-if="scroll" :style="dialogStyle">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</ElScrollbar>
|
</ElScrollbar>
|
||||||
<!-- 情况二:如果 scroll 为 false,说明关闭滚动条滚动条 -->
|
|
||||||
<slot v-else></slot>
|
<slot v-else></slot>
|
||||||
|
|
||||||
<template v-if="slots.footer" #footer>
|
<template v-if="slots.footer" #footer>
|
||||||
<slot name="footer"></slot>
|
<slot name="footer"></slot>
|
||||||
</template>
|
</template>
|
||||||
@ -99,24 +107,32 @@ const dialogStyle = computed(() => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.#{$elNamespace}-overlay-dialog {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.#{$elNamespace}-dialog {
|
.#{$elNamespace}-dialog {
|
||||||
|
margin: 0 !important;
|
||||||
|
|
||||||
&__header {
|
&__header {
|
||||||
|
height: 54px;
|
||||||
|
padding: 0;
|
||||||
margin-right: 0 !important;
|
margin-right: 0 !important;
|
||||||
border-bottom: 1px solid var(--el-border-color);
|
border-bottom: 1px solid var(--el-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__body {
|
&__body {
|
||||||
padding: 0 !important;
|
padding: 15px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__footer {
|
&__footer {
|
||||||
border-top: 1px solid var(--el-border-color);
|
border-top: 1px solid var(--el-border-color);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.is-hover {
|
&__headerbtn {
|
||||||
&:hover {
|
top: 0;
|
||||||
color: var(--el-color-primary) !important;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -101,7 +101,7 @@ const getDetail = async () => {
|
|||||||
if ('ProductSpuDetail' === name) {
|
if ('ProductSpuDetail' === name) {
|
||||||
isDetail.value = true
|
isDetail.value = true
|
||||||
}
|
}
|
||||||
const id = params.spuId as number
|
const id = params.spuId as unknown as number
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
@ -155,15 +155,15 @@ const submitForm = async () => {
|
|||||||
item.subCommissionSecondPrice = convertToInteger(item.subCommissionSecondPrice)
|
item.subCommissionSecondPrice = convertToInteger(item.subCommissionSecondPrice)
|
||||||
})
|
})
|
||||||
// 处理轮播图列表
|
// 处理轮播图列表
|
||||||
const newSliderPicUrls = []
|
const newSliderPicUrls: any[] = []
|
||||||
deepCopyFormData.sliderPicUrls.forEach((item) => {
|
deepCopyFormData.sliderPicUrls.forEach((item: any) => {
|
||||||
// 如果是前端选的图
|
// 如果是前端选的图
|
||||||
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
|
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
|
||||||
})
|
})
|
||||||
deepCopyFormData.sliderPicUrls = newSliderPicUrls
|
deepCopyFormData.sliderPicUrls = newSliderPicUrls
|
||||||
// 校验都通过后提交表单
|
// 校验都通过后提交表单
|
||||||
const data = deepCopyFormData as ProductSpuApi.Spu
|
const data = deepCopyFormData as ProductSpuApi.Spu
|
||||||
const id = params.spuId as number
|
const id = params.spuId as unknown as number
|
||||||
if (!id) {
|
if (!id) {
|
||||||
await ProductSpuApi.createSpu(data)
|
await ProductSpuApi.createSpu(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
Loading…
Reference in New Issue
Block a user