restructure/src/components/CardModal/index.vue

60 lines
1.2 KiB
Vue
Raw Normal View History

2022-05-24 09:09:30 +08:00
<template>
2022-05-24 10:02:06 +08:00
<n-modal
v-bind="getModalOptions"
:style="`width:${getModalOptions.width}px`"
preset="card"
2022-05-24 16:52:14 +08:00
:title="options.title"
2022-05-24 10:02:06 +08:00
@update:show="handleClose"
>
<n-card :bordered="false">
2022-05-24 09:09:30 +08:00
<slot name="Context" />
2022-05-24 16:52:14 +08:00
<n-space style="float: right">
2022-05-25 14:38:40 +08:00
<n-button @click="handleClose">取消</n-button>
<n-button type="primary" @click="handleClick">确认</n-button>
2022-05-24 16:52:14 +08:00
</n-space>
2022-05-24 09:09:30 +08:00
</n-card>
</n-modal>
</template>
<script>
2022-05-24 09:20:29 +08:00
import { defineComponent, computed, unref } from 'vue'
2022-05-24 09:09:30 +08:00
export default defineComponent({
2022-05-24 10:02:06 +08:00
name: 'CardModal',
2022-05-24 09:09:30 +08:00
props: {
2022-05-24 09:20:29 +08:00
options: {
type: Object,
default: () => {}
2022-05-24 09:09:30 +08:00
}
},
emits: {
2022-05-25 14:38:40 +08:00
save: null, // click事件没有检验
2022-05-24 09:09:30 +08:00
onClose: (value) => {
return value
}
},
setup(props, { emit }) {
const getModalOptions = computed(() => {
2022-05-24 10:02:06 +08:00
return {
...props.options,
width: props.options.width || 600
}
2022-05-24 09:09:30 +08:00
})
const handleClick = function() {
2022-05-25 14:38:40 +08:00
emit('save')
2022-05-24 09:09:30 +08:00
}
2022-05-24 10:02:06 +08:00
const handleClose = function() {
2022-05-24 09:09:30 +08:00
emit('onClose', true)
}
return {
getModalOptions,
handleClick,
2022-05-24 10:02:06 +08:00
handleClose
2022-05-24 09:09:30 +08:00
}
}
})
</script>
<style scoped lang='scss'>
</style>