mirror of https://github.com/layui/layui
优化 transfer 内部数据渲染方法的相关代码
parent
b0a595fe26
commit
3bcc12285a
|
@ -193,33 +193,35 @@ layui.define(['laytpl', 'form'], function(exports){
|
||||||
that.events(); //事件
|
that.events(); //事件
|
||||||
};
|
};
|
||||||
|
|
||||||
//渲染数据
|
// 渲染数据
|
||||||
Class.prototype.renderData = function(){
|
Class.prototype.renderData = function(){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config;
|
var options = that.config;
|
||||||
|
|
||||||
//左右穿梭框差异数据
|
// 左右穿梭框差异数据
|
||||||
var arr = [{
|
var arr = [{
|
||||||
checkName: 'layTransferLeftCheck'
|
checkName: 'layTransferLeftCheck',
|
||||||
,views: []
|
views: []
|
||||||
}, {
|
}, {
|
||||||
checkName: 'layTransferRightCheck'
|
checkName: 'layTransferRightCheck',
|
||||||
,views: []
|
views: []
|
||||||
}];
|
}];
|
||||||
|
|
||||||
//解析格式
|
// 解析格式
|
||||||
that.parseData(function(item){
|
that.parseData(function(item){
|
||||||
//标注为 selected 的为右边的数据
|
// 标注为 selected 的为右边的数据
|
||||||
var _index = item.selected ? 1 : 0
|
var _index = item.selected ? 1 : 0
|
||||||
,listElem = ['<li>'
|
var listElem = ['<li>',
|
||||||
,'<input type="checkbox" name="'+ arr[_index].checkName +'" lay-skin="primary" lay-filter="layTransferCheckbox" title="'+ item.title +'"'+ (item.disabled ? ' disabled' : '') + (item.checked ? ' checked' : '') +' value="'+ item.value +'">'
|
'<input type="checkbox" name="'+ arr[_index].checkName +'" lay-skin="primary" lay-filter="layTransferCheckbox" title="'+ item.title +'"'+ (item.disabled ? ' disabled' : '') + (item.checked ? ' checked' : '') +' value="'+ item.value +'">',
|
||||||
,'</li>'].join('');
|
'</li>'].join('');
|
||||||
//按照options.value顺序排列右侧数据
|
// 按照 options.value 顺序排列右侧数据
|
||||||
if(_index){
|
if(_index){
|
||||||
for(let key in options.value) {
|
layui.each(options.value, function(i, v){
|
||||||
if(options.value[key] == item.value && item.selected) arr[_index].views[key] = listElem;
|
if(v == item.value && item.selected){
|
||||||
}
|
arr[_index].views[i] = listElem;
|
||||||
}else{
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
arr[_index].views.push(listElem);
|
arr[_index].views.push(listElem);
|
||||||
}
|
}
|
||||||
delete item.selected;
|
delete item.selected;
|
||||||
|
@ -229,7 +231,7 @@ layui.define(['laytpl', 'form'], function(exports){
|
||||||
that.layData.eq(1).html(arr[1].views.join(''));
|
that.layData.eq(1).html(arr[1].views.join(''));
|
||||||
|
|
||||||
that.renderCheckBtn();
|
that.renderCheckBtn();
|
||||||
}
|
};
|
||||||
|
|
||||||
//渲染表单
|
//渲染表单
|
||||||
Class.prototype.renderForm = function(type){
|
Class.prototype.renderForm = function(type){
|
||||||
|
|
Loading…
Reference in New Issue