Browse Source

期间控件BUG修复

zhouy 7 years ago
parent
commit
65e0d6cfa1
1 changed files with 16 additions and 11 deletions
  1. 16 11
      frontend/saas-web/app/view/core/form/field/Month.js

+ 16 - 11
frontend/saas-web/app/view/core/form/field/Month.js

@@ -5,7 +5,7 @@ Ext.define('saas.view.core.form.field.Month', {
     extend:'Ext.form.field.Picker',
     alias: 'widget.monthdatefield',
     requires: ['Ext.picker.Month'],
-    format : "Y-m",
+    format : "Ym",
     disabledDaysText : "Disabled",
     disabledDatesText : "Disabled",
     triggerCls : Ext.baseCSSPrefix + 'form-date-trigger',
@@ -29,17 +29,23 @@ Ext.define('saas.view.core.form.field.Month', {
         if(isString(max)){
             me.maxValue = me.parseDate(max);
         }
-        me.disabledDatesRE = null;
-        if(Ext.isEmpty(me.value)){
+     /*   if(Ext.isEmpty(me.value)){
             me.value=me.getCurrentVal();
-        }
+        }*/
         me.callParent();
     },
+    listeners : {
+        afterrender: function (field) {
+            if(field.autoValue && Ext.isEmpty(field.value)){
+                field.setValue(field.getCurrentVal());
+            }
+        }
+    },
     createPicker: function() {
         var me = this,
             picker = me.monthPicker,
             format = Ext.String.format;
-       return me.monthPicker=picker=new Ext.picker.Month({
+        return me.monthPicker=picker=new Ext.picker.Month({
             id: me.id + '-picker',
             pickerField: me,
             floating: true,
@@ -84,12 +90,12 @@ Ext.define('saas.view.core.form.field.Month', {
                     return;
                 }
             }
-            this.setValue(year + '-' + month);
+            this.setValue(year + '' + month);
         }
         me.onSelect();
     },
     getCurrentVal:function(){
-        return Ext.Date.format(new Date(), this.format);
+        return Ext.Date.format(new Date(),this.format);
     },
     onCancelClick: function() {
         this.onSelect();
@@ -107,11 +113,10 @@ Ext.define('saas.view.core.form.field.Month', {
         return [month, year];
     },
     setValue : function(value) {
-       if (Ext.isEmpty(value)) {
-            value =this.getCurrentVal();
+        if (Ext.isEmpty(value)) {
+            value =me.getCurrentVal();
         }
-        value = Ext.Date.format(new Date(value), this.format);
-        this.callParent([value]);
+        this.callParent(arguments);
     },
     onSelect: function() {
         this.monthPicker.hide();