Compare commits
10 Commits
2458e523ba
...
bagdata-sc
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ea9d9e4da | |||
| b6c6d19d96 | |||
| f4fe3db2b8 | |||
| c3ac588bdb | |||
| 526d1cbec1 | |||
| 5e10d720e6 | |||
| 4f40e560bb | |||
| bc8d400b01 | |||
| 6a0e0fd6b1 | |||
| 096ee2fc96 |
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"svn.ignoreMissingSvnWarning": true
|
||||||
|
}
|
||||||
31
README.md
31
README.md
@@ -73,3 +73,34 @@ layui 原官网已于2021年10月13日下线。详见:
|
|||||||
|
|
||||||
鉴于 Layui 相对庞大的受众群体,从此 Github 和 Gitee 平台将支撑起 Layui 的后续。<br>
|
鉴于 Layui 相对庞大的受众群体,从此 Github 和 Gitee 平台将支撑起 Layui 的后续。<br>
|
||||||
**Layui 将继续陪伴着所有为之热爱的人们,共同去探索和论证「Layui 开发模式的可行性」**
|
**Layui 将继续陪伴着所有为之热爱的人们,共同去探索和论证「Layui 开发模式的可行性」**
|
||||||
|
|
||||||
|
## 维护修改问题
|
||||||
|
|
||||||
|
1. table排序后多选无法选中
|
||||||
|
2. table合计将统计所有数据而不是当前页
|
||||||
|
3. longing修改动画效果
|
||||||
|
4. 修改结合soultable重载后高度问题
|
||||||
|
5. 修正table窗口变更大小可能出现内存泄漏问题
|
||||||
|
|
||||||
|
## 维护增加功能
|
||||||
|
|
||||||
|
1. table 增加`getData()`函数,方便获取当前table所有数据,包括行内输入之后的值
|
||||||
|
2. table 增加`onColumnsWidth()`函数,可以让table列宽手动调整后返回调整后的cols,方便保存手动调整后的状态
|
||||||
|
3. table 增加`sortCallback`属性,用于排序后回调函数,方便获取排序后处理下拉等
|
||||||
|
|
||||||
|
## 使用示例
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// getData()
|
||||||
|
layui.table.getData('tableId')
|
||||||
|
// onColumnsWidth
|
||||||
|
let tab = table.render(config)
|
||||||
|
tab.onColumnsWidth(callback)
|
||||||
|
// 视情况添加layui.table.onColumnsWidth 暂时没有用到
|
||||||
|
|
||||||
|
table.render({
|
||||||
|
...,
|
||||||
|
sortCallback: function (res, curr, count) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|||||||
BIN
dist/css/modules/layer/default/icon.png
vendored
BIN
dist/css/modules/layer/default/icon.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
24722
dist/layui.js
vendored
Normal file
24722
dist/layui.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -12,21 +12,23 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/layui/layui/",
|
"homepage": "https://github.com/layui/layui/",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"del": "^2.2.2",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-uglify": "^3.0.2",
|
|
||||||
"gulp-clean-css": "^4.3.0",
|
"gulp-clean-css": "^4.3.0",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-replace": "^1.1.3",
|
|
||||||
"gulp-rename": "^2.0.0",
|
|
||||||
"gulp-header": "^2.0.9",
|
|
||||||
"gulp-footer": "^2.1.0",
|
"gulp-footer": "^2.1.0",
|
||||||
"del": "^2.2.2",
|
"gulp-header": "^2.0.9",
|
||||||
|
"gulp-rename": "^2.0.0",
|
||||||
|
"gulp-replace": "^1.1.3",
|
||||||
|
"gulp-uglify": "^3.0.2",
|
||||||
"minimist": "^1.2.5"
|
"minimist": "^1.2.5"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitee.com/sentsin/layui/issues"
|
"url": "https://gitee.com/sentsin/layui/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"layui": "file:"
|
||||||
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"layui",
|
"layui",
|
||||||
"ui",
|
"ui",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
87
src/layui.js
87
src/layui.js
@@ -701,6 +701,93 @@
|
|||||||
desc && clone.reverse(); // 倒序
|
desc && clone.reverse(); // 倒序
|
||||||
return clone;
|
return clone;
|
||||||
};
|
};
|
||||||
|
// 不复制 将数组中的成员对象按照某个 key 的 value 值进行排序
|
||||||
|
Layui.prototype.thissort = function(arr, key, desc){
|
||||||
|
var that = this
|
||||||
|
,clone = (arr || []);
|
||||||
|
|
||||||
|
// 若未传入 key,则直接返回原对象
|
||||||
|
if(that.type(arr) === 'object' && !key){
|
||||||
|
return clone;
|
||||||
|
} else if(typeof arr !== 'object'){ //若 arr 非对象
|
||||||
|
return [clone];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始排序
|
||||||
|
clone.sort(function(o1, o2){
|
||||||
|
var v1 = o1[key]
|
||||||
|
,v2 = o2[key];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 特殊数据
|
||||||
|
* 若比较的成员均非对象
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 若比较的成员均为数字
|
||||||
|
if(!isNaN(o1) && !isNaN(o2)) return o1 - o2;
|
||||||
|
// 若比较的成员只存在某一个非对象
|
||||||
|
if(!isNaN(o1) && isNaN(o2)){
|
||||||
|
if(key && typeof o2 === 'object'){
|
||||||
|
v1 = o1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (isNaN(o1) && !isNaN(o2)){
|
||||||
|
if(key && typeof o1 === 'object'){
|
||||||
|
v2 = o2;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 正常数据
|
||||||
|
* 即成员均为对象,也传入了对比依据: key
|
||||||
|
* 若 value 为数字,按「大小」排序;若 value 非数字,则按「字典序」排序
|
||||||
|
*/
|
||||||
|
|
||||||
|
// value 是否为数字
|
||||||
|
var isNum = [!isNaN(v1), !isNaN(v2)];
|
||||||
|
|
||||||
|
// 若为数字比较
|
||||||
|
if(isNum[0] && isNum[1]){
|
||||||
|
if(v1 && (!v2 && v2 !== 0)){ //数字 vs 空
|
||||||
|
return 1;
|
||||||
|
} else if((!v1 && v1 !== 0) && v2){ //空 vs 数字
|
||||||
|
return -1;
|
||||||
|
} else { //数字 vs 数字
|
||||||
|
return v1 - v2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典序排序
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 若为非数字比较
|
||||||
|
if(!isNum[0] && !isNum[1]){
|
||||||
|
// 字典序比较
|
||||||
|
if(v1 > v2){
|
||||||
|
return 1;
|
||||||
|
} else if (v1 < v2) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 若为混合比较
|
||||||
|
if(isNum[0] || !isNum[1]){ //数字 vs 非数字
|
||||||
|
return -1;
|
||||||
|
} else if(!isNum[0] || isNum[1]) { //非数字 vs 数字
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
desc && clone.reverse(); // 倒序
|
||||||
|
return clone;
|
||||||
|
};
|
||||||
|
|
||||||
//阻止事件冒泡
|
//阻止事件冒泡
|
||||||
Layui.prototype.stope = function(thisEvent){
|
Layui.prototype.stope = function(thisEvent){
|
||||||
|
|||||||
@@ -450,7 +450,12 @@ layui.define('layer', function(exports){
|
|||||||
hideDown(true);
|
hideDown(true);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
dds.on('mousedown',(events)=>{
|
||||||
|
events.stopPropagation()
|
||||||
|
});
|
||||||
|
dds.on('mouseup',(events)=>{
|
||||||
|
events.stopPropagation()
|
||||||
|
});
|
||||||
reElem.find('dl>dt').on('click', function(e){
|
reElem.find('dl>dt').on('click', function(e){
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ var Class = function(setings){
|
|||||||
var that = this, creat = function(){
|
var that = this, creat = function(){
|
||||||
that.creat();
|
that.creat();
|
||||||
};
|
};
|
||||||
|
that.yesStatus = true
|
||||||
that.index = ++layer.index;
|
that.index = ++layer.index;
|
||||||
that.config.maxWidth = $(win).width() - 15*2; //初始最大宽度:当前屏幕宽,左右留 15px 边距
|
that.config.maxWidth = $(win).width() - 15*2; //初始最大宽度:当前屏幕宽,左右留 15px 边距
|
||||||
that.config = $.extend({}, that.config, ready.config, setings);
|
that.config = $.extend({}, that.config, ready.config, setings);
|
||||||
@@ -683,11 +684,21 @@ Class.pt.callback = function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer.ie == 6 && that.IE6(layero);
|
layer.ie == 6 && that.IE6(layero);
|
||||||
|
// 节流函数
|
||||||
|
|
||||||
//按钮
|
//按钮
|
||||||
|
// 按钮的事件在这里
|
||||||
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
||||||
var index = $(this).index();
|
var index = $(this).index();
|
||||||
if(index === 0){
|
if(index === 0){
|
||||||
|
if(that.yesStatus){
|
||||||
|
that.yesStatus = false
|
||||||
|
setTimeout(()=>{
|
||||||
|
that.yesStatus = true
|
||||||
|
},1000)
|
||||||
|
}else{
|
||||||
|
return
|
||||||
|
}
|
||||||
if(config.yes){
|
if(config.yes){
|
||||||
config.yes(that.index, layero)
|
config.yes(that.index, layero)
|
||||||
} else if(config['btn1']){
|
} else if(config['btn1']){
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ layui.define('jquery', function(exports){
|
|||||||
,options = that.config;
|
,options = that.config;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setValue: function(value, index){ //设置值
|
setValue: function(value, index,s){ //设置值
|
||||||
options.value = value;
|
options.value = value;
|
||||||
return that.slide('set', value, index || 0);
|
return that.slide('set', value, index || 0,s);
|
||||||
}
|
}
|
||||||
,config: options
|
,config: options
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,7 @@ layui.define('jquery', function(exports){
|
|||||||
that.index = ++slider.index;
|
that.index = ++slider.index;
|
||||||
that.config = $.extend({}, that.config, slider.config, options);
|
that.config = $.extend({}, that.config, slider.config, options);
|
||||||
that.render();
|
that.render();
|
||||||
|
that.anxia = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
//默认配置
|
//默认配置
|
||||||
@@ -206,7 +207,7 @@ layui.define('jquery', function(exports){
|
|||||||
};
|
};
|
||||||
|
|
||||||
//滑块滑动
|
//滑块滑动
|
||||||
Class.prototype.slide = function(setValue, value, i){
|
Class.prototype.slide = function(setValue, value, i,s){
|
||||||
var that = this
|
var that = this
|
||||||
,options = that.config
|
,options = that.config
|
||||||
,sliderAct = that.elemTemp
|
,sliderAct = that.elemTemp
|
||||||
@@ -217,7 +218,7 @@ layui.define('jquery', function(exports){
|
|||||||
,sliderTxt = sliderAct.next('.' + SLIDER_INPUT)
|
,sliderTxt = sliderAct.next('.' + SLIDER_INPUT)
|
||||||
,inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val()
|
,inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val()
|
||||||
,step = 100 / ((options.max - options.min) / Math.ceil(options.step))
|
,step = 100 / ((options.max - options.min) / Math.ceil(options.step))
|
||||||
,change = function(offsetValue, index){
|
,change = function(offsetValue, index,s){
|
||||||
if(Math.ceil(offsetValue) * step > 100){
|
if(Math.ceil(offsetValue) * step > 100){
|
||||||
offsetValue = Math.ceil(offsetValue) * step
|
offsetValue = Math.ceil(offsetValue) * step
|
||||||
}else{
|
}else{
|
||||||
@@ -259,7 +260,7 @@ layui.define('jquery', function(exports){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//回调
|
//回调
|
||||||
options.change && options.change(options.range ? arrValue : selfValue);
|
options.change && options.change(options.range ? arrValue : selfValue,selfValue,s);
|
||||||
}
|
}
|
||||||
,valueTo = function(value){
|
,valueTo = function(value){
|
||||||
var oldLeft = value / sliderWidth() * 100 / step
|
var oldLeft = value / sliderWidth() * 100 / step
|
||||||
@@ -283,7 +284,7 @@ layui.define('jquery', function(exports){
|
|||||||
};
|
};
|
||||||
|
|
||||||
//动态赋值
|
//动态赋值
|
||||||
if(setValue === 'set') return change(value, i);
|
if(setValue === 'set') return change(value, i,s);
|
||||||
|
|
||||||
//滑块滑动
|
//滑块滑动
|
||||||
sliderAct.find('.' + SLIDER_WRAP_BTN).each(function(index){
|
sliderAct.find('.' + SLIDER_WRAP_BTN).each(function(index){
|
||||||
@@ -304,7 +305,7 @@ layui.define('jquery', function(exports){
|
|||||||
if(left < 0)left = 0;
|
if(left < 0)left = 0;
|
||||||
if(left > sliderWidth())left = sliderWidth();
|
if(left > sliderWidth())left = sliderWidth();
|
||||||
var reaLeft = left / sliderWidth() * 100 / step;
|
var reaLeft = left / sliderWidth() * 100 / step;
|
||||||
change(reaLeft, index);
|
change(reaLeft, index,2);
|
||||||
othis.addClass(ELEM_HOVER);
|
othis.addClass(ELEM_HOVER);
|
||||||
sliderAct.find('.' + SLIDER_TIPS).show();
|
sliderAct.find('.' + SLIDER_TIPS).show();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -336,11 +337,46 @@ layui.define('jquery', function(exports){
|
|||||||
}else{
|
}else{
|
||||||
index = 0;
|
index = 0;
|
||||||
};
|
};
|
||||||
change(reaLeft, index);
|
// console.log(reaLeft,left,step)
|
||||||
|
change(reaLeft, index,true);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// 拖动滑块
|
||||||
|
sliderAct.find('.' + SLIDER_BAR).on("mousemove",function (e){
|
||||||
|
if(!that.anxia){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
var main = $('.' + SLIDER_WRAP_BTN);
|
||||||
|
if(!main.is(event.target) && main.has(event.target).length === 0 && main.length){
|
||||||
|
var left = options.type === 'vertical' ? (sliderWidth() - e.clientY + $(this).offset().top):(e.clientX - $(this).offset().left), index;
|
||||||
|
if(left < 0)left = 0;
|
||||||
|
if(left > sliderWidth())left = sliderWidth();
|
||||||
|
var reaLeft = left / sliderWidth() * 100 / step;
|
||||||
|
if(options.range){
|
||||||
|
if(options.type === 'vertical'){
|
||||||
|
index = Math.abs(left - parseInt($(sliderWrap[0]).css('bottom'))) > Math.abs(left - parseInt($(sliderWrap[1]).css('bottom'))) ? 1 : 0;
|
||||||
|
}else{
|
||||||
|
index = Math.abs(left - sliderWrap[0].offsetLeft) > Math.abs(left - sliderWrap[1].offsetLeft) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
index = 0;
|
||||||
|
};
|
||||||
|
console.log(reaLeft,left,step)
|
||||||
|
change(reaLeft, index);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
sliderAct.find('.' + SLIDER_BAR).on("mousedown",function (){
|
||||||
|
that.anxia = true
|
||||||
|
})
|
||||||
|
sliderAct.find('.' + SLIDER_BAR).on("mouseup",function (){
|
||||||
|
that.anxia = false
|
||||||
|
})
|
||||||
|
sliderAct.find('.' + SLIDER_BAR).on("click",function (e){
|
||||||
|
e.preventDefault();
|
||||||
|
})
|
||||||
//点击加减输入框
|
//点击加减输入框
|
||||||
sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){
|
sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){
|
||||||
$(this).on('click', function(){
|
$(this).on('click', function(){
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,disabledName: 'LAY_DISABLED'
|
,disabledName: 'LAY_DISABLED'
|
||||||
} //全局配置项
|
} //全局配置项
|
||||||
,cache: {} //数据缓存
|
,cache: {} //数据缓存
|
||||||
|
,allData:[] // 全部数据
|
||||||
,index: layui.table ? (layui.table.index + 10000) : 0
|
,index: layui.table ? (layui.table.index + 10000) : 0
|
||||||
|
,winResiz:[]
|
||||||
//设置全局项
|
//设置全局项
|
||||||
,set: function(options){
|
,set: function(options){
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -43,7 +44,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
var that = this
|
var that = this
|
||||||
,options = that.config
|
,options = that.config
|
||||||
,id = options.id || options.index;
|
,id = options.id || options.index;
|
||||||
|
|
||||||
if(id){
|
if(id){
|
||||||
thisTable.that[id] = that; //记录当前实例对象
|
thisTable.that[id] = that; //记录当前实例对象
|
||||||
thisTable.config[id] = options; //记录当前实例配置项
|
thisTable.config[id] = options; //记录当前实例配置项
|
||||||
@@ -62,6 +62,17 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
}
|
}
|
||||||
,resize: function(){ //重置表格尺寸/结构
|
,resize: function(){ //重置表格尺寸/结构
|
||||||
that.resize.call(that);
|
that.resize.call(that);
|
||||||
|
},
|
||||||
|
getData: function(){
|
||||||
|
// return JSON.parse(JSON.stringify(that.config.data))
|
||||||
|
return that.config.data
|
||||||
|
},
|
||||||
|
mergeData:function(id,data,index){
|
||||||
|
table.mergeData(id,data,index)
|
||||||
|
},
|
||||||
|
// 设置列宽调整后的回调
|
||||||
|
onColumnsWidth: function(fun){
|
||||||
|
that.config.onColumnsWidth = fun;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +264,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
|
|
||||||
//构造器
|
//构造器
|
||||||
,Class = function(options){
|
,Class = function(options){
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
that.reanderTime = new Date().getTime()
|
||||||
that.index = ++table.index;
|
that.index = ++table.index;
|
||||||
that.config = $.extend({}, that.config, table.config, options);
|
that.config = $.extend({}, that.config, table.config, options);
|
||||||
that.render();
|
that.render();
|
||||||
@@ -268,6 +281,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
,editTrigger: 'click' //单元格编辑的事件触发方式
|
,editTrigger: 'click' //单元格编辑的事件触发方式
|
||||||
,defaultToolbar: ['filter', 'exports', 'print'] //工具栏右侧图标
|
,defaultToolbar: ['filter', 'exports', 'print'] //工具栏右侧图标
|
||||||
,autoSort: true //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
|
,autoSort: true //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
|
||||||
|
,sortCallback:function(){}
|
||||||
,text: {
|
,text: {
|
||||||
none: '无数据'
|
none: '无数据'
|
||||||
}
|
}
|
||||||
@@ -350,7 +364,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
|
|
||||||
options.index = that.index;
|
options.index = that.index;
|
||||||
that.key = options.id || options.index;
|
that.key = options.id || options.index;
|
||||||
|
table.allData[that.key] = options.data
|
||||||
|
|
||||||
|
// 添加到全局渲染中,为了全局resize防止内存泄漏
|
||||||
|
table.winResiz[that.key] = that
|
||||||
//生成替代元素
|
//生成替代元素
|
||||||
hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender
|
hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender
|
||||||
othis.after(reElem);
|
othis.after(reElem);
|
||||||
@@ -739,7 +756,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
|
|
||||||
//对参数进行深度或浅扩展
|
//对参数进行深度或浅扩展
|
||||||
that.config = $.extend(deep, {}, that.config, options);
|
that.config = $.extend(deep, {}, that.config, options);
|
||||||
|
table.allData[that.key] = that.config.data
|
||||||
//执行渲染
|
//执行渲染
|
||||||
that.render(type);
|
that.render(type);
|
||||||
};
|
};
|
||||||
@@ -1012,6 +1029,14 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
//同步表头父列的相关值
|
//同步表头父列的相关值
|
||||||
options.HAS_SET_COLS_PATCH || that.setColsPatch();
|
options.HAS_SET_COLS_PATCH || that.setColsPatch();
|
||||||
options.HAS_SET_COLS_PATCH = true;
|
options.HAS_SET_COLS_PATCH = true;
|
||||||
|
// 判断是否需要执行排序回调
|
||||||
|
if(sort){
|
||||||
|
try{
|
||||||
|
that.config.sortCallback.call(that.config,res, curr, count, sort)
|
||||||
|
}catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
table.cache[that.key] = data; //记录数据
|
table.cache[that.key] = data; //记录数据
|
||||||
@@ -1041,6 +1066,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
|
|
||||||
//如果执行初始排序
|
//如果执行初始排序
|
||||||
if(sort){
|
if(sort){
|
||||||
|
|
||||||
return render();
|
return render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,18 +1266,18 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
//默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
|
//默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
|
||||||
if(options.autoSort){
|
if(options.autoSort){
|
||||||
if(type === 'asc'){ //升序
|
if(type === 'asc'){ //升序
|
||||||
thisData = layui.sort(data, field);
|
thisData = layui.thissort(data, field);
|
||||||
} else if(type === 'desc'){ //降序
|
} else if(type === 'desc'){ //降序
|
||||||
thisData = layui.sort(data, field, true);
|
thisData = layui.thissort(data, field, true);
|
||||||
} else { //清除排序
|
} else { //清除排序
|
||||||
thisData = layui.sort(data, table.config.indexName);
|
thisData = layui.thissort(data, table.config.indexName);
|
||||||
delete that.sortKey;
|
delete that.sortKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res[options.response.dataName] = thisData || data;
|
res[options.response.dataName] = thisData || data;
|
||||||
that.renderData(res, that.page, that.count, true);
|
that.renderData(res, that.page, that.count, true);
|
||||||
|
// table.cache[that.key] = thisData
|
||||||
if(formEvent){
|
if(formEvent){
|
||||||
options.initSort = {
|
options.initSort = {
|
||||||
field: field
|
field: field
|
||||||
@@ -1259,6 +1285,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
};
|
};
|
||||||
layui.event.call(th, MOD_NAME, 'sort('+ filter +')', options.initSort);
|
layui.event.call(th, MOD_NAME, 'sort('+ filter +')', options.initSort);
|
||||||
}
|
}
|
||||||
|
// if(this)
|
||||||
|
this.config.afterSort && this.config.afterSort()
|
||||||
};
|
};
|
||||||
|
|
||||||
//请求loading
|
//请求loading
|
||||||
@@ -1365,16 +1393,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
bodyHeight -= (that.layPage.outerHeight() || 41);
|
bodyHeight -= (that.layPage.outerHeight() || 41);
|
||||||
}
|
}
|
||||||
// 减去筛选插件高度
|
// 减去筛选插件高度
|
||||||
// console.log(this.layBorderBox.find(".soul-bottom-contion"))
|
|
||||||
if(this.layBorderBox.find(".soul-bottom-contion")[0]){
|
if(this.layBorderBox.find(".soul-bottom-contion")[0]){
|
||||||
bodyHeight -= (this.layBorderBox.find(".soul-bottom-contion")[0].offsetHeight || 31);
|
bodyHeight -= (this.layBorderBox.find(".soul-bottom-contion")[0].offsetHeight || 31);
|
||||||
}
|
}
|
||||||
console.log(bodyHeight,"bodyHeight")
|
|
||||||
let h = bodyHeight - 2 - parseFloat(that.layMain.css('height'));
|
let h = bodyHeight - 2 - parseFloat(that.layMain.css('height'));
|
||||||
// console.log(h)
|
|
||||||
// that.layBody.css("height", parseFloat(that.layBody.css("height")) + h);
|
// that.layBody.css("height", parseFloat(that.layBody.css("height")) + h);
|
||||||
// that.layBorderBox.css("height", parseFloat(that.layBorderBox.css("height")) + h);
|
// that.layBorderBox.css("height", parseFloat(that.layBorderBox.css("height")) + h);
|
||||||
console.log(this.config)
|
|
||||||
|
|
||||||
that.layMain.css('height', bodyHeight - 2);
|
that.layMain.css('height', bodyHeight - 2);
|
||||||
};
|
};
|
||||||
@@ -1605,12 +1629,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dict.resizeStart = true; //开始拖拽
|
dict.resizeStart = true; //开始拖拽
|
||||||
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
|
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
|
||||||
|
|
||||||
that.getCssRule(key, function(item){
|
that.getCssRule(key, function(item){
|
||||||
var width = item.style.width || othis.outerWidth();
|
var width = item.style.width || othis.outerWidth();
|
||||||
dict.rule = item;
|
dict.rule = item;
|
||||||
dict.ruleWidth = parseFloat(width);
|
dict.ruleWidth = parseFloat(width);
|
||||||
dict.minWidth = othis.data('minwidth') || options.cellMinWidth;
|
dict.minWidth = othis.data('minwidth') || options.cellMinWidth;
|
||||||
|
dict.target = othis[0]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1629,6 +1653,16 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
}
|
}
|
||||||
}).on('mouseup', function(e){
|
}).on('mouseup', function(e){
|
||||||
if(dict.resizeStart){
|
if(dict.resizeStart){
|
||||||
|
// 处理宽度
|
||||||
|
for(let j of that.config.cols){
|
||||||
|
for(let i of j){
|
||||||
|
if(i.field == dict.target.dataset.field){
|
||||||
|
i.width = dict.target.clientWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that.config.onColumnsWidth && that.config.onColumnsWidth(that.config.cols)
|
||||||
|
if (layui.soulTable) { layui.soulTable.fixTableRemember(that.config, dict) } //拖动列宽 记忆开启
|
||||||
dict = {};
|
dict = {};
|
||||||
_BODY.css('cursor', '');
|
_BODY.css('cursor', '');
|
||||||
that.scrollPatch();
|
that.scrollPatch();
|
||||||
@@ -1965,10 +1999,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
layer.close(that.tipsIndex);
|
layer.close(that.tipsIndex);
|
||||||
});
|
});
|
||||||
|
|
||||||
//自适应
|
// //自适应
|
||||||
_WIN.on('resize', function(){
|
// _WIN.on('resize', function(){
|
||||||
that.resize();
|
// that.resize();
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
//一次性事件
|
//一次性事件
|
||||||
@@ -2282,6 +2316,50 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
return table.reload.apply(null, args);
|
return table.reload.apply(null, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 仅仅合并数据
|
||||||
|
table.mergeData = function(id,data,index){
|
||||||
|
var config = getThisTableConfig(id); //获取当前实例配置项
|
||||||
|
if(!config) return;
|
||||||
|
var that = thisTable.that[id];
|
||||||
|
let arr = []
|
||||||
|
for(let i in data){
|
||||||
|
if(table.cache[that.key][i]){
|
||||||
|
arr.push({...table.cache[that.key][i],...data[i]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let tr = $(that.layMain).find(`tr[data-index=${index}]`)
|
||||||
|
layui.each(data[index], function(key, value){
|
||||||
|
var td = tr.children('td[data-field="'+ key +'"]')
|
||||||
|
,cell = td.children('.layui-table-cell'); //获取当前修改的列
|
||||||
|
let d = data[index]
|
||||||
|
//更新缓存中的数据
|
||||||
|
that.eachCols(function(i, item3){
|
||||||
|
//更新相应列视图
|
||||||
|
if(item3.field == key){
|
||||||
|
cell.html(parseTempData.call(that, {
|
||||||
|
item3: item3
|
||||||
|
,content: value
|
||||||
|
,tplData: d
|
||||||
|
}));
|
||||||
|
td.data('content', value);
|
||||||
|
} else if(item3.templet || item3.toolbar){ //更新所有其他列的模板
|
||||||
|
var thisTd = tr.children('td[data-field="'+ (item3.field || i) +'"]')
|
||||||
|
,content = d[item3.field];
|
||||||
|
thisTd.children('.layui-table-cell').html(parseTempData.call(that, {
|
||||||
|
item3: item3
|
||||||
|
,content: content
|
||||||
|
,tplData: d
|
||||||
|
}));
|
||||||
|
thisTd.data('content', content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
table.cache[that.key] = arr
|
||||||
|
config.data = arr
|
||||||
|
}
|
||||||
|
|
||||||
// 核心入口
|
// 核心入口
|
||||||
table.render = function(options){
|
table.render = function(options){
|
||||||
var inst = new Class(options);
|
var inst = new Class(options);
|
||||||
@@ -2302,6 +2380,17 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||||||
table.init();
|
table.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(function (){
|
||||||
|
//自适应
|
||||||
|
_WIN.on('resize', function(){
|
||||||
|
// that.resize();
|
||||||
|
for(let i in table.winResiz){
|
||||||
|
table.winResiz[i].resize()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
exports(MOD_NAME, table);
|
exports(MOD_NAME, table);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||||||
obj = obj || {};
|
obj = obj || {};
|
||||||
return ['<div class="layui-transfer-box" data-index="'+ obj.index +'">'
|
return ['<div class="layui-transfer-box" data-index="'+ obj.index +'">'
|
||||||
,'<div class="layui-transfer-header">'
|
,'<div class="layui-transfer-header">'
|
||||||
,'<input type="checkbox" name="'+ obj.checkAllName +'" lay-filter="layTransferCheckbox" lay-type="all" lay-skin="primary" title="{{ d.data.title['+ obj.index +'] || \'list'+ (obj.index + 1) +'\' }}">'
|
,'<input type="checkbox"' + (obj.disAll && obj.disAll.includes(obj.index) ? ' disabled' : '') + ' name="'+ obj.checkAllName +'" lay-filter="layTransferCheckbox" lay-type="all" lay-skin="primary" title="{{ d.data.title['+ obj.index +'] || \'list'+ (obj.index + 1) +'\' }}">'
|
||||||
,'</div>'
|
,'</div>'
|
||||||
,'{{# if(d.data.showSearch){ }}'
|
,'{{# if(d.data.showSearch){ }}'
|
||||||
,'<div class="layui-transfer-search">'
|
,'<div class="layui-transfer-search">'
|
||||||
@@ -81,10 +81,11 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//主模板
|
//主模板
|
||||||
,TPL_MAIN = ['<div class="layui-transfer layui-form layui-border-box" lay-filter="LAY-transfer-{{ d.index }}">'
|
,TPL_MAIN = function(option){ return ['<div class="layui-transfer layui-form layui-border-box" lay-filter="LAY-transfer-{{ d.index }}">'
|
||||||
,TPL_BOX({
|
,TPL_BOX({
|
||||||
index: 0
|
index: 0
|
||||||
,checkAllName: 'layTransferLeftCheckAll'
|
,checkAllName: 'layTransferLeftCheckAll',
|
||||||
|
disAll: option.disAll
|
||||||
})
|
})
|
||||||
,'<div class="layui-transfer-active">'
|
,'<div class="layui-transfer-active">'
|
||||||
,'<button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-btn-disabled" data-index="0">'
|
,'<button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-btn-disabled" data-index="0">'
|
||||||
@@ -98,7 +99,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||||||
index: 1
|
index: 1
|
||||||
,checkAllName: 'layTransferRightCheckAll'
|
,checkAllName: 'layTransferRightCheckAll'
|
||||||
})
|
})
|
||||||
,'</div>'].join('')
|
,'</div>'].join('')}
|
||||||
|
|
||||||
//构造器
|
//构造器
|
||||||
,Class = function(options){
|
,Class = function(options){
|
||||||
@@ -136,7 +137,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||||||
,options = that.config;
|
,options = that.config;
|
||||||
|
|
||||||
//解析模板
|
//解析模板
|
||||||
var thisElem = that.elem = $(laytpl(TPL_MAIN).render({
|
var thisElem = that.elem = $(laytpl(TPL_MAIN(options)).render({
|
||||||
data: options
|
data: options
|
||||||
,index: that.index //索引
|
,index: that.index //索引
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -195,9 +195,9 @@ layui.define('form', function(exports){
|
|||||||
//节点
|
//节点
|
||||||
,function(){
|
,function(){
|
||||||
if(options.isJump && item.href){
|
if(options.isJump && item.href){
|
||||||
return '<a href="'+ item.href +'" target="_blank" class="'+ ELEM_TEXT +'">'+ (item.title || item.label || options.text.defaultNodeName) +'</a>';
|
return '<a href="'+ item.href +'" target="_blank" class="'+ ELEM_TEXT +'"' +` style="${item.fontColor && 'color: ' + item.fontColor}"` + '>'+ (item.title || item.label || options.text.defaultNodeName) +'</a>';
|
||||||
}else{
|
}else{
|
||||||
return '<span class="'+ ELEM_TEXT + (item.disabled ? ' '+ DISABLED : '') +'">'+ (item.title || item.label || options.text.defaultNodeName) +'</span>';
|
return '<span class="'+ ELEM_TEXT + (item.disabled ? ' '+ DISABLED : '') + '"' +` style="${item.fontColor && 'color: ' + item.fontColor}"` + '>'+ (item.title || item.label || options.text.defaultNodeName) +'</span>';
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
,'</div>'
|
,'</div>'
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ layui.define('layer' , function(exports){
|
|||||||
,contentType: false
|
,contentType: false
|
||||||
,processData: false
|
,processData: false
|
||||||
,dataType: 'json'
|
,dataType: 'json'
|
||||||
|
,async: false
|
||||||
,headers: options.headers || {}
|
,headers: options.headers || {}
|
||||||
//成功回调
|
//成功回调
|
||||||
,success: function(res){
|
,success: function(res){
|
||||||
|
|||||||
Reference in New Issue
Block a user