haoxuan
2023-11-02 031b4d9a2a6a757571015b1903bb125d414ecb2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
  <div class="base-modal" :class="{ wider: props.wider }">
    <el-dialog v-model="modelData" :close-on-click-modal="false" width="753px" :show-close="false">
      <template #header>
        <div class="modal-title">
          <div class="modal-title-text">
            <slot name="title"></slot>
          </div>
          <div v-if="props.wider" class="modal-title-close" @click="closeModal">
            <el-icon :size="22"><CloseBold /></el-icon>
          </div>
        </div>
      </template>
      <template #default>
        <slot name="default"></slot>
      </template>
      <template #footer>
        <slot name="footer"></slot>
      </template>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
import { useVModel } from '@vueuse/core'
import { CloseBold } from '@element-plus/icons-vue'
 
export interface BaseModalProps {
  /** 是否展示模态框 */
  modelValue: boolean
  /** 更宽版本 */
  wider: boolean
}
const props = withDefaults(defineProps<BaseModalProps>(), {
  modelValue: false,
  wider: false
})
const emit = defineEmits<{
  'update:modelValue': [show: boolean]
  close: []
}>()
 
const modelData = useVModel(props, 'modelValue', emit)
function closeModal() {
  emit('close')
}
</script>
<style scoped lang="scss">
:deep(.el-dialog) {
  background: transparent !important;
  background-image: url('/modal-background.png') !important;
  background-repeat: no-repeat;
  background-size: 100% 100% !important;
  width: 753px;
  height: 728px;
}
 
.wider {
  :deep(.el-dialog) {
    background: transparent !important;
    background-image: url('/modal-background-wider.png') !important;
    background-repeat: no-repeat;
    background-size: 100% 100% !important;
    width: 938px;
    height: 733px;
  }
}
 
.modal-title {
  position: relative;
  display: flex;
  align-items: center;
  &-text {
    padding-left: 12px;
    font-size: 26px;
    font-weight: 600;
  }
  &-close {
    cursor: pointer;
    height: 36px;
    width: 36px;
    border-radius: 50%;
    background-color: #00d7e9;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    top: -16px;
    right: -30px;
  }
}
</style>