File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export interface ConfigInterface {
29
29
maskClosable ?: boolean ;
30
30
wrapClassName ?: string ;
31
31
footer ?: TemplateRef < any > | boolean ;
32
+ showConfirmLoading ?: boolean ;
32
33
onOk ?: Function ;
33
34
onCancel ?: Function ;
34
35
componentParams ?: Object ;
@@ -81,16 +82,20 @@ export class NzModalService {
81
82
}
82
83
} ) ;
83
84
84
- props [ 'onOk' ] = this . _getConfirmCb ( props [ 'nzOnOk' ] ) ;
85
+ const isShowConfirmLoading = ! ! config [ 'showConfirmLoading' ] ;
86
+ props [ 'onOk' ] = this . _getConfirmCb ( props [ 'nzOnOk' ] , isShowConfirmLoading ) ;
85
87
props [ 'onCancel' ] = this . _getConfirmCb ( props [ 'nzOnCancel' ] ) ;
86
88
// 在service模式下,不需要nzOnOk,防止触发this.nzOnOk.emit(e);
87
89
delete props [ 'nzOnOk' ] ;
88
90
delete props [ 'nzOnCancel' ] ;
89
91
return props ;
90
92
}
91
93
92
- _getConfirmCb ( fn ?: Function ) : Function {
93
- return ( _close ) => {
94
+ _getConfirmCb ( fn ?: Function , isShowConfirmLoading : boolean = false ) : Function {
95
+ return ( _close , _instance ) => {
96
+ if ( isShowConfirmLoading ) {
97
+ _instance . nzConfirmLoading = true ;
98
+ }
94
99
if ( fn ) {
95
100
const ret = fn ( ) ;
96
101
if ( ! ret ) {
@@ -132,7 +137,7 @@ export class NzModalService {
132
137
setTimeout ( ( ) => {
133
138
compRef . destroy ( ) ;
134
139
} , 200 ) ;
135
- } ) ;
140
+ } , instance ) ;
136
141
}
137
142
} ) ;
138
143
} ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export class NzDemoConfirmAsyncComponent {
16
16
this . confirmServ . confirm ( {
17
17
title : '您是否确认要删除这项内容' ,
18
18
content : '点确认 1 秒后关闭' ,
19
+ showConfirmLoading : true ,
19
20
onOk ( ) {
20
21
return new Promise ( ( resolve ) => {
21
22
setTimeout ( resolve , 1000 ) ;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export class NzDemoModalServiceComponent {
49
49
title : '对话框标题' ,
50
50
content : '纯文本内容,点确认 1 秒后关闭' ,
51
51
closable : false ,
52
+ showConfirmLoading : true ,
52
53
onOk ( ) {
53
54
return new Promise ( ( resolve ) => {
54
55
setTimeout ( resolve , 1000 ) ;
Original file line number Diff line number Diff line change 1
- < article >
1
+ < article >
2
2
< section class ="markdown "> < h1 > Modal 对话框</ h1 >
3
3
< section class ="markdown "> < p > 模态对话框。</ p >
4
4
< h2 id ="何时使用 "> < span > 何时使用</ span >
@@ -355,6 +355,13 @@ <h2 id="NzModalService_xxx"><span>NzModalService.xxx()</span>
355
355
< td > open</ td >
356
356
< td > 无</ td >
357
357
</ tr >
358
+ < tr >
359
+ < td > showConfirmLoading</ td >
360
+ < td > 如果footer没有指定(即展示默认footer)时,确定按钮在执行确定回调时是否显示 loading 状态</ td >
361
+ < td > Boolean</ td >
362
+ < td > All</ td >
363
+ < td > false</ td >
364
+ </ tr >
358
365
</ tbody >
359
366
</ table >
360
367
< h2 id ="NzModalSubject "> < span > NzModalSubject对象</ span >
You can’t perform that action at this time.
0 commit comments