Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var readOnly = (ops.readOnly + '') === 'true';
var hasLine = (ops.hasLine + '') === 'true';
var valueKey = ops.valueKey || 'value';
var textKey = ops.textKey || 'text';
var parentKey = ops.parentKey || 'pValue';
// 是否需要全选功能,默认关闭
var needAll = (ops.needAll + '') === 'true';
// 是否可展开收起,默认false
var needExpand = (ops.needExpand + '') === 'true';
// 组织树状结构
var info = Util.listToTree(ops.list, valueKey, parentKey);
var list;
if (needAll) {
var all = {};
all[valueKey] = me.id + '_all';
all[textKey] = I18n['select.all'];
all.isAll = true;
all.children = info.list;
list = [all];
}
else {
list = info.list;
}
// 展开收起状态,默认false
// 切换数据时保留历史展开收起状态
var close = (ops.close + '') === 'true';
var map = {};
var _lp1 = function (arr) {
arr.forEach(function (item) {
map[item[valueKey]] = close;
if (item.children && item.children.length > 0) {
_lp1(item.children);
parents.forEach(function (parent) {
parent.list.forEach(function (item) {
item.selected = (selectedValues.indexOf(item.value + '') > -1);
});
});
this.updater.set({
parents: parents,
hasGroups: data.hasGroups,
searchbox: data.searchbox,
multiple: data.multiple,
spm: data.spm,
height: data.height,
keyword: (data.keyword || ''),
text: {
search: I18n['dropdown.search'],
select: I18n['select.all'],
unselect: I18n['unselect.all'],
submit: I18n['dialog.submit'],
cancel: I18n['dialog.cancel'],
empty: I18n['empty.text']
}
});
},
render: function () {
parents.forEach(function (parent) {
parent.list.forEach(function (item) {
item.selected = (selectedValues.indexOf(item.value + '') > -1);
});
});
this.updater.set({
parents: parents,
hasGroups: data.hasGroups,
searchbox: data.searchbox,
multiple: data.multiple,
spm: data.spm,
height: data.height,
keyword: (data.keyword || ''),
text: {
search: I18n['dropdown.search'],
select: I18n['select.all'],
unselect: I18n['unselect.all'],
submit: I18n['dialog.submit'],
cancel: I18n['dialog.cancel'],
empty: I18n['empty.text']
}
});
},
render: function () {
parents.forEach(parent => {
parent.list.forEach(item => {
item.selected = (selectedValues.indexOf(item.value + '') > -1);
})
})
this.updater.set({
parents,
hasGroups: data.hasGroups,
searchbox: data.searchbox,
multiple: data.multiple,
spm: data.spm,
height: data.height,
keyword: (data.keyword || ''),
text: {
search: I18n['dropdown.search'],
select: I18n['select.all'],
unselect: I18n['unselect.all'],
submit: I18n['dialog.submit'],
cancel: I18n['dialog.cancel'],
empty: I18n['empty.text']
}
})
},
render() {
needAll: needAll,
searchbox: searchbox,
map: map,
selected: selected,
imme: selected,
min: min,
max: max,
continuous: (ops.continuous + '' === 'true'),
over: (count > 20),
groups: groups,
height: ops.height || 400,
spm: me['@{owner.node}'].attr('data-spm-click') || '',
placementClass: me['@{ui.placement}'],
text: {
search: I18n['dropdown.search'],
select: I18n['select.all'],
unselect: I18n['unselect.all'],
submit: I18n['dialog.submit'],
cancel: I18n['dialog.cancel'],
empty: I18n['empty.text']
}
});
},
render: function () {
needAll: needAll,
searchbox: searchbox,
map: map,
selected: selected,
imme: selected,
min: min,
max: max,
continuous: (ops.continuous + '' === 'true'),
over: (count > 20),
groups: groups,
height: ops.height || 400,
spm: me['@{owner.node}'].attr('data-spm-click') || '',
placementClass: me['@{ui.placement}'],
text: {
search: I18n['dropdown.search'],
select: I18n['select.all'],
unselect: I18n['unselect.all'],
submit: I18n['dialog.submit'],
cancel: I18n['dialog.cancel'],
empty: I18n['empty.text']
}
});
},
render: function () {