luoyifan 3 年 前
コミット
3229cf9696
5 ファイル変更34 行追加17 行削除
  1. 3 1
      src/index.ts
  2. 13 6
      src/init.ts
  3. 3 2
      src/lib/lib.ts
  4. 9 7
      src/lib/systemLib.ts
  5. 6 1
      src/types.ts

+ 3 - 1
src/index.ts

@@ -17,7 +17,9 @@ export {
     Defaults
 }
 
-export * from './lib/ajax'
 export * from './Scope'
 export * from './init'
+export * from './lib/ajax'
+export * from './lib/Lib'
 export * from './lib/config'
+export * from './lib/systemLib'

+ 13 - 6
src/init.ts

@@ -12,6 +12,7 @@ import initRows from './controls/rows'
 import initCols from './controls/cols'
 import initButton from './controls/button'
 import initStores from './controls/stores'
+import {lookupFn, lookupScope} from "./lib/lib";
 
 export function init() {
     // 引入 filters 过滤插件
@@ -63,13 +64,19 @@ export function init() {
      */
     const _doAddListener = Ext.mixin.Observable.prototype.doAddListener
     Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
-        if (typeof fn === 'string' && _.startsWith(fn, 'scope.')) {
+        if (typeof fn === 'string' &&
+            (_.startsWith(fn, 'scope.') ||
+                _.startsWith(fn, 'system.') ||
+                _.startsWith(fn, 'format.')
+            )) {
             // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
-            const vm = this.lookupViewModel()
-            if (vm && vm.yvanScope) {
-                scope = vm.yvanScope
-                fn = scope[fn.substr('scope.'.length)]
-            }
+            // const vm = this.lookupViewModel()
+            // if (vm && vm.yvanScope) {
+            //     scope = vm.yvanScope
+            //     fn = scope[fn.substr('scope.'.length)]
+            // }
+            scope = lookupScope(this)
+            fn = lookupFn(scope, fn)
         }
 
         _doAddListener.call(this, ename, fn, scope, options, order, caller, manager)

+ 3 - 2
src/lib/lib.ts

@@ -13,10 +13,10 @@ export function Lib(registe: FunctionRegiste) {
         })
 
         if (registe.type === 'system') {
-            _.set(window, 'system.' + propertyKey, target[propertyKey])
+            _.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey])
 
         } else if (registe.type === 'format') {
-            _.set(window, 'format.' + propertyKey, target[propertyKey])
+            _.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey])
         }
 
         return target
@@ -31,6 +31,7 @@ export function Lib(registe: FunctionRegiste) {
  */
 export function lookupFn(scope: Scope, event: string): Function {
     // 为 eval 准备环境
+    const {system, format} = window['yvanLib']
     const func: Function = eval(event)
 
     if (typeof func !== 'function') {

+ 9 - 7
src/lib/systemLib.ts

@@ -10,13 +10,15 @@ export function tplExpress(viewModel, express) {
         return viewModel.get(express)
 
     } else {
-        let ret = undefined
-        viewModel.bind(express, function (v) {
-            ret = v
-            debugger
-        })
-        // Ext.app.bind.TemplateBinding
-        debugger
+        // Ext.app.bind.Parser.prototype.compile("{theGrid.selection.data}")
+        throw new TypeError("没有做完")
+        // let ret = undefined
+        // viewModel.bind(express, function (v) {
+        //     ret = v
+        //     debugger
+        // })
+        // // Ext.app.bind.TemplateBinding
+        // debugger
     }
 }
 

+ 6 - 1
src/types.ts

@@ -21,7 +21,7 @@ export interface FunctionArgument {
     /**
      * 列举类型
      */
-    type: 'module' | 'control'
+    type: 'module' | 'control' | 'viewModel' | 'refs' | 'string' | 'object'
 
     /**
      * 参数中文说明
@@ -34,6 +34,11 @@ export interface FunctionArgument {
     name: string
 
     /**
+     * 是否允许为空
+     */
+    allowEmpty: boolean
+
+    /**
      * 过滤器
      * @param list
      */