luoyifan пре 4 година
родитељ
комит
dd9bba999d
5 измењених фајлова са 68 додато и 2 уклоњено
  1. 5 0
      src/Defaults.ts
  2. 5 1
      src/controls/input/combo.js
  3. 33 1
      src/controls/input/datefield.js
  4. 23 0
      src/controls/input/numberfield.js
  5. 2 0
      src/init.ts

+ 5 - 0
src/Defaults.ts

@@ -21,6 +21,11 @@ export const combo = {
     autoLoad: true,
 }
 
+export const numberfield = {
+    labelAlign: 'right',
+    labelWidth: 70,
+}
+
 export const grid = {
     border: true,
     columnLines: true,

+ 5 - 1
src/controls/input/combo.js

@@ -66,7 +66,11 @@ export default function () {
 
         initComponent() {
             const that = this
-            const toggle = () => {
+            const toggle = (e) => {
+                if ($(e.target).is('.x-form-trigger')) {
+                    return
+                }
+
                 if (that.isExpanded) {
                     that.collapse()
 

+ 33 - 1
src/controls/input/datefield.js

@@ -1,6 +1,7 @@
 import _ from 'lodash'
 import {baseConfig} from "../base";
 import {date} from "../../Defaults";
+import {dataSourceReload} from "../../DataSourceHelper";
 
 export default function () {
 
@@ -25,8 +26,39 @@ export default function () {
             return nv
         },
 
+
         initComponent() {
+            const that = this
+            const toggle = (e) => {
+                if ($(e.target).is('.x-form-trigger')) {
+                    return
+                }
+                if (that.isExpanded) {
+                    that.collapse()
+
+                } else {
+                    that.expand();
+                }
+            }
+
+            this.on({
+                afterrender() {
+                    const {config} = this
+                    $(this.el.dom).on('click', toggle)
+                },
+                destory() {
+                    $(this.el.dom).off('click', toggle)
+                },
+                // focus: {
+                //     // 获得焦点后自动下拉
+                //     fn(sender) {
+                //         sender.expand();
+                //         this.doQuery(this.allQuery, true);
+                //     },
+                // },
+            })
+
             initComponent.call(this)
-        }
+        },
     });
 }

+ 23 - 0
src/controls/input/numberfield.js

@@ -0,0 +1,23 @@
+import _ from 'lodash'
+import {baseConfig} from "../base";
+import {numberfield} from "../../Defaults";
+
+export default function () {
+
+    const cc = Ext.form.field.Number.prototype.constructor
+    const {initComponent} = Ext.form.field.Number.prototype
+    Ext.form.field.Number.override({
+        constructor(config) {
+            const newConfig = _.defaultsDeep({
+                // 强制属性
+
+            }, baseConfig(config, 'col-item'), config, numberfield)
+
+            cc.call(this, newConfig)
+        },
+
+        initComponent() {
+            initComponent.call(this)
+        },
+    });
+}

+ 2 - 0
src/init.ts

@@ -7,6 +7,7 @@ import initSplitter from './controls/splitter'
 import initCombo from './controls/input/combo'
 import initSearch from './controls/input/search'
 import initDate from './controls/input/datefield'
+import initNumber from './controls/input/numberfield'
 import initRows from './controls/rows'
 import initCols from './controls/cols'
 import initButton from './controls/button'
@@ -86,4 +87,5 @@ export function init() {
     initStores()
     initSearch()
     initDate()
+    initNumber()
 }