Browse Source

BI-27974:阅读,理解,实践demo中的button_group,custom_tree,layer,popup_view

es6
Zhenfei.Li 6 years ago
parent
commit
dcaec9d05b
  1. 32
      demo/js/core/abstract/demo.button_group.js
  2. 234
      demo/js/core/abstract/demo.custom_tree.js
  3. 20
      demo/js/core/popup/demo.layer.js
  4. 29
      demo/js/core/popup/demo.popup_view.js

32
demo/js/core/abstract/demo.button_group.js

@ -11,12 +11,24 @@ Demo.Func = BI.inherit(BI.Widget, {
ref: function (_ref) {
ref = _ref;
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_NONE,
behaviors: {
highlight: function () {
return true;
}
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
listeners: [{
eventName: BI.ButtonGroup.EVENT_CHANGE,
action: function (value) {
var content = "传递的参数为:" + value + " getValue方法得到的值为:" + this.getValue();
BI.Msg.alert("", content);
}
}],
layouts: [{
type: "bi.vertical",
items: [{
type: "bi.vtape",
height: 200
height: 300
}]
}],
items: [{
@ -28,7 +40,19 @@ Demo.Func = BI.inherit(BI.Widget, {
}, {
el: {
type: "bi.button",
text: "1"
value: "button1"
},
height: 50
}, {
el: {
type: "bi.button",
value: "button2"
},
height: 50
}, {
el: {
type: "bi.button",
value: "button3"
}
}]
}, {
@ -44,7 +68,7 @@ Demo.Func = BI.inherit(BI.Widget, {
}, {
el: {
type: "bi.button",
text: "2"
value: "2"
},
height: 50
}, {

234
demo/js/core/abstract/demo.custom_tree.js

@ -28,7 +28,12 @@ Demo.Func = BI.inherit(BI.Widget, {
hgap: 30
}]
},
items: BI.deepClone(TREEITEMS)
items: BI.deepClone(TREEITEMS),
expander: {
el: {},
popup: {type: "bi.custom_tree"},
trigger: "hover"
}
});
return this.tree;
},
@ -58,58 +63,57 @@ Demo.Func = BI.inherit(BI.Widget, {
}]);
} else {
if (op.node.id == 1) {
callback([
{
id: 11,
pId: 1,
type: "bi.plus_group_node",
text: "test11",
value: 11,
height: 25,
isParent: true
},
{
id: 12,
pId: 1,
type: "bi.single_select_item",
text: "test12",
value: 12,
height: 35
},
{
id: 13,
pId: 1,
type: "bi.single_select_item",
text: "test13",
value: 13,
height: 35
},
{
id: 14,
pId: 1,
type: "bi.single_select_item",
text: "test14",
value: 14,
height: 35
},
{
id: 15,
pId: 1,
type: "bi.single_select_item",
text: "test15",
value: 15,
height: 35
},
{
id: 16,
pId: 1,
type: "bi.single_select_item",
text: "test16",
value: 16,
height: 35
},
{id: 17, pId: 1, type: "bi.single_select_item", text: "test17", value: 17, height: 35}
]);
callback([{
id: 11,
pId: 1,
type: "bi.plus_group_node",
text: "test11",
value: 11,
height: 25,
isParent: true
}, {
id: 12,
pId: 1,
type: "bi.single_select_item",
text: "test12",
value: 12,
height: 35
}, {
id: 13,
pId: 1,
type: "bi.single_select_item",
text: "test13",
value: 13,
height: 35
}, {
id: 14,
pId: 1,
type: "bi.single_select_item",
text: "test14",
value: 14,
height: 35
}, {
id: 15,
pId: 1,
type: "bi.single_select_item",
text: "test15",
value: 15,
height: 35
}, {
id: 16,
pId: 1,
type: "bi.single_select_item",
text: "test16",
value: 16,
height: 35
}, {
id: 17,
pId: 1,
type: "bi.single_select_item",
text: "test17",
value: 17,
height: 35
}]);
} else if (op.node.id == 2) {
callback([{
id: 21,
@ -118,8 +122,7 @@ Demo.Func = BI.inherit(BI.Widget, {
text: "test21",
value: 21,
height: 35
},
{
}, {
id: 22,
pId: 2,
type: "bi.single_select_item",
@ -151,6 +154,12 @@ Demo.Func = BI.inherit(BI.Widget, {
vgap: 0
}]
}
},
expander: {
el: {},
popup: {type: "bi.custom_tree"},
trigger: "click",
direction: "bottom"
}
});
return this.asyncTree;
@ -168,75 +177,68 @@ Demo.Func = BI.inherit(BI.Widget, {
row: 0,
el: {
type: "bi.vtape",
items: [
{
el: this._createDefaultTree()
items: [{
el: this._createDefaultTree()
}, {
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.tree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeByValue(第一级目录1)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + self.tree.getNodeByValue("第一级目录1").getValue());
}
}]
},
{
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.tree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeByValue(第一级目录1)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + self.tree.getNodeByValue("第一级目录1").getValue());
}
}]
},
height: 30
}
]
height: 30
}]
}
}, {
column: 1,
row: 0,
el: {
type: "bi.vtape",
items: [
{
type: "bi.label",
text: "异步加载数据",
height: 30
},
{
el: this._createAsyncTree()
items: [{
type: "bi.label",
text: "异步加载数据",
height: 30
}, {
el: this._createAsyncTree()
}, {
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.asyncTree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeById(11)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + (self.asyncTree.getNodeById(11) && self.asyncTree.getNodeById(11).getText()));
}
}]
},
{
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.asyncTree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeById(11)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + (self.asyncTree.getNodeById(11) && self.asyncTree.getNodeById(11).getText()));
}
}]
},
height: 30
}
]
height: 30
}]
}
}]
});

20
demo/js/core/popup/demo.layer.js

@ -18,16 +18,16 @@ Demo.Func = BI.inherit(BI.Widget, {
BI.Layers.create(id1, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
left: 20,
right: 20,
top: 20,
bottom: 20
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
text: "点击隐藏",
handler: function () {
BI.Layers.hide(id1);
}
@ -43,16 +43,16 @@ Demo.Func = BI.inherit(BI.Widget, {
BI.Layers.make(id2, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
left: 20,
right: 20,
top: 20,
bottom: 20
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
text: "点击移除",
handler: function () {
BI.Layers.remove(id2);
}

29
demo/js/core/popup/demo.popup_view.js

@ -23,6 +23,35 @@ Demo.Func = BI.inherit(BI.Widget, {
},
popup: {
type: "bi.popup_view",
ref: function (_ref) {
self.popupView = _ref;
},
tabs: [{
type: "bi.text_button",
value: "tab1",
cls: "bi-border",
handler: function () {
BI.Msg.alert("", "点击tab1");
}
}, {
type: "bi.text_button",
value: "tab2",
cls: "bi-border",
handler: function () {
BI.Msg.alert("", "点击tab2");
}
}],
logic: {
dynamic: true
},
tools: true,
buttons: [{
type: "bi.text_button",
value: "getValue",
handler: function () {
BI.Msg.alert("getValue", JSON.stringify(self.popupView.getValue()));
}
}],
el: {
type: "bi.button_group",
layouts: [{

Loading…
Cancel
Save