Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

yuliang 3 anni fa
parent
commit
4a0c19214c

+ 10 - 0
src/Defaults.ts

@@ -8,6 +8,11 @@ export const windows = {
     // scrollable: true,
 }
 
+export const date = {
+    labelAlign: 'right',
+    labelWidth: 70,
+}
+
 export const combo = {
     labelAlign: 'right',
     labelWidth: 70,
@@ -16,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()
 

+ 64 - 0
src/controls/input/datefield.js

@@ -0,0 +1,64 @@
+import _ from 'lodash'
+import {baseConfig} from "../base";
+import {date} from "../../Defaults";
+import {dataSourceReload} from "../../DataSourceHelper";
+
+export default function () {
+
+    const cc = Ext.form.field.Date.prototype.constructor
+    const {initComponent, getValue} = Ext.form.field.Date.prototype
+    Ext.form.field.Date.override({
+        constructor(config) {
+            const newConfig = _.defaultsDeep({
+                // 强制属性
+                format: 'Y-m-d',
+                altFormats: 'Y-m-d',
+
+            }, baseConfig(config, 'col-item'), config, date)
+
+            cc.call(this, newConfig)
+        },
+
+        getValue() {
+            const ov = getValue.call(this)
+            const nv = Ext.util.Format.date(ov, 'Y-m-d')
+            // console.log('cc:', nv, ov)
+            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)
+        },
+    });
+}

+ 1 - 1
src/controls/input/textfield.js

@@ -4,7 +4,7 @@ import {text} from "../../Defaults";
 
 export default function () {
 
-    const cc = Ext.form.field.ComboBox.prototype.constructor
+    const cc = Ext.form.field.Text.prototype.constructor
     const {initComponent} = Ext.form.field.Text.prototype
     Ext.form.field.Text.override({
         constructor(config) {

+ 4 - 0
src/init.ts

@@ -7,6 +7,8 @@ import initToolbar from './controls/toolbar/toolbar'
 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'
@@ -91,4 +93,6 @@ export function init() {
     initButton()
     initStores()
     initSearch()
+    initDate()
+    initNumber()
 }