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.

155 lines
4.8 KiB

8 years ago
/**
8 years ago
* Created by zcf_1 on 2017/5/11.
8 years ago
*/
8 years ago
BI.MultiSelectTree = BI.inherit(BI.Widget, {
8 years ago
_defaultConfig: function () {
8 years ago
return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
8 years ago
baseCls: 'bi-multi-select-tree',
8 years ago
itemsCreator: BI.emptyFn,
height: 25
8 years ago
})
8 years ago
},
_init: function () {
8 years ago
BI.MultiSelectTree.superclass._init.apply(this, arguments);
8 years ago
var self = this, o = this.options;
8 years ago
this.storeValue = {value: {}};
8 years ago
8 years ago
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
8 years ago
itemsCreator: o.itemsCreator
});
8 years ago
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
8 years ago
}
8 years ago
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
8 years ago
});
8 years ago
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
8 years ago
},
8 years ago
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
8 years ago
}
});
8 years ago
this.searcherPane.setVisible(false);
8 years ago
8 years ago
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () {
self.adapter.populate();
});
}
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
self._showAdapter();
}
}]
8 years ago
});
BI.createWidget({
type: "bi.vtape",
8 years ago
element: this,
8 years ago
height: "100%",
width: "100%",
items: [{
el: this.trigger,
8 years ago
height: 30
8 years ago
}, {
8 years ago
el: this.adapter,
8 years ago
height: "fill"
}]
8 years ago
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
8 years ago
})
8 years ago
8 years ago
},
8 years ago
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
8 years ago
},
resize: function () {
8 years ago
8 years ago
},
setValue: function (v) {
this.storeValue.value = v || {};
8 years ago
this.adapter.setValue({
8 years ago
value: v || {}
});
this.trigger.setValue({
value: v || {}
});
},
getValue: function () {
return this.storeValue.value;
},
populate: function () {
this.trigger.populate.apply(this.trigger, arguments);
8 years ago
this.adapter.populate.apply(this.adapter, arguments);
8 years ago
}
});
8 years ago
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);