luoyifan преди 4 години
родител
ревизия
3acbbe6756
променени са 4 файла, в които са добавени 29 реда и са изтрити 2 реда
  1. 4 0
      src/Defaults.ts
  2. 5 0
      src/controls/grid.js
  3. 9 1
      src/controls/input/search.js
  4. 11 1
      src/controls/stores.js

+ 4 - 0
src/Defaults.ts

@@ -2,6 +2,10 @@ export const windows = {
     modal: true,
     width: 900,
     height: 600,
+    maximizable: true,
+    constrain: true,
+    // draggable: true,
+    // scrollable: true,
 }
 
 export const combo = {

+ 5 - 0
src/controls/grid.js

@@ -128,6 +128,11 @@ export default function () {
                 // },
             })
 
+            if (this.store?.proxy) {
+                // 为 stores.proxy.buildRequest 做准备
+                this.store.proxy.$owner = this
+            }
+
             this.superclass.initComponent.call(this)
         },
 

+ 9 - 1
src/controls/input/search.js

@@ -2,6 +2,7 @@ import _ from 'lodash'
 import {baseConfig} from "../base";
 import {search} from "../../Defaults";
 import {invokeMethod} from "../../utils";
+import {lookupScope} from "../../lib/lib";
 
 export default function () {
 
@@ -59,6 +60,7 @@ export default function () {
             const me = this
             const {config} = me
             const {widget, vjson, lookup} = config
+            const parentScope = lookupScope(sender)
 
             if (e) {
                 e.preventDefault()
@@ -75,6 +77,12 @@ export default function () {
                 const WidgetScopeClass = widgetScope.default
                 widgetScope = new WidgetScopeClass()
 
+                const rawValue = this.getRawValue()
+                const widgetDialogData = {
+                    queryKeyword: rawValue
+                }
+                widgetScope.parentScope = parentScope
+                widgetScope.queryKeyword = rawValue
                 widgetScope.searchWidgetSuccess = (data) => {
                     if (typeof lookup === 'string') {
                         // lookup 是字符串的情况下,就是取某个列作为 value 值
@@ -106,7 +114,7 @@ export default function () {
 
                     return true
                 }
-                widgetScope.showDialog(sender)
+                widgetScope.showDialog(sender, vjson, {data: widgetDialogData})
             })
         },
 

+ 11 - 1
src/controls/stores.js

@@ -1,5 +1,6 @@
 import _ from 'lodash'
 import $ from 'jquery'
+import {lookupScope} from "../lib/lib";
 
 export default function () {
 
@@ -15,6 +16,8 @@ export default function () {
         buildRequest: function (operation) {
             // 参考源码 ext-all-debug.js:71468 method:buildRequest
             const me = this
+            const {$owner} = me // 在 grid.initComponent 中赋值 $owner
+            const scope = lookupScope($owner)
 
             const gridParam = me.getParams(operation)
             const customParam = {}
@@ -55,7 +58,14 @@ export default function () {
                 delete gridParam.filter
             }
 
-            const params = _.defaultsDeep(gridParam, me.extraParams)
+            const extraParams = me.extraParams
+            _.forOwn(extraParams, (value, key) => {
+                if (typeof value === 'function') {
+                    value = value.call(scope, scope)
+                }
+                extraParams[key] = value
+            })
+            const params = _.defaultsDeep(gridParam, extraParams)
 
             // var request = this.superclass.buildRequest.apply(this, arguments);
             let request = new Ext.data.Request({