Browse Source

平台用

es6
guy 8 years ago
parent
commit
7daa9b1102
  1. 2
      bi/base.js
  2. 12
      bi/widget.js
  3. 215
      demo/js/component/demo.multilayerselecttree.leveltree.js
  4. 4
      demo/js/config/component.js
  5. 2
      docs/base.js
  6. 220
      docs/demo.js
  7. 12
      docs/widget.js
  8. 2
      src/base/single/button/button.basic.js
  9. 5
      src/widget/multiselect/multiselect.combo.js
  10. 3
      src/widget/multiselect/search/multiselect.search.loader.js
  11. 4
      src/widget/multiselectlist/multiselectlist.js

2
bi/base.js

@ -857,7 +857,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
setSelected: function (b) {
var o = this.options;
o.selected = b;
if (this.isSelected()) {
if (b) {
this.handle().element.addClass("active");
} else {
this.handle().element.removeClass("active");

12
bi/widget.js

@ -9585,7 +9585,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
self.trigger.setValue(self.getValue());
//预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
@ -9638,7 +9639,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
assertShowValue();
});
} else {
self._join(this.getValue(), function () {//安徽省 北京
self._join(this.getValue(), function () {
assertShowValue();
});
}
@ -10431,7 +10432,8 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
},
setValue: function (v) {
this.storeValue = v;
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v);
this.button_group.setValue(v);
},
@ -10982,7 +10984,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
// self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11034,7 +11036,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
action: function () {
self._showSearcherPane();
self._setStartValue("");
this.setValue(self.storeValue);
this.setValue(BI.deepClone(self.storeValue));
}
}, {
eventName: BI.Searcher.EVENT_STOP,

215
demo/js/component/demo.multilayerselecttree.leveltree.js

@ -0,0 +1,215 @@
/**
* guy
* 二级树
* @class BI.PlatformLevelTree
* @extends BI.Select
*/
BI.PlatformLevelTree = BI.inherit(BI.Widget, {
props: {
baseCls: "platform-level-tree",
itemsCreator: BI.emptyFn
},
render: function () {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.custom_tree",
element: this,
expander: {
type: "bi.select_tree_expander",
isDefaultInit: false,
el: {},
popup: {
type: "bi.custom_tree"
}
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (items) {
callback(self._formatItems(items))
})
},
el: {
type: "bi.loader",
next: false,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.tree.on(BI.CustomTree.EVENT_CHANGE, function () {
self.fireEvent(BI.PlatformLevelTree.EVENT_CHANGE, arguments);
})
},
_formatItems: function (nodes) {
var self = this;
BI.each(nodes, function (i, node) {
var extend = {};
if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
switch (i) {
case 0 :
extend.type = "bi.multilayer_select_tree_first_plus_group_node";
break;
case nodes.length - 1 :
extend.type = "bi.multilayer_select_tree_last_plus_group_node";
break;
default :
extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
break;
}
BI.defaults(node, extend);
} else {
switch (i) {
case nodes.length - 1:
extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
break;
default :
extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
}
BI.defaults(node, extend);
}
});
return nodes;
},
populate: function () {
this.tree.populate();
},
getValue: function () {
return this.tree.getValue();
}
});
BI.PlatformLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.platform_level_tree", BI.PlatformLevelTree);
BI.DemoLevelTree = BI.inherit(BI.Widget, {
render: function () {
var self = this;
return {
type: "bi.vtape",
items: [{
el: {
type: "bi.platform_level_tree",
ref: function () {
self.tree = this;
},
itemsCreator: function (op, callback) {
if (!op.node) {//根节点
callback([{
"id": 1,
"pId": 0,
text: "A",
value: 1,
isParent: true
}, {
"id": 2,
"pId": 0,
"text": "B",
value: 2,
isParent: true,
open: true,
}])
} else {
if (op.node.id == 1) {
callback([
{
"id": 11,
"pId": 1,
"text": "test11",
value: 11,
layer: 1,
isParent: true
},
{
"id": 12,
"pId": 1,
"text": "test12",
value: 12,
layer: 1,
},
{
"id": 13,
"pId": 1,
"text": "test13",
value: 13,
layer: 1,
},
{
"id": 14,
"pId": 1,
"text": "test14",
value: 14,
layer: 1,
height: 35
},
{
"id": 15,
"pId": 1,
"text": "test15",
value: 15,
layer: 1,
},
{
"id": 16,
"pId": 1,
"text": "test16",
value: 16,
layer: 1,
},
{"id": 17, "pId": 1, "text": "test17", layer: 1, value: 17}
])
} else if (op.node.id == 2) {
callback([{
"id": 21,
"pId": 2,
"text": "test21",
value: 21,
layer: 1,
},
{
"id": 22,
"pId": 2,
"text": "test22",
value: 22,
layer: 1,
}])
} else if (op.node.id == 11) {
callback([{
"id": 111,
"pId": 11,
"text": "test111",
value: 111,
layer: 2,
}])
}
}
}
}
}, {
el: {
type: "bi.button",
text: "确定",
handler: function () {
BI.Msg.toast(JSON.stringify(self.tree.getValue()));
}
},
height: 25
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.platform_level_tree", BI.DemoLevelTree);

4
demo/js/config/component.js

@ -20,4 +20,8 @@ Demo.COMPONENT_CONFIG = [{
pId: 5,
text: "bi.tree_value_chooser_pane",
value: "demo.tree_value_chooser_pane"
}, {
pId: 5,
text: "平台用",
value: "demo.platform_level_tree"
}];

2
docs/base.js

@ -857,7 +857,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
setSelected: function (b) {
var o = this.options;
o.selected = b;
if (this.isSelected()) {
if (b) {
this.handle().element.addClass("active");
} else {
this.handle().element.removeClass("active");

220
docs/demo.js

@ -2618,7 +2618,221 @@ BI.shortcut("demo.center", Demo.Center);Demo.Func = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.axis_chart", Demo.Func);
Demo.TreeValueChooser = BI.inherit(BI.Widget, {
/**
* guy
* 二级树
* @class BI.PlatformLevelTree
* @extends BI.Select
*/
BI.PlatformLevelTree = BI.inherit(BI.Widget, {
props: {
baseCls: "platform-level-tree",
itemsCreator: BI.emptyFn
},
render: function () {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.custom_tree",
element: this,
expander: {
type: "bi.select_tree_expander",
isDefaultInit: false,
el: {},
popup: {
type: "bi.custom_tree"
}
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (items) {
callback(self._formatItems(items))
})
},
el: {
type: "bi.loader",
next: false,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.tree.on(BI.CustomTree.EVENT_CHANGE, function () {
self.fireEvent(BI.PlatformLevelTree.EVENT_CHANGE, arguments);
})
},
_formatItems: function (nodes) {
var self = this;
BI.each(nodes, function (i, node) {
var extend = {};
if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
switch (i) {
case 0 :
extend.type = "bi.multilayer_select_tree_first_plus_group_node";
break;
case nodes.length - 1 :
extend.type = "bi.multilayer_select_tree_last_plus_group_node";
break;
default :
extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
break;
}
BI.defaults(node, extend);
} else {
switch (i) {
case nodes.length - 1:
extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
break;
default :
extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
}
BI.defaults(node, extend);
}
});
return nodes;
},
populate: function () {
this.tree.populate();
},
getValue: function () {
return this.tree.getValue();
}
});
BI.PlatformLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.platform_level_tree", BI.PlatformLevelTree);
BI.DemoLevelTree = BI.inherit(BI.Widget, {
render: function () {
var self = this;
return {
type: "bi.vtape",
items: [{
el: {
type: "bi.platform_level_tree",
ref: function () {
self.tree = this;
},
itemsCreator: function (op, callback) {
if (!op.node) {//根节点
callback([{
"id": 1,
"pId": 0,
text: "A",
value: 1,
isParent: true
}, {
"id": 2,
"pId": 0,
"text": "B",
value: 2,
isParent: true,
open: true,
}])
} else {
if (op.node.id == 1) {
callback([
{
"id": 11,
"pId": 1,
"text": "test11",
value: 11,
layer: 1,
isParent: true
},
{
"id": 12,
"pId": 1,
"text": "test12",
value: 12,
layer: 1,
},
{
"id": 13,
"pId": 1,
"text": "test13",
value: 13,
layer: 1,
},
{
"id": 14,
"pId": 1,
"text": "test14",
value: 14,
layer: 1,
height: 35
},
{
"id": 15,
"pId": 1,
"text": "test15",
value: 15,
layer: 1,
},
{
"id": 16,
"pId": 1,
"text": "test16",
value: 16,
layer: 1,
},
{"id": 17, "pId": 1, "text": "test17", layer: 1, value: 17}
])
} else if (op.node.id == 2) {
callback([{
"id": 21,
"pId": 2,
"text": "test21",
value: 21,
layer: 1,
},
{
"id": 22,
"pId": 2,
"text": "test22",
value: 22,
layer: 1,
}])
} else if (op.node.id == 11) {
callback([{
"id": 111,
"pId": 11,
"text": "test111",
value: 111,
layer: 2,
}])
}
}
}
}
}, {
el: {
type: "bi.button",
text: "确定",
handler: function () {
BI.Msg.toast(JSON.stringify(self.tree.getValue()));
}
},
height: 25
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.platform_level_tree", BI.DemoLevelTree);Demo.TreeValueChooser = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-tree-value-chooser-combo"
},
@ -2931,6 +3145,10 @@ Demo.COMPONENT_CONFIG = [{
pId: 5,
text: "bi.tree_value_chooser_pane",
value: "demo.tree_value_chooser_pane"
}, {
pId: 5,
text: "平台用",
value: "demo.platform_level_tree"
}];Demo.CORE_CONFIG = [{
id: 1,
text: "核心控件",

12
docs/widget.js

@ -9585,7 +9585,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
self.trigger.setValue(self.getValue());
//预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
@ -9638,7 +9639,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
assertShowValue();
});
} else {
self._join(this.getValue(), function () {//安徽省 北京
self._join(this.getValue(), function () {
assertShowValue();
});
}
@ -10431,7 +10432,8 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
},
setValue: function (v) {
this.storeValue = v;
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v);
this.button_group.setValue(v);
},
@ -10982,7 +10984,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
// self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11034,7 +11036,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
action: function () {
self._showSearcherPane();
self._setStartValue("");
this.setValue(self.storeValue);
this.setValue(BI.deepClone(self.storeValue));
}
}, {
eventName: BI.Searcher.EVENT_STOP,

2
src/base/single/button/button.basic.js

@ -274,7 +274,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
setSelected: function (b) {
var o = this.options;
o.selected = b;
if (this.isSelected()) {
if (b) {
this.handle().element.addClass("active");
} else {
this.handle().element.removeClass("active");

5
src/widget/multiselect/multiselect.combo.js

@ -41,7 +41,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
self.trigger.setValue(self.getValue());
//预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
@ -94,7 +95,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
assertShowValue();
});
} else {
self._join(this.getValue(), function () {//安徽省 北京
self._join(this.getValue(), function () {
assertShowValue();
});
}

3
src/widget/multiselect/search/multiselect.search.loader.js

@ -119,7 +119,8 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
},
setValue: function (v) {
this.storeValue = v;
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v);
this.button_group.setValue(v);
},

4
src/widget/multiselectlist/multiselectlist.js

@ -17,7 +17,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
// self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -69,7 +69,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
action: function () {
self._showSearcherPane();
self._setStartValue("");
this.setValue(self.storeValue);
this.setValue(BI.deepClone(self.storeValue));
}
}, {
eventName: BI.Searcher.EVENT_STOP,

Loading…
Cancel
Save