码迷,mamicode.com
首页 > Web开发 > 详细

extjs日期控件使用

时间:2017-10-31 11:04:51      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:date()   cond   turn   form   func   bsp   24*   code   ini   

pp.priceApplyQuery.FORMAT_TIME  = ‘Y-m-d H:i:s‘; //格式化时间字符串

  支持 查询,修改,增加

//验证日期
Ext.apply(Ext.form.VTypes, {
    priceApplyQuery_dateRange: function(val, field){ 
        if(field.dateRange){
            var beginId = field.dateRange.begin;
            this.beginField = Ext.getCmp(beginId);
            var endId = field.dateRange.end;
            this.endField = Ext.getCmp(endId);
            beginDate = this.beginField.getValue();
            var endDate = this.endField.getValue();
            var typeName = field.dateRange.type;
        }
        if(beginDate <= endDate){
            if(typeName == "query"){
                  if(new Date(endDate).getTime()-new Date(beginDate).getTime()>3600*1000*24*30){
                        this.priceApplyQuery_dateRangeText = "查询时长不能超过30天!";
                        return false;  
                     }else{
                         return true;  
                     }
            }else if(typeName =="add" || typeName == "update"){
                 var nowDate = new Date();
                if(new Date(beginDate).getTime()<nowDate.getTime()){
                        this.priceApplyQuery_dateRangeText = "启用时间不能小于当前时间!";
                        return false;
                  }else{
                      return true;
                  }
            }else{
               return true;
            }  
        }else{
            this.priceApplyQuery_dateRangeText = "开始时间不能大于结束时间!";
            return false;  
        }
    }
});

  

pp.priceApplyQuery.formatDefaultDate = function(isBegin,format,type) {
    var nowDate = new Date();
    if(isBegin) {
        if(type == "query"){
            nowDate.setHours(0);
            nowDate.setSeconds(0);
            nowDate.setMinutes(0);
        }
    } else {
        nowDate.setHours(23);
        nowDate.setSeconds(59);
        nowDate.setMinutes(59);
    }
    return Ext.Date.format(nowDate,format);
};
{
            xtype:‘datetimefield_date97‘,
            name:‘q_time_beginDate‘, 
            id:‘priceApplyQuery_beginDate_query‘,
            fieldLabel:‘开始‘,
          columnWidth:0.6,
              labelWidth:40,
            format:‘Y-m-d H:i:s‘,
            dateConfig: {
                el: ‘priceApplyQuery_beginDate_query-inputEl‘,
                dateFmt: ‘yyyy-MM-dd HH:mi:ss‘
            },
            editable:false,
            allowBlank:false ,
            time:true,
            value:pp.priceApplyQuery.formatDefaultDate(true,pp.priceApplyQuery.FORMAT_TIME,"query" ),
            dateRange: {begin: ‘priceApplyQuery_beginDate_query‘, end: ‘priceApplyQuery_endDate_query‘,type:‘query‘},  
            vtype: ‘priceApplyQuery_dateRange‘ 

        },{
            xtype:‘datetimefield_date97‘,
            id:‘priceApplyQuery_endDate_query‘,
            name:‘q_time_endDate‘,
           columnWidth:0.6,
            labelWidth:40,
            fieldLabel:‘结束‘,
            format:‘Y-m-d H:i:s‘,
            dateConfig: {
                el: ‘priceApplyQuery_endDate_query-inputEl‘,
                dateFmt: ‘yyyy-MM-dd HH:mi:ss‘
            },
            editable:false,
            allowBlank:false,
            value:pp.priceApplyQuery.formatDefaultDate(false,pp.priceApplyQuery.FORMAT_TIME ,"query" ) ,
            dateRange: {begin: ‘priceApplyQuery_beginDate_query‘, end: ‘priceApplyQuery_endDate_query‘ ,type:‘query‘ },  
            vtype: ‘priceApplyQuery_dateRange‘ 
        }

  

extjs日期控件使用

标签:date()   cond   turn   form   func   bsp   24*   code   ini   

原文地址:http://www.cnblogs.com/zfzf1/p/7760020.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!