restructure/src/components/Modal/index.vue

56 lines
1.0 KiB
Vue

<template>
<n-modal
v-bind="getModalOptions"
:style="`width:${getModalOptions.width}px`"
:title="options.title"
>
<n-card :bordered="false">
<slot name="Context" />
</n-card>
</n-modal>
</template>
<script>
import { defineComponent, computed } from 'vue'
export default defineComponent({
props: {
options: {
type: Object,
default: () => {}
}
},
emits: {
onConfirm: null,
onClose: (value) => {
return value
}
},
setup(props, { emit }) {
const getModalOptions = computed(() => {
return {
...props.options,
width: props.options.width || 600,
preset: props.options.preset || 'dialog',
showIcon: !!props.options.showIcon
}
})
const handleConfirm = function() {
emit('onConfirm')
return false
}
const handleClose = function() {
emit('onClose', true)
}
return {
getModalOptions,
handleConfirm,
handleClose
}
}
})
</script>
<style scoped lang='scss'>
</style>