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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
<i-button
:class="buttonClass"
:type="type"
:ghost="buttonGhost"
:style="styleContent"
:disabled="disabled"
:title="tooltip"
:loading="loading"
:shape="shape"
@click.stop="onClick"
>
<div :class="['btn-content', flexType]">
<span v-if="(iconcls || icon) && showIcon" class="icon">
<i v-if="iconcls" :class="iconcls" />
<img v-else-if="icon" :src="icon" />
</span>
<span v-if="showCaption && caption" class="caption">{{ caption }}</span>
<slot></slot>
</div>
</i-button>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
@Component({})
export default class AppButton extends Vue {
/**
* 禁用状态
*
* @memberof AppButton
*/
@Prop({ default: false }) public disabled?: boolean;
/**
* 加载状态
*
* @memberof AppButton
*/
@Prop({ default: false }) public loading?: boolean;
/**
* 动态样式
*
* @memberof AppButton
*/
@Prop({ default: '' }) public styleContent?: string;
/**
* 动态样式类
*
* @memberof AppButton
*/
@Prop({ default: '' }) public classContent?: string;
/**
* 按钮样式
*
* @memberof AppButton
*/
get buttonClass() {
let buttonClass = 'app-button ivu-button ';
if (this.classContent) {
buttonClass += this.classContent;
}
return buttonClass;
}
/**
* 按钮名称
*
* @memberof AppButton
*/
@Prop({ default: '' }) public name?: string;
/**
* 图片路径
*
* @memberof AppButton
*/
@Prop({ default: '' }) public icon?: string;
/**
* i图标类名
*
* @memberof AppButton
*/
@Prop({ default: '' }) public iconcls?: string;
/**
* 显示提示
*
* @memberof AppButton
*/
@Prop({ default: '' }) public tooltip?: string;
/**
* 标题
*
* @memberof AppButton
*/
@Prop({ default: '' }) public caption?: string;
/**
* 显示标题
*
* @memberof AppButton
*/
@Prop({ default: true }) public showCaption?: boolean;
/**
* 显示图标
*
* @memberof AppButton
*/
@Prop({ default: true }) public showIcon?: boolean;
/**
* 按钮类型
*
* @memberof AppButton
*/
@Prop({ default: 'default' }) public type?: string;
/**
* 按钮幽灵属性,使按钮背景透明
*
* @memberof AppButton
*/
@Prop({ default: false }) public buttonGhost?: boolean;
/**
* 按钮图标方向
*
* @memberof AppButton
*/
@Prop({ default: 'LEFT' }) public iconAlign?: 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM';
/**
* 按钮内容布局类型
*
* @memberof AppButton
*/
get flexType() {
let flexClass = 'left';
if (this.iconAlign) {
switch (this.iconAlign) {
case 'LEFT':
flexClass = 'left';
break;
case 'TOP':
flexClass = 'top';
break;
case 'RIGHT':
flexClass = 'right';
break;
case 'BOTTOM':
flexClass = 'bottom';
break;
}
}
return flexClass;
}
/**
* 圆角
*
* @memberof AppButtonContainer
*/
@Prop({ default: undefined }) public shape?: string | undefined;
/**
* 初始化完成
*
* @memberof AppButton
*/
public created() {}
/**
* 点击按钮
*
* @param {*} event
* @memberof AppButton
*/
public onClick(event: any) {
this.$emit('onClick', event);
}
}
</script>