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.

173 lines
4.3 KiB

7 years ago
// local函数
7 years ago
LocalView = BI.inherit(BI.View, {
7 years ago
_defaultConfig: function () {
return BI.extend(LocalView.superclass._defaultConfig.apply(this, arguments), {
7 years ago
baseCls: "bi-local"
7 years ago
});
7 years ago
},
7 years ago
_init: function () {
7 years ago
LocalView.superclass._init.apply(this, arguments);
this.buttons = {};
},
7 years ago
_addElement2Vessel: function (id) {
7 years ago
var self = this;
this.buttons[id] = this.elementVessel.addItem({
type: "bi.text_button",
text: "Button:" + id,
width: 180,
height: 22,
cls: "delete-button button",
7 years ago
handler: function () {
7 years ago
self.set("delete", id);
}
7 years ago
});
7 years ago
},
7 years ago
_deleteElement: function (id) {
7 years ago
this.buttons[id] && this.buttons[id].destroy();
delete this.buttons[id];
},
7 years ago
_createTop: function () {
7 years ago
var self = this;
this.elementVessel = BI.createWidget({
type: "bi.left",
height: 200,
cls: "vessel-border",
scrollable: true,
vgap: 10,
hgap: 10
});
return BI.createWidget({
type: "bi.vertical",
items: [
{
el: {
type: "bi.text_button",
text: "点击添加元素",
cls: "top-button",
7 years ago
handler: function () {
7 years ago
self.model.set("add", true);
},
height: 30
}
},
this.elementVessel
]
7 years ago
});
7 years ago
},
7 years ago
_showModelData: function () {
7 years ago
this.text.setText(JSON.stringify(this.model.toJSON()));
},
7 years ago
_createCenter: function () {
7 years ago
var modelData = BI.createWidget({
type: "bi.center",
vgap: 10,
hgap: 10,
cls: "vessel-border",
height: 200,
items: [{
el: this.text = BI.createWidget({
type: "bi.label",
hgap: 30,
textHeight: 30,
whiteSpace: "normal"
})
}]
});
return BI.createWidget({
type: "bi.vertical",
items: [
{
el: {
type: "bi.label",
cls: "bottom-label",
text: "Model层数据",
height: 30
}
},
modelData
]
7 years ago
});
7 years ago
},
7 years ago
render: function (vessel) {
7 years ago
BI.createWidget({
type: "bi.vertical",
element: vessel,
items: [{
7 years ago
el: this._createTop()
}, {
el: this._createCenter()
7 years ago
}],
hgap: 50,
vgap: 20
});
this._showModelData();
},
7 years ago
local: function () {
if(this.model.has("add")) {
7 years ago
var add = this.model.get("add");
this._addElement2Vessel(this.model.getEditing());
this._showModelData();
return true;
}
7 years ago
if(this.model.has("delete")) {
7 years ago
var id = this.model.get("delete");
this._deleteElement(id);
this._showModelData();
return true;
}
return false;
}
});
LocalModel = BI.inherit(BI.Model, {
7 years ago
_defaultConfig: function () {
return BI.extend(LocalModel.superclass._defaultConfig.apply(this, arguments), {
7 years ago
7 years ago
});
7 years ago
},
7 years ago
_init: function () {
7 years ago
LocalModel.superclass._init.apply(this, arguments);
},
7 years ago
local: function () {
if(this.has("add")) {
7 years ago
this.get("add");
var id = BI.UUID();
7 years ago
this.set(id, "这是新增的属性:" + id);
7 years ago
this.setEditing(id);
return true;
}
7 years ago
if(this.has("delete")) {
7 years ago
var id = this.get("delete");
this.unset(id);
return true;
}
return false;
}
});
Demo.Func = BI.inherit(BI.Widget, {
render: function () {
var view = BI.View.createView("/local", {}, {
element: this
});
view.populate();
},
mounted: function () {
}
});
BI.shortcut("demo.local", Demo.Func);