Merge pull request #1068 from layui/2.x

合并 2.x 最新代码
pull/1070/head
贤心 2022-07-06 00:34:37 +08:00 committed by GitHub
commit c1f0745209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 140 additions and 114 deletions

View File

@ -17,7 +17,7 @@
</head>
<body>
<form class="layui-form" method="get" lay-filter="top">
<form class="layui-form" method="get" lay-filter="top" id="AAA">
<div class="layui-form-item">
<div class="layui-input-inline">
<input type="text" name="arr[]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">

View File

@ -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']
]
});
//墨绿主题

View File

@ -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:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, edit: 'text', templet: function(d){
return '<em>'+ layui.util.escape(d.email) +'</em> <input type="checkbox" title="激活">'
,{field:'email', minWidth: 160, title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, edit: 'text', templet: function(d){
return '<em>'+ layui.util.escape(d.email) +'</em>'
}}
,{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;

View File

@ -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",

View File

@ -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;}

View File

@ -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;}

View File

@ -15,7 +15,7 @@
}
,Layui = function(){
this.v = '2.7.2'; // layui 版本号
this.v = '2.7.3'; // layui 版本号
}
//识别预先可能定义的指定全局对象

View File

@ -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);

View File

@ -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 //日期时间改变后的回调
@ -282,10 +281,6 @@
,'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){
var ymd = [], hms = [];
@ -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('<span class="laydate-day-workrest ' + workclsArr[idx] + '">' + YMD[2] + '</span>');
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('<span class="laydate-day-holidays"' + (
type[idx] ? ('type="'+ type[idx] +'"') : ''
) + '>' + YMD[2] + '</span>');
}
});
});
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_);
}
});
//同步头部年月

View File

@ -1,5 +1,5 @@
/**
* layedit 富文本编辑器
* layedit 富文本编辑器该组件已被弃用为了向下兼容而保留
*/
layui.define(['layer', 'form'], function(exports){

View File

@ -125,6 +125,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
,ELEM_EDIT = 'layui-table-edit'
,ELEM_HOVER = 'layui-table-hover'
,DATA_MOVE_NAME = 'LAY_TABLE_MOVE_DICT'
// thead 区域模板
,TPL_HEADER = function(options){
var rowCols = '{{#if(item2.colspan){}} colspan="{{=item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{=item2.rowspan}}"{{#}}}';
@ -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 [
'<li data-type="csv">导出 csv 格式文件</li>'
,'<li data-type="xls">导出 xls 格式文件</li>'
'<li data-type="csv">导出 csv 格式文件</li>',
'<li data-type="xls">导出 xls 格式文件</li>'
].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 = ['<style>'
,'body{font-size: 12px; color: #5F5F5F;}'
@ -1632,7 +1639,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
},{}));
});
//分页栏操作事件
// 分页栏操作事件
that.layPagebar.on('click', '*[lay-event]', function(e){
var othis = $(this)
,events = othis.attr('lay-event');
@ -1643,26 +1650,25 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
},{}));
});
//拖拽调整宽度
// 拖拽调整宽度
th.on('mousemove', function(e){
var othis = $(this)
,oLeft = othis.offset().left
,pLeft = e.clientX - oLeft;
if(othis.data('unresize') || dict.resizeStart){
if(othis.data('unresize') || thisTable.eventMoveElem){
return;
}
dict.allowResize = othis.width() - pLeft <= 10; //是否处于拖拽允许区域
_BODY.css('cursor', (dict.allowResize ? 'col-resize' : ''));
}).on('mouseleave', function(){
var othis = $(this);
if(dict.resizeStart) return;
if(thisTable.eventMoveElem) return;
_BODY.css('cursor', '');
}).on('mousedown', function(e){
var othis = $(this);
if(dict.allowResize){
var key = othis.data('key');
e.preventDefault();
dict.resizeStart = true; //开始拖拽
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
that.getCssRule(key, function(item){
@ -1671,40 +1677,57 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
dict.ruleWidth = parseFloat(width);
dict.minWidth = othis.data('minwidth') || options.cellMinWidth;
});
// 临时记录当前拖拽信息
othis.data(DATA_MOVE_NAME, dict);
thisTable.eventMoveElem = othis;
}
});
//拖拽中
// 拖拽中
if(!thisTable.docEvent){
_DOC.on('mousemove', function(e){
if(dict.resizeStart){
if(thisTable.eventMoveElem){
var dict = thisTable.eventMoveElem.data(DATA_MOVE_NAME) || {};
thisTable.eventMoveElem.data('resizing', 1);
e.preventDefault();
if(dict.rule){
var setWidth = dict.ruleWidth + e.clientX - dict.offset[0];
if(setWidth < dict.minWidth) setWidth = dict.minWidth;
dict.rule.style.width = setWidth + 'px';
layer.close(that.tipsIndex);
}
resizing = 1
}
}).on('mouseup', function(e){
if(dict.resizeStart){
if(thisTable.eventMoveElem){
dict = {};
_BODY.css('cursor', '');
that.scrollPatch();
}
if(resizing === 2){
resizing = null;
// 清除当前拖拽信息
thisTable.eventMoveElem.removeData(DATA_MOVE_NAME);
delete thisTable.eventMoveElem;
}
});
}
//排序
// 已给 document 执行全局事件,避免重复绑定
thisTable.docEvent = true;
// 排序
th.on('click', function(e){
var othis = $(this)
,elemSort = othis.find(ELEM_SORT)
,nowType = elemSort.attr('lay-sort')
,type;
var othis = $(this);
var elemSort = othis.find(ELEM_SORT);
var nowType = elemSort.attr('lay-sort');
var type;
if(!elemSort[0] || resizing === 1) return resizing = 2;
// 排序不触发的条件
if(!elemSort[0] || othis.data('resizing') === 1){
return othis.removeData('resizing');
}
if(nowType === 'asc'){
type = 'desc';
@ -1771,8 +1794,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
}, sets);
};
//复选框选择
that.elem.on('click', 'input[name="layTableCheckbox"]+', function(){ //替代元素的 click 事件
// 复选框选择(替代元素的 click 事件)
that.elem.on('click', 'input[name="layTableCheckbox"]+', function(){
var checkbox = $(this).prev()
,children = that.layBody.find('input[name="layTableCheckbox"]')
,index = checkbox.parents('tr').eq(0).data('index')
@ -1844,7 +1867,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
setRowEvent.call(this, 'rowDouble');
});
//创建行单击、双击事件
// 创建行单击、双击事件
var setRowEvent = function(eventType){
var othis = $(this);
if(othis.data('off')) return; //不触发事件
@ -2324,7 +2347,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
var args = $.extend([], arguments);
args[3] = 'reloadData';
// 过滤与数据无关的参数
// 重载时,与数据相关的参数
var dataParams = new RegExp('^('+ [
'data', 'url', 'method', 'contentType',
'dataType','jsonpCallback',
@ -2333,6 +2356,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
'scrollPos'
].join('|') + ')$');
// 过滤与数据无关的参数
layui.each(args[1], function (key, value) {
if(!dataParams.test(key)){
delete args[1][key];