fineui是帆软报表和BI产品线所使用的前端框架。
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.

61 lines
2.0 KiB

!(function () {
var Store = BI.inherit(Fix.Model, {
_init: function () {
},
computed: {},
watch: {},
actions: {
init: function (cb) {
var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG);
var traversal = function (array, callback) {
var t = [];
BI.some(array, function (i, item) {
var match = callback(i, item);
if (match) {
t.push(item.id);
}
var b = traversal(item.children, callback);
if (BI.isNotEmptyArray(b)) {
t = BI.concat([item.id], b);
}
});
return t;
};
var paths = traversal(tree, function (index, node) {
if (!node.children || BI.isEmptyArray(node.children)) {
if (node.value === Demo.showIndex) {
return true;
}
}
});
BI.each(Demo.CONFIG, function (index, item) {
if (BI.contains(paths, item.id)) {
item.open = true;
}
});
cb();
},
handleTreeSelectChange: function (v) {
var matched = BI.some(Demo.CONFIG, function (index, item) {
if (item.value === v) {
3 years ago
BI.Router.$router.push(item.text);
4 years ago
// BI.history.navigate(item.text, {trigger: true});
return true;
}
});
if (!matched) {
3 years ago
BI.Router.$router.push("/");
4 years ago
// BI.history.navigate("", {trigger: true});
}
}
}
});
BI.store("demo.store.main", Store);
3 years ago
})();