1 | <template>
|
2 | <transition name="z-dialog-transition">
|
3 | <div
|
4 | class="z-shape is-extension primary"
|
5 | :class="[componentType]"
|
6 | :style="styles.main">
|
7 | <z-slider v-if="selfClose" :progress="progress"></z-slider>
|
8 | <div class="z-outer-circle" :style="styles.plate"></div>
|
9 | <div class="z-content">
|
10 | <slot></slot>
|
11 | </div>
|
12 | <slot name="extension"></slot>
|
13 | </div>
|
14 | </transition>
|
15 | </template>
|
16 |
|
17 | <script>
|
18 | import ZSlider from './child-components/z-slider'
|
19 | export default {
|
20 | name: 'z-dialog',
|
21 | props: {
|
22 | selfClose: {
|
23 | type: Boolean,
|
24 | default: false
|
25 | },
|
26 | size: {
|
27 | type: String,
|
28 | default: 'xxl'
|
29 | }
|
30 | },
|
31 | components: {
|
32 | ZSlider
|
33 | },
|
34 | data () {
|
35 | return {
|
36 | componentType: this.$options.name,
|
37 | progress: 0
|
38 | }
|
39 | },
|
40 | computed: {
|
41 | styles () {
|
42 | var zwidth = this.$zircle.getComponentWidth(this.size)
|
43 | return {
|
44 | main: {
|
45 | width: zwidth + 50 + 'px',
|
46 | height: zwidth + 50 + 'px',
|
47 | margin: -((zwidth + 50) / 2) + 'px 0 0 ' + -((zwidth + 50) / 2) + 'px'
|
48 | },
|
49 | plate: {
|
50 | width: zwidth + 180 + 'px',
|
51 | height: zwidth + 180 + 'px',
|
52 | margin: -((zwidth + 180) / 2) + 'px 0 0 ' + -((zwidth + 180) / 2) + 'px'
|
53 | }
|
54 | }
|
55 | }
|
56 | },
|
57 | mounted () {
|
58 | if (this.selfClose) {
|
59 | var vm = this
|
60 | this.progress = 5
|
61 | var id = setInterval(function () {
|
62 | if (vm.progress >= 100) {
|
63 | clearInterval(id)
|
64 | vm.$emit('done')
|
65 | } else {
|
66 | vm.progress++
|
67 | }
|
68 | }, 100)
|
69 | }
|
70 | }
|
71 | }
|
72 | </script>
|