mirror of https://github.com/layui/layui
commit
4198f1be26
|
@ -65,9 +65,6 @@ Layui 是一套开源的 Web UI 组件库,采用自身轻量级模块化规范
|
|||
## 项目参与
|
||||
[项目参与者](https://github.com/layui/layui/graphs/contributors)
|
||||
|
||||
## 在 Cloud IDE 中预览
|
||||
[https://idegithub.com/layui/layui](https://idegithub.com/layui/layui)
|
||||
|
||||
## 破旧立新 🌱
|
||||
Layui 原官网已于2021年10月13日下线。详见:
|
||||
> 1. <a href="https://unpkg.com/outeres@0.0.7/img/layui/notice-2021.png" target="_blank">Layui 原官网下线公告</a> 2. <a href="https://www.zhihu.com/question/488668647/answer/2159962082" target="_blank">Layui 原官网为什么要下线?</a>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -22,8 +22,11 @@
|
|||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="getData">获取当前页数据</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="isAll">是否全选</button>
|
||||
|
||||
<button class="layui-btn layui-btn-sm" id="setRowChecked">
|
||||
设置行选中状态
|
||||
<i class="layui-icon layui-icon-down layui-font-12"></i>
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-sm" id="reloadTest">
|
||||
重载测试
|
||||
<i class="layui-icon layui-icon-down layui-font-12"></i>
|
||||
|
@ -132,6 +135,7 @@ layui.use(['table', 'dropdown'], function(){
|
|||
|
||||
//,size: 'sm'
|
||||
//,skin: 'line'
|
||||
//,even: true
|
||||
//,loading: false
|
||||
|
||||
,totalRow: true
|
||||
|
@ -202,6 +206,52 @@ layui.use(['table', 'dropdown'], function(){
|
|||
});
|
||||
*/
|
||||
|
||||
// 设置选中行状态
|
||||
dropdown.render({
|
||||
elem: '#setRowChecked' //可绑定在任意元素中,此处以上述按钮为例
|
||||
,data: [{
|
||||
id: 'checked',
|
||||
title: '选中某行'
|
||||
},{
|
||||
id: 'unchecked',
|
||||
title: '取消选中某行'
|
||||
},{
|
||||
id: 'reset-checked',
|
||||
title: '给选中行取消选中状态'
|
||||
}]
|
||||
//菜单被点击的事件
|
||||
,click: function(obj){
|
||||
if(obj.id === 'reset-checked'){
|
||||
// 给选中行取消选中状态
|
||||
table.setRowChecked(id, {
|
||||
index: 'all',
|
||||
checked: false
|
||||
});
|
||||
} else {
|
||||
layer.prompt({
|
||||
title: '请输入表格行号',
|
||||
value: 1,
|
||||
shade: false
|
||||
}, function(value, i){
|
||||
switch(obj.id){
|
||||
case 'checked':
|
||||
table.setRowChecked(id, {
|
||||
index: value
|
||||
});
|
||||
break;
|
||||
case 'unchecked':
|
||||
table.setRowChecked(id, {
|
||||
index: value,
|
||||
checked: false
|
||||
});
|
||||
break;
|
||||
}
|
||||
layer.close(i);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 重载测试
|
||||
dropdown.render({
|
||||
elem: '#reloadTest' //可绑定在任意元素中,此处以上述按钮为例
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<table id="test-json"></table>
|
||||
|
||||
<div style="display: none1;">
|
||||
<table class="layui-table" lay-data="{width:800, height: 300, url:'json/table/demo2.json', page: true, limit: 6, toolbar: true}">
|
||||
<table class="layui-table" lay-data="{width:800, height: 300, url:'json/table/demo2.json', page: true, even: true, limit: 6, toolbar: true}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th lay-data="{checkbox:true, fixed:'left'}" rowspan="2"></th>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "layui",
|
||||
"version": "2.8.0-rc.6",
|
||||
"version": "2.8.0-rc.7",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
|
11
preview.yml
11
preview.yml
|
@ -1,11 +0,0 @@
|
|||
# preview.yml
|
||||
autoOpen: true # 打开工作空间时是否自动开启所有应用的预览
|
||||
apps:
|
||||
- port: 3000 # 应用的端口
|
||||
run: # 应用的启动命令
|
||||
command: # 使用此命令启动服务,且不执行run
|
||||
preview: /examples/all.html # 预览文件
|
||||
root: ./ # 应用的启动目录
|
||||
name: layui # 应用名称
|
||||
description: Classic modular Front-End UI library # 应用描述
|
||||
autoOpen: true # 打开工作空间时是否自动开启预览(优先级高于根级 autoOpen)
|
|
@ -541,7 +541,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
/* 卡片面板 */
|
||||
.layui-card{margin-bottom: 15px; border-radius: 2px; background-color: #fff; box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}
|
||||
.layui-card:last-child{margin-bottom: 0;}
|
||||
.layui-card-header{position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f6f6f6; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}
|
||||
.layui-card-header{position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f8f8f8; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}
|
||||
.layui-card-body{position: relative; padding: 10px 15px; line-height: 24px;}
|
||||
.layui-card-body[pad15]{padding: 15px;}
|
||||
.layui-card-body[pad20]{padding: 20px;}
|
||||
|
@ -629,7 +629,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-text p:first-child{margin-top: 0;}
|
||||
.layui-text p:last-child{margin-bottom: 0;}
|
||||
.layui-text blockquote:not(.layui-elem-quote){padding: 5px 15px; border-left: 5px solid #eee;}
|
||||
.layui-text pre > code:not(.layui-code){padding: 15px; font-family: Lucida Console,Consolas,Courier New; background-color: #FAFAFA;}
|
||||
.layui-text pre > code:not(.layui-code){padding: 15px; font-family: Courier New,Lucida Console,Consolas; background-color: #FAFAFA;}
|
||||
|
||||
/* 字体大小及颜色 */
|
||||
.layui-font-12{font-size: 12px !important;}
|
||||
|
@ -787,11 +787,11 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-form-select dl dd{padding: 0 10px; line-height: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
|
||||
.layui-form-select dl dt{font-size: 12px; color: #999;}
|
||||
.layui-form-select dl dd{cursor: pointer;}
|
||||
.layui-form-select dl dd:hover{background-color: #F6F6F6; -webkit-transition: .5s all; transition: .5s all;}
|
||||
.layui-form-select dl dd:hover{background-color: #f8f8f8; -webkit-transition: .5s all; transition: .5s all;}
|
||||
.layui-form-select .layui-select-group dd{padding-left: 20px;}
|
||||
.layui-form-select dl dd.layui-select-tips{padding-left: 10px !important; color: #999;}
|
||||
.layui-form-select dl dd.layui-this{background-color: #F7F7F7; color: #5FB878; font-weight: 700;}
|
||||
/*.layui-form-select dl dd.layui-this{background-color: #F6F6F6; color: #5FB878; font-weight: 700;}*/
|
||||
.layui-form-select dl dd.layui-this{background-color: #f8f8f8; color: #5FB878; font-weight: 700;}
|
||||
/*.layui-form-select dl dd.layui-this{background-color: #f8f8f8; color: #5FB878; font-weight: 700;}*/
|
||||
.layui-form-select dl dd.layui-disabled{background-color: #fff;}
|
||||
.layui-form-selected dl{display: block;}
|
||||
.layui-form-selected .layui-edge{margin-top: -9px; -webkit-transform:rotate(180deg); transform: rotate(180deg);}
|
||||
|
@ -936,9 +936,10 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-table-patch{}
|
||||
.layui-table-mend{background-color: #fff;}
|
||||
.layui-table-hover,
|
||||
.layui-table-click{background-color: #FAFAFA;}
|
||||
.layui-table-click,
|
||||
.layui-table[lay-even] tbody tr:nth-child(even){background-color: #f8f8f8;}
|
||||
|
||||
|
||||
.layui-table[lay-even] tr:nth-child(even){background-color: #f2f2f2;}
|
||||
|
||||
.layui-table th,
|
||||
.layui-table td,
|
||||
|
@ -1008,7 +1009,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-table-tool-panel{position: absolute; top: 29px; left: -1px; z-index: 399; padding: 5px 0 !important; min-width: 150px; min-height: 40px; border: 1px solid #d2d2d2; text-align: left; overflow-y: auto; background-color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.12);}
|
||||
.layui-table-tool-panel li{padding: 0 10px; margin: 0 !important; line-height: 30px; list-style-type: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-transition: .5s all; transition: .5s all;}
|
||||
.layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"]{width: 100%;}
|
||||
.layui-table-tool-panel li:hover{background-color: #F6F6F6;}
|
||||
.layui-table-tool-panel li:hover{background-color: #f8f8f8;}
|
||||
.layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"]{padding-left: 28px;}
|
||||
.layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"] i{position: absolute; left: 0; top: 0;}
|
||||
.layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"] span{padding: 0;}
|
||||
|
@ -1040,7 +1041,6 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
|
||||
.layui-table-body{position: relative; overflow: auto; margin-right: -1px; margin-bottom: -1px;}
|
||||
.layui-table-body .layui-none{line-height: 26px; padding: 30px 15px; text-align: center; color: #999;}
|
||||
.layui-table-body .layui-table[lay-even] tr:nth-child(even){background-color: #f2f2f2;}
|
||||
.layui-table-fixed{position: absolute; left: 0; top: 0; z-index: 101;}
|
||||
.layui-table-fixed .layui-table-body{overflow: hidden;}
|
||||
.layui-table-fixed-l{box-shadow: 1px 0 8px rgba(0,0,0,.08);}
|
||||
|
@ -1118,7 +1118,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
|
|||
.layui-menu li,
|
||||
.layui-menu-body-title a{padding: 5px 15px; color: initial}
|
||||
.layui-menu li{position: relative; margin: 1px 0; width: calc(100% + 1px); line-height: 26px; color: rgba(0,0,0,.8); font-size: 14px; white-space: nowrap; cursor: pointer; transition: all .3s;}
|
||||
.layui-menu li:hover{background-color: #F6F6F6; }
|
||||
.layui-menu li:hover{background-color: #f8f8f8; }
|
||||
|
||||
.layui-menu-item-parent:hover>.layui-menu-body-panel{display: block; animation-name: layui-fadein; animation-duration: 0.3s; animation-fill-mode: both; animation-delay:.2s;}
|
||||
.layui-menu-item-parent .layui-menu-body-title,
|
||||
|
@ -1143,7 +1143,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
|
|||
.layui-menu .layui-menu-item-down>ul{visibility: visible; height: auto;}
|
||||
|
||||
.layui-menu .layui-menu-item-checked,
|
||||
.layui-menu .layui-menu-item-checked2{background-color: #F6F6F6!important; color: #5FB878;}
|
||||
.layui-menu .layui-menu-item-checked2{background-color: #f8f8f8!important; color: #5FB878;}
|
||||
.layui-menu .layui-menu-item-checked a,
|
||||
.layui-menu .layui-menu-item-checked2 a{color: #5FB878;}
|
||||
.layui-menu .layui-menu-item-checked:after{position: absolute; right: 0; top: 0; bottom: 0; border-right: 3px solid #5FB878; content: "";}
|
||||
|
@ -1193,9 +1193,9 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
|
|||
|
||||
.layui-nav-child{display: none; position: absolute; left: 0; top: 65px; min-width: 100%; line-height: 36px; padding: 5px 0; box-shadow: 0 2px 4px rgba(0,0,0,.12); border: 1px solid #eee; background-color: #fff; z-index: 100; border-radius: 2px; white-space: nowrap; box-sizing: border-box;}
|
||||
.layui-nav .layui-nav-child a{color: #5F5F5F; color: rgba(0,0,0,.8);}
|
||||
.layui-nav .layui-nav-child a:hover{background-color: #F6F6F6; color: rgba(0,0,0,.8);}
|
||||
.layui-nav .layui-nav-child a:hover{background-color: #f8f8f8; color: rgba(0,0,0,.8);}
|
||||
.layui-nav-child dd{margin: 1px 0; position: relative;}
|
||||
.layui-nav-child dd.layui-this{background-color: #F6F6F6; color: #000;}
|
||||
.layui-nav-child dd.layui-this{background-color: #f8f8f8; color: #000;}
|
||||
.layui-nav-child dd.layui-this:after{display: none;}
|
||||
.layui-nav-child-r{left: auto; right: 0;}
|
||||
.layui-nav-child-c{text-align: center;}
|
||||
|
@ -1393,7 +1393,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
|
|||
.layui-util-face ul li:hover{position: relative; z-index: 2; border: 1px solid #eb7350; background: #fff9ec;}
|
||||
|
||||
/** 代码文本修饰 **/
|
||||
.layui-code{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border: 1px solid #eee; border-left-width: 6px; background-color: #FAFAFA; color: #333; font-family: Courier New; font-size: 12px;}
|
||||
.layui-code{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border: 1px solid #eee; border-left-width: 6px; background-color: #FAFAFA; color: #333; font-family: Courier New,Lucida Console,Consolas; font-size: 12px;}
|
||||
|
||||
/** 穿梭框 **/
|
||||
.layui-transfer-box,
|
||||
|
@ -1412,7 +1412,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
|
|||
.layui-transfer-active .layui-btn .layui-icon{margin: 0; font-size: 14px !important;}
|
||||
.layui-transfer-data{padding: 5px 0; overflow: auto;}
|
||||
.layui-transfer-data li{height: 32px; line-height: 32px; padding: 0 10px;}
|
||||
.layui-transfer-data li:hover{background-color: #F6F6F6; transition: .5s all;}
|
||||
.layui-transfer-data li:hover{background-color: #f8f8f8; transition: .5s all;}
|
||||
.layui-transfer-data .layui-none{padding: 15px 10px; text-align: center; color: #999;}
|
||||
|
||||
/** 评分组件 **/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.8.0-rc.6'; // Layui 版本号
|
||||
this.v = '2.8.0-rc.7'; // Layui 版本号
|
||||
}
|
||||
|
||||
//识别预先可能定义的指定全局对象
|
||||
|
|
|
@ -618,12 +618,18 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
// 复选框/开关
|
||||
,checkbox: function(elem){
|
||||
var CLASS = {
|
||||
checkbox: ['layui-form-checkbox', 'layui-form-checked', 'checkbox']
|
||||
,_switch: ['layui-form-switch', 'layui-form-onswitch', 'switch']
|
||||
}
|
||||
,checks = elem || elemForm.find('input[type=checkbox]')
|
||||
|
||||
,events = function(reElem, RE_CLASS){
|
||||
"checkbox": ['layui-form-checkbox', 'layui-form-checked', 'checkbox'],
|
||||
"switch": ['layui-form-switch', 'layui-form-onswitch', 'switch']
|
||||
};
|
||||
var checks = elem || elemForm.find('input[type=checkbox]');
|
||||
// 风格
|
||||
var skins = {
|
||||
"primary": true, // 默认风格
|
||||
"tag": true, // 标签风格
|
||||
"switch": true // 开关风格
|
||||
};
|
||||
// 事件
|
||||
var events = function(reElem, RE_CLASS){
|
||||
var check = $(this);
|
||||
|
||||
// 勾选
|
||||
|
@ -647,20 +653,19 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
,othis: reElem
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 遍历复选框
|
||||
checks.each(function(index, check){
|
||||
var othis = $(this);
|
||||
var skin = othis.attr('lay-skin') || 'primary';
|
||||
check.title || (check.title = othis.attr('lay-text') || ''); // 向下兼容将以前设置在lay-text的值赋给title
|
||||
var title = (check.title.replace(/\s/g, '') || '').split('|');
|
||||
var title = (function(title){
|
||||
// 向下兼容 lay-text 属性
|
||||
return title || othis.attr('lay-text') || '';
|
||||
})(check.title).replace(/\s/g, '').split('|');
|
||||
var disabled = this.disabled;
|
||||
|
||||
if(skin === 'switch') {
|
||||
skin = '_'+ skin;
|
||||
} else if (skin !== 'tag') {
|
||||
skin = 'primary';
|
||||
}
|
||||
if(!skins[skin]) skin = 'primary'; // 若非内置风格,则强制为默认风格
|
||||
var RE_CLASS = CLASS[skin] || CLASS.checkbox;
|
||||
|
||||
if(typeof othis.attr('lay-ignore') === 'string') return othis.show();
|
||||
|
@ -676,13 +681,13 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
,function(){ // 不同风格的内容
|
||||
var type = {
|
||||
// 复选框
|
||||
checkbox: [
|
||||
"checkbox": [
|
||||
(title[0] ? ('<span>'+ util.escape(title[0]) +'</span>') : '')
|
||||
,'<i class="layui-icon layui-icon-ok"></i>'
|
||||
].join('')
|
||||
].join(''),
|
||||
|
||||
// 开关
|
||||
,_switch: '<em>'+ ((check.checked ? title[0] : title[1]) || '') +'</em><i></i>'
|
||||
"switch": '<em>'+ ((check.checked ? title[0] : title[1]) || '') +'</em><i></i>'
|
||||
};
|
||||
return type[skin] || type['checkbox'];
|
||||
}()
|
||||
|
|
|
@ -1145,7 +1145,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
if(tplData[disabledName]) arr.push('disabled');
|
||||
|
||||
return arr.join(' ');
|
||||
}() +'>';
|
||||
}() +' lay-type="layTableCheckbox">';
|
||||
break;
|
||||
case 'radio': // 单选
|
||||
if(tplData[checkName]){
|
||||
|
@ -1200,7 +1200,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
that.layFixRight.find('tbody').html(trs_fixed_r.join(''));
|
||||
|
||||
that.renderForm();
|
||||
typeof thisCheckedRowIndex === 'number' && that.setThisRowChecked(thisCheckedRowIndex);
|
||||
|
||||
// 标注选中行样式
|
||||
typeof thisCheckedRowIndex === 'number' && that.setRowChecked({
|
||||
type: 'radio',
|
||||
index: thisCheckedRowIndex
|
||||
}, true);
|
||||
|
||||
that.syncCheckAll();
|
||||
|
||||
// 因为 page 参数有可能发生变化 先重新铺满
|
||||
|
@ -1385,33 +1391,48 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
form.render(type, filter);
|
||||
};
|
||||
|
||||
// 标记当前行选中状态
|
||||
Class.prototype.setThisRowChecked = function(index, dataChecked){
|
||||
// 标记行选中状态
|
||||
Class.prototype.setRowChecked = function(opts, onlyStyle){
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var ELEM_CLICK = 'layui-table-click';
|
||||
var tr = that.layBody.find('tr[data-index="'+ index +'"]');
|
||||
var tr = that.layBody.find('tr'+ (
|
||||
opts.index === 'all' ? '' : '[data-index="'+ opts.index +'"]'
|
||||
));
|
||||
|
||||
opts = $.extend({
|
||||
type: 'checkbox', // 选中方式
|
||||
checked: true // 选中状态
|
||||
}, opts);
|
||||
|
||||
// 标注当前行选中样式
|
||||
if(opts.type !== 'checkbox' && !opts.isAll){
|
||||
tr.addClass(ELEM_CLICK).siblings('tr').removeClass(ELEM_CLICK);
|
||||
}
|
||||
|
||||
// 仅设置样式状态
|
||||
if(onlyStyle) return;
|
||||
|
||||
// 同步数据选中属性值
|
||||
if(dataChecked){
|
||||
var thisData = table.cache[that.key];
|
||||
var thisData = table.cache[that.key];
|
||||
|
||||
// 重置数据单选选中属性
|
||||
layui.each(thisData, function(i, item){
|
||||
if(index === i){
|
||||
item[options.checkName] = true;
|
||||
} else {
|
||||
delete item[options.checkName];
|
||||
}
|
||||
});
|
||||
// 设置数据选中属性
|
||||
layui.each(thisData, function(i, item){
|
||||
if(opts.index === i || opts.index === 'all'){
|
||||
item[options.checkName] = opts.checked;
|
||||
} else if(opts.type === 'radio') {
|
||||
delete item[options.checkName];
|
||||
}
|
||||
});
|
||||
|
||||
// 若存在单选框,则标注单选框选中样式
|
||||
tr.find('input[lay-type="layTableRadio"]').prop('checked', true);
|
||||
that.renderForm('radio');
|
||||
}
|
||||
|
||||
// 选中样式
|
||||
tr.addClass(ELEM_CLICK).siblings('tr').removeClass(ELEM_CLICK);
|
||||
// 若存在复选框或单选框,则标注选中样式
|
||||
tr.find('input[lay-type="'+ ({
|
||||
radio: 'layTableRadio',
|
||||
checkbox: 'layTableCheckbox'
|
||||
}[opts.type] || 'checkbox') +'"]').prop('checked', opts.checked);
|
||||
|
||||
that.syncCheckAll();
|
||||
that.renderForm(opts.type);
|
||||
};
|
||||
|
||||
// 数据排序
|
||||
|
@ -2047,8 +2068,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
that.renderForm();
|
||||
}
|
||||
// 设置行选中状态
|
||||
,setRowChecked: function(checked){
|
||||
that.setThisRowChecked(index, true);
|
||||
,setRowChecked: function(opts){
|
||||
that.setRowChecked($.extend({
|
||||
type: 'radio',
|
||||
index: index
|
||||
}, opts));
|
||||
}
|
||||
// 获取当前列
|
||||
};
|
||||
|
@ -2097,7 +2121,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
var index = radio.parents('tr').eq(0).data('index');
|
||||
|
||||
// 单选框选中状态
|
||||
that.setThisRowChecked(index, true);
|
||||
that.setRowChecked({
|
||||
type: 'radio',
|
||||
index: index
|
||||
});
|
||||
|
||||
// 事件
|
||||
layui.event.call(this, MOD_NAME, 'radio('+ filter +')', commonMember.call(this, {
|
||||
checked: checked
|
||||
|
@ -2289,7 +2317,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
event: othis.attr('lay-event')
|
||||
})
|
||||
);
|
||||
that.setThisRowChecked(index);
|
||||
// 设置当前行选中样式
|
||||
that.setRowChecked({
|
||||
type: 'radio',
|
||||
index: index
|
||||
}, true);
|
||||
};
|
||||
|
||||
// 行工具条单击事件
|
||||
|
@ -2474,7 +2506,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
eachArrs();
|
||||
};
|
||||
|
||||
// 表格选中状态
|
||||
// 获取表格选中状态
|
||||
table.checkStatus = function(id){
|
||||
var nums = 0
|
||||
,invalidNum = 0
|
||||
|
@ -2499,6 +2531,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
,isAll: data.length ? (nums === (data.length - invalidNum)) : false //是否全选
|
||||
};
|
||||
};
|
||||
|
||||
// 设置行选中状态
|
||||
table.setRowChecked = function(id, opts){
|
||||
var that = getThisTable(id);
|
||||
if(!that) return;
|
||||
that.setRowChecked(opts);
|
||||
};
|
||||
|
||||
// 获取表格当前页的所有行数据
|
||||
table.getData = function(id){
|
||||
|
@ -2512,17 +2551,33 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
});
|
||||
return arr;
|
||||
};
|
||||
|
||||
// 重置表格尺寸结构
|
||||
table.resize = function(id){
|
||||
// 若指定表格唯一 id,则只执行该 id 对应的表格实例
|
||||
if(id){
|
||||
var config = getThisTableConfig(id); // 获取当前实例配置项
|
||||
if(!config) return;
|
||||
|
||||
getThisTable(id).resize();
|
||||
|
||||
} else { // 否则重置所有表格实例尺寸
|
||||
layui.each(thisTable.that, function(){
|
||||
this.resize();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 表格导出
|
||||
table.exportFile = function(id, data, options){
|
||||
table.exportFile = function(id, data, opts){
|
||||
data = data || table.clearCacheKey(table.cache[id]);
|
||||
options = typeof options === 'object' ? options : function(){
|
||||
opts = typeof opts === 'object' ? opts : function(){
|
||||
var obj = {};
|
||||
options && (obj.type = options);
|
||||
opts && (obj.type = opts);
|
||||
return obj;
|
||||
}();
|
||||
|
||||
var type = options.type || 'csv';
|
||||
var type = opts.type || 'csv';
|
||||
var thatTable = thisTable.that[id];
|
||||
var config = thisTable.config[id] || {};
|
||||
var textType = ({
|
||||
|
@ -2598,27 +2653,64 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(',');
|
||||
}());
|
||||
//return;
|
||||
alink.download = (options.title || config.title || 'table_'+ (config.index || '')) + '.' + type;
|
||||
alink.download = (opts.title || config.title || 'table_'+ (config.index || '')) + '.' + type;
|
||||
document.body.appendChild(alink);
|
||||
alink.click();
|
||||
document.body.removeChild(alink);
|
||||
};
|
||||
|
||||
// 重置表格尺寸结构
|
||||
table.resize = function(id){
|
||||
// 若指定表格唯一 id,则只执行该 id 对应的表格实例
|
||||
if(id){
|
||||
var config = getThisTableConfig(id); // 获取当前实例配置项
|
||||
if(!config) return;
|
||||
|
||||
getThisTable(id).resize();
|
||||
|
||||
} else { // 否则重置所有表格实例尺寸
|
||||
layui.each(thisTable.that, function(){
|
||||
this.resize();
|
||||
|
||||
// 获取表格配置信息
|
||||
table.getOptions = function (id) {
|
||||
return $.extend(true, {}, getThisTableConfig(id));
|
||||
}
|
||||
|
||||
// 显示或隐藏列
|
||||
table.hideCol = function (id, cols) {
|
||||
var that = getThisTable(id);
|
||||
if (!that) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (layui.type(cols) === 'boolean') {
|
||||
// 显示全部或者隐藏全部
|
||||
that.eachCols(function (i2, item2) {
|
||||
var key = item2.key;
|
||||
var col = that.col(key);
|
||||
var parentKey = item2.parentKey;
|
||||
// 同步勾选列的 hide 值和隐藏样式
|
||||
if (col.hide != cols) {
|
||||
var hide = col.hide = cols;
|
||||
that.elem.find('*[data-key="'+ key +'"]')[
|
||||
hide ? 'addClass' : 'removeClass'
|
||||
](HIDE);
|
||||
// 根据列的显示隐藏,同步多级表头的父级相关属性值
|
||||
that.setParentCol(hide, parentKey);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
layui.each(cols, function (i1, item1) {
|
||||
that.eachCols(function (i2, item2) {
|
||||
if (item1.field === item2.field) {
|
||||
var key = item2.key;
|
||||
var col = that.col(key);
|
||||
var parentKey = item2.parentKey;
|
||||
// 同步勾选列的 hide 值和隐藏样式
|
||||
if ('hide' in item1 && col.hide != item1.hide) {
|
||||
var hide = col.hide = !!item1.hide;
|
||||
that.elem.find('*[data-key="'+ key +'"]')[
|
||||
hide ? 'addClass' : 'removeClass'
|
||||
](HIDE);
|
||||
// 根据列的显示隐藏,同步多级表头的父级相关属性值
|
||||
that.setParentCol(hide, parentKey);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
$('.' + ELEM_TOOL_PANEL).remove(); // 关闭字段筛选面板如果打开的话
|
||||
// 重新适配尺寸
|
||||
that.resize();
|
||||
}
|
||||
|
||||
// 重载
|
||||
table.reload = function(id, options, deep, type){
|
||||
|
@ -2670,58 +2762,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
delete data[table.config.disabledName];
|
||||
return data;
|
||||
};
|
||||
|
||||
// 获取表格配置信息
|
||||
table.getOptions = function (id) {
|
||||
return $.extend(true, {}, getThisTableConfig(id));
|
||||
}
|
||||
|
||||
table.hideCol = function (id, cols) {
|
||||
var that = getThisTable(id);
|
||||
if (!that) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (layui.type(cols) === 'boolean') {
|
||||
// 显示全部或者隐藏全部
|
||||
that.eachCols(function (i2, item2) {
|
||||
var key = item2.key;
|
||||
var col = that.col(key);
|
||||
var parentKey = item2.parentKey;
|
||||
// 同步勾选列的 hide 值和隐藏样式
|
||||
if (col.hide != cols) {
|
||||
var hide = col.hide = cols;
|
||||
that.elem.find('*[data-key="'+ key +'"]')[
|
||||
hide ? 'addClass' : 'removeClass'
|
||||
](HIDE);
|
||||
// 根据列的显示隐藏,同步多级表头的父级相关属性值
|
||||
that.setParentCol(hide, parentKey);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
layui.each(cols, function (i1, item1) {
|
||||
that.eachCols(function (i2, item2) {
|
||||
if (item1.field === item2.field) {
|
||||
var key = item2.key;
|
||||
var col = that.col(key);
|
||||
var parentKey = item2.parentKey;
|
||||
// 同步勾选列的 hide 值和隐藏样式
|
||||
if ('hide' in item1 && col.hide != item1.hide) {
|
||||
var hide = col.hide = !!item1.hide;
|
||||
that.elem.find('*[data-key="'+ key +'"]')[
|
||||
hide ? 'addClass' : 'removeClass'
|
||||
](HIDE);
|
||||
// 根据列的显示隐藏,同步多级表头的父级相关属性值
|
||||
that.setParentCol(hide, parentKey);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
$('.' + ELEM_TOOL_PANEL).remove(); // 关闭字段筛选面板如果打开的话
|
||||
// 重新适配尺寸
|
||||
that.resize();
|
||||
}
|
||||
|
||||
// 自动完成渲染
|
||||
$(function(){
|
||||
|
|
Loading…
Reference in New Issue