mirror of https://github.com/layui/layui
commit
7e60639211
|
@ -250,6 +250,7 @@ layer.prompt({
|
|||
| photos | 图片层的数据源,格式详见下述示例。 | object | - |
|
||||
| hideFooter <sup>2.8+</sup> | 是否隐藏底部栏 | boolean | `false` |
|
||||
| tab | 图片层切换后的回调函数,返回的参数见下述示例 | function | - |
|
||||
| toolbar <sup>2.8.16+</sup> | 是否显示顶部工具栏 | boolean | `false` |
|
||||
|
||||
该方法用于弹出图片层,基于 `type: 1`(即 `page` 层)的自定义内容。
|
||||
|
||||
|
|
|
@ -254,6 +254,14 @@ html #layuicss-layer{display: none; position: absolute; width: 1989px;}
|
|||
.layui-layer-imgtit a:hover{color: #fff; text-decoration: underline;}
|
||||
.layui-layer-imgtit em{font-style: normal;}
|
||||
|
||||
/*photo工具栏*/
|
||||
.layui-layer-images-toolbar{position: fixed;top: 0;left: 0;right: 0;height: 40px;background-color: #000\9;filter: Alpha(opacity=60);background-color: rgba(2,0,0,.35);display: flex;align-items: center;justify-content: center;color: white;}
|
||||
.layui-layer-images-toolbar .layer-images-tool-item{position: relative;width: auto;height: 100%;display: flex;align-items: center;}
|
||||
.layui-layer-images-toolbar .layer-images-tool-item span{padding: 8px 10px; transition: all .4s;cursor: pointer;}
|
||||
.layui-layer-images-toolbar .layer-images-tool-item span:hover{background-color: rgba(64, 64, 64, 0.67);}
|
||||
.layui-layer-images-toolbar .layer-images-tool-item span i{font-size: 22px;}
|
||||
.layui-layer-photos .layui-layer-content.layui-layer-images-toolbar-mode{overflow: visible !important;}
|
||||
|
||||
/* 关闭动画 */
|
||||
@-webkit-keyframes layer-bounceOut {
|
||||
100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)}
|
||||
|
|
|
@ -1498,8 +1498,28 @@ layer.photos = function(options, loop, key){
|
|||
return layer.photos(options, true, key);
|
||||
}
|
||||
|
||||
dict.isNumber = function (n) {
|
||||
return typeof n === 'number' && !isNaN(n);
|
||||
}
|
||||
|
||||
dict.getTransform = function(options){
|
||||
var transforms = [];
|
||||
var rotate = options.rotate;
|
||||
var scaleX = options.scaleX;
|
||||
|
||||
if (dict.isNumber(rotate) && rotate !== 0) {
|
||||
transforms.push('rotate(' + rotate + 'deg)');
|
||||
}
|
||||
|
||||
if (dict.isNumber(scaleX) && scaleX !== 1) {
|
||||
transforms.push('scaleX(' + scaleX + ')');
|
||||
}
|
||||
|
||||
return transforms.length ? transforms.join(' ') : 'none';
|
||||
}
|
||||
|
||||
// 一些动作
|
||||
dict.event = function(){
|
||||
dict.event = function(layero, index){
|
||||
/*
|
||||
dict.bigimg.hover(function(){
|
||||
dict.imgsee.show();
|
||||
|
@ -1519,6 +1539,64 @@ layer.photos = function(options, loop, key){
|
|||
});
|
||||
|
||||
$(document).on('keyup', dict.keyup);
|
||||
|
||||
var scalexFlag = true;
|
||||
//工具栏事件
|
||||
layero.off('click').on('click','*[toolbar-event]', function () {
|
||||
var othis = $(this), event = othis.attr('toolbar-event');
|
||||
switch (event) {
|
||||
case 'rotate':
|
||||
dict.image.rotate = ((dict.image.rotate || 0) + Number(othis.attr('data-option'))) % 360;
|
||||
dict.imgElem.css({
|
||||
transform: dict.getTransform(dict.image)
|
||||
});
|
||||
break;
|
||||
case 'scalex':
|
||||
if (scalexFlag){
|
||||
dict.image.scaleX = -1;
|
||||
scalexFlag = false;
|
||||
}else {
|
||||
dict.image.scaleX = 1;
|
||||
scalexFlag = true;
|
||||
}
|
||||
scalexFlag !== scalexFlag;
|
||||
dict.imgElem.css({
|
||||
transform: dict.getTransform(dict.image)
|
||||
});
|
||||
break;
|
||||
case 'zoom':
|
||||
var ratio = Number(othis.attr('data-option'));
|
||||
if (ratio < 0) {
|
||||
ratio = 1 / (1 - ratio);
|
||||
} else {
|
||||
ratio = 1 + ratio;
|
||||
}
|
||||
dict.image.width = dict.image.width * ratio;
|
||||
dict.image.height = dict.image.height * ratio;
|
||||
dict.imgElem.css({
|
||||
width: dict.image.width,
|
||||
height: dict.image.height,
|
||||
transform: dict.getTransform(dict.image)
|
||||
});
|
||||
break;
|
||||
case 'reset':
|
||||
scalexFlag = true;
|
||||
dict.image.scaleX = 1;
|
||||
dict.image.rotate = 0;
|
||||
dict.image.width = dict.image.oldWidth;
|
||||
dict.image.height = dict.image.oldHeight;
|
||||
dict.imgElem.css({
|
||||
width: dict.image.oldWidth,
|
||||
height: dict.image.oldHeight,
|
||||
transform: 'none'
|
||||
});
|
||||
break;
|
||||
case 'close':
|
||||
layer.close(index);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// 图片预加载
|
||||
|
@ -1570,7 +1648,12 @@ layer.photos = function(options, loop, key){
|
|||
imgarea[1] = imgarea[1]/wh[1];
|
||||
}
|
||||
}
|
||||
|
||||
dict.image = {
|
||||
oldWidth : imgarea[0],
|
||||
oldHeight : imgarea[1],
|
||||
width : imgarea[0],
|
||||
height : imgarea[1],
|
||||
};
|
||||
return [imgarea[0]+'px', imgarea[1]+'px'];
|
||||
}(),
|
||||
title: false,
|
||||
|
@ -1607,6 +1690,22 @@ layer.photos = function(options, loop, key){
|
|||
,'</div>'
|
||||
,'</div>'].join(''));
|
||||
}
|
||||
//工具栏
|
||||
if (options.toolbar){
|
||||
arr.push([
|
||||
'<div class="layui-layer-images-toolbar">',
|
||||
'<div class="layer-images-tool-item">',
|
||||
'<span toolbar-event="rotate" data-option="-15" title="向左旋转15°" style="transform: scaleX(-1);"><i class="layui-icon layui-icon-refresh rotate"></i></span>',
|
||||
'<span toolbar-event="rotate" data-option="15" title="向右旋转15°"><i class="layui-icon layui-icon-refresh"></i></span>',
|
||||
'<span toolbar-event="scalex" title="翻转"><i class="layui-icon layui-icon-slider"></i></span>',
|
||||
'<span toolbar-event="zoom" data-option="0.1" title="放大图片"><i class="layui-icon layui-icon-add-circle"></i></span>',
|
||||
'<span toolbar-event="zoom" data-option="-0.1" title="缩小图片"><i class="layui-icon layui-icon-reduce-circle"></i></span>',
|
||||
'<span toolbar-event="reset" title="重置图片"><i class="layui-icon layui-icon-refresh-1"></i></span>',
|
||||
'<span toolbar-event="close" title="关闭"><i class="layui-icon layui-icon-close"></i></span>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
].join(''));
|
||||
}
|
||||
|
||||
arr.push('</div>');
|
||||
return arr.join('');
|
||||
|
@ -1615,7 +1714,15 @@ layer.photos = function(options, loop, key){
|
|||
success: function(layero, index){
|
||||
dict.bigimg = layero.find('.layui-layer-phimg');
|
||||
dict.imgsee = layero.find('.layui-layer-imgbar');
|
||||
dict.event(layero);
|
||||
if (options.toolbar){
|
||||
layero.find('.layui-layer-content').addClass('layui-layer-images-toolbar-mode');
|
||||
dict.imgElem = dict.bigimg.find('img');
|
||||
dict.imgElem.css({
|
||||
width : dict.image.width,
|
||||
height : dict.image.height
|
||||
});
|
||||
}
|
||||
dict.event(layero, index);
|
||||
options.tab && options.tab(data[start], layero);
|
||||
typeof success === 'function' && success(layero);
|
||||
}, end: function(){
|
||||
|
|
|
@ -329,18 +329,18 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
//请求参数的自定义格式
|
||||
options.request = $.extend({
|
||||
pageName: 'page'
|
||||
,limitName: 'limit'
|
||||
pageName: 'page',
|
||||
limitName: 'limit'
|
||||
}, options.request)
|
||||
|
||||
// 响应数据的自定义格式
|
||||
options.response = $.extend({
|
||||
statusName: 'code' //规定数据状态的字段名称
|
||||
,statusCode: 0 //规定成功的状态码
|
||||
,msgName: 'msg' //规定状态信息的字段名称
|
||||
,dataName: 'data' //规定数据总数的字段名称
|
||||
,totalRowName: 'totalRow' //规定数据统计的字段名称
|
||||
,countName: 'count'
|
||||
statusName: 'code', //规定数据状态的字段名称
|
||||
statusCode: 0, //规定成功的状态码
|
||||
msgName: 'msg', //规定状态信息的字段名称
|
||||
dataName: 'data', //规定数据总数的字段名称
|
||||
totalRowName: 'totalRow', //规定数据统计的字段名称
|
||||
countName: 'count'
|
||||
}, options.response);
|
||||
|
||||
//如果 page 传入 laypage 对象
|
||||
|
@ -386,11 +386,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}
|
||||
|
||||
//开始插入替代元素
|
||||
var othis = options.elem
|
||||
,hasRender = othis.next('.' + ELEM_VIEW)
|
||||
var othis = options.elem;
|
||||
var hasRender = othis.next('.' + ELEM_VIEW);
|
||||
|
||||
//主容器
|
||||
,reElem = that.elem = $('<div></div>');
|
||||
var reElem = that.elem = $('<div></div>');
|
||||
|
||||
reElem.addClass(function(){
|
||||
var arr = [
|
||||
|
@ -402,9 +402,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
if(options.className) arr.push(options.className);
|
||||
return arr.join(' ');
|
||||
}()).attr({
|
||||
'lay-filter': 'LAY-TABLE-FORM-DF-'+ that.index
|
||||
,'lay-id': options.id
|
||||
,'style': function(){
|
||||
'lay-filter': 'LAY-TABLE-FORM-DF-'+ that.index,
|
||||
'lay-id': options.id,
|
||||
'style': function(){
|
||||
var arr = [];
|
||||
if(options.width) arr.push('width:'+ options.width + 'px;');
|
||||
// if(options.height) arr.push('height:'+ options.height + 'px;');
|
||||
|
@ -414,8 +414,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
open: '{{', // 标签符前缀
|
||||
close: '}}' // 标签符后缀
|
||||
}).render({
|
||||
data: options
|
||||
,index: that.index //索引
|
||||
data: options,
|
||||
index: that.index //索引
|
||||
}));
|
||||
|
||||
//生成替代元素
|
||||
|
@ -450,12 +450,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
//根据列类型,定制化参数
|
||||
Class.prototype.initOpts = function(item){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,initWidth = {
|
||||
checkbox: 50
|
||||
,radio: 50
|
||||
,space: 30
|
||||
,numbers: 60
|
||||
var options = that.config;
|
||||
var initWidth = {
|
||||
checkbox: 50,
|
||||
radio: 50,
|
||||
space: 30,
|
||||
numbers: 60
|
||||
};
|
||||
|
||||
//让 type 参数兼容旧版本
|
||||
|
@ -471,8 +471,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
//初始化一些参数
|
||||
Class.prototype.setInit = function(type){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
options.clientWidth = options.width || function(){ //获取容器宽度
|
||||
//如果父元素宽度为0(一般为隐藏元素),则继续查找上层元素,直到找到真实宽度为止
|
||||
|
@ -926,6 +926,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
options.HAS_SET_COLS_PATCH = true;
|
||||
var request = options.request;
|
||||
var response = options.response;
|
||||
var res;
|
||||
var sort = function(){
|
||||
if(typeof options.initSort === 'object'){
|
||||
that.sort({
|
||||
|
@ -951,7 +952,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
that.startTime = new Date().getTime(); // 渲染开始时间
|
||||
|
||||
if (opts.renderData) { // 将 cache 信息重新渲染
|
||||
var res = {};
|
||||
res = {};
|
||||
res[response.dataName] = table.cache[that.key];
|
||||
res[response.countName] = options.url ? (layui.type(options.page) === 'object' ? options.page.count : res[response.dataName].length) : options.data.length;
|
||||
|
||||
|
@ -1021,7 +1022,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}
|
||||
});
|
||||
} else if(layui.type(options.data) === 'array'){ //已知数据
|
||||
var res = {};
|
||||
res = {};
|
||||
var startLimit = curr*options.limit - options.limit;
|
||||
var newData = options.data.concat();
|
||||
|
||||
|
@ -1074,8 +1075,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
curr = curr || 1
|
||||
|
||||
layui.each(data, function(i1, item1){
|
||||
var tds = [], tds_fixed = [], tds_fixed_r = []
|
||||
,numbers = i1 + options.limit*(curr - 1) + 1; // 序号
|
||||
var tds = [];
|
||||
var tds_fixed = [];
|
||||
var tds_fixed_r = [];
|
||||
var numbers = i1 + options.limit*(curr - 1) + 1; // 序号
|
||||
|
||||
// 数组值是否为 object,如果不是,则自动转为 object
|
||||
if(typeof item1 !== 'object'){
|
||||
|
@ -1159,7 +1162,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
return arr.join(' ');
|
||||
}() +' lay-type="layTableCheckbox">';
|
||||
break;
|
||||
//break;
|
||||
case 'radio': // 单选
|
||||
return '<input type="radio" name="layTableRadio_'+ options.index +'" '
|
||||
+ function(){
|
||||
|
@ -1168,10 +1171,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
if(tplData[disabledName]) arr.push('disabled');
|
||||
return arr.join(' ');
|
||||
}() +' lay-type="layTableRadio">';
|
||||
break;
|
||||
//break;
|
||||
case 'numbers':
|
||||
return numbers;
|
||||
break;
|
||||
//break;
|
||||
};
|
||||
|
||||
//解析工具列模板
|
||||
|
@ -1309,15 +1312,15 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
//同步分页状态
|
||||
if(options.page){
|
||||
options.page = $.extend({
|
||||
elem: 'layui-table-page' + options.index
|
||||
,count: count
|
||||
,limit: options.limit
|
||||
,limits: options.limits || [10,20,30,40,50,60,70,80,90]
|
||||
,groups: 3
|
||||
,layout: ['prev', 'page', 'next', 'skip', 'count', 'limit']
|
||||
,prev: '<i class="layui-icon"></i>'
|
||||
,next: '<i class="layui-icon"></i>'
|
||||
,jump: function(obj, first){
|
||||
elem: 'layui-table-page' + options.index,
|
||||
count: count,
|
||||
limit: options.limit,
|
||||
limits: options.limits || [10,20,30,40,50,60,70,80,90],
|
||||
groups: 3,
|
||||
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
||||
prev: '<i class="layui-icon"></i>',
|
||||
next: '<i class="layui-icon"></i>',
|
||||
jump: function(obj, first){
|
||||
if(!first){
|
||||
//分页本身并非需要做以下更新,下面参数的同步,主要是因为其它处理统一用到了它们
|
||||
//而并非用的是 options.page 中的参数(以确保分页未开启的情况仍能正常使用)
|
||||
|
@ -1394,9 +1397,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 获取自动计算的合并内容
|
||||
var getContent = item3.totalRow ? (parseTempData.call(that, {
|
||||
item3: item3
|
||||
,content: thisTotalNum
|
||||
,tplData: tplData
|
||||
item3: item3,
|
||||
content: thisTotalNum,
|
||||
tplData: tplData
|
||||
}) || text) : text;
|
||||
|
||||
// 如果直接传入了合计行数据,则不输出自动计算的结果
|
||||
|
@ -1421,8 +1424,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
if(item3.hide) classNames.push(HIDE); // 插入隐藏列样式
|
||||
if(!item3.field) classNames.push(ELEM_COL_SPECIAL); // 插入特殊列样式
|
||||
return classNames.join(' ');
|
||||
}() +'">'
|
||||
,'<div class="layui-table-cell laytable-cell-'+ function(){ // 返回对应的CSS类标识
|
||||
}() +'">',
|
||||
'<div class="layui-table-cell laytable-cell-'+ function(){ // 返回对应的CSS类标识
|
||||
var key = item3.key;
|
||||
return item3.type === 'normal' ? key
|
||||
: (key + ' laytable-cell-' + item3.type);
|
||||
|
@ -1443,8 +1446,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}, item3));
|
||||
}
|
||||
return content;
|
||||
}()
|
||||
,'</div></td>'].join('');
|
||||
}(),
|
||||
'</div></td>'].join('');
|
||||
|
||||
tds.push(td);
|
||||
});
|
||||
|
@ -1455,8 +1458,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
//找到对应的列元素
|
||||
Class.prototype.getColElem = function(parent, key){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
//var options = that.config;
|
||||
return parent.eq(0).find('.laytable-cell-'+ key + ':eq(0)');
|
||||
};
|
||||
|
||||
|
@ -1530,7 +1533,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 设置数据选中属性
|
||||
layui.each(thisData, function(i, item){
|
||||
if(layui.type(item) === 'array') return; // 空项
|
||||
if(layui.type(item) === 'array' || item[options.disabledName]) return; // 空项
|
||||
if(Number(opts.index) === i || opts.index === 'all'){
|
||||
var checked = item[options.checkName] = getChecked(item[options.checkName]);
|
||||
tr[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); // 标记当前选中行背景色
|
||||
|
@ -1547,7 +1550,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
var checkedElem = tr.find('input[lay-type="'+ ({
|
||||
radio: 'layTableRadio',
|
||||
checkbox: 'layTableCheckbox'
|
||||
}[opts.type] || 'checkbox') +'"]');
|
||||
}[opts.type] || 'checkbox') +'"]:not(:disabled)');
|
||||
|
||||
checkedElem.prop('checked', getChecked(checkedElem.last().prop('checked')));
|
||||
|
||||
|
@ -1570,8 +1573,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
if(typeof opts.field === 'string'){
|
||||
field = opts.field;
|
||||
that.layHeader.find('th').each(function(i, item){
|
||||
var othis = $(this)
|
||||
,_field = othis.data('field');
|
||||
var othis = $(this);
|
||||
var _field = othis.data('field');
|
||||
if(_field === opts.field){
|
||||
opts.field = othis;
|
||||
field = _field;
|
||||
|
@ -1581,8 +1584,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}
|
||||
|
||||
try {
|
||||
var field = field || opts.field.data('field')
|
||||
,key = opts.field.data('key');
|
||||
field = field || opts.field.data('field');
|
||||
var key = opts.field.data('key');
|
||||
|
||||
// 如果欲执行的排序已在状态中,则不执行渲染
|
||||
if(that.sortKey && !opts.pull){
|
||||
|
@ -1601,8 +1604,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 记录排序索引和类型
|
||||
that.sortKey = {
|
||||
field: field
|
||||
,sort: opts.type
|
||||
field: field,
|
||||
sort: opts.type
|
||||
};
|
||||
|
||||
// 默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
|
||||
|
@ -1632,8 +1635,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
// 排序是否来自于点击表头事件触发
|
||||
if(opts.fromEvent){
|
||||
options.initSort = {
|
||||
field: field
|
||||
,type: opts.type
|
||||
field: field,
|
||||
type: opts.type
|
||||
};
|
||||
layui.event.call(opts.field, MOD_NAME, 'sort('+ filter +')', $.extend({
|
||||
config: options
|
||||
|
@ -1651,9 +1654,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
delete that.layInit;
|
||||
that.layBox.find(ELEM_INIT).remove();
|
||||
} else {
|
||||
that.layInit = $(['<div class="layui-table-init">'
|
||||
,'<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>'
|
||||
,'</div>'].join(''));
|
||||
that.layInit = $(['<div class="layui-table-init">',
|
||||
'<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>',
|
||||
'</div>'].join(''));
|
||||
that.layBox.append(that.layInit);
|
||||
}
|
||||
}
|
||||
|
@ -1674,10 +1677,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
//让表格铺满
|
||||
Class.prototype.fullSize = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,height = options.height
|
||||
,bodyHeight;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var height = options.height;
|
||||
var bodyHeight;
|
||||
|
||||
if(that.fullHeightGap){
|
||||
height = _WIN.height() - that.fullHeightGap;
|
||||
|
@ -1842,6 +1845,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
switch(events){
|
||||
case 'LAYTABLE_COLS': // 筛选列
|
||||
if (!table.cache[options.id].length) return layer.msg('暂时没有数据,不能使用筛选列功能!', {icon: 5});
|
||||
openPanel({
|
||||
list: function(){
|
||||
var lis = [];
|
||||
|
@ -1887,6 +1891,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
});
|
||||
break;
|
||||
case 'LAYTABLE_EXPORT': // 导出
|
||||
if (!table.cache[options.id].length) return layer.msg('暂时没有数据,不能使用导出功能!', {icon: 5});
|
||||
if(device.ie){
|
||||
layer.tips('导出功能不支持 IE,请用 Chrome 等高级浏览器导出', this, {
|
||||
tips: 3
|
||||
|
@ -1898,8 +1903,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
'<li data-type="csv">导出 csv 格式文件</li>',
|
||||
'<li data-type="xls">导出 xls 格式文件</li>'
|
||||
].join('')
|
||||
}()
|
||||
,done: function(panel, list){
|
||||
}(),
|
||||
done: function(panel, list){
|
||||
list.on('click', function(){
|
||||
var type = $(this).data('type')
|
||||
table.exportFile.call(that, options.id, null, type);
|
||||
|
@ -1909,6 +1914,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}
|
||||
break;
|
||||
case 'LAYTABLE_PRINT': // 打印
|
||||
if (!table.cache[options.id].length) return layer.msg('暂时没有数据,不能使用打印功能!', {icon: 5});
|
||||
var printWin = window.open('about:blank', '_blank');
|
||||
var style = ['<style>',
|
||||
'body{font-size: 12px; color: #5F5F5F;}',
|
||||
|
@ -1944,8 +1950,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
}
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'toolbar('+ filter +')', $.extend({
|
||||
event: events
|
||||
,config: options
|
||||
event: events,
|
||||
config: options
|
||||
},{}));
|
||||
});
|
||||
|
||||
|
@ -1970,16 +1976,16 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
var events = othis.attr('lay-event');
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'pagebar('+ filter +')', $.extend({
|
||||
event: events
|
||||
,config: options
|
||||
event: events,
|
||||
config: options
|
||||
},{}));
|
||||
});
|
||||
|
||||
// 拖拽调整宽度
|
||||
th.on('mousemove', function(e){
|
||||
var othis = $(this)
|
||||
,oLeft = othis.offset().left
|
||||
,pLeft = e.clientX - oLeft;
|
||||
var othis = $(this);
|
||||
var oLeft = othis.offset().left;
|
||||
var pLeft = e.clientX - oLeft;
|
||||
if(othis.data('unresize') || thisTable.eventMoveElem){
|
||||
return;
|
||||
}
|
||||
|
@ -2095,9 +2101,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
fromEvent: true
|
||||
});
|
||||
}).find(ELEM_SORT+' .layui-edge ').on('click', function(e){
|
||||
var othis = $(this)
|
||||
,index = othis.index()
|
||||
,field = othis.parents('th').eq(0).data('field')
|
||||
var othis = $(this);
|
||||
var index = othis.index();
|
||||
var field = othis.parents('th').eq(0).data('field');
|
||||
layui.stope(e);
|
||||
if(index === 0){
|
||||
that.sort({
|
||||
|
@ -2652,8 +2658,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 遍历表头
|
||||
table.eachCols = function(id, callback, cols){
|
||||
var config = thisTable.config[id] || {}
|
||||
,arrs = [], index = 0;
|
||||
var config = thisTable.config[id] || {};
|
||||
var arrs = [], index = 0;
|
||||
|
||||
cols = $.extend(true, [], cols || config.cols);
|
||||
|
||||
|
@ -2687,7 +2693,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
//计算全选个数
|
||||
layui.each(data, function(i, item){
|
||||
if(layui.type(item) === 'array'){
|
||||
if(layui.type(item) === 'array' || item[table.config.disabledName]){
|
||||
invalidNum++; // 无效数据,或已删除的
|
||||
return;
|
||||
}
|
||||
|
@ -2713,12 +2719,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 获取表格当前页的所有行数据
|
||||
table.getData = function(id){
|
||||
var arr = []
|
||||
,data = table.cache[id] || [];
|
||||
var arr = [];
|
||||
var data = table.cache[id] || [];
|
||||
layui.each(data, function(i, item){
|
||||
if(layui.type(item) === 'array'){
|
||||
return;
|
||||
};
|
||||
}
|
||||
arr.push(table.clearCacheKey(item));
|
||||
});
|
||||
return arr;
|
||||
|
@ -2753,8 +2759,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
var thatTable = thisTable.that[id];
|
||||
var config = thisTable.config[id] || {};
|
||||
var textType = ({
|
||||
csv: 'text/csv'
|
||||
,xls: 'application/vnd.ms-excel'
|
||||
csv: 'text/csv',
|
||||
xls: 'application/vnd.ms-excel'
|
||||
})[type];
|
||||
var alink = document.createElement("a");
|
||||
|
||||
|
@ -2792,11 +2798,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 解析内容
|
||||
content = parseTempData.call(thatTable, {
|
||||
item3: item3
|
||||
,content: content
|
||||
,tplData: item1
|
||||
,text: 'text'
|
||||
,obj: {
|
||||
item3: item3,
|
||||
content: content,
|
||||
tplData: item1,
|
||||
text: 'text',
|
||||
obj: {
|
||||
td: function(field){
|
||||
var td = thatTable.layBody.find('tr[data-index="'+ i1 +'"]>td');
|
||||
return td.filter('[data-field="'+ field +'"]');
|
||||
|
|
|
@ -345,16 +345,14 @@ layui.define(['table'], function (exports) {
|
|||
var tableId = options.id;
|
||||
var customName = treeOptions.customName;
|
||||
|
||||
var treeNode = {
|
||||
// 带上一些常用的方法
|
||||
return {
|
||||
data: data,
|
||||
dataIndex: data[LAY_DATA_INDEX],
|
||||
getParentNode: function () {
|
||||
return that.getNodeByIndex(data[LAY_PARENT_INDEX])
|
||||
},
|
||||
}
|
||||
// 带上一些常用的方法
|
||||
|
||||
return treeNode;
|
||||
};
|
||||
}
|
||||
|
||||
// 通过 index 返回节点信息
|
||||
|
@ -576,6 +574,7 @@ layui.define(['table'], function (exports) {
|
|||
if (trExpand) {
|
||||
// 展开
|
||||
if (trExpanded) { // 已经展开过
|
||||
if (!childNodes.length) return ;//异步如果子节点没有数据情况下双点行展开所有已展开的节点问题解决
|
||||
trsElem.nextAll(childNodes.map(function (value, index, array) {
|
||||
return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"]'
|
||||
}).join(',')).removeClass(HIDE);
|
||||
|
@ -602,7 +601,11 @@ layui.define(['table'], function (exports) {
|
|||
options: options,
|
||||
}, true);
|
||||
}
|
||||
})
|
||||
});
|
||||
treeTableThat.updateStatus(childNodes, function (d) {
|
||||
d['LAY_HIDE'] = false;
|
||||
});
|
||||
options.hasNumberCol && formatNumber(tableId);
|
||||
} else {
|
||||
var asyncSetting = treeOptions.async || {};
|
||||
var asyncUrl = asyncSetting.url || options.url;
|
||||
|
@ -760,6 +763,11 @@ layui.define(['table'], function (exports) {
|
|||
tableViewElem.find(childNodesFlat.map(function (value, index, array) {
|
||||
return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"]'
|
||||
}).join(',')).addClass(HIDE);
|
||||
|
||||
treeTableThat.updateStatus(childNodes, function (d) {
|
||||
d['LAY_HIDE'] = true;
|
||||
});
|
||||
options.hasNumberCol && formatNumber(tableId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1029,13 +1037,14 @@ layui.define(['table'], function (exports) {
|
|||
});
|
||||
} else {
|
||||
debounceFn('renderTreeTable-' + tableId, function () {
|
||||
options.hasNumberCol && formatNumber(that);
|
||||
options.hasNumberCol && formatNumber(tableId);
|
||||
form.render($('.layui-table-tree[lay-id="' + tableId + '"]'));
|
||||
}, 0)();
|
||||
}
|
||||
}
|
||||
|
||||
var formatNumber = function (that) {
|
||||
var formatNumber = function (id) {
|
||||
var that = getThisTable(id);
|
||||
var options = that.getOptions();
|
||||
var tableViewElem = options.elem.next();
|
||||
|
||||
|
@ -1044,6 +1053,7 @@ layui.define(['table'], function (exports) {
|
|||
var trFixedL = tableViewElem.find('.layui-table-fixed-l tbody tr');
|
||||
var trFixedR = tableViewElem.find('.layui-table-fixed-r tbody tr');
|
||||
layui.each(that.treeToFlat(table.cache[options.id]), function (i1, item1) {
|
||||
if (item1['LAY_HIDE']) return;
|
||||
var itemData = that.getNodeDataByIndex(item1[LAY_DATA_INDEX]);
|
||||
itemData['LAY_NUM'] = ++num;
|
||||
trMain.eq(i1).find('.laytable-cell-numbers').html(num);
|
||||
|
@ -1242,7 +1252,7 @@ layui.define(['table'], function (exports) {
|
|||
layui.each(table.cache[id], function (i4, item4) {
|
||||
tableView.find('tr[data-level="0"][lay-data-index="' + item4[LAY_DATA_INDEX] + '"]').attr('data-index', i4);
|
||||
})
|
||||
options.hasNumberCol && formatNumber(that);
|
||||
options.hasNumberCol && formatNumber(id);
|
||||
|
||||
// 重新适配尺寸
|
||||
treeTable.resize(id);
|
||||
|
@ -1568,7 +1578,11 @@ layui.define(['table'], function (exports) {
|
|||
// 更新全选的状态
|
||||
var isAll = true;
|
||||
var isIndeterminate = false;
|
||||
layui.each(treeOptions.data.cascade === 'all' ? table.cache[tableId] : treeTable.getData(tableId, true), function (i1, item1) {
|
||||
var data = treeOptions.data.cascade === 'all' ? table.cache[tableId] : treeTable.getData(tableId, true);
|
||||
data = data.filter(function (item) {
|
||||
return !item[options.disabledName];
|
||||
});
|
||||
layui.each(data, function (i1, item1) {
|
||||
if (item1[checkName] || item1[LAY_CHECKBOX_HALF]) {
|
||||
isIndeterminate = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue