主题插件示例。
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.
 
 

290 lines
10 KiB

/*! fine-decision-webui 2018-10-14 15:29:23 */
!(function () {
BI.config("dec.constant.config", function (config) {
config.theme.config4Frame.west.width = 240;
config.theme.config4EntryPane.pinable = false;
return config;
});
BI.config("dec.provider.layout", function (provider) {
provider.setConfig({
type: "bi.absolute",
items: [
{
el: {
type: "bi.absolute",
items: [
{
el: {
type: "dec.workbench.tabs"
},
top: 0, bottom: 0, right: 0,
left: 240
}, {
el: {
type: "dec.workbench.panel",
width: 240
},
top: 0, bottom: 0,
left: 0
}
]
},
top: 40, left: 0, right: 0, bottom: 0
}, {
el: {
type: "dec.header"
},
height: 40,
top: 0, left: 0, right: 0
}
]
});
return provider;
});
BI.config("dec.workbench.directory", function (config) {
config.type = "my.theme.directory";
return config;
});
}());
!(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("dec.theme.modules", Nav);
}());
(function () {
var Model = BI.inherit(Fix.Model, {
_init: function () {
this.platform = Dec.globleModel;
},
state: function () {
return {
modules: [],
reports: []
};
},
context: ["isPin"],
computed: {
selectedManageNav: function () {
return this.platform.selectedManageNav;
},
items: function () {
var self = this;
var constant = BI.Constants.getConstant("dec.constant.management.navigation");
var results = [];
results = BI.concat(results, this.model.reports);
results.push({
id: "decision-management-root",
value: "decision-management-root",
isParent: true,
open: true,
cls: "setting-font",
text: BI.i18nText("Dec-Authority_PlatformModule")
});
BI.each(constant, function (index, item) {
var match = BI.find(self.model.modules, function (index, i) {
return item.id === i.id;
});
if (match) {
results.push(BI.extend({}, match, item));
}
});
BI.each(results, function (index, item) {
if (item.value === self.platform.selectedManageNav && (item.pId === "decision-management-maintenance")) {
BI.some(results, function (index, i) {
if (i.id === "decision-management-maintenance") {
i.open = true;
return true;
}
});
}
if (item.value === self.model.selectedManageNav) {
item.selected = true;
}
if (!item.pId) {
item.pId = "management";
}
});
BI.each(constant, function (index, item) {
if (item.dev) {
results.push(BI.extend({}, item));
}
});
return BI.Tree.transformToTreeFormat(results);
}
},
actions: {
initData: function (callback) {
this.initDecisionModules();
this.initReports(callback);
},
initDecisionModules: function () {
var self = this;
Dec.Plugin.getManagementModules(function (modules) {
self.model.modules = modules;
});
},
initReports: function (callback) {
var self = this;
Dec.Utils.getWorkbenchSubDirectoryById(DecCst.DIRECTORY_TREE_ROOT_ID, function (res) {
self.model.reports = self._formatReportItems(res.data);
callback();
});
},
getSubItemsByPId: function (pId, layer, callback) {
var self = this;
Dec.Plugin.getEntriesByPid(pId, function (res) {
BI.some(self.model.reports, function (index, item) {
if (item.id === pId) {
item.open = true;
return true;
}
});
self.model.reports = self.model.reports.concat(self._formatReportItems(res.data));
});
},
openTab: function (tab) {
var module = BI.find(BI.Constants.getConstant("dec.constant.management.navigation"), function (index, item) {
return item.value === tab;
});
var report = BI.find(this.model.reports, function (index, item) {
return item.value === tab;
});
if (module) {
// Dec.Plugin.tabPane.addItem(card.text, card.value, card.cardType);
BI.Services.getService("dec.service.tabs").addItem(module);
} else {
BI.Services.getService("dec.service.tabs").addItem(report);
// this._openReports(tab);
}
}
},
_formatReportItems: function (nodes) {
var self = this;
var iconClsMap = BI.Constants.getConstant("dec.constant.look.icons.map");
var temps = BI.deepClone(nodes);
BI.each(temps, function (i, node) {
var extend = {
value: node.id
};
var cls = iconClsMap[node.nodeIcon];
if (cls) {
extend.iconCls = cls;
} else {
extend.iconCls = node.isParent ? "dir-panel-folder-font" : "dir-panel-template-font";
}
BI.defaults(node, extend);
});
return temps;
}
});
BI.model("dec.model.modules", Model);
}());