This commit is contained in:
sentsin
2017-09-01 07:52:28 +08:00
parent 50a68bf875
commit b644b76ce3
33 changed files with 103 additions and 75 deletions

View File

@@ -1,6 +1,6 @@
/**
@Name : layDate 5.0.3 日期时间控件
@Name : layDate 5.0.4 日期时间控件
@Author: 贤心
@Sitehttp://www.layui.com/laydate/
@LicenseMIT
@@ -55,7 +55,7 @@
}
,laydate = {
v: '5.0.3'
v: '5.0.4'
,config: {} //全局配置项
,index: (window.laydate && window.laydate.v) ? 100000 : 0
,path: ready.getPath
@@ -71,6 +71,7 @@
,ready: function(fn){
var cssname = 'laydate', ver = ''
,path = (isLayui ? 'modules/laydate/' : 'theme/') + 'default/laydate.css?v='+ laydate.v + ver;
if(typeof define === 'function' && define.amd) return fn();
isLayui ? layui.addcss(path, fn, cssname) : ready.link(path, fn, cssname);
return this;
}
@@ -438,6 +439,9 @@
options.eventElem = lay(options.eventElem);
if(!options.elem[0]) return;
//默认赋值
options.value && that.setValue(options.value);
//日期范围分隔符
if(options.range === true) options.range = '-';
@@ -927,10 +931,11 @@
Class.prototype.mark = function(td, YMD){
var that = this
,mark, options = that.config;
lay.each(options.mark, function(key, title){
var keys = key.split('-');
if((keys[0] == YMD[0] || keys[0] == 0) && keys[1] == YMD[1] && keys[2] == YMD[2]){
if((keys[0] == YMD[0] || keys[0] == 0) //每年的每月
&& (keys[1] == YMD[1] || keys[1] == 0) //每月的每日
&& keys[2] == YMD[2]){ //特定日
mark = title || YMD[2];
}
});
@@ -1124,7 +1129,7 @@
if(yearNum < that.firstDate.year){
ymd.month = options.min.month;
ymd.date = options.min.date;
} else if(yearNum > that.firstDate.year){
} else if(yearNum >= that.firstDate.year){
ymd.month = options.max.month;
ymd.date = options.max.date;
}
@@ -1143,7 +1148,7 @@
ul.appendChild(li);
if(listYM[0] < that.firstDate.year){
ymd.date = options.min.date;
} else if(listYM[0] > that.firstDate.year){
} else if(listYM[0] >= that.firstDate.year){
ymd.date = options.max.date;
}
that.limit(lay(li), ymd, index);

View File

@@ -35,7 +35,8 @@ layui.define(function(exports){
//分页视图
Class.prototype.view = function(){
var that = this
,config = that.config;
,config = that.config
,groups = config.groups = 'groups' in config ? (config.groups|0) : 5; //连续页码个数
//排版
config.layout = typeof config.layout === 'object'
@@ -44,7 +45,6 @@ layui.define(function(exports){
config.count = config.count|0; //数据总数
config.curr = (config.curr|0) || 1; //当前页
config.groups = (config.groups|0) || 5; //连续页码个数
//每页条数的选择项
config.limits = typeof config.limits === 'object'
@@ -61,18 +61,18 @@ layui.define(function(exports){
}
//连续分页个数不能低于0且不能大于总页数
if(config.groups < 0){
config.groups = 0
} else if (config.groups > config.pages){
config.groups = config.pages;
if(groups < 0){
groups = 1;
} else if (groups > config.pages){
groups = config.pages;
}
config.prev = 'prev' in config ? config.prev : '&#x4E0A;&#x4E00;&#x9875;'; //上一页文本
config.next = 'next' in config ? config.next : '&#x4E0B;&#x4E00;&#x9875;'; //下一页文本
//计算当前组
var index = config.pages > config.groups
? Math.ceil( (config.curr + (config.groups > 1 ? 1 : 0)) / (config.groups > 0 ? config.groups : 1) )
var index = config.pages > groups
? Math.ceil( (config.curr + (groups > 1 ? 1 : 0)) / (groups > 0 ? groups : 1) )
: 1
//试图片段
@@ -94,21 +94,21 @@ layui.define(function(exports){
}
//首页
if(index > 1 && config.first !== false && config.groups !== 0){
if(index > 1 && config.first !== false && groups !== 0){
pager.push('<a href="javascript:;" class="layui-laypage-first" data-page="1" title="&#x9996;&#x9875;">'+ (config.first || 1) +'</a>');
}
//计算当前页码组的起始页
var halve = Math.floor((config.groups-1)/2) //页码数等分
var halve = Math.floor((groups-1)/2) //页码数等分
,start = index > 1 ? config.curr - halve : 1
,end = index > 1 ? (function(){
var max = config.curr + (config.groups - halve - 1);
var max = config.curr + (groups - halve - 1);
return max > config.pages ? config.pages : max;
}()) : config.groups;
}()) : groups;
//防止最后一组出现“不规定”的连续页码数
if(end - start < config.groups - 1){
start = end - config.groups + 1;
if(end - start < groups - 1){
start = end - groups + 1;
}
//输出左分割符
@@ -127,11 +127,11 @@ layui.define(function(exports){
}
//输出输出右分隔符 & 末页
if(config.pages > config.groups && config.pages > end && config.last !== false){
if(config.pages > groups && config.pages > end && config.last !== false){
if(end + 1 < config.pages){
pager.push('<span class="layui-laypage-spr">&#x2026;</span>');
}
if(config.groups !== 0){
if(groups !== 0){
pager.push('<a href="javascript:;" class="layui-laypage-last" title="&#x5C3E;&#x9875;" data-page="'+ config.pages +'">'+ (config.last || config.pages) +'</a>');
}
}

View File

@@ -69,8 +69,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
,'{{# layui.each(d.data.cols, function(i1, item1){ }}'
,'<tr>'
,'{{# layui.each(item1, function(i2, item2){ }}'
,'{{# if(item2.fixed && item2.fixed !== "right"){ fixed = true; } }}'
,'{{# if(item2.fixed){ right = true; } }}'
,'{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}'
,'{{# if(item2.fixed === "right"){ right = true; } }}'
,function(){
if(options.fixed && options.fixed !== 'right'){
return '{{# if(item2.fixed && item2.fixed !== "right"){ }}';
@@ -81,9 +81,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
return '';
}()
,'{{# if(item2.checkbox){ }}'
,'<th data-field="{{ item2.field||i2 }}" data-type="checkbox" unresize="true"><div class="layui-table-cell laytable-cell-checkbox"><input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose" {{# if(item2[d.data.checkName]){ }}checked{{# }; }}></div></th>'
,'<th data-field="{{ item2.field||i2 }}" data-type="checkbox" {{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}} unresize="true"><div class="layui-table-cell laytable-cell-checkbox"><input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose" {{# if(item2[d.data.checkName]){ }}checked{{# }; }}></div></th>'
,'{{# } else if(item2.space){ }}'
,'<th data-field="{{ item2.field||i2 }}" unresize="true"><div class="layui-table-cell laytable-cell-space"></div></th>'
,'<th data-field="{{ item2.field||i2 }}" {{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}} unresize="true"><div class="layui-table-cell laytable-cell-space"></div></th>'
,'{{# } else { }}'
,'<th data-field="{{ item2.field||i2 }}" {{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}} {{# if(item2.unresize){ }}unresize="true"{{# } }}>'
,'{{# if(item2.colspan > 1){ }}'
@@ -116,7 +116,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
//主模板
,TPL_MAIN = ['<div class="layui-form layui-border-box {{d.VIEW_CLASS}}" lay-filter="LAY-table-{{d.index}}" style="{{# if(d.data.width){ }}width:{{d.data.width}}px;{{# } }} {{# if(d.data.height){ }}height:{{d.data.height}}px;{{# } }}">'
,'{{# var fixed, right; }}'
,'{{# var left, right; }}'
,'<div class="layui-table-header">'
,TPL_HEADER()
,'</div>'
@@ -124,7 +124,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
,TPL_BODY
,'</div>'
,'{{# if(fixed && fixed !== "right"){ }}'
,'{{# if(left){ }}'
,'<div class="layui-table-fixed layui-table-fixed-l">'
,'<div class="layui-table-header">'
,TPL_HEADER({fixed: true})
@@ -241,6 +241,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
that.fullSize();
}
//如果多级表头,则填补表头高度
if(options.cols.length > 1){
var th = that.layFixed.find(ELEM_HEADER).find('th');
th.height(that.layHeader.height() - 1 - parseFloat(th.css('padding-top')) - parseFloat(th.css('padding-bottom')));
}
that.pullData(1);
that.events();
};
@@ -257,7 +263,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
var that = this
,options = that.config
,request = options.request
,response = options.response;
,response = options.response
,sort = function(){
if(typeof options.initSort === 'object'){
that.sort(options.initSort.field, options.initSort.type);
}
};
if(options.url){ //Ajax请求
var params = {};
@@ -274,7 +285,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
that.renderForm();
return that.layMain.html('<div class="layui-none">'+ (res[response.msgName] || '返回的数据状态异常') +'</div>');;
}
that.renderData(res, curr, res[response.countName]);
that.renderData(res, curr, res[response.countName]), sort();
loadIndex && layer.close(loadIndex);
typeof options.done === 'function' && options.done(res, curr, res[response.countName]);
}
@@ -291,7 +302,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
res[response.dataName] = options.data.concat().splice(startLimit, options.limit);
res[response.countName] = options.data.length;
that.renderData(res, curr, options.data.length);
that.renderData(res, curr, options.data.length), sort();
typeof options.done === 'function' && options.done(res, curr, res[response.countName]);
}
};
@@ -471,7 +482,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
elemSort.attr('lay-sort', type || null);
that.layFixed.find('th')
} catch(e){
return hint.error('Did not match to field');
return hint.error('Table modules: Did not match to field');
}
//记录排序索引和类型

View File

@@ -341,19 +341,20 @@ layui.define('layer' , function(exports){
//检验文件大小
if(options.size > 0 && !(device.ie && device.ie < 10)){
return layui.each(that.chooseFiles, function(index, file){
var limitSize;
layui.each(that.chooseFiles, function(index, file){
if(file.size > 1024*options.size){
var size = options.size/1024;
size = size >= 1
? (Math.floor(size) + (size%1 > 0 ? size.toFixed(1) : 0)) + 'MB'
: options.size + 'KB'
elemFile.value = '';
return that.msg('文件不能超过'+ size);
limitSize = size;
}
send();
});
if(limitSize) return that.msg('文件不能超过'+ limitSize);
}
send();
};

View File

@@ -19,7 +19,7 @@
}
,Layui = function(){
this.v = '2.1.0'; //版本号
this.v = '2.1.1'; //版本号
}
//获取layui所在目录
@@ -56,7 +56,7 @@
,jquery: 'modules/jquery' //DOM库第三方
,mobile: 'modules/mobile' //移动大模块 | 若当前为开发目录,则为移动模块入口,否则为移动模块集合
,'layui.all': 'dest/layui.all' //PC模块合并版
,'layui.all': '../layui.all' //PC模块合并版
};
//记录基础数据