Ver código fonte

text/date/combo/number clean

luoyifan 3 anos atrás
pai
commit
ff54b49542
3 arquivos alterados com 46 adições e 7 exclusões
  1. 0 2
      src/controls/input/search.js
  2. 33 0
      src/controls/input/textfield.js
  3. 13 5
      src/types.ts

+ 0 - 2
src/controls/input/search.js

@@ -148,8 +148,6 @@ export default function () {
                 me.getTrigger('clear').hide();
                 me.updateLayout();
             }
-
-            console.log('onChange', newVal, oldVal)
         },
 
         /**

+ 33 - 0
src/controls/input/textfield.js

@@ -10,11 +10,28 @@ export default function () {
         constructor(config) {
             const newConfig = _.defaultsDeep({
                 // 强制属性
+                triggers: {
+                    clear: {
+                        weight: -1,
+                        cls: Ext.baseCSSPrefix + 'form-clear-trigger',
+                        hidden: true,
+                        handler: 'onClearClick',
+                    },
+                }
+
             }, baseConfig(config, 'col-item'), config, text)
 
             cc.call(this, newConfig)
         },
 
+        /**
+         * 清空所有值
+         */
+        onClearClick(sender, e) {
+            const me = this
+            me.setValue('')
+        },
+
         initComponent() {
 
             /**
@@ -25,6 +42,22 @@ export default function () {
                     '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
                 ];
             }
+
+            const me = this
+            this.on({
+                change(sender, newVal) {
+                    const value = newVal
+
+                    if (value) {
+                        me.getTrigger('clear').show();
+                        me.updateLayout();
+                    } else {
+                        me.getTrigger('clear').hide();
+                        me.updateLayout();
+                    }
+                }
+            })
+
             initComponent.call(this)
         }
     });

+ 13 - 5
src/types.ts

@@ -19,9 +19,16 @@ export type ConfigProcess = (me, config) => any
  */
 export interface FunctionArgument {
     /**
-     * 列举类型
+     * 参数值存放的内容(类型)
+     *    module 选择一个功能模块
+     *    control 从当前模块的 controller 中选择一个方法
+     *    viewModel 从当前模块的 VM 中的一个属性
+     *    refs 从当前模块的 refs 中选一个控件
+     *    event 当成事件输入框来填写
+     *    string 任意字符串
+     *    object 任意对象 (JSON5)
      */
-    type: 'module' | 'control' | 'viewModel' | 'refs' | 'string' | 'object'
+    type: 'module' | 'control' | 'viewModel' | 'refs' | 'event' | 'string' | 'object'
 
     /**
      * 参数中文说明
@@ -83,16 +90,17 @@ export interface FunctionRegiste {
      * 类型
      * system: 系统方法
      * format: 格式化作用
-     * ajaxMethod: AjaxMethod
-     * fix: 修正 vjson
      */
-    type: 'system' | 'format' | 'fix'
+    type: 'system' | 'format'
 
     /**
      * 分类名称
      */
     category?: string
 
+    /**
+     * 参数值
+     */
     args?: FunctionArgument[]
 
     /**