@@ -254,7 +254,7 @@ export class CommonServiceBase {
254
254
* @private
255
255
*/
256
256
serviceProcessCompleted ( result , options ) {
257
- result = Util . transformResult ( result ) ;
257
+ result = this . transformResult ( result ) . result ;
258
258
this . events . triggerEvent ( 'processCompleted' , {
259
259
result : result ,
260
260
options : options
@@ -269,7 +269,7 @@ export class CommonServiceBase {
269
269
* @private
270
270
*/
271
271
serviceProcessFailed ( result , options ) {
272
- result = Util . transformResult ( result ) ;
272
+ result = this . transformErrorResult ( result ) . error ;
273
273
let error = result . error || result ;
274
274
this . events . triggerEvent ( 'processFailed' , {
275
275
error : error ,
@@ -360,23 +360,25 @@ export class CommonServiceBase {
360
360
object : this
361
361
} ;
362
362
if ( requestResult . error ) {
363
+ const type = 'processFailed' ;
363
364
// 兼容服务在构造函数中使用 eventListeners 的老用法
364
- if ( options . failure === this . serviceProcessFailed ) {
365
- var failure = options . scope ? FunctionExt . bind ( options . failure , options . scope ) : options . failure ;
366
- failure ( requestResult , options ) ;
365
+ if ( this . events && this . events . listeners [ type ] && this . events . listeners [ type ] . length ) {
366
+ var failure = options . failure && ( options . scope ? FunctionExt . bind ( options . failure , options . scope ) : options . failure ) ;
367
+ failure ? failure ( requestResult , options ) : this . serviceProcessFailed ( requestResult , options ) ;
367
368
} else {
368
369
response = { ...response , ...this . transformErrorResult ( requestResult , options ) } ;
369
- response . type = 'processFailed' ;
370
+ response . type = type ;
370
371
options . failure && options . failure ( response ) ;
371
372
}
372
373
} else {
373
- if ( options . success === this . serviceProcessCompleted ) {
374
- var success = options . scope ? FunctionExt . bind ( options . success , options . scope ) : options . success ;
375
- success ( requestResult , options ) ;
374
+ const type = 'processCompleted' ;
375
+ if ( this . events && this . events . listeners [ type ] && this . events . listeners [ type ] . length ) {
376
+ var success = options . success && ( options . scope ? FunctionExt . bind ( options . success , options . scope ) : options . success ) ;
377
+ success ? success ( requestResult , options ) : this . serviceProcessCompleted ( requestResult , options ) ;
376
378
} else {
377
379
requestResult . succeed = requestResult . succeed == undefined ? true : requestResult . succeed ;
378
380
response = { ...response , ...this . transformResult ( requestResult , options ) } ;
379
- response . type = 'processCompleted' ;
381
+ response . type = type ;
380
382
options . success && options . success ( response ) ;
381
383
}
382
384
}
0 commit comments