Browse Source

monthdatefield

zhuth 7 years ago
parent
commit
70f65c549f
1 changed files with 10 additions and 5 deletions
  1. 10 5
      frontend/saas-web/app/view/core/form/field/Month.js

+ 10 - 5
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',
@@ -84,7 +84,7 @@ Ext.define('saas.view.core.form.field.Month', {
                     return;
                 }
             }
-            this.setValue(year + '-' + month);
+            this.setValue(year + month);
         }
         me.onSelect();
     },
@@ -106,12 +106,17 @@ Ext.define('saas.view.core.form.field.Month', {
         }
         return [month, year];
     },
-    setValue : function(value) {
-       if (Ext.isEmpty(value)) {
+    setValue: function (value) {
+        if (Ext.isEmpty(value)) {
             value =this.getCurrentVal();
         }
-        value = Ext.Date.format(new Date(value), this.format);
+        var f = value.match(/^(\d{4})(\d{2})$/);
+        if(f) {
+            var d = f[1] + '-' + f[2];
+            value = Ext.Date.format(new Date(d), this.format);
+        }
         this.callParent([value]);
+        this.publishState('value', value);
     },
     onSelect: function() {
         this.monthPicker.hide();