mirror of https://github.com/layui/layui
Merge branch '2.x' of github.com:layui/layui into 2.x
commit
ae10c95a0c
|
@ -872,7 +872,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||||
/* 小表格 */
|
/* 小表格 */
|
||||||
.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; padding-top: 5px; padding-right: 5px;}
|
.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-left: 5px; padding-right: 5px;}
|
||||||
|
|
||||||
/* 数据表格 */
|
/* 数据表格 */
|
||||||
.layui-table[lay-data]{display: none;}
|
.layui-table[lay-data]{display: none;}
|
||||||
|
|
|
@ -302,9 +302,9 @@
|
||||||
year: tDate.getFullYear()
|
year: tDate.getFullYear()
|
||||||
,month: tDate.getMonth()
|
,month: tDate.getMonth()
|
||||||
,date: tDate.getDate()
|
,date: tDate.getDate()
|
||||||
,hours: '23'
|
,hours: i ? 23 : 0
|
||||||
,minutes: '59'
|
,minutes: i ? 59 : 0
|
||||||
,seconds: '59'
|
,seconds: i ? 59 : 0
|
||||||
}).getTime()
|
}).getTime()
|
||||||
,STAMP = 86400000 //代表一天的毫秒数
|
,STAMP = 86400000 //代表一天的毫秒数
|
||||||
,thisDate = new Date(
|
,thisDate = new Date(
|
||||||
|
@ -774,16 +774,20 @@
|
||||||
|
|
||||||
//如果当前日期不在设定的最大小日期区间,则自动纠正在可选区域
|
//如果当前日期不在设定的最大小日期区间,则自动纠正在可选区域
|
||||||
//校验主面板是否在可选日期区间
|
//校验主面板是否在可选日期区间
|
||||||
|
var minMaxError;
|
||||||
if(that.getDateTime(dateTime) > that.getDateTime(options.max)){ //若超出最大日期
|
if(that.getDateTime(dateTime) > that.getDateTime(options.max)){ //若超出最大日期
|
||||||
dateTime = options.dateTime = lay.extend({}, options.max);
|
dateTime = options.dateTime = lay.extend({}, options.max);
|
||||||
|
minMaxError = true;
|
||||||
} else if(that.getDateTime(dateTime) < that.getDateTime(options.min)){ //若少于最小日期
|
} else if(that.getDateTime(dateTime) < that.getDateTime(options.min)){ //若少于最小日期
|
||||||
dateTime = options.dateTime = lay.extend({}, options.min);
|
dateTime = options.dateTime = lay.extend({}, options.min);
|
||||||
|
minMaxError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验右侧面板是否在可选日期区间
|
//校验右侧面板是否在可选日期区间
|
||||||
if(options.range){
|
if(options.range){
|
||||||
if(that.getDateTime(that.endDate) < that.getDateTime(options.min) || that.getDateTime(that.endDate) > that.getDateTime(options.max)){
|
if(that.getDateTime(that.endDate) < that.getDateTime(options.min) || that.getDateTime(that.endDate) > that.getDateTime(options.max)){
|
||||||
that.endDate = lay.extend({}, options.max);
|
that.endDate = lay.extend({}, options.max);
|
||||||
|
minMaxError = true;
|
||||||
}
|
}
|
||||||
// 有时间范围的情况下初始化startTime和endTime
|
// 有时间范围的情况下初始化startTime和endTime
|
||||||
that.startTime = {
|
that.startTime = {
|
||||||
|
@ -797,7 +801,10 @@
|
||||||
seconds: that.endDate.seconds,
|
seconds: that.endDate.seconds,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//初始值不在最大最小范围内
|
||||||
|
minMaxError && that.setValue(that.parse()).hint('初始值' + lang.invalidDate + lang.formatError[1]);
|
||||||
|
|
||||||
fn && fn();
|
fn && fn();
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
|
@ -154,7 +154,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
return '';
|
return '';
|
||||||
}()
|
}()
|
||||||
,'{{# var isSort = !(item2.colGroup) && item2.sort; }}'
|
,'{{# var isSort = !(item2.colGroup) && item2.sort; }}'
|
||||||
,'<th data-field="{{= item2.field||i2 }}" data-key="{{=d.index}}-{{=i1}}-{{=i2}}" {{# if( item2.parentKey){ }}data-parentkey="{{= item2.parentKey }}"{{# } }} {{# if(item2.minWidth){ }}data-minwidth="{{=item2.minWidth}}"{{# } }} '+ rowCols +' {{# if(item2.unresize || item2.colGroup){ }}data-unresize="true"{{# } }} class="{{# if(item2.hide){ }}layui-hide{{# } }}{{# if(isSort){ }} layui-unselect{{# } }}{{# if(!item2.field){ }} layui-table-col-special{{# } }}">'
|
,'<th data-field="{{= item2.field||i2 }}" data-key="{{=d.index}}-{{=i1}}-{{=i2}}" {{# if( item2.parentKey){ }}data-parentkey="{{= item2.parentKey }}"{{# } }} {{# if(item2.minWidth){ }}data-minwidth="{{=item2.minWidth}}"{{# } }} '+ rowCols +' {{# if(item2.unresize || item2.colGroup){ }}data-unresize="true"{{# } }} class="{{# if(item2.hide){ }}layui-hide{{# } }}{{# if(isSort){ }} layui-unselect{{# } }}{{# if(!item2.field){ }} layui-table-col-special{{# } }}"{{# if(item2.title){ }} title="{{ layui.$(\'<div>\' + item2.title + \'</div>\').text() }}"{{# } }}>'
|
||||||
,'<div class="layui-table-cell laytable-cell-'
|
,'<div class="layui-table-cell laytable-cell-'
|
||||||
,'{{# if(item2.colGroup){ }}'
|
,'{{# if(item2.colGroup){ }}'
|
||||||
,'group'
|
,'group'
|
||||||
|
@ -491,8 +491,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
item2.key = i1 + '-' + i2;
|
item2.key = i1 + '-' + i2;
|
||||||
item2.hide = item2.hide || false;
|
item2.hide = item2.hide || false;
|
||||||
item2.colspan = item2.colspan || 1;
|
item2.colspan = item2.colspan || 0;
|
||||||
item2.rowspan = item2.rowspan || 1;
|
item2.rowspan = item2.rowspan || 0;
|
||||||
|
|
||||||
//根据列类型,定制化参数
|
//根据列类型,定制化参数
|
||||||
that.initOpts(item2);
|
that.initOpts(item2);
|
||||||
|
@ -636,7 +636,35 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 设置合并表头的宽度
|
||||||
|
Class.prototype.setGroupWidth = function (thElem) {
|
||||||
|
var that = this;
|
||||||
|
var options = that.config;
|
||||||
|
var parentKey;
|
||||||
|
if (options.cols.length > 1) {
|
||||||
|
for (var i = thElem ? thElem.closest('tr').index() - 1 : options.cols.length - 1; i >= 0; i--) {
|
||||||
|
// 自下向上处理合并表头的宽度
|
||||||
|
parentKey = thElem ? thElem.attr('data-parentkey') : '';
|
||||||
|
layui.each(that.layHeader.first().find('tr').eq(i).find('>th' + (parentKey && '[data-key="' + that.index + '-' + parentKey + '"]') + '>div.laytable-cell-group'), function (i1, item1) {
|
||||||
|
item1 = $(item1);
|
||||||
|
var width = 0;
|
||||||
|
var key = item1.parent().attr('data-key');
|
||||||
|
layui.each(that.layHeader.first().find('th[data-parentkey="' + key.substr(key.indexOf('-') + 1) + '"]'), function (i2, item2) {
|
||||||
|
item2 = $(item2);
|
||||||
|
if (item2.hasClass(HIDE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
width += item2.children('div.layui-table-cell').outerWidth();
|
||||||
|
});
|
||||||
|
that.layHeader.find('th[data-key="'+key+'"]').children('div.layui-table-cell').outerWidth(width);
|
||||||
|
thElem && (thElem = item1.parent());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//动态分配列宽
|
//动态分配列宽
|
||||||
Class.prototype.setColsWidth = function(){
|
Class.prototype.setColsWidth = function(){
|
||||||
var that = this;
|
var that = this;
|
||||||
|
@ -680,6 +708,9 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
} else if(!width){ // 列宽未填写
|
} else if(!width){ // 列宽未填写
|
||||||
item2.width = width = 0;
|
item2.width = width = 0;
|
||||||
autoColNums++;
|
autoColNums++;
|
||||||
|
} else {
|
||||||
|
// 设置了宽度校验是否小于最小宽度,这里是否要判断
|
||||||
|
item2.type === 'normal' && width < minWidth && (item2.width = width = minWidth);
|
||||||
}
|
}
|
||||||
} else if(autoWidth && autoWidth < minWidth){
|
} else if(autoWidth && autoWidth < minWidth){
|
||||||
autoColNums--;
|
autoColNums--;
|
||||||
|
@ -721,6 +752,13 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
item.style.width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth) + 'px';
|
item.style.width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth) + 'px';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 因为有可能设置的width小于minWidth被调整过,这里重新设置一遍确保最新
|
||||||
|
else {
|
||||||
|
that.getCssRule(options.index +'-'+ item3.key, function(item){
|
||||||
|
item.style.width = item3.width + 'px';
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 填补 Math.floor 造成的数差
|
// 填补 Math.floor 造成的数差
|
||||||
|
@ -750,7 +788,9 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.setGroupWidth();
|
||||||
|
|
||||||
that.loading(!0);
|
that.loading(!0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1571,7 +1611,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
var lis = [];
|
var lis = [];
|
||||||
that.eachCols(function(i, item){
|
that.eachCols(function(i, item){
|
||||||
if(item.field && item.type == 'normal'){
|
if(item.field && item.type == 'normal'){
|
||||||
lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ util.escape(item.title || item.field) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
|
lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ util.escape($('<div>' + (item.title || item.field) + '</div>').text()) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return lis.join('');
|
return lis.join('');
|
||||||
|
@ -1721,6 +1761,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
var setWidth = dict.ruleWidth + e.clientX - dict.offset[0];
|
var setWidth = dict.ruleWidth + e.clientX - dict.offset[0];
|
||||||
if(setWidth < dict.minWidth) setWidth = dict.minWidth;
|
if(setWidth < dict.minWidth) setWidth = dict.minWidth;
|
||||||
dict.rule.style.width = setWidth + 'px';
|
dict.rule.style.width = setWidth + 'px';
|
||||||
|
thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].setGroupWidth(thisTable.eventMoveElem);
|
||||||
layer.close(that.tipsIndex);
|
layer.close(that.tipsIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1728,7 +1769,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
if(thisTable.eventMoveElem){
|
if(thisTable.eventMoveElem){
|
||||||
dict = {};
|
dict = {};
|
||||||
_BODY.css('cursor', '');
|
_BODY.css('cursor', '');
|
||||||
that.scrollPatch();
|
thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].scrollPatch();
|
||||||
|
|
||||||
// 清除当前拖拽信息
|
// 清除当前拖拽信息
|
||||||
thisTable.eventMoveElem.removeData(DATA_MOVE_NAME);
|
thisTable.eventMoveElem.removeData(DATA_MOVE_NAME);
|
||||||
|
@ -1920,11 +1961,12 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
var field = othis.parent().data('field');
|
var field = othis.parent().data('field');
|
||||||
var index = othis.parents('tr').eq(0).data('index');
|
var index = othis.parents('tr').eq(0).data('index');
|
||||||
var data = table.cache[that.key][index];
|
var data = table.cache[that.key][index];
|
||||||
|
var oldValue = data[field];
|
||||||
data[field] = value; // 更新缓存中的值
|
data[field] = value; // 更新缓存中的值
|
||||||
layui.event.call(this, MOD_NAME, 'edit('+ filter +')', commonMember.call(this, {
|
layui.event.call(this, MOD_NAME, 'edit('+ filter +')', commonMember.call(this, {
|
||||||
value: value
|
value: value
|
||||||
,field: field
|
,field: field
|
||||||
|
,oldValue: oldValue
|
||||||
}));
|
}));
|
||||||
}).on('blur', '.'+ELEM_EDIT, function(){
|
}).on('blur', '.'+ELEM_EDIT, function(){
|
||||||
var othis = $(this);
|
var othis = $(this);
|
||||||
|
@ -2140,8 +2182,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
var row = $.extend({
|
var row = $.extend({
|
||||||
title: th.text()
|
title: th.text()
|
||||||
,colspan: th.attr('colspan') || 1 //列单元格
|
,colspan: th.attr('colspan') || 0 //列单元格
|
||||||
,rowspan: th.attr('rowspan') || 1 //行单元格
|
,rowspan: th.attr('rowspan') || 0 //行单元格
|
||||||
}, itemData);
|
}, itemData);
|
||||||
|
|
||||||
if(row.colspan < 2) cols.push(row);
|
if(row.colspan < 2) cols.push(row);
|
||||||
|
|
Loading…
Reference in New Issue