穿梭框增加禁用选择所有,table增加只刷新数据不刷新dom
This commit is contained in:
parent
5e10d720e6
commit
526d1cbec1
24697
dist/layui.js
vendored
Normal file
24697
dist/layui.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,id = options.id || options.index;
|
||||
|
||||
if(id){
|
||||
thisTable.that[id] = that; //记录当前实例对象
|
||||
thisTable.config[id] = options; //记录当前实例配置项
|
||||
@ -65,8 +64,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
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;
|
||||
@ -2300,6 +2303,50 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
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){
|
||||
var inst = new Class(options);
|
||||
|
@ -68,7 +68,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
||||
obj = obj || {};
|
||||
return ['<div class="layui-transfer-box" data-index="'+ obj.index +'">'
|
||||
,'<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>'
|
||||
,'{{# if(d.data.showSearch){ }}'
|
||||
,'<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({
|
||||
index: 0
|
||||
,checkAllName: 'layTransferLeftCheckAll'
|
||||
,checkAllName: 'layTransferLeftCheckAll',
|
||||
disAll: option.disAll
|
||||
})
|
||||
,'<div class="layui-transfer-active">'
|
||||
,'<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
|
||||
,checkAllName: 'layTransferRightCheckAll'
|
||||
})
|
||||
,'</div>'].join('')
|
||||
,'</div>'].join('')}
|
||||
|
||||
//构造器
|
||||
,Class = function(options){
|
||||
@ -136,7 +137,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
||||
,options = that.config;
|
||||
|
||||
//解析模板
|
||||
var thisElem = that.elem = $(laytpl(TPL_MAIN).render({
|
||||
var thisElem = that.elem = $(laytpl(TPL_MAIN(options)).render({
|
||||
data: options
|
||||
,index: that.index //索引
|
||||
}));
|
||||
|
@ -195,9 +195,9 @@ layui.define('form', function(exports){
|
||||
//节点
|
||||
,function(){
|
||||
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{
|
||||
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>'
|
||||
|
Loading…
Reference in New Issue
Block a user