schangxiang@126.com
2025-05-07 cace264ad9d86a7831099810b079da1141957add
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { Component, computed, defineComponent, onMounted, ref } from 'vue'
import styles from './BaseDrawer.module.scss'
import Icon from '../Icon/Icon'
import { _t } from '@/libs/Language/Language'
 
//@ts-ignore
export default defineComponent<{
  [key: string]: any
}>({
  // @ts-ignore
  name: 'BaseDrawer',
  props: {
    // 遮罩是否可点击
    clickable: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '',
    },
    width: {
      type: String,
      default: '',
    },
    submitDisabled: {
      type: Boolean,
      default: false,
    },
    appendToBody: {
      type: Boolean,
      default: true,
    },
 
    // modelValue: {
    //   type: Boolean,
    //   default: false,
    // },
  },
  emits: ['close', 'confirm', 'update:modelValue', 'open', 'beforeClose'],
  setup(props: any, { emit, slots, attrs }: any) {
    // const size = computed(() => {
    //   if (attrs.size.includes('px')) {
    //     return attrs.size
    //   }
    // })
 
    // const model = computed(() => {
    //   if (attrs.model.includes('')) {
    //     return attrs.model
    //   }
    // })
 
    return () => {
      const vSlots: {
        footer: () => Component
        title?: () => Component
      } = {
        footer() {
          return (
            <div class={styles.csDialogFooter}>
              <el-button
                onClick={() => emit('close')}
                type="info"
                plain
                class={{
                  [styles.dialogBtn]: true,
                  [styles.csBaseBtn]: true,
                }}
              >
                {_t('取消')}
              </el-button>
              <el-button
                onClick={() => emit('confirm')}
                type="primary"
                disabled={props.submitDisabled}
                class={{
                  [styles.csBaseBtn]: true,
                }}
              >
                {_t('确认')}
              </el-button>
            </div>
          )
        },
      }
      if (slots.title) {
        vSlots.title = () => {
          return slots.title?.()
        }
      }
      return (
        <div
          class={styles.drawContent}
          //@ts-ignore
          // style={props.clickable ? { '--drawer-width': size.value } : {}}
        >
          <el-drawer
            // modal-class={props.clickable ? styles.modal : ''}
            class={{
              [styles.informationDrawer]: true,
              // [styles.informationDrawerPosition]: props.clickable,
            }}
            onOpen={() => emit('open')}
            onClose={() => emit('close')}
            v-slots={vSlots}
            append-to-body={props.appendToBody}
            {...attrs}
            title={props.title}
            size={props.width || attrs.size}
          >
            <Icon
              width={167}
              height={54}
              class={styles.iconPosition}
              icon="drawer_bg"
            />
            {slots.default?.()}
          </el-drawer>
        </div>
      )
    }
  },
})