diff --git a/examples/laydate.html b/examples/laydate.html
index 95e21780..01857051 100644
--- a/examples/laydate.html
+++ b/examples/laydate.html
@@ -138,10 +138,6 @@ layui.use('laydate', function(laydate){
//全局配置
laydate.set({
//trigger: 'focus'
- workrest: [
- ['2022-1-1', '2022-1-2', '2022-1-3', '2022-1-31', '2022-2-1', '2022-2-2', '2022-2-3', '2022-2-4', '2022-2-5', '2022-2-6', '2022-4-3', '2022-4-4', '2022-4-5', '2022-4-30', '2022-5-1', '2022-5-2', '2022-5-3', '2022-5-4', '2022-6-3', '2022-6-4', '2022-6-5', '2022-9-10', '2022-9-11', '2022-9-12', '2022-10-1', '2022-10-2', '2022-10-3', '2022-10-4', '2022-10-5', '2022-10-6', '2022-10-7'],
- ['2022-1-29', '2022-1-30', '2022-4-2', '2022-4-24', '2022-5-7', '2022-10-8', '2022-10-9']
- ]
})
//范围选择1
@@ -274,14 +270,14 @@ layui.use('laydate', function(laydate){
elem: '#test555'
//,calendar: true //是否开启公历重要节日
,mark: { //标记重要日子
- '0-8-15': '纪念' //0代表:每年
+ '0-10-14': '生日' //0代表:每年
,'0-0-15': '中旬'
- ,'2017-8-20': '发布'
+ ,'2017-8-20': 'v2'
,'2017-8-31': '月底'
}
,done: function(value, date, endDate){
- if(date.year == 2017 && date.month == 8 && date.date == 15){
- //console.log('中国人民战胜日本法西斯纪念日');
+ if(date.year == 2016 && date.month == 10 && date.date == 14){
+ //console.log('Layui 诞生日');
}
}
,change: function(value, date, endDate){
@@ -290,10 +286,14 @@ layui.use('laydate', function(laydate){
});
// 标注法定节假日及补班
- var ins5555 = laydate.render({
+ laydate.render({
elem: '#test5555',
value: '2022-5-21',
- isWorkrest: true
+ holidays: [
+ ['2022-1-1', '2022-1-2', '2022-1-3', '2022-1-31', '2022-2-1', '2022-2-2', '2022-2-3', '2022-2-4', '2022-2-5', '2022-2-6', '2022-4-3', '2022-4-4', '2022-4-5', '2022-4-30', '2022-5-1', '2022-5-2', '2022-5-3', '2022-5-4', '2022-6-3', '2022-6-4', '2022-6-5', '2022-9-10', '2022-9-11', '2022-9-12', '2022-10-1', '2022-10-2', '2022-10-3', '2022-10-4', '2022-10-5', '2022-10-6', '2022-10-7'],
+
+ ['2022-1-29', '2022-1-30', '2022-4-2', '2022-4-24', '2022-5-7', '2022-10-8', '2022-10-9']
+ ]
});
//墨绿主题
diff --git a/examples/table-test.html b/examples/table-test.html
index 4e5621b0..ca2a8955 100644
--- a/examples/table-test.html
+++ b/examples/table-test.html
@@ -130,7 +130,7 @@ layui.use(['table', 'dropdown'], function(){
].join('')
//,className: '.demo-table-view'
- //,size: 'sm'
+ //,size: 'lg'
//,skin: 'line'
//,loading: false
@@ -153,8 +153,8 @@ layui.use(['table', 'dropdown'], function(){
//,{type: 'numbers', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
- ,{field:'email', minWidth: 230, title:'邮箱 ', hide: 0, edit: 'text', templet: function(d){
- return ''+ layui.util.escape(d.email) +' '
+ ,{field:'email', minWidth: 160, title:'邮箱 ', hide: 0, edit: 'text', templet: function(d){
+ return ''+ layui.util.escape(d.email) +''
}}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){
@@ -183,6 +183,10 @@ layui.use(['table', 'dropdown'], function(){
,key: 'experience'
,order: 'asc'
}
+ ,before: function(options){
+ options.where.AAAAA = 123;
+ //console.log(options)
+ }
,done: function(res, curr, count){
var id = this.id;
diff --git a/package.json b/package.json
index 0ef8a64a..f39cd745 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "layui",
"realname": "layui",
- "version": "2.7.2",
+ "version": "2.7.3",
"description": "Classic modular Front-End UI library",
"main": "dist/layui.js",
"license": "MIT",
diff --git a/src/css/layui.css b/src/css/layui.css
index 9a7939a6..12ba1d30 100644
--- a/src/css/layui.css
+++ b/src/css/layui.css
@@ -892,12 +892,15 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-table img{max-width:100px;}
-/* 大表格 */.layui-table[lay-size="lg"] th,
+/* 大表格 */
+.layui-table[lay-size="lg"] th,
.layui-table[lay-size="lg"] td{padding-top: 15px; padding-right: 30px; padding-bottom: 15px; padding-left: 30px;}
.layui-table-view .layui-table[lay-size="lg"] .layui-table-cell{height: 50px; line-height: 40px;}
-/* 小表格 */.layui-table[lay-size="sm"] th,
+
+/* 小表格 */
+.layui-table[lay-size="sm"] th,
.layui-table[lay-size="sm"] td{padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;}
-.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px;}
+.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-right: 5px;}
/* 数据表格 */
.layui-table[lay-data]{display: none;}
@@ -951,6 +954,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-table-cell{height: 38px; line-height: 28px; padding: 6px 15px; position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-sizing: border-box;}
.layui-table-cell .layui-form-checkbox[lay-skin="primary"]{top: -1px; padding: 0;}
.layui-table-cell .layui-table-link{color: #01AAED;}
+.layui-table-cell .layui-btn{vertical-align: inherit;}
.layui-table-cell[align="center"]{-webkit-box-pack: center;}
.layui-table-cell[align="right"]{-webkit-box-pack: end;}
diff --git a/src/css/modules/laydate/default/laydate.css b/src/css/modules/laydate/default/laydate.css
index 9a0f3e9a..1238c92c 100644
--- a/src/css/modules/laydate/default/laydate.css
+++ b/src/css/modules/laydate/default/laydate.css
@@ -60,10 +60,10 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.layui-laydate-content td{position: relative; cursor: pointer;}
.laydate-day-mark{position: absolute; left: 0; top: 0; width: 100%; line-height: 30px; font-size: 12px; overflow: hidden;}
.laydate-day-mark::after{position: absolute; content:''; right: 2px; top: 2px; width: 5px; height: 5px; border-radius: 50%;}
-.laydate-day-workrest:before{position: absolute; left: 0;top: 3px;font-size: 12px;transform: scale(.7);}
-.laydate-day-workrest.rest:before{content:'假';color: #d11211;}
-.laydate-day-workrest.work:before{content:'班';color: #1589ee;}
-.layui-laydate .layui-this .laydate-day-workrest:before{color: #fff;}
+.laydate-day-holidays:before{position: absolute; left: 0; top: 0; font-size: 12px; transform: scale(.7);}
+.laydate-day-holidays:before{content:'\4F11'; color: #FF5722;}
+.laydate-day-holidays[type="work"]:before{content:'\73ED'; color: inherit;}
+.layui-laydate .layui-this .laydate-day-holidays:before{color: #fff;}
/* 底部结构 */
.layui-laydate-footer{position: relative; height: 46px; line-height: 26px; padding: 10px;}
diff --git a/src/layui.js b/src/layui.js
index 3ef03950..ee7987fb 100644
--- a/src/layui.js
+++ b/src/layui.js
@@ -15,7 +15,7 @@
}
,Layui = function(){
- this.v = '2.7.2'; // layui 版本号
+ this.v = '2.7.3'; // layui 版本号
}
//识别预先可能定义的指定全局对象
diff --git a/src/modules/form.js b/src/modules/form.js
index dd0c92ad..712dfeb4 100644
--- a/src/modules/form.js
+++ b/src/modules/form.js
@@ -681,7 +681,8 @@ layui.define('layer', function(exports){
if(!elem[0]) return !0;
// 若节点不存在特定属性,则查找容器内有待验证的子节点
- if(elem.attr('lay-verify') === undefined){ // 如果校验的是一个不带验证规则的容器,校验内部的verify节点
+ if(elem.attr('lay-verify') === undefined){
+ // 若校验的是一个不带验证规则的容器,校验内部的 lay-verify 节点
if (that.validate(elem.find('*[lay-verify]')) === false) {
return false;
}
@@ -706,6 +707,7 @@ layui.define('layer', function(exports){
//匹配验证规则
if(verify[thisVer]){
var isTrue = isFn ? errorText = verify[thisVer](value, item) : !verify[thisVer][0].test(value)
+
//是否属于美化替换后的表单元素
,isForm2Elem = item.tagName.toLowerCase() === 'select' || /^checkbox|radio$/.test(item.type);
diff --git a/src/modules/laydate.js b/src/modules/laydate.js
index 8d2a421b..97a7be64 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -121,8 +121,7 @@
,position: null //控件定位方式定位, 默认absolute,支持:fixed/absolute/static
,calendar: false //是否开启公历重要节日,仅支持中文版
,mark: {} //日期备注,如重要事件或活动标记
- ,isWorkrest: false // 是否标注节假日或补假上班, 默认 false
- ,workrest: [] // 标注法定节假日或补假上班
+ ,holidays: null // 标注法定节假日或补假上班
,zIndex: null //控件层叠顺序
,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发
,change: null //日期时间改变后的回调
@@ -281,10 +280,6 @@
,'0-10-1': '国庆'
,'0-12-25': '圣诞'
} : {}, options.mark);
-
- if(options.isWorkrest){
- options.workrest = lay.extend({}, (options.calendar && options.lang === 'cn') ? [] : [], options.workrest);
- }
//获取限制内日期
lay.each(['min', 'max'], function(i, item){
@@ -785,7 +780,7 @@
return that;
};
- //公历重要日期与自定义备注
+ // 公历重要日期与自定义备注
Class.prototype.mark = function(td, YMD){
var that = this
,mark, options = that.config;
@@ -803,18 +798,23 @@
};
// 标注法定节假日或补假上班
- Class.prototype.workrest = function(td, YMD) {
- var that = this,
- workrest,
- workclsArr = ['rest', 'work'],
- options = that.config;
- lay.each(options.workrest, function(idx, itm) {
- lay.each(itm, function(i, dayStr) {
- if(dayStr === td[0].getAttribute('lay-ymd')){
- td.html('' + YMD[2] + '');
+ Class.prototype.holidays = function(td, YMD) {
+ var that = this;
+ var options = that.config;
+ var type = ['', 'work'];
+
+ if(layui.type(options.holidays) !== 'array') return that;
+
+ lay.each(options.holidays, function(idx, item) {
+ lay.each(item, function(i, dayStr) {
+ if(dayStr === td.attr('lay-ymd')){
+ td.html('' + YMD[2] + '');
}
});
});
+
return that;
}
@@ -903,19 +903,11 @@
YMD[1]++;
YMD[2] = st + 1;
item.attr('lay-ymd', YMD.join('-')).html(YMD[2]);
- that.mark(item, YMD).limit(item, {
+ that.mark(item, YMD).holidays(item, YMD).limit(item, {
year: YMD[0]
,month: YMD[1] - 1
,date: YMD[2]
}, index_);
-
- if(options.isWorkrest){
- that.workrest(item, YMD).limit(item, {
- year: YMD[0]
- ,month: YMD[1] - 1
- ,date: YMD[2]
- }, index_);
- }
});
//同步头部年月
diff --git a/src/modules/layedit.js b/src/modules/layedit.js
index 4f3f3a02..87cad7ab 100644
--- a/src/modules/layedit.js
+++ b/src/modules/layedit.js
@@ -1,5 +1,5 @@
/**
- * layedit 富文本编辑器
+ * layedit 富文本编辑器(该组件已被弃用,为了向下兼容而保留)
*/
layui.define(['layer', 'form'], function(exports){
diff --git a/src/modules/table.js b/src/modules/table.js
index 3d50ad48..add230be 100644
--- a/src/modules/table.js
+++ b/src/modules/table.js
@@ -124,6 +124,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
,ELEM_SORT = '.layui-table-sort'
,ELEM_EDIT = 'layui-table-edit'
,ELEM_HOVER = 'layui-table-hover'
+
+ ,DATA_MOVE_NAME = 'LAY_TABLE_MOVE_DICT'
// thead 区域模板
,TPL_HEADER = function(options){
@@ -817,6 +819,10 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
opts = opts || {};
+ // 数据拉取前的回调
+ typeof options.before === 'function' && options.before(
+ options
+ );
that.startTime = new Date().getTime(); // 渲染开始时间
if(options.url){ // Ajax请求
@@ -837,8 +843,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
,url: options.url
,contentType: options.contentType
,data: data
- ,dataType:options.dataType || 'json'
- ,jsonpCallback:options.jsonpCallback
+ ,dataType: options.dataType || 'json'
+ ,jsonpCallback: options.jsonpCallback
,headers: options.headers || {}
,success: function(res){
// 若有数据解析的回调,则获得其返回的数据
@@ -1496,18 +1502,19 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
that.layFixRight.css('right', scollWidth - 1);
};
- //事件处理
+ // 事件处理
Class.prototype.events = function(){
- var that = this
- ,options = that.config
- ,_BODY = $('body')
- ,dict = {}
- ,th = that.layHeader.find('th')
- ,resizing
- ,ELEM_CELL = '.layui-table-cell'
- ,filter = options.elem.attr('lay-filter');
+ var that = this;
+ var options = that.config;
+
+ var filter = options.elem.attr('lay-filter');
+ var th = that.layHeader.find('th');
+ var ELEM_CELL = '.layui-table-cell';
+
+ var _BODY = $('body');
+ var dict = {};
- //工具栏操作事件
+ // 工具栏操作事件
that.layTool.on('click', '*[lay-event]', function(e){
var othis = $(this)
,events = othis.attr('lay-event')
@@ -1517,12 +1524,12 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
panel.html(list);
- //限制最大高度
+ // 限制最大高度
if(options.height){
panel.css('max-height', options.height - (that.layTool.outerHeight() || 50));
}
- //插入元素
+ // 插入元素
othis.find('.layui-table-tool-panel')[0] || othis.append(panel);
that.renderForm();
@@ -1538,7 +1545,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
layer.close(that.tipsIndex);
switch(events){
- case 'LAYTABLE_COLS': //筛选列
+ case 'LAYTABLE_COLS': // 筛选列
openPanel({
list: function(){
var lis = [];
@@ -1561,17 +1568,17 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
if(i1+ '-'+ i2 === key){
var hide = item2.hide;
- //同步勾选列的 hide 值和隐藏样式
+ // 同步勾选列的 hide 值和隐藏样式
item2.hide = !checked;
that.elem.find('*[data-key="'+ options.index +'-'+ key +'"]')
[checked ? 'removeClass' : 'addClass'](HIDE);
- //根据列的显示隐藏,同步多级表头的父级相关属性值
+ // 根据列的显示隐藏,同步多级表头的父级相关属性值
if(hide != item2.hide){
that.setParentCol(!checked, parentKey);
}
- //重新适配尺寸
+ // 重新适配尺寸
that.resize();
}
});
@@ -1580,7 +1587,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
}
});
break;
- case 'LAYTABLE_EXPORT': //导出
+ case 'LAYTABLE_EXPORT': // 导出
if(device.ie){
layer.tips('导出功能不支持 IE,请用 Chrome 等高级浏览器导出', this, {
tips: 3
@@ -1589,8 +1596,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
openPanel({
list: function(){
return [
- '
导出 csv 格式文件'
- ,'导出 xls 格式文件'
+ '导出 csv 格式文件',
+ '导出 xls 格式文件'
].join('')
}()
,done: function(panel, list){
@@ -1602,7 +1609,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
});
}
break;
- case 'LAYTABLE_PRINT': //打印
+ case 'LAYTABLE_PRINT': // 打印
var printWin = window.open('about:blank', '_blank')
,style = ['