forked from Spikef/vmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.vue
49 lines (46 loc) · 1.29 KB
/
submit.vue
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
<template>
<span class="vmc-button" :class="[type, {disabled: disabled}]" :style="style" @click="_submit">
<div class="block">
<slot name="icon-left"></slot>
<slot>{{text}}</slot>
<span slot="icon-right" v-show="status === STATUS.DOING">
<spinner color="white" size="20"></spinner>
</span>
</div>
</span>
</template>
<script type="text/ecmascript-6">
import vButton from '../button';
import Spinner from '../spinner';
const STATUS = {
NORMAL: 'normal',
DOING: 'doing'
};
export default {
components: {
Spinner
},
extends: vButton,
data() {
return {
STATUS,
status: STATUS.NORMAL
}
},
methods: {
_submit() {
this.$nextTick(() => {
if (!this.disabled && this.status !== STATUS.DOING) {
this.disabled = true;
this.status = STATUS.DOING;
this.$emit('submit', this);
}
});
},
done() {
this.disabled = false;
this.status = STATUS.NORMAL;
}
}
}
</script>