@@ -254,7 +254,7 @@ export class CommonServiceBase {
254254 * @private
255255 */
256256 serviceProcessCompleted ( result , options ) {
257- result = Util . transformResult ( result ) ;
257+ result = this . transformResult ( result ) . result ;
258258 this . events . triggerEvent ( 'processCompleted' , {
259259 result : result ,
260260 options : options
@@ -269,7 +269,7 @@ export class CommonServiceBase {
269269 * @private
270270 */
271271 serviceProcessFailed ( result , options ) {
272- result = Util . transformResult ( result ) ;
272+ result = this . transformErrorResult ( result ) . error ;
273273 let error = result . error || result ;
274274 this . events . triggerEvent ( 'processFailed' , {
275275 error : error ,
@@ -360,23 +360,25 @@ export class CommonServiceBase {
360360 object : this
361361 } ;
362362 if ( requestResult . error ) {
363+ const type = 'processFailed' ;
363364 // 兼容服务在构造函数中使用 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 ) ;
367368 } else {
368369 response = { ...response , ...this . transformErrorResult ( requestResult , options ) } ;
369- response . type = 'processFailed' ;
370+ response . type = type ;
370371 options . failure && options . failure ( response ) ;
371372 }
372373 } 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 ) ;
376378 } else {
377379 requestResult . succeed = requestResult . succeed == undefined ? true : requestResult . succeed ;
378380 response = { ...response , ...this . transformResult ( requestResult , options ) } ;
379- response . type = 'processCompleted' ;
381+ response . type = type ;
380382 options . success && options . success ( response ) ;
381383 }
382384 }
0 commit comments