Bladeren bron

text / combo

luoyifan 4 jaren geleden
bovenliggende
commit
f9538e72c9
3 gewijzigde bestanden met toevoegingen van 30 en 9 verwijderingen
  1. 10 1
      src/Defaults.ts
  2. 1 1
      src/controls/combo.js
  3. 19 7
      src/controls/textfield.js

+ 10 - 1
src/Defaults.ts

@@ -10,8 +10,17 @@ export const combo = {
     selectOnFocus: true,
 }
 
+export const text = {
+    labelAlign: 'right',
+    labelWidth: 70,
+}
+
 export const maintab = {}
 
 export const rows = {}
 
-export const cols = {}
+export const cols = {
+    defaults: {
+        flex: 1
+    },
+}

+ 1 - 1
src/controls/combo.js

@@ -1,6 +1,5 @@
 import _ from 'lodash'
 import {combo} from '../Defaults'
-import {invokeMethod} from "../utils";
 import {baseConfig} from "./base";
 
 export default function () {
@@ -18,6 +17,7 @@ export default function () {
         initComponent() {
             this.on({
                 focus: {
+                    // 获得焦点后自动下拉
                     fn(sender) {
                         sender.expand();
                         this.doQuery(this.allQuery, true);

+ 19 - 7
src/controls/textfield.js

@@ -1,19 +1,31 @@
 import _ from 'lodash'
-import $ from 'jquery'
+import {baseConfig} from "./base";
+import {text} from "../Defaults";
 
 export default function () {
-    /**
-     * 改变必填项之前加星号
-     */
-    const t1 = Ext.form.field.Text.prototype.initComponent
+
+    const cc = Ext.form.field.ComboBox.prototype.constructor
+    const {initComponent} = Ext.form.field.Text.prototype
     Ext.form.field.Text.override({
-        initComponent(config) {
+        constructor(config) {
+            const newConfig = _.defaultsDeep({
+                // 强制属性
+            }, baseConfig(config, 'col-item'), config, text)
+
+            cc.call(this, newConfig)
+        },
+
+        initComponent() {
+
+            /**
+             * 改变必填项之前加星号
+             */
             if (this.allowBlank === false || this.validateBlank === true) {
                 this.beforeLabelTextTpl = [
                     '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
                 ];
             }
-            t1.call(this, config)
+            initComponent.call(this)
         }
     });
 }