zhuoyuan.wang
2024-06-19 15ebe96f28cadec6a726c5324593a40bbf56205f
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
<template>
  <el-drawer v-model="visible" v-bind="$attrs" :width="props.width" :draggable="true">
    <slot/>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="onReset()" icon="RefreshRight">重置</el-button>
        <el-button @click="onClose()" icon="Close" type="danger">取消</el-button>
        <el-button type="primary" @click="onSubmit()" icon="DocumentAdd">
          提交
        </el-button>
      </div>
    </template>
  </el-drawer>
</template>
 
<script setup>
 
import {context} from '@/hooks';
 
const {useForceUpdate} = context;
 
const props = defineProps({
  width: {
    type: Number,
    default: 750
  },
  subSubmit: {
    type: Function,
    default: () => {
    }
  },
  subReset: {
    type: Function,
    default: () => {
    }
  },
  subClose: {
    type: Function,
    default: () => {
    }
  },
});
 
const [$props, forceUpdate] = useForceUpdate(props);
 
const $forceUpdate = forceUpdate;
 
const visible = ref(false);
 
const onClose = async () => {
  props.subClose();
  visible.value = false;
}
 
const subReset = async () => {
  await props.onReset();
}
 
const subSubmit = async () => {
  await props.onSubmit();
  visible.value = false;
}
 
const onOpen = async () => {
  visible.value = true;
};
 
/**
 * 暴露给父组件的参数和方法 (外部需要什么,都可以从这里暴露出去)
 */
defineExpose({
  onOpen,
  $forceUpdate
});
 
</script>
 
<style lang='scss' scoped>
</style>