Browse Source

pda-client 显示用户姓名

lizw 3 năm trước cách đây
mục cha
commit
1e0900781c
1 tập tin đã thay đổi với 29 bổ sung3 xóa
  1. 29 3
      src/Scope.ts

+ 29 - 3
src/Scope.ts

@@ -2,6 +2,8 @@ import _ from 'lodash'
 import {lookupScope} from "./lib/lib";
 
 export class Scope {
+    private static readonly SHOW_PAGE_STACK: Scope[] = [];
+
     /**
      * 业务模块的唯一编号
      */
@@ -43,6 +45,8 @@ export class Scope {
      */
     topScope
 
+    _lastShowTime = 0
+
     constructor({model, vjson}) {
         const that = this
         this.model = model
@@ -111,7 +115,7 @@ export class Scope {
                 has = true
             }
         })
-        if(!has) {
+        if (!has) {
             _.defaults(option, {
                 allowBack: true,
                 vjsonOption: {},
@@ -183,10 +187,30 @@ export class Scope {
                             .find('.navbar>.x-panelheader')
                             .find('.x-body-el>.fa-angle-left')
                         $back.on('click', () => {
+                            // // 显示前一个页面
+                            // const index = Scope.SHOW_PAGE_STACK.findIndex(scope => scope === this);
+                            // if (index >= 0) {
+                            //     Scope.SHOW_PAGE_STACK.splice(index, 1);
+                            // }
+                            // const scopeArr = _.sortBy(Scope.SHOW_PAGE_STACK, scope => scope._lastShowTime)
+                            // if (scopeArr.length > 0) {
+                            //     const scope = scopeArr[scopeArr.length - 1]
+                            //     scope._handle.setStyle({'z-index': 1})
+                            //     let actived = false;
+                            //     (Ext.Viewport.getItems().items as []).forEach((item, idx) => {
+                            //         if (!actived && item === scope._handle) {
+                            //             actived = true
+                            //             Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
+                            //             Ext.Viewport.setActiveItem(idx)
+                            //             scope._lastShowTime = new Date().getTime()
+                            //         }
+                            //     })
+                            // }
+                            // 关闭
                             that._handle.setStyle({'z-index': 0})
                             Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
                             Ext.Viewport.remove(that._handle)
-                            that._handle.close()
+                            that.close()
                         })
                     }
                 },
@@ -196,7 +220,6 @@ export class Scope {
                     that._onDestroy()
                 },
             })
-            Ext.Viewport.add(that._handle)
         } else {
             window['cp'] = that
             // 调用onLoad回调
@@ -206,6 +229,7 @@ export class Scope {
                 console.error('errorAt onLoad', e)
             }
         }
+        Ext.Viewport.add(that._handle)
         that._handle.setStyle({'z-index': 1})
         let actived = false;
         (Ext.Viewport.getItems().items as []).forEach((item, idx) => {
@@ -213,6 +237,8 @@ export class Scope {
                 actived = true
                 Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'left', duration: 300})
                 Ext.Viewport.setActiveItem(idx)
+                that._lastShowTime = new Date().getTime()
+                Scope.SHOW_PAGE_STACK.push(that)
             }
         })
         return that._handle