You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.3 KiB
97 lines
3.3 KiB
!(function () { |
|
var Nav = BI.inherit(BI.Widget, { |
|
|
|
props: { |
|
baseCls: "dec-management-nav dec-popover", |
|
pinedPane: false |
|
}, |
|
|
|
_store: function () { |
|
return BI.Models.getModel("dec.model.modules"); |
|
}, |
|
|
|
watch: { |
|
selectedManageNav: function (v) { |
|
this.tree.setValue(v); |
|
}, |
|
items: function () { |
|
this.populate(this.model.items); |
|
} |
|
}, |
|
|
|
beforeInit: function (render) { |
|
this.store.initData(render); |
|
}, |
|
|
|
render: function () { |
|
var self = this, o = this.options; |
|
return { |
|
type: "bi.vertical", |
|
hgap: 10, |
|
items: [ |
|
{ |
|
type: "bi.custom_tree", |
|
cls: "dec-text", |
|
ref: function (_ref) { |
|
self.tree = _ref; |
|
}, |
|
el: { |
|
type: "bi.loader", |
|
next: false, |
|
el: { |
|
type: "bi.button_tree", |
|
chooseType: 0, |
|
layouts: [{ |
|
type: "bi.vertical", |
|
vgap: 5 |
|
}] |
|
} |
|
}, |
|
listeners: [{ |
|
eventName: "EVENT_CHANGE", |
|
action: function () { |
|
self.store.openTab(this.getValue()[0]); |
|
} |
|
}], |
|
itemsCreator: function (op, callback) { |
|
if (!op.node) { |
|
self.store.initRootNodes(function (items) { |
|
callback(items); |
|
}); |
|
} else { |
|
self.store.getSubItemsByPId(op.node.id, op.node.layer + 1, function (items) { |
|
callback(items); |
|
}); |
|
} |
|
}, |
|
items: this._formatItems(this.model.items, 0) |
|
} |
|
] |
|
}; |
|
}, |
|
|
|
// 解析层级结构的树数据.即带有children字段的 |
|
_formatItems: function (nodes, layer) { |
|
var self = this; |
|
BI.each(nodes, function (i, node) { |
|
var extend = {layer: layer}; |
|
if (node.isParent === true || BI.isNotEmptyArray(node.children)) { |
|
extend.type = "dec.nav.node"; |
|
BI.defaults(node, extend); |
|
self._formatItems(node.children, layer + 1); |
|
} else { |
|
extend.type = "dec.nav.item"; |
|
BI.defaults(node, extend); |
|
} |
|
}); |
|
return nodes; |
|
}, |
|
|
|
populate: function (nodes) { |
|
nodes = this._formatItems(nodes, 0); |
|
this.tree.populate(nodes); |
|
} |
|
}); |
|
Nav.EVENT_VALUE_CHANGE = "EVENT_VALUE_CHANGE"; |
|
BI.shortcut("my.theme.directory", Nav); |
|
}());
|
|
|