feat: add modal component

This commit is contained in:
xingyu4j
2022-11-04 16:43:11 +08:00
parent 1c1cafdc7f
commit d79b23c8a2
7 changed files with 386 additions and 341 deletions

View File

@ -0,0 +1,3 @@
import XModal from './src/XModal.vue'
export { XModal }

View File

@ -0,0 +1,62 @@
<script setup lang="ts">
import { propTypes } from '@/utils/propTypes'
import { computed, useAttrs, useSlots } from 'vue'
const slots = useSlots()
const props = defineProps({
id: propTypes.string.def('model_1'),
modelValue: propTypes.bool.def(false),
fullscreen: propTypes.bool.def(false),
loading: propTypes.bool.def(false),
title: propTypes.string.def('弹窗'),
width: propTypes.string.def('800'),
height: propTypes.string.def('480'),
minWidth: propTypes.string.def('460'),
minHeight: propTypes.string.def('320'),
showFooter: propTypes.bool.def(true)
})
const getBindValue = computed(() => {
const delArr: string[] = ['title']
const attrs = useAttrs()
const obj = { ...attrs, ...props }
for (const key in obj) {
if (delArr.indexOf(key) !== -1) {
delete obj[key]
}
}
return obj
})
</script>
<template>
<vxe-modal
v-bind="getBindValue"
:width="width"
:height="height"
:title="title"
min-width="460"
min-height="320"
:loading="loading"
:fullscreen="fullscreen"
destroy-on-close
show-zoom
resize
transfer
:show-footer="showFooter"
>
<template v-if="slots.header" #header>
<slot name="header"></slot>
</template>
<template v-if="slots.default" #default>
<slot name="default"></slot>
</template>
<template v-if="slots.corner" #corner>
<slot name="corner"></slot>
</template>
<template v-if="slots.footer" #footer>
<slot name="footer"></slot>
</template>
</vxe-modal>
</template>

View File

@ -4,6 +4,7 @@ import { Form } from '@/components/Form'
import { Table } from '@/components/Table'
import { Search } from '@/components/Search'
import { Dialog } from '@/components/Dialog'
import { XModal } from '@/components/XModal'
import { DictTag } from '@/components/DictTag'
import { ContentWrap } from '@/components/ContentWrap'
import { Descriptions } from '@/components/Descriptions'
@ -14,6 +15,7 @@ export const setupGlobCom = (app: App<Element>): void => {
app.component('Table', Table)
app.component('Search', Search)
app.component('Dialog', Dialog)
app.component('XModal', XModal)
app.component('DictTag', DictTag)
app.component('ContentWrap', ContentWrap)
app.component('Descriptions', Descriptions)