| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- const n = `<template>
- <a-drawer
- rootClassName="s-drawer-wrap"
- :title="title"
- :placement="mode"
- :width="width"
- :height="height"
- :visible="visible"
- @close="handClose"
- :bodyStyle="{
- padding: 0,
- display: 'flex',
- flexDirection: 'column'
- }"
- >
- <div class="s-drawer-body">
- <slot />
- </div>
- <div class="s-drawer-footer">
- <a-space :size="spaceSize">
- <slot name="footer">
- <a-button @click="handClose">{{ $l('取消') }}</a-button>
- <a-button type="primary" @click="handConfirm">{{ $l('确定') }}</a-button>
- </slot>
- </a-space>
- </div>
- </a-drawer>
- </template>
- <script setup>
- import { ref, watch, watchEffect } from 'vue'
- const emit = defineEmits(['update:value', 'confirm'])
- const props = defineProps({
- // 显隐(v-model:value)
- value: {
- type: Boolean,
- default: false
- },
- // 抽屉标题
- title: {
- type: String,
- default: ''
- },
- // 弹出方向:right / left / top / bottom
- mode: {
- type: String,
- default: 'right'
- },
- // 左右方向时的宽度,单位 px
- width: {
- type: Number,
- default: 500
- },
- // 上下方向时的高度,单位 px
- height: {
- type: Number,
- default: 378
- }
- })
- const visible = ref(props.value)
- watch(
- () => props.value,
- (val) => {
- visible.value = val
- },
- { immediate: true }
- )
- const placement = ref(props.mode)
- const spaceSize = ref(8)
- watchEffect(() => {
- const modes = {
- left: '',
- right: '',
- top: '',
- bottom: ''
- }
- if (!Object.keys(modes).includes(props.mode)) {
- console.warn(\`当前设置mode【\${props.mode}】不在【\${modes}】中,已默认为【right】\`)
- placement.value = 'right'
- }
- })
- const handClose = () => {
- emit('update:value', false)
- }
- const handConfirm = () => {
- emit('update:value', false)
- emit('confirm')
- }
- <\/script>
- <style lang="less" scoped>
- .s-drawer-wrap {
- max-height: calc(100vh - 4rpx);
- overflow: hidden;
- }
- .s-drawer-body {
- height: calc(100% - 60px);
- overflow: hidden auto;
- padding: 12px;
- box-sizing: border-box;
- }
- .s-drawer-footer {
- height: 60px;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- border-top: 1px solid var(--s-border-color-split);
- padding: 0 12px;
- box-sizing: border-box;
- }
- </style>
- `;
- export {
- n as default
- };
|