mirror of https://github.com/layui/layui
commit
c1f0745209
|
@ -17,7 +17,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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-form-item">
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input type="text" name="arr[]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
|
<input type="text" name="arr[]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
|
||||||
|
|
|
@ -138,10 +138,6 @@ layui.use('laydate', function(laydate){
|
||||||
//全局配置
|
//全局配置
|
||||||
laydate.set({
|
laydate.set({
|
||||||
//trigger: 'focus'
|
//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
|
//范围选择1
|
||||||
|
@ -274,14 +270,14 @@ layui.use('laydate', function(laydate){
|
||||||
elem: '#test555'
|
elem: '#test555'
|
||||||
//,calendar: true //是否开启公历重要节日
|
//,calendar: true //是否开启公历重要节日
|
||||||
,mark: { //标记重要日子
|
,mark: { //标记重要日子
|
||||||
'0-8-15': '纪念' //0代表:每年
|
'0-10-14': '生日' //0代表:每年
|
||||||
,'0-0-15': '中旬'
|
,'0-0-15': '中旬'
|
||||||
,'2017-8-20': '发布'
|
,'2017-8-20': 'v2'
|
||||||
,'2017-8-31': '月底'
|
,'2017-8-31': '月底'
|
||||||
}
|
}
|
||||||
,done: function(value, date, endDate){
|
,done: function(value, date, endDate){
|
||||||
if(date.year == 2017 && date.month == 8 && date.date == 15){
|
if(date.year == 2016 && date.month == 10 && date.date == 14){
|
||||||
//console.log('中国人民战胜日本法西斯纪念日');
|
//console.log('Layui 诞生日');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,change: function(value, date, endDate){
|
,change: function(value, date, endDate){
|
||||||
|
@ -290,10 +286,14 @@ layui.use('laydate', function(laydate){
|
||||||
});
|
});
|
||||||
|
|
||||||
// 标注法定节假日及补班
|
// 标注法定节假日及补班
|
||||||
var ins5555 = laydate.render({
|
laydate.render({
|
||||||
elem: '#test5555',
|
elem: '#test5555',
|
||||||
value: '2022-5-21',
|
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']
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
//墨绿主题
|
//墨绿主题
|
||||||
|
|
|
@ -130,7 +130,7 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
].join('')
|
].join('')
|
||||||
//,className: '.demo-table-view'
|
//,className: '.demo-table-view'
|
||||||
|
|
||||||
//,size: 'sm'
|
//,size: 'lg'
|
||||||
//,skin: 'line'
|
//,skin: 'line'
|
||||||
//,loading: false
|
//,loading: false
|
||||||
|
|
||||||
|
@ -153,8 +153,8 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
//,{type: 'numbers', fixed: 'left'}
|
//,{type: 'numbers', fixed: 'left'}
|
||||||
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
||||||
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
|
,{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){
|
,{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> <input type="checkbox" title="激活">'
|
return '<em>'+ layui.util.escape(d.email) +'</em>'
|
||||||
}}
|
}}
|
||||||
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
||||||
,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){
|
,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){
|
||||||
|
@ -183,6 +183,10 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
,key: 'experience'
|
,key: 'experience'
|
||||||
,order: 'asc'
|
,order: 'asc'
|
||||||
}
|
}
|
||||||
|
,before: function(options){
|
||||||
|
options.where.AAAAA = 123;
|
||||||
|
//console.log(options)
|
||||||
|
}
|
||||||
,done: function(res, curr, count){
|
,done: function(res, curr, count){
|
||||||
var id = this.id;
|
var id = this.id;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "layui",
|
"name": "layui",
|
||||||
"realname": "layui",
|
"realname": "layui",
|
||||||
"version": "2.7.2",
|
"version": "2.7.3",
|
||||||
"description": "Classic modular Front-End UI library",
|
"description": "Classic modular Front-End UI library",
|
||||||
"main": "dist/layui.js",
|
"main": "dist/layui.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -892,12 +892,15 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||||
|
|
||||||
.layui-table img{max-width:100px;}
|
.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[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-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[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;}
|
.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{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-form-checkbox[lay-skin="primary"]{top: -1px; padding: 0;}
|
||||||
.layui-table-cell .layui-table-link{color: #01AAED;}
|
.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="center"]{-webkit-box-pack: center;}
|
||||||
.layui-table-cell[align="right"]{-webkit-box-pack: end;}
|
.layui-table-cell[align="right"]{-webkit-box-pack: end;}
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
|
||||||
.layui-laydate-content td{position: relative; cursor: pointer;}
|
.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{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-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-holidays:before{position: absolute; left: 0; top: 0; font-size: 12px; transform: scale(.7);}
|
||||||
.laydate-day-workrest.rest:before{content:'假';color: #d11211;}
|
.laydate-day-holidays:before{content:'\4F11'; color: #FF5722;}
|
||||||
.laydate-day-workrest.work:before{content:'班';color: #1589ee;}
|
.laydate-day-holidays[type="work"]:before{content:'\73ED'; color: inherit;}
|
||||||
.layui-laydate .layui-this .laydate-day-workrest:before{color: #fff;}
|
.layui-laydate .layui-this .laydate-day-holidays:before{color: #fff;}
|
||||||
|
|
||||||
/* 底部结构 */
|
/* 底部结构 */
|
||||||
.layui-laydate-footer{position: relative; height: 46px; line-height: 26px; padding: 10px;}
|
.layui-laydate-footer{position: relative; height: 46px; line-height: 26px; padding: 10px;}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
,Layui = function(){
|
,Layui = function(){
|
||||||
this.v = '2.7.2'; // layui 版本号
|
this.v = '2.7.3'; // layui 版本号
|
||||||
}
|
}
|
||||||
|
|
||||||
//识别预先可能定义的指定全局对象
|
//识别预先可能定义的指定全局对象
|
||||||
|
|
|
@ -681,7 +681,8 @@ layui.define('layer', function(exports){
|
||||||
if(!elem[0]) return !0;
|
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) {
|
if (that.validate(elem.find('*[lay-verify]')) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -706,6 +707,7 @@ layui.define('layer', function(exports){
|
||||||
//匹配验证规则
|
//匹配验证规则
|
||||||
if(verify[thisVer]){
|
if(verify[thisVer]){
|
||||||
var isTrue = isFn ? errorText = verify[thisVer](value, item) : !verify[thisVer][0].test(value)
|
var isTrue = isFn ? errorText = verify[thisVer](value, item) : !verify[thisVer][0].test(value)
|
||||||
|
|
||||||
//是否属于美化替换后的表单元素
|
//是否属于美化替换后的表单元素
|
||||||
,isForm2Elem = item.tagName.toLowerCase() === 'select' || /^checkbox|radio$/.test(item.type);
|
,isForm2Elem = item.tagName.toLowerCase() === 'select' || /^checkbox|radio$/.test(item.type);
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,7 @@
|
||||||
,position: null //控件定位方式定位, 默认absolute,支持:fixed/absolute/static
|
,position: null //控件定位方式定位, 默认absolute,支持:fixed/absolute/static
|
||||||
,calendar: false //是否开启公历重要节日,仅支持中文版
|
,calendar: false //是否开启公历重要节日,仅支持中文版
|
||||||
,mark: {} //日期备注,如重要事件或活动标记
|
,mark: {} //日期备注,如重要事件或活动标记
|
||||||
,isWorkrest: false // 是否标注节假日或补假上班, 默认 false
|
,holidays: null // 标注法定节假日或补假上班
|
||||||
,workrest: [] // 标注法定节假日或补假上班
|
|
||||||
,zIndex: null //控件层叠顺序
|
,zIndex: null //控件层叠顺序
|
||||||
,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发
|
,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发
|
||||||
,change: null //日期时间改变后的回调
|
,change: null //日期时间改变后的回调
|
||||||
|
@ -281,10 +280,6 @@
|
||||||
,'0-10-1': '国庆'
|
,'0-10-1': '国庆'
|
||||||
,'0-12-25': '圣诞'
|
,'0-12-25': '圣诞'
|
||||||
} : {}, options.mark);
|
} : {}, options.mark);
|
||||||
|
|
||||||
if(options.isWorkrest){
|
|
||||||
options.workrest = lay.extend({}, (options.calendar && options.lang === 'cn') ? [] : [], options.workrest);
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取限制内日期
|
//获取限制内日期
|
||||||
lay.each(['min', 'max'], function(i, item){
|
lay.each(['min', 'max'], function(i, item){
|
||||||
|
@ -785,7 +780,7 @@
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
//公历重要日期与自定义备注
|
// 公历重要日期与自定义备注
|
||||||
Class.prototype.mark = function(td, YMD){
|
Class.prototype.mark = function(td, YMD){
|
||||||
var that = this
|
var that = this
|
||||||
,mark, options = that.config;
|
,mark, options = that.config;
|
||||||
|
@ -803,18 +798,23 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// 标注法定节假日或补假上班
|
// 标注法定节假日或补假上班
|
||||||
Class.prototype.workrest = function(td, YMD) {
|
Class.prototype.holidays = function(td, YMD) {
|
||||||
var that = this,
|
var that = this;
|
||||||
workrest,
|
var options = that.config;
|
||||||
workclsArr = ['rest', 'work'],
|
var type = ['', 'work'];
|
||||||
options = that.config;
|
|
||||||
lay.each(options.workrest, function(idx, itm) {
|
if(layui.type(options.holidays) !== 'array') return that;
|
||||||
lay.each(itm, function(i, dayStr) {
|
|
||||||
if(dayStr === td[0].getAttribute('lay-ymd')){
|
lay.each(options.holidays, function(idx, item) {
|
||||||
td.html('<span class="laydate-day-workrest ' + workclsArr[idx] + '">' + YMD[2] + '</span>');
|
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;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,19 +903,11 @@
|
||||||
YMD[1]++;
|
YMD[1]++;
|
||||||
YMD[2] = st + 1;
|
YMD[2] = st + 1;
|
||||||
item.attr('lay-ymd', YMD.join('-')).html(YMD[2]);
|
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]
|
year: YMD[0]
|
||||||
,month: YMD[1] - 1
|
,month: YMD[1] - 1
|
||||||
,date: YMD[2]
|
,date: YMD[2]
|
||||||
}, index_);
|
}, index_);
|
||||||
|
|
||||||
if(options.isWorkrest){
|
|
||||||
that.workrest(item, YMD).limit(item, {
|
|
||||||
year: YMD[0]
|
|
||||||
,month: YMD[1] - 1
|
|
||||||
,date: YMD[2]
|
|
||||||
}, index_);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//同步头部年月
|
//同步头部年月
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* layedit 富文本编辑器
|
* layedit 富文本编辑器(该组件已被弃用,为了向下兼容而保留)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
layui.define(['layer', 'form'], function(exports){
|
layui.define(['layer', 'form'], function(exports){
|
||||||
|
|
|
@ -124,6 +124,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
,ELEM_SORT = '.layui-table-sort'
|
,ELEM_SORT = '.layui-table-sort'
|
||||||
,ELEM_EDIT = 'layui-table-edit'
|
,ELEM_EDIT = 'layui-table-edit'
|
||||||
,ELEM_HOVER = 'layui-table-hover'
|
,ELEM_HOVER = 'layui-table-hover'
|
||||||
|
|
||||||
|
,DATA_MOVE_NAME = 'LAY_TABLE_MOVE_DICT'
|
||||||
|
|
||||||
// thead 区域模板
|
// thead 区域模板
|
||||||
,TPL_HEADER = function(options){
|
,TPL_HEADER = function(options){
|
||||||
|
@ -817,6 +819,10 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
|
// 数据拉取前的回调
|
||||||
|
typeof options.before === 'function' && options.before(
|
||||||
|
options
|
||||||
|
);
|
||||||
that.startTime = new Date().getTime(); // 渲染开始时间
|
that.startTime = new Date().getTime(); // 渲染开始时间
|
||||||
|
|
||||||
if(options.url){ // Ajax请求
|
if(options.url){ // Ajax请求
|
||||||
|
@ -837,8 +843,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
,url: options.url
|
,url: options.url
|
||||||
,contentType: options.contentType
|
,contentType: options.contentType
|
||||||
,data: data
|
,data: data
|
||||||
,dataType:options.dataType || 'json'
|
,dataType: options.dataType || 'json'
|
||||||
,jsonpCallback:options.jsonpCallback
|
,jsonpCallback: options.jsonpCallback
|
||||||
,headers: options.headers || {}
|
,headers: options.headers || {}
|
||||||
,success: function(res){
|
,success: function(res){
|
||||||
// 若有数据解析的回调,则获得其返回的数据
|
// 若有数据解析的回调,则获得其返回的数据
|
||||||
|
@ -1496,18 +1502,19 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
that.layFixRight.css('right', scollWidth - 1);
|
that.layFixRight.css('right', scollWidth - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
//事件处理
|
// 事件处理
|
||||||
Class.prototype.events = function(){
|
Class.prototype.events = function(){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config
|
var options = that.config;
|
||||||
,_BODY = $('body')
|
|
||||||
,dict = {}
|
var filter = options.elem.attr('lay-filter');
|
||||||
,th = that.layHeader.find('th')
|
var th = that.layHeader.find('th');
|
||||||
,resizing
|
var ELEM_CELL = '.layui-table-cell';
|
||||||
,ELEM_CELL = '.layui-table-cell'
|
|
||||||
,filter = options.elem.attr('lay-filter');
|
var _BODY = $('body');
|
||||||
|
var dict = {};
|
||||||
|
|
||||||
//工具栏操作事件
|
// 工具栏操作事件
|
||||||
that.layTool.on('click', '*[lay-event]', function(e){
|
that.layTool.on('click', '*[lay-event]', function(e){
|
||||||
var othis = $(this)
|
var othis = $(this)
|
||||||
,events = othis.attr('lay-event')
|
,events = othis.attr('lay-event')
|
||||||
|
@ -1517,12 +1524,12 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
panel.html(list);
|
panel.html(list);
|
||||||
|
|
||||||
//限制最大高度
|
// 限制最大高度
|
||||||
if(options.height){
|
if(options.height){
|
||||||
panel.css('max-height', options.height - (that.layTool.outerHeight() || 50));
|
panel.css('max-height', options.height - (that.layTool.outerHeight() || 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
//插入元素
|
// 插入元素
|
||||||
othis.find('.layui-table-tool-panel')[0] || othis.append(panel);
|
othis.find('.layui-table-tool-panel')[0] || othis.append(panel);
|
||||||
that.renderForm();
|
that.renderForm();
|
||||||
|
|
||||||
|
@ -1538,7 +1545,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
layer.close(that.tipsIndex);
|
layer.close(that.tipsIndex);
|
||||||
|
|
||||||
switch(events){
|
switch(events){
|
||||||
case 'LAYTABLE_COLS': //筛选列
|
case 'LAYTABLE_COLS': // 筛选列
|
||||||
openPanel({
|
openPanel({
|
||||||
list: function(){
|
list: function(){
|
||||||
var lis = [];
|
var lis = [];
|
||||||
|
@ -1561,17 +1568,17 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
if(i1+ '-'+ i2 === key){
|
if(i1+ '-'+ i2 === key){
|
||||||
var hide = item2.hide;
|
var hide = item2.hide;
|
||||||
|
|
||||||
//同步勾选列的 hide 值和隐藏样式
|
// 同步勾选列的 hide 值和隐藏样式
|
||||||
item2.hide = !checked;
|
item2.hide = !checked;
|
||||||
that.elem.find('*[data-key="'+ options.index +'-'+ key +'"]')
|
that.elem.find('*[data-key="'+ options.index +'-'+ key +'"]')
|
||||||
[checked ? 'removeClass' : 'addClass'](HIDE);
|
[checked ? 'removeClass' : 'addClass'](HIDE);
|
||||||
|
|
||||||
//根据列的显示隐藏,同步多级表头的父级相关属性值
|
// 根据列的显示隐藏,同步多级表头的父级相关属性值
|
||||||
if(hide != item2.hide){
|
if(hide != item2.hide){
|
||||||
that.setParentCol(!checked, parentKey);
|
that.setParentCol(!checked, parentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
//重新适配尺寸
|
// 重新适配尺寸
|
||||||
that.resize();
|
that.resize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1580,7 +1587,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'LAYTABLE_EXPORT': //导出
|
case 'LAYTABLE_EXPORT': // 导出
|
||||||
if(device.ie){
|
if(device.ie){
|
||||||
layer.tips('导出功能不支持 IE,请用 Chrome 等高级浏览器导出', this, {
|
layer.tips('导出功能不支持 IE,请用 Chrome 等高级浏览器导出', this, {
|
||||||
tips: 3
|
tips: 3
|
||||||
|
@ -1589,8 +1596,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
openPanel({
|
openPanel({
|
||||||
list: function(){
|
list: function(){
|
||||||
return [
|
return [
|
||||||
'<li data-type="csv">导出 csv 格式文件</li>'
|
'<li data-type="csv">导出 csv 格式文件</li>',
|
||||||
,'<li data-type="xls">导出 xls 格式文件</li>'
|
'<li data-type="xls">导出 xls 格式文件</li>'
|
||||||
].join('')
|
].join('')
|
||||||
}()
|
}()
|
||||||
,done: function(panel, list){
|
,done: function(panel, list){
|
||||||
|
@ -1602,7 +1609,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'LAYTABLE_PRINT': //打印
|
case 'LAYTABLE_PRINT': // 打印
|
||||||
var printWin = window.open('about:blank', '_blank')
|
var printWin = window.open('about:blank', '_blank')
|
||||||
,style = ['<style>'
|
,style = ['<style>'
|
||||||
,'body{font-size: 12px; color: #5F5F5F;}'
|
,'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){
|
that.layPagebar.on('click', '*[lay-event]', function(e){
|
||||||
var othis = $(this)
|
var othis = $(this)
|
||||||
,events = othis.attr('lay-event');
|
,events = othis.attr('lay-event');
|
||||||
|
@ -1643,26 +1650,25 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
},{}));
|
},{}));
|
||||||
});
|
});
|
||||||
|
|
||||||
//拖拽调整宽度
|
// 拖拽调整宽度
|
||||||
th.on('mousemove', function(e){
|
th.on('mousemove', function(e){
|
||||||
var othis = $(this)
|
var othis = $(this)
|
||||||
,oLeft = othis.offset().left
|
,oLeft = othis.offset().left
|
||||||
,pLeft = e.clientX - oLeft;
|
,pLeft = e.clientX - oLeft;
|
||||||
if(othis.data('unresize') || dict.resizeStart){
|
if(othis.data('unresize') || thisTable.eventMoveElem){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dict.allowResize = othis.width() - pLeft <= 10; //是否处于拖拽允许区域
|
dict.allowResize = othis.width() - pLeft <= 10; //是否处于拖拽允许区域
|
||||||
_BODY.css('cursor', (dict.allowResize ? 'col-resize' : ''));
|
_BODY.css('cursor', (dict.allowResize ? 'col-resize' : ''));
|
||||||
}).on('mouseleave', function(){
|
}).on('mouseleave', function(){
|
||||||
var othis = $(this);
|
var othis = $(this);
|
||||||
if(dict.resizeStart) return;
|
if(thisTable.eventMoveElem) return;
|
||||||
_BODY.css('cursor', '');
|
_BODY.css('cursor', '');
|
||||||
}).on('mousedown', function(e){
|
}).on('mousedown', function(e){
|
||||||
var othis = $(this);
|
var othis = $(this);
|
||||||
if(dict.allowResize){
|
if(dict.allowResize){
|
||||||
var key = othis.data('key');
|
var key = othis.data('key');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dict.resizeStart = true; //开始拖拽
|
|
||||||
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
|
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
|
||||||
|
|
||||||
that.getCssRule(key, function(item){
|
that.getCssRule(key, function(item){
|
||||||
|
@ -1671,40 +1677,57 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
dict.ruleWidth = parseFloat(width);
|
dict.ruleWidth = parseFloat(width);
|
||||||
dict.minWidth = othis.data('minwidth') || options.cellMinWidth;
|
dict.minWidth = othis.data('minwidth') || options.cellMinWidth;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//拖拽中
|
|
||||||
_DOC.on('mousemove', function(e){
|
|
||||||
if(dict.resizeStart){
|
|
||||||
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){
|
|
||||||
dict = {};
|
|
||||||
_BODY.css('cursor', '');
|
|
||||||
that.scrollPatch();
|
|
||||||
}
|
|
||||||
if(resizing === 2){
|
|
||||||
resizing = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//排序
|
|
||||||
th.on('click', function(e){
|
|
||||||
var othis = $(this)
|
|
||||||
,elemSort = othis.find(ELEM_SORT)
|
|
||||||
,nowType = elemSort.attr('lay-sort')
|
|
||||||
,type;
|
|
||||||
|
|
||||||
if(!elemSort[0] || resizing === 1) return resizing = 2;
|
// 临时记录当前拖拽信息
|
||||||
|
othis.data(DATA_MOVE_NAME, dict);
|
||||||
|
thisTable.eventMoveElem = othis;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 拖拽中
|
||||||
|
if(!thisTable.docEvent){
|
||||||
|
_DOC.on('mousemove', function(e){
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).on('mouseup', function(e){
|
||||||
|
if(thisTable.eventMoveElem){
|
||||||
|
dict = {};
|
||||||
|
_BODY.css('cursor', '');
|
||||||
|
that.scrollPatch();
|
||||||
|
|
||||||
|
// 清除当前拖拽信息
|
||||||
|
thisTable.eventMoveElem.removeData(DATA_MOVE_NAME);
|
||||||
|
delete thisTable.eventMoveElem;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已给 document 执行全局事件,避免重复绑定
|
||||||
|
thisTable.docEvent = true;
|
||||||
|
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
th.on('click', function(e){
|
||||||
|
var othis = $(this);
|
||||||
|
var elemSort = othis.find(ELEM_SORT);
|
||||||
|
var nowType = elemSort.attr('lay-sort');
|
||||||
|
var type;
|
||||||
|
|
||||||
|
// 排序不触发的条件
|
||||||
|
if(!elemSort[0] || othis.data('resizing') === 1){
|
||||||
|
return othis.removeData('resizing');
|
||||||
|
}
|
||||||
|
|
||||||
if(nowType === 'asc'){
|
if(nowType === 'asc'){
|
||||||
type = 'desc';
|
type = 'desc';
|
||||||
|
@ -1771,8 +1794,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
}, sets);
|
}, sets);
|
||||||
};
|
};
|
||||||
|
|
||||||
//复选框选择
|
// 复选框选择(替代元素的 click 事件)
|
||||||
that.elem.on('click', 'input[name="layTableCheckbox"]+', function(){ //替代元素的 click 事件
|
that.elem.on('click', 'input[name="layTableCheckbox"]+', function(){
|
||||||
var checkbox = $(this).prev()
|
var checkbox = $(this).prev()
|
||||||
,children = that.layBody.find('input[name="layTableCheckbox"]')
|
,children = that.layBody.find('input[name="layTableCheckbox"]')
|
||||||
,index = checkbox.parents('tr').eq(0).data('index')
|
,index = checkbox.parents('tr').eq(0).data('index')
|
||||||
|
@ -1844,7 +1867,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
setRowEvent.call(this, 'rowDouble');
|
setRowEvent.call(this, 'rowDouble');
|
||||||
});
|
});
|
||||||
|
|
||||||
//创建行单击、双击事件
|
// 创建行单击、双击事件
|
||||||
var setRowEvent = function(eventType){
|
var setRowEvent = function(eventType){
|
||||||
var othis = $(this);
|
var othis = $(this);
|
||||||
if(othis.data('off')) return; //不触发事件
|
if(othis.data('off')) return; //不触发事件
|
||||||
|
@ -2324,7 +2347,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
var args = $.extend([], arguments);
|
var args = $.extend([], arguments);
|
||||||
args[3] = 'reloadData';
|
args[3] = 'reloadData';
|
||||||
|
|
||||||
// 过滤与数据无关的参数
|
// 重载时,与数据相关的参数
|
||||||
var dataParams = new RegExp('^('+ [
|
var dataParams = new RegExp('^('+ [
|
||||||
'data', 'url', 'method', 'contentType',
|
'data', 'url', 'method', 'contentType',
|
||||||
'dataType','jsonpCallback',
|
'dataType','jsonpCallback',
|
||||||
|
@ -2333,6 +2356,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
'scrollPos'
|
'scrollPos'
|
||||||
].join('|') + ')$');
|
].join('|') + ')$');
|
||||||
|
|
||||||
|
// 过滤与数据无关的参数
|
||||||
layui.each(args[1], function (key, value) {
|
layui.each(args[1], function (key, value) {
|
||||||
if(!dataParams.test(key)){
|
if(!dataParams.test(key)){
|
||||||
delete args[1][key];
|
delete args[1][key];
|
||||||
|
|
Loading…
Reference in New Issue