haoxuan
2023-11-06 2bb9a863e75312fe90869ea3deea137b46b1bb1e
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
<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 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">
$status-ready: #10256c;
$status-done: #0059ffd0;
:deep(.el-dialog) {
  width: 553px;
  min-height: 200px;
  height: auto;
  background: $status-ready;
}
 
.wider {
  :deep(.el-dialog) {
    width: 938px;
    height: 733px;
    background: $status-ready;
  }
}
 
.modal-title {
  position: relative;
  display: flex;
  align-items: center;
  &-text {
    padding-left: 12px;
    font-size: 20px;
    font-weight: 600;
  }
  &-close {
    cursor: pointer;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 0px;
    right: 0px;
  }
}
</style>