update
This commit is contained in:
parent
37443a5c45
commit
8cf6798137
@ -3,7 +3,7 @@
|
|||||||
,"msg": ""
|
,"msg": ""
|
||||||
,"count": 3000000
|
,"count": 3000000
|
||||||
,"totalRow": {
|
,"totalRow": {
|
||||||
"experience": "777"
|
"checkin": "777"
|
||||||
}
|
}
|
||||||
,"data": [{
|
,"data": [{
|
||||||
"id": "10001"
|
"id": "10001"
|
||||||
@ -11,11 +11,12 @@
|
|||||||
,"email": "test1@email.com"
|
,"email": "test1@email.com"
|
||||||
,"sex": "<strong>男</strong>"
|
,"sex": "<strong>男</strong>"
|
||||||
,"city": "浙江杭州"
|
,"city": "浙江杭州"
|
||||||
,"sign": "鼠标移动到此处,可以通过点击单元格右侧的下拉图标,查看到被隐藏的全部内容。"
|
,"sign": "舍南舍北皆春水,但见群鸥日日来。花径不曾缘客扫,蓬门今始为君开。盘飧市远无兼味,樽酒家贫只旧醅。肯与邻翁相对饮,隔篱呼取尽余杯。"
|
||||||
,"experience": 7
|
,"experience": 7
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": 0
|
,"checkin": 0
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
|
,"LAY_DISABLED": true
|
||||||
}, {
|
}, {
|
||||||
"id": "10002"
|
"id": "10002"
|
||||||
,"username": "李白"
|
,"username": "李白"
|
||||||
@ -25,7 +26,7 @@
|
|||||||
,"sign": "君不见,黄河之水天上来,奔流到海不复回。 君不见,高堂明镜悲白发,朝如青丝暮成雪。 人生得意须尽欢,莫使金樽空对月。 天生我材必有用,千金散尽还复来。 烹羊宰牛且为乐,会须一饮三百杯。 岑夫子,丹丘生,将进酒,杯莫停。 与君歌一曲,请君为我倾耳听。(倾耳听 一作:侧耳听) 钟鼓馔玉不足贵,但愿长醉不复醒。(不足贵 一作:何足贵;不复醒 一作:不愿醒/不用醒) 古来圣贤皆寂寞,惟有饮者留其名。(古来 一作:自古;惟 通:唯) 陈王昔时宴平乐,斗酒十千恣欢谑。 主人何为言少钱,径须沽取对君酌。 五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。"
|
,"sign": "君不见,黄河之水天上来,奔流到海不复回。 君不见,高堂明镜悲白发,朝如青丝暮成雪。 人生得意须尽欢,莫使金樽空对月。 天生我材必有用,千金散尽还复来。 烹羊宰牛且为乐,会须一饮三百杯。 岑夫子,丹丘生,将进酒,杯莫停。 与君歌一曲,请君为我倾耳听。(倾耳听 一作:侧耳听) 钟鼓馔玉不足贵,但愿长醉不复醒。(不足贵 一作:何足贵;不复醒 一作:不愿醒/不用醒) 古来圣贤皆寂寞,惟有饮者留其名。(古来 一作:自古;惟 通:唯) 陈王昔时宴平乐,斗酒十千恣欢谑。 主人何为言少钱,径须沽取对君酌。 五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。"
|
||||||
,"experience": 9
|
,"experience": 9
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
,"LAY_CHECKED": true
|
,"LAY_CHECKED": true
|
||||||
}, {
|
}, {
|
||||||
@ -34,10 +35,10 @@
|
|||||||
,"email": "test3@email.com"
|
,"email": "test3@email.com"
|
||||||
,"sex": "男"
|
,"sex": "男"
|
||||||
,"city": "浙江杭州"
|
,"city": "浙江杭州"
|
||||||
,"sign": "人生恰似一场修行"
|
,"sign": "大江东去,浪淘尽,千古风流人物。故垒西边,人道是,三国周郎赤壁。乱石穿空,惊涛拍岸,卷起千堆雪。江山如画,一时多少豪杰。遥想公瑾当年,小乔初嫁了,雄姿英发。羽扇纶巾,谈笑间,樯橹灰飞烟灭。故国神游,多情应笑我,早生华发。人生如梦,一尊还酹江月。"
|
||||||
,"experience": 8
|
,"experience": 8
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": null
|
,"checkin": null
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}, {
|
}, {
|
||||||
"id": "10004"
|
"id": "10004"
|
||||||
@ -48,7 +49,7 @@
|
|||||||
,"sign": "人生恰似一场修行"
|
,"sign": "人生恰似一场修行"
|
||||||
,"experience": 6
|
,"experience": 6
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}, {
|
}, {
|
||||||
"id": "10005"
|
"id": "10005"
|
||||||
@ -59,7 +60,7 @@
|
|||||||
,"sign": "人生恰似一场修行"
|
,"sign": "人生恰似一场修行"
|
||||||
,"experience": 64
|
,"experience": 64
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}, {
|
}, {
|
||||||
"id": "10006"
|
"id": "10006"
|
||||||
@ -70,7 +71,7 @@
|
|||||||
,"sign": "人生恰似一场修行"
|
,"sign": "人生恰似一场修行"
|
||||||
,"experience": 65
|
,"experience": 65
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}, {
|
}, {
|
||||||
"id": "10007"
|
"id": "10007"
|
||||||
@ -81,7 +82,7 @@
|
|||||||
,"sign": "人生恰似一场修行"
|
,"sign": "人生恰似一场修行"
|
||||||
,"experience": 49
|
,"experience": 49
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}, {
|
}, {
|
||||||
"id": "10008"
|
"id": "10008"
|
||||||
@ -92,7 +93,7 @@
|
|||||||
,"sign": "人生恰似一场修行"
|
,"sign": "人生恰似一场修行"
|
||||||
,"experience": 5
|
,"experience": 5
|
||||||
,"ip": "192.168.0.8"
|
,"ip": "192.168.0.8"
|
||||||
,"logins": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
@ -21,7 +21,6 @@
|
|||||||
<script type="text/html" id="toolbarDemo">
|
<script type="text/html" id="toolbarDemo">
|
||||||
<div class="layui-btn-container">
|
<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="getCheckData">获取选中行数据</button>
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
|
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="getData">获取当前页数据</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" lay-event="isAll">是否全选</button>
|
||||||
|
|
||||||
@ -86,6 +85,20 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
var dropdown = layui.dropdown;
|
var dropdown = layui.dropdown;
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
|
|
||||||
|
|
||||||
|
// 仅用于各类测试的表头
|
||||||
|
var test_cols = [[
|
||||||
|
{type: 'checkbox', fixed: 'left'}
|
||||||
|
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
||||||
|
,{field:'username', title:'用户名', width:120, edit: 'text'}
|
||||||
|
,{field:'email', title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, width:150, edit: 'text'}
|
||||||
|
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
||||||
|
,{field:'city', title:'城市', width: 120}
|
||||||
|
,{field:'sign', title:'签名'}
|
||||||
|
,{field: 'experience', title: '积分', width:80, sort: true, align:'center', totalRow: '{{ d.TOTAL_NUMS }} 😊'}
|
||||||
|
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
|
||||||
|
]];
|
||||||
|
|
||||||
// 全局设定某参数
|
// 全局设定某参数
|
||||||
table.set({
|
table.set({
|
||||||
where: {
|
where: {
|
||||||
@ -97,9 +110,6 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
//,height: 300
|
//,height: 300
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#appendtest').append($('#TPL_appendtest').html())
|
|
||||||
table.init('appendtest');
|
|
||||||
|
|
||||||
//渲染
|
//渲染
|
||||||
window.ins1 = table.render({
|
window.ins1 = table.render({
|
||||||
elem: '#test'
|
elem: '#test'
|
||||||
@ -109,7 +119,7 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
,url: 'json/table/demo1.json'
|
,url: 'json/table/demo1.json'
|
||||||
|
|
||||||
,pagebar: '#pagebarDemo' // 分页栏模板
|
,pagebar: '#pagebarDemo' // 分页栏模板
|
||||||
,lineStyle: 'height: 100px;' // 行样式
|
,lineStyle: 'height: 95px;' // 行样式
|
||||||
,css: [ // 自定义样式
|
,css: [ // 自定义样式
|
||||||
'.layui-table-page{text-align: right;}'
|
'.layui-table-page{text-align: right;}'
|
||||||
,'.layui-table-pagebar{float: left;}'
|
,'.layui-table-pagebar{float: left;}'
|
||||||
@ -120,7 +130,9 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
//,autoSort: false //是否自动排序。如果否,则由服务端排序
|
//,autoSort: false //是否自动排序。如果否,则由服务端排序
|
||||||
//,loading: false
|
//,loading: false
|
||||||
,totalRow: true
|
,totalRow: true
|
||||||
,page: true
|
,page: {
|
||||||
|
// curr: layui.data('tableCache').curr || 1 // 读取记录中的页码,赋值给起始页
|
||||||
|
}
|
||||||
,limit: 30
|
,limit: 30
|
||||||
,toolbar: '#toolbarDemo'
|
,toolbar: '#toolbarDemo'
|
||||||
,defaultToolbar: ['filter', 'exports', 'print', {
|
,defaultToolbar: ['filter', 'exports', 'print', {
|
||||||
@ -129,17 +141,7 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
,icon: 'layui-icon-tips'
|
,icon: 'layui-icon-tips'
|
||||||
}]
|
}]
|
||||||
//,escape: false
|
//,escape: false
|
||||||
,cols: !1 ? [[ //仅用于测试
|
,cols: !1 ? test_cols : [[
|
||||||
{type: 'checkbox', fixed: 'left'}
|
|
||||||
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
|
||||||
,{field:'username', title:'用户名', width:120, edit: 'text'}
|
|
||||||
,{field:'email', title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, width:150, edit: 'text'}
|
|
||||||
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
|
||||||
,{field:'city', title:'城市', width:120}
|
|
||||||
,{field:'sign', title:'签名'}
|
|
||||||
,{field: 'experience', title: '积分', width:80, sort: true, align:'center', totalRow: '{{ d.TOTAL_NUMS }} 😊'}
|
|
||||||
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
|
|
||||||
]] : [[
|
|
||||||
{type: 'checkbox', fixed: 'left'}
|
{type: 'checkbox', 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'}
|
||||||
@ -152,15 +154,16 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
var td = obj.td(this.field); //获取当前 td
|
var td = obj.td(this.field); //获取当前 td
|
||||||
return td.find('select').val();
|
return td.find('select').val();
|
||||||
}}
|
}}
|
||||||
,{field:'sign', title:'签名', edit: 'textarea'}
|
,{field:'sign', title:'签名', minWidth: 200, style:'color: #5FB878', edit: 'textarea'}
|
||||||
,{field: 'experience', title: '积分', width:80, sort: true, align:'center', totalRow: '{{ d.TOTAL_NUMS }} 😊', templet: '<div>{{ d.experience }} 分</div>'}
|
,{field: 'experience', title: '积分', width: 100, sort: true, align:'center', totalRow: !1 || '{{= d.TOTAL_NUMS }} 分 😊', templet: '<div><a href="" class="layui-table-link">{{ d.experience }}</a> 分</div>'}
|
||||||
,{field:'ip', title:'IP', width: 120}
|
,{field:'ip', title:'IP', width: 120, align: 'right'}
|
||||||
,{field:'logins', title:'登入次数', width: 100, sort: true, totalRow: '{{ parseInt(d.TOTAL_NUMS) }} 次'}
|
,{field:'checkin', title:'打卡', width: 100, sort: true, totalRow: '{{= parseInt(d.TOTAL_NUMS) }} 次'}
|
||||||
,{field:'joinTime', title:'加入时间', width: 120}
|
,{field:'joinTime', title:'加入时间', width: 120}
|
||||||
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 180}
|
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 180}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
,initSort1: {
|
//,autoSort: false // 禁用前端自动排序
|
||||||
|
,initSort11111: { // 初始排序状态
|
||||||
field: 'experience' //排序字段,对应 cols 设定的各字段名
|
field: 'experience' //排序字段,对应 cols 设定的各字段名
|
||||||
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
||||||
}
|
}
|
||||||
@ -172,9 +175,17 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
,key: 'experience'
|
,key: 'experience'
|
||||||
,order: 'asc'
|
,order: 'asc'
|
||||||
}
|
}
|
||||||
,done: function(){
|
,done: function(res, curr, count){
|
||||||
var id = this.id;
|
var id = this.id;
|
||||||
|
|
||||||
|
// 记录当前页码
|
||||||
|
/*
|
||||||
|
layui.data('tableCache', {
|
||||||
|
key: 'curr',
|
||||||
|
value: curr
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
// 重载测试
|
// 重载测试
|
||||||
dropdown.render({
|
dropdown.render({
|
||||||
elem: '#reloadTest' //可绑定在任意元素中,此处以上述按钮为例
|
elem: '#reloadTest' //可绑定在任意元素中,此处以上述按钮为例
|
||||||
@ -326,19 +337,20 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
|
|
||||||
//排序事件
|
//排序事件
|
||||||
table.on('sort(test)', function(obj){
|
table.on('sort(test)', function(obj){
|
||||||
console.log(obj);
|
//console.log(obj);
|
||||||
|
|
||||||
return;
|
//return;
|
||||||
layer.msg('服务端排序。order by '+ obj.field + ' ' + obj.type);
|
layer.msg('服务端排序。order by '+ obj.field + ' ' + obj.type);
|
||||||
|
|
||||||
//服务端排序
|
//服务端排序
|
||||||
table.reload('test', {
|
table.reloadData('test', {
|
||||||
initSort: obj
|
//initSort: obj,
|
||||||
//,page: {curr: 1} //重新从第一页开始
|
//page: {curr: 1}, //重新从第一页开始
|
||||||
,where: { //重新请求服务端
|
where: { // 向服务端传入排序参数
|
||||||
key: obj.field //排序字段
|
key: obj.field, //排序字段
|
||||||
,order: obj.type //排序方式
|
order: obj.type //排序方式
|
||||||
}
|
}
|
||||||
}, true);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 工具栏事件
|
// 工具栏事件
|
||||||
@ -351,10 +363,6 @@ layui.use(['table', 'dropdown'], function(){
|
|||||||
var data = checkStatus.data;
|
var data = checkStatus.data;
|
||||||
layer.alert(layui.util.escape(JSON.stringify(data)));
|
layer.alert(layui.util.escape(JSON.stringify(data)));
|
||||||
break;
|
break;
|
||||||
case 'getCheckLength':
|
|
||||||
var data = checkStatus.data;
|
|
||||||
layer.msg('选中了:'+ data.length + ' 个');
|
|
||||||
break;
|
|
||||||
case 'getData':
|
case 'getData':
|
||||||
var getData = table.getData(id);
|
var getData = table.getData(id);
|
||||||
console.log(getData);
|
console.log(getData);
|
||||||
|
@ -201,6 +201,7 @@ layui.use('table', function(){
|
|||||||
//,height: 300
|
//,height: 300
|
||||||
,cellMinWidth: 80
|
,cellMinWidth: 80
|
||||||
//,skin: 'line'
|
//,skin: 'line'
|
||||||
|
//,size: 'lg'
|
||||||
,toolbar: true
|
,toolbar: true
|
||||||
,cols: [[
|
,cols: [[
|
||||||
{field: 'id', hide: true}
|
{field: 'id', hide: true}
|
||||||
@ -236,7 +237,7 @@ layui.use('table', function(){
|
|||||||
,{field: 'sex', title: '性别', width: 80}
|
,{field: 'sex', title: '性别', width: 80}
|
||||||
,{field: 'city', title: '城市', width: 100}
|
,{field: 'city', title: '城市', width: 100}
|
||||||
// ,{field: 'experience', title: '积分', width: 80, sort: true}
|
// ,{field: 'experience', title: '积分', width: 80, sort: true}
|
||||||
,{field: 'experience', title: '积分', width: 80, sort: true, totalRow: true, totalRowDecimals: 3}
|
,{field: 'experience', title: '积分', width: 80, sort: true, totalRow: '{{= parseInt(d.TOTAL_NUMS) }}'}
|
||||||
]]
|
]]
|
||||||
,data: [{
|
,data: [{
|
||||||
"id": "10001"
|
"id": "10001"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "layui",
|
"name": "layui",
|
||||||
"realname": "layui",
|
"realname": "layui",
|
||||||
"version": "2.7.0",
|
"version": "2.7.1",
|
||||||
"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",
|
||||||
|
@ -723,6 +723,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||||||
.layui-form-checkbox[lay-skin="primary"]:hover i{border-color: #5FB878; color: #fff;}
|
.layui-form-checkbox[lay-skin="primary"]:hover i{border-color: #5FB878; color: #fff;}
|
||||||
.layui-form-checked[lay-skin="primary"] i{border-color: #5FB878 !important; background-color: #5FB878; color: #fff;}
|
.layui-form-checked[lay-skin="primary"] i{border-color: #5FB878 !important; background-color: #5FB878; color: #fff;}
|
||||||
.layui-checkbox-disabled[lay-skin="primary"] span{background: none!important; color: #c2c2c2!important;}
|
.layui-checkbox-disabled[lay-skin="primary"] span{background: none!important; color: #c2c2c2!important;}
|
||||||
|
.layui-form-checked.layui-checkbox-disabled[lay-skin="primary"] i{background: #eee!important; border-color: #eee!important;}
|
||||||
.layui-checkbox-disabled[lay-skin="primary"]:hover i{border-color: #d2d2d2;}
|
.layui-checkbox-disabled[lay-skin="primary"]:hover i{border-color: #d2d2d2;}
|
||||||
.layui-form-item .layui-form-checkbox[lay-skin="primary"]{margin-top: 10px;}
|
.layui-form-item .layui-form-checkbox[lay-skin="primary"]{margin-top: 10px;}
|
||||||
|
|
||||||
@ -950,6 +951,8 @@ 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[align="center"]{-webkit-box-pack: center;}
|
||||||
|
.layui-table-cell[align="right"]{-webkit-box-pack: end;}
|
||||||
|
|
||||||
.laytable-cell-checkbox,
|
.laytable-cell-checkbox,
|
||||||
.laytable-cell-radio,
|
.laytable-cell-radio,
|
||||||
@ -991,7 +994,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||||||
.layui-table-view select[lay-ignore]{display: inline-block;}
|
.layui-table-view select[lay-ignore]{display: inline-block;}
|
||||||
.layui-table-patch .layui-table-cell{padding: 0; width: 30px;}
|
.layui-table-patch .layui-table-cell{padding: 0; width: 30px;}
|
||||||
|
|
||||||
.layui-table-edit{position: absolute; left: 0; top: 0; z-index: 900; min-width: 100%; min-height: 100%; padding: 0 14px 1px; border-radius: 0; box-shadow: 1px 1px 20px rgba(0,0,0,.15); background-color: #fff;}
|
.layui-table-edit{position: absolute; left: 0; top: 0; z-index: 900; min-width: 100%; min-height: 100%; padding: 5px 14px; border-radius: 0; box-shadow: 1px 1px 20px rgba(0,0,0,.15); background-color: #fff;}
|
||||||
.layui-table-edit:focus{border-color: #5FB878!important;}
|
.layui-table-edit:focus{border-color: #5FB878!important;}
|
||||||
select.layui-table-edit{padding: 0 0 0 10px; border-color: #d2d2d2;}
|
select.layui-table-edit{padding: 0 0 0 10px; border-color: #d2d2d2;}
|
||||||
.layui-table-view .layui-form-switch,
|
.layui-table-view .layui-form-switch,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
,Layui = function(){
|
,Layui = function(){
|
||||||
this.v = '2.7.0'; // layui 版本号
|
this.v = '2.7.1'; // layui 版本号
|
||||||
}
|
}
|
||||||
|
|
||||||
//识别预先可能定义的指定全局对象
|
//识别预先可能定义的指定全局对象
|
||||||
|
@ -20,6 +20,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
config: {
|
config: {
|
||||||
checkName: 'LAY_CHECKED' //是否选中状态的字段名
|
checkName: 'LAY_CHECKED' //是否选中状态的字段名
|
||||||
,indexName: 'LAY_TABLE_INDEX' //初始下标索引名,用于恢复排序
|
,indexName: 'LAY_TABLE_INDEX' //初始下标索引名,用于恢复排序
|
||||||
|
,disabledName: 'LAY_DISABLED'
|
||||||
} //全局配置项
|
} //全局配置项
|
||||||
,cache: {} //数据缓存
|
,cache: {} //数据缓存
|
||||||
,index: layui.table ? (layui.table.index + 10000) : 0
|
,index: layui.table ? (layui.table.index + 10000) : 0
|
||||||
@ -233,11 +234,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,' }'
|
,' }'
|
||||||
,'{{# });'
|
,'{{# });'
|
||||||
,'}); }}'
|
,'}); }}'
|
||||||
,'{{# if(d.data.lineStyle){ }}'
|
,'{{# if(d.data.lineStyle){'
|
||||||
,'.layui-table-view-{{= d.index }} .layui-table-body .layui-table .layui-table-cell{'
|
,'var cellClassName = ".layui-table-view-"+ d.index +" .layui-table-body .layui-table .layui-table-cell";'
|
||||||
,' display: -webkit-box; -webkit-box-align: center; display: -moz-box; -moz-box-align: center; white-space: normal; {{- d.data.lineStyle }} '
|
,'}}'
|
||||||
|
,'{{= cellClassName }}{'
|
||||||
|
,'display: -webkit-box; -webkit-box-align: center; white-space: normal; {{- d.data.lineStyle }} '
|
||||||
,'}'
|
,'}'
|
||||||
,'.layui-table-view-{{= d.index }} .layui-table-body .layui-table .layui-table-cell:hover{overflow: auto;}'
|
,'{{= cellClassName }}:hover{overflow: auto;}'
|
||||||
,'{{# } }}'
|
,'{{# } }}'
|
||||||
,'{{# if(d.data.css){ }}'
|
,'{{# if(d.data.css){ }}'
|
||||||
,'{{- d.data.css }}'
|
,'{{- d.data.css }}'
|
||||||
@ -429,7 +432,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
if(type === 'width') return options.clientWidth;
|
if(type === 'width') return options.clientWidth;
|
||||||
|
|
||||||
// 初始化 css 参数
|
// 初始化 css 参数
|
||||||
if(options.css){
|
if(options.css && options.css.indexOf(ELEM_VIEW) === -1){
|
||||||
var css = options.css.split('}');
|
var css = options.css.split('}');
|
||||||
layui.each(css, function(index, value){
|
layui.each(css, function(index, value){
|
||||||
if(value){
|
if(value){
|
||||||
@ -762,7 +765,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
table.cache[that.key] = []; //格式化缓存数据
|
table.cache[that.key] = []; //格式化缓存数据
|
||||||
};
|
};
|
||||||
|
|
||||||
//页码
|
// 初始页码
|
||||||
Class.prototype.page = 1;
|
Class.prototype.page = 1;
|
||||||
|
|
||||||
//获得数据
|
//获得数据
|
||||||
@ -896,7 +899,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
if(item3.templet) attr.push('data-content="'+ content +'"'); //自定义模板
|
if(item3.templet) attr.push('data-content="'+ content +'"'); //自定义模板
|
||||||
if(item3.toolbar) attr.push('data-off="true"'); //行工具列关闭单元格事件
|
if(item3.toolbar) attr.push('data-off="true"'); //行工具列关闭单元格事件
|
||||||
if(item3.event) attr.push('lay-event="'+ item3.event +'"'); //自定义事件
|
if(item3.event) attr.push('lay-event="'+ item3.event +'"'); //自定义事件
|
||||||
if(item3.style) attr.push('style="'+ item3.style +'"'); //自定义样式
|
|
||||||
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); //单元格最小宽度
|
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); //单元格最小宽度
|
||||||
return attr.join(' ');
|
return attr.join(' ');
|
||||||
}() +' class="'+ function(){ //追加样式
|
}() +' class="'+ function(){ //追加样式
|
||||||
@ -908,31 +910,52 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,'<div class="layui-table-cell laytable-cell-'+ function(){ //返回对应的CSS类标识
|
,'<div class="layui-table-cell laytable-cell-'+ function(){ //返回对应的CSS类标识
|
||||||
return item3.type === 'normal' ? key
|
return item3.type === 'normal' ? key
|
||||||
: (key + ' laytable-cell-' + item3.type);
|
: (key + ' laytable-cell-' + item3.type);
|
||||||
}() +'"'+ (item3.align ? ' align="'+ item3.align +'"' : '') +'>' + function(){
|
}() +'"'
|
||||||
|
+ (item3.align ? ' align="'+ item3.align +'"' : '')
|
||||||
|
+ function(){
|
||||||
|
var attr = [];
|
||||||
|
if(item3.style) attr.push('style="'+ item3.style +'"'); //自定义单元格样式
|
||||||
|
return attr.join(' ');
|
||||||
|
}() +'>'
|
||||||
|
+ function(){
|
||||||
var tplData = $.extend(true, {
|
var tplData = $.extend(true, {
|
||||||
LAY_INDEX: numbers
|
LAY_INDEX: numbers
|
||||||
,LAY_COL: item3
|
,LAY_COL: item3
|
||||||
}, item1)
|
}, item1)
|
||||||
,checkName = table.config.checkName;
|
,checkName = table.config.checkName
|
||||||
|
,disabledName = table.config.disabledName;
|
||||||
|
|
||||||
//渲染不同风格的列
|
//渲染不同风格的列
|
||||||
switch(item3.type){
|
switch(item3.type){
|
||||||
case 'checkbox':
|
case 'checkbox': // 复选
|
||||||
return '<input type="checkbox" name="layTableCheckbox" lay-skin="primary" '+ function(){
|
return '<input type="checkbox" name="layTableCheckbox" lay-skin="primary" '+ function(){
|
||||||
|
// 其他属性
|
||||||
|
var arr = [];
|
||||||
|
|
||||||
//如果是全选
|
//如果是全选
|
||||||
if(item3[checkName]){
|
if(item3[checkName]){
|
||||||
item1[checkName] = item3[checkName];
|
item1[checkName] = item3[checkName];
|
||||||
return item3[checkName] ? 'checked' : '';
|
if(item3[checkName]) arr[0] = 'checked';
|
||||||
}
|
}
|
||||||
return tplData[checkName] ? 'checked' : '';
|
if(tplData[checkName]) arr[0] = 'checked';
|
||||||
|
|
||||||
|
// 禁选
|
||||||
|
if(tplData[disabledName]) arr.push('disabled');
|
||||||
|
|
||||||
|
return arr.join(' ');
|
||||||
}() +'>';
|
}() +'>';
|
||||||
break;
|
break;
|
||||||
case 'radio':
|
case 'radio': // 单选
|
||||||
if(tplData[checkName]){
|
if(tplData[checkName]){
|
||||||
thisCheckedRowIndex = i1;
|
thisCheckedRowIndex = i1;
|
||||||
}
|
}
|
||||||
return '<input type="radio" name="layTableRadio_'+ options.index +'" '
|
return '<input type="radio" name="layTableRadio_'+ options.index +'" '
|
||||||
+ (tplData[checkName] ? 'checked' : '') +' lay-type="layTableRadio">';
|
+ function(){
|
||||||
|
var arr = [];
|
||||||
|
if(tplData[checkName]) arr[0] = 'checked';
|
||||||
|
if(tplData[disabledName]) arr.push('disabled');
|
||||||
|
return arr.join(' ');
|
||||||
|
}() +' lay-type="layTableRadio">';
|
||||||
break;
|
break;
|
||||||
case 'numbers':
|
case 'numbers':
|
||||||
return numbers;
|
return numbers;
|
||||||
@ -961,7 +984,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
trs_fixed_r.push('<tr data-index="'+ i1 +'">'+ tds_fixed_r.join('') + '</tr>');
|
trs_fixed_r.push('<tr data-index="'+ i1 +'">'+ tds_fixed_r.join('') + '</tr>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 容器的滚动条位置复位
|
||||||
that.layBody.scrollTop(0);
|
that.layBody.scrollTop(0);
|
||||||
|
if(options.resetScrollbar){
|
||||||
|
that.layBody.scrollLeft(0);
|
||||||
|
}
|
||||||
|
|
||||||
that.layMain.find('.'+ NONE).remove();
|
that.layMain.find('.'+ NONE).remove();
|
||||||
that.layMain.find('tbody').html(trs.join(''));
|
that.layMain.find('tbody').html(trs.join(''));
|
||||||
that.layFixLeft.find('tbody').html(trs_fixed.join(''));
|
that.layFixLeft.find('tbody').html(trs_fixed.join(''));
|
||||||
@ -1077,7 +1105,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
//td 内容
|
//td 内容
|
||||||
var content = function(){
|
var content = function(){
|
||||||
var text = item3.totalRowText || ''
|
var text = item3.totalRowText || ''
|
||||||
,decimals = item3.totalRowDecimals || 2
|
,decimals = 'totalRowDecimals' in item3 ? item3.totalRowDecimals : 2
|
||||||
,thisTotalNum = parseFloat(totalNums[field]).toFixed(decimals)
|
,thisTotalNum = parseFloat(totalNums[field]).toFixed(decimals)
|
||||||
,tplData = {}
|
,tplData = {}
|
||||||
,getContent;
|
,getContent;
|
||||||
@ -1097,7 +1125,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,td = ['<td data-field="'+ field +'" data-key="'+ options.index + '-'+ item3.key +'" '+ function(){
|
,td = ['<td data-field="'+ field +'" data-key="'+ options.index + '-'+ item3.key +'" '+ function(){
|
||||||
var attr = [];
|
var attr = [];
|
||||||
if(item3.align) attr.push('align="'+ item3.align +'"'); //对齐方式
|
if(item3.align) attr.push('align="'+ item3.align +'"'); //对齐方式
|
||||||
if(item3.style) attr.push('style="'+ item3.style +'"'); //自定义样式
|
|
||||||
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); //单元格最小宽度
|
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); //单元格最小宽度
|
||||||
return attr.join(' ');
|
return attr.join(' ');
|
||||||
}() +' class="'+ function(){ //追加样式
|
}() +' class="'+ function(){ //追加样式
|
||||||
@ -1110,13 +1137,18 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
var str = (options.index + '-' + item3.key);
|
var str = (options.index + '-' + item3.key);
|
||||||
return item3.type === 'normal' ? str
|
return item3.type === 'normal' ? str
|
||||||
: (str + ' laytable-cell-' + item3.type);
|
: (str + ' laytable-cell-' + item3.type);
|
||||||
}() +'">' + function(){
|
}() +'"'+ function(){
|
||||||
|
var attr = [];
|
||||||
|
if(item3.style) attr.push('style="'+ item3.style +'"'); //自定义单元格样式
|
||||||
|
return attr.join(' ');
|
||||||
|
}() +'>' + function(){
|
||||||
var totalRow = item3.totalRow || options.totalRow;
|
var totalRow = item3.totalRow || options.totalRow;
|
||||||
|
|
||||||
//如果 totalRow 参数为字符类型,则解析为自定义模版
|
//如果 totalRow 参数为字符类型,则解析为自定义模版
|
||||||
if(typeof totalRow === 'string'){
|
if(typeof totalRow === 'string'){
|
||||||
return laytpl(totalRow).render($.extend({
|
return laytpl(totalRow).render($.extend({
|
||||||
TOTAL_NUMS: content
|
TOTAL_NUMS: totalNums[field]
|
||||||
}, item3))
|
}, item3));
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
}()
|
}()
|
||||||
@ -1218,10 +1250,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
that.renderData(res, that.page, that.count, true);
|
that.renderData(res, that.page, that.count, true);
|
||||||
|
|
||||||
if(formEvent){
|
if(formEvent){
|
||||||
layui.event.call(th, MOD_NAME, 'sort('+ filter +')', {
|
options.initSort = {
|
||||||
field: field
|
field: field
|
||||||
,type: type
|
,type: type
|
||||||
});
|
};
|
||||||
|
layui.event.call(th, MOD_NAME, 'sort('+ filter +')', options.initSort);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1253,7 +1286,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
thisData[index][options.checkName] = checked;
|
thisData[index][options.checkName] = checked;
|
||||||
};
|
};
|
||||||
|
|
||||||
//同步全选按钮状态
|
// 同步全选按钮状态
|
||||||
Class.prototype.syncCheckAll = function(){
|
Class.prototype.syncCheckAll = function(){
|
||||||
var that = this
|
var that = this
|
||||||
,options = that.config
|
,options = that.config
|
||||||
@ -1683,6 +1716,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,checked = checkbox[0].checked
|
,checked = checkbox[0].checked
|
||||||
,isAll = checkbox.attr('lay-filter') === 'layTableAllChoose';
|
,isAll = checkbox.attr('lay-filter') === 'layTableAllChoose';
|
||||||
|
|
||||||
|
if(checkbox[0].disabled) return;
|
||||||
|
|
||||||
//全选
|
//全选
|
||||||
if(isAll){
|
if(isAll){
|
||||||
childs.each(function(i, item){
|
childs.each(function(i, item){
|
||||||
@ -1696,10 +1731,15 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
that.syncCheckAll();
|
that.syncCheckAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
layui.event.call(checkbox[0], MOD_NAME, 'checkbox('+ filter +')', commonMember.call(checkbox[0], {
|
// 事件
|
||||||
checked: checked
|
layui.event.call(
|
||||||
,type: isAll ? 'all' : 'one'
|
checkbox[0],
|
||||||
}));
|
MOD_NAME, 'checkbox('+ filter +')',
|
||||||
|
commonMember.call(checkbox[0], {
|
||||||
|
checked: checked,
|
||||||
|
type: isAll ? 'all' : 'one'
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
//单选框选择
|
//单选框选择
|
||||||
@ -2067,6 +2107,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,invalidNum = 0
|
,invalidNum = 0
|
||||||
,arr = []
|
,arr = []
|
||||||
,data = table.cache[id] || [];
|
,data = table.cache[id] || [];
|
||||||
|
|
||||||
//计算全选个数
|
//计算全选个数
|
||||||
layui.each(data, function(i, item){
|
layui.each(data, function(i, item){
|
||||||
if(layui.type(item) === 'array'){
|
if(layui.type(item) === 'array'){
|
||||||
@ -2075,8 +2116,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
}
|
}
|
||||||
if(item[table.config.checkName]){
|
if(item[table.config.checkName]){
|
||||||
nums++;
|
nums++;
|
||||||
|
if(!item[table.config.disabledName]){
|
||||||
arr.push(table.clearCacheKey(item));
|
arr.push(table.clearCacheKey(item));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
data: arr //选中的数据
|
data: arr //选中的数据
|
||||||
@ -2236,6 +2279,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
data = $.extend({}, data);
|
data = $.extend({}, data);
|
||||||
delete data[table.config.checkName];
|
delete data[table.config.checkName];
|
||||||
delete data[table.config.indexName];
|
delete data[table.config.indexName];
|
||||||
|
delete data[table.config.disabledName];
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user