File tree 3 files changed +33
-14
lines changed
3 files changed +33
-14
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" result" >
3
3
<div >
4
- <a-icon :class =" { 'icon': true, 'success': isSuccess, 'error': !isSuccess }" :type =" isSuccess ? 'check-circle' : 'close-circle'" />
4
+ <a-icon :class =" { 'icon': true, [`${type}`]: true }" :type =" localIsSuccess ? 'check-circle' : 'close-circle'" />
5
5
</div >
6
- <div class =" title" v-if =" title" >{{ title }}</div >
7
- <div class =" description" v-if =" description" >{{ description }}</div >
8
- <div class =" content" v-if =" content" >
6
+ <div class =" title" >
7
+ <slot name =" title" >
8
+ {{ title }}
9
+ </slot >
10
+ </div >
11
+ <div class =" description" >
12
+ <slot name =" description" >
13
+ {{ description }}
14
+ </slot >
15
+ </div >
16
+ <div class =" extra" v-if =" $slots.default" >
9
17
<slot ></slot >
10
18
</div >
11
- <div class =" action" >
19
+ <div class =" action" v-if = " $slots.action " >
12
20
<slot name =" action" ></slot >
13
21
</div >
14
22
</div >
15
23
</template >
16
24
17
25
<script >
26
+ const resultEnum = [' success' , ' error' ]
27
+
18
28
export default {
19
29
name: ' Result' ,
20
30
props: {
31
+ /** @Deprecated */
21
32
isSuccess: {
22
33
type: Boolean ,
23
34
default: false
24
35
},
36
+ type: {
37
+ type: String ,
38
+ default: resultEnum[0 ],
39
+ validator (val ) {
40
+ return (val ) => resultEnum .includes (val)
41
+ }
42
+ },
25
43
title: {
26
44
type: String ,
27
45
default: ' '
28
46
},
29
47
description: {
30
48
type: String ,
31
49
default: ' '
32
- },
33
- content: {
34
- type: Boolean ,
35
- default: true
50
+ }
51
+ },
52
+ computed: {
53
+ localIsSuccess : function () {
54
+ return this .type === resultEnum[0 ]
36
55
}
37
56
}
38
57
}
@@ -69,7 +88,7 @@ export default {
69
88
color : rgba (0 , 0 , 0 , 0.45 );
70
89
margin-bottom : 24px ;
71
90
}
72
- .content {
91
+ .extra {
73
92
background : #fafafa ;
74
93
padding : 24px 40px ;
75
94
border-radius : 2px ;
Original file line number Diff line number Diff line change 1
1
<template >
2
- <a-card :bordered =" false" >
3
- <result :is-success = " false " :title =" title" :description =" description" >
2
+ <a-card :bordered =" false" style = " margin : -24 px -24 px 0 px ; " >
3
+ <result type = " error " :title =" title" :description =" description" >
4
4
<template slot="action">
5
5
<a-button type =" primary" >返回修改</a-button >
6
6
</template >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <a-card :bordered =" false" >
3
- <result :is-success = " true " :description =" description" :title =" title" >
2
+ <a-card :bordered =" false" style = " margin : -24 px -24 px 0 px ; " >
3
+ <result type = " success " :description =" description" :title =" title" >
4
4
<template slot="action">
5
5
<a-button type =" primary" >返回列表</a-button >
6
6
<a-button style =" margin-left : 8px " >查看项目</a-button >
You can’t perform that action at this time.
0 commit comments