Browse Source

Merge branch 'master' of ssh://cloud.finedevelop.com:7999/~young/fineui

es6
Young 7 years ago
parent
commit
b76b4348fa
  1. 23
      Gruntfile.js
  2. 4
      demo/js/config/core.js
  3. 68
      demo/js/core/popup/demo.layer.js
  4. 7
      demo/js/core/popup/demo.popover.js
  5. 155
      demo/js/widget/downlist/demo.downlist.js
  6. 2
      dist/README.md
  7. 50
      dist/_fineui.min.js
  8. 6
      dist/base.js
  9. 462
      dist/bundle.js
  10. 46
      dist/bundle.min.js
  11. 4
      dist/case.js
  12. 22
      dist/core.js
  13. 233
      dist/demo.js
  14. 451
      dist/fineui.js
  15. 323
      dist/fineui.min.js
  16. 430
      dist/widget.js
  17. 3
      package.json
  18. 4
      src/base/layer/layer.popover.js
  19. 2
      src/base/single/input/file.js
  20. 4
      src/case/trigger/trigger.text.select.small.js
  21. 20
      src/core/controller/controller.layer.js
  22. 6
      src/widget/month/combo.month.js
  23. 90
      src/widget/multilayerdownlist/combo.downlist.js
  24. 327
      src/widget/multilayerdownlist/popup.downlist.js
  25. 4
      src/widget/quarter/combo.quarter.js
  26. 4
      src/widget/year/combo.year.js
  27. 1
      src/widget/yearmonth/combo.yearmonth.js
  28. 2
      utils/utils.js

23
Gruntfile.js

@ -111,8 +111,8 @@ module.exports = function (grunt) {
},
fineuiJs: {
src: ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "dist/fix/fix.compact.js", "dist/base.js", "dist/case.js", "dist/widget.js", "dist/router.js", "ui/js/**/*.js"],
dest: "dist/fineui.js"
src: ["dist/_fineui.min.js", "src/base/formula/formulaeditor.js"],
dest: "dist/fineui.min.js"
},
fineuiCss: {
@ -199,7 +199,23 @@ module.exports = function (grunt) {
dist: {
files: {
"dist/bundle.min.js": ["<%= concat.bundleJs.dest %>"],
"dist/fineui.min.js": ["<%= concat.fineuiJs.dest %>"]
"dist/_fineui.min.js": ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "dist/fix/fix.compact.js", "src/third/**/*.js",
"src/base/formula/config.js",
"src/base/pane.js",
"src/base/single/single.js",
"src/base/single/text.js",
"src/base/single/button/button.basic.js",
"src/base/single/button/button.node.js",
"src/base/single/tip/tip.js",
"src/base/combination/group.button.js",
"src/base/combination/tree.button.js",
"src/base/combination/map.button.js",
"src/base/tree/treeview.js",
"src/base/tree/asynctree.js",
"src/base/tree/parttree.js",
"src/base/**/*.js",
"!src/base/formula/formulaeditor.js",
"dist/case.js", "dist/widget.js", "dist/router.js", "ui/js/**/*.js"]
}
}
},
@ -254,4 +270,5 @@ module.exports = function (grunt) {
grunt.registerTask("default", ["less", "concat", "watch"]);
grunt.registerTask("min", ["less", "concat", "uglify", "cssmin"]);
grunt.registerTask("build", ["less", "concat", "uglify", "cssmin", "uglify", "concat"]);
};

4
demo/js/config/core.js

@ -160,6 +160,10 @@ Demo.CORE_CONFIG = [{
pId: 102,
id: 10202,
text: "弹出层"
}, {
pId: 10202,
text: "layer",
value: "demo.layer"
}, {
pId: 10202,
text: "bi.popover",

68
demo/js/core/popup/demo.layer.js

@ -0,0 +1,68 @@
/**
* Created by Windy on 2017/12/13.
*/
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
var self = this, id1 = BI.UUID(), id2 = BI.UUID();
return {
type: "bi.vertical",
vgap: 10,
items: [{
type: "bi.button",
text: "create形式创建layer, 遮住当前面板, 返回创建的面板对象",
height: 30,
handler: function () {
BI.Layers.create(id1, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
handler: function () {
BI.Layers.hide(id1);
}
}]
});
BI.Layers.show(id1);
}
}, {
type: "bi.button",
text: "make形式创建layer,可以指定放到哪个面板内,这里指定当前面板(默认放在body下撑满), 返回创建的面板对象",
height: 30,
handler: function () {
BI.Layers.make(id2, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
handler: function () {
BI.Layers.remove(id2);
}
}]
});
BI.Layers.show(id2);
}
}]
};
}
});
BI.shortcut("demo.layer", Demo.Func);

7
demo/js/core/popup/demo.popover.js

@ -8,10 +8,12 @@ Demo.Func = BI.inherit(BI.Widget, {
render: function () {
var id = BI.UUID();
return {
type: "bi.vertical",
vgap: 10,
items: [{
type: "bi.text_button",
text: "点击弹出Popover",
width: 200,
height: 80,
height: 30,
handler: function () {
BI.Popovers.remove(id);
BI.Popovers.create(id, {
@ -30,6 +32,7 @@ Demo.Func = BI.inherit(BI.Widget, {
// }
}).open(id);
}
}]
};
}
});

155
demo/js/widget/downlist/demo.downlist.js

@ -34,6 +34,10 @@ Demo.Downlist = BI.inherit(BI.Widget, {
mounted: function () {
var downlist = this.downlist;
var label = this.label;
this.downlist.setValue([{
value: [11, 6],
childValue: 67
}]);
downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) {
label.setValue(JSON.stringify(downlist.getValue()));
});
@ -54,95 +58,106 @@ Demo.Downlist = BI.inherit(BI.Widget, {
self.downlist = _ref;
},
cls: "layout-bg3",
value: [{"childValue":22,"value":11},{"value":18},{"value":20}],
// value: [{"childValue":22,"value":11},{"value":18},{"value":20}],
height: 30,
width: 100,
items: [[{text: "temp", value: 1111111}],
items: [
[{
el: {
text: "column 1111",
iconCls1: "check-mark-e-font",
value: 11
iconCls1: "dot-e-font",
value: 12
},
children: [{
text: "column 1.1",
value: 21,
cls: "dot-e-font"
}, {
text: "column 1.222222222222222222222222222222222222",
cls: "dot-e-font",
value: 22
text: "column 1.2",
value: 22,
cls: "dot-e-font"
}]
}],
[{
el: {
type: "bi.icon_text_icon_item",
text: "column 2",
iconCls1: "chart-type-e-font",
cls: "dot-e-font",
value: 12
text: "column 1111",
iconCls1: "dot-e-font",
value: 11
},
children: [{
type: "bi.icon_text_item",
cls: "dot-e-font",
height: 25,
text: "column 2.1",
value: 11
text: "column 1.1",
value: 21,
cls: "dot-e-font"
}, {
text: "column 2.2",
value: 12,
text: "column 1.2",
value: 22,
cls: "dot-e-font"
}]
}],
[{
text: "column 8",
value: 18,
cls: "dot-e-font"
},
{
text: "column 9",
cls: "dot-e-font",
value: 19
}
],
[{
text: "column 10",
value: 20,
cls: "dot-e-font"
},
{
text: "column 11",
cls: "dot-e-font",
value: 21
},
{
text: "column 12",
cls: "dot-e-font",
value: 22
},
{
text: "column 13",
cls: "dot-e-font",
value: 23
},
{
text: "column 14",
cls: "dot-e-font",
value: 24
},
{
text: "column 15",
cls: "dot-e-font",
value: 25,
bubble: "hahahaha"
}
]
// children: [{
// text: BI.i18nText("BI-Basic_None"),
// cls: "dot-e-font",
// value: 1
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Period"),
// cls: "dot-e-font",
// value: 2
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Ring"),
// cls: "dot-e-font",
// value: 3
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Period_Rate"),
// cls: "dot-e-font",
// value: 4
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Ring_Rate"),
// cls: "dot-e-font",
// value: 5
// }, {
// el: {
// text: BI.i18nText("BI-Basic_Rank"),
// iconCls1: "dot-e-font",
// value: 6
// },
// children: [{
// text: "test1",
// cls: "dot-e-font",
// value: 67
// }, {
// text: "test2",
// cls: "dot-e-font",
// value: 68
// }]
// }, {
// text: BI.i18nText("BI-Basic_Rank_In_Group"),
// cls: "dot-e-font",
// value: 7
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_All"),
// cls: "dot-e-font",
// value: 8
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_All_In_Group"),
// cls: "dot-e-font",
// value: 9
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_Above"),
// cls: "dot-e-font",
// value: 10
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_Above_In_Group"),
// cls: "dot-e-font",
// value: 11
// }, {
// text: BI.i18nText("BI-Design_Current_Dimension_Percent"),
// cls: "dot-e-font",
// value: 12
// }, {
// text: BI.i18nText("BI-Design_Current_Target_Percent"),
// cls: "dot-e-font",
// value: 13
// }]
}]
]
}, {
@ -156,7 +171,7 @@ Demo.Downlist = BI.inherit(BI.Widget, {
}],
vgap: 20
};
}
},
});
BI.shortcut("demo.down_list", Demo.Downlist);

2
dist/README.md vendored

@ -1,6 +1,6 @@
#### fineui.js
整个fineui打包文件,不包括配置文件和路由
整个fineui打包文件,不包括配置文件
#### fineui.css

50
dist/_fineui.min.js vendored

File diff suppressed because one or more lines are too long

6
dist/base.js vendored

@ -15418,12 +15418,12 @@ BI.Popover = BI.inherit(BI.Widget, {
open: function () {
this.show();
this.fireEvent(BI.Popover.EVENT_OPEN);
this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
},
close: function () {
this.hide();
this.fireEvent(BI.Popover.EVENT_CLOSE);
this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
},
setZindex: function (zindex) {
@ -19170,8 +19170,10 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
break;
}
};
if (isFunction(upload.onloadstart)) {
upload.onloadstart();
}
}
var boundary = "AjaxUploadBoundary" + (new Date).getTime();
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
if (handler.file.getAsBinary) {

462
dist/bundle.js vendored

@ -19488,7 +19488,7 @@ if (!window.BI) {
});
// 集合相关方法
_.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
_.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI[name] = _apply(name);
});
_.each(["get", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
@ -26573,14 +26573,15 @@ BI.LayerController = BI.inherit(BI.Controller, {
});
},
make: function (name, container, op) {
make: function (name, container, op, context) {
if (BI.isWidget(container)) {
op = op || {};
op.container = container;
} else {
context = op;
op = container;
}
return this.create(name, null, op);
return this.create(name, null, op, context);
},
create: function (name, from, op, context) {
@ -26599,10 +26600,9 @@ BI.LayerController = BI.inherit(BI.Controller, {
if (this.has(name)) {
return this.get(name);
}
var widget = BI.createWidget((op.render || {}), {
type: "bi.layout",
cls: op.cls
}, context);
var widget = BI.createWidget((op.render || {}), BI.extend({
type: "bi.layout"
}, op), context);
var layout = BI.createWidget({
type: "bi.absolute",
items: [{
@ -26629,16 +26629,16 @@ BI.LayerController = BI.inherit(BI.Controller, {
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
});
}
@ -49245,12 +49245,12 @@ BI.Popover = BI.inherit(BI.Widget, {
open: function () {
this.show();
this.fireEvent(BI.Popover.EVENT_OPEN);
this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
},
close: function () {
this.hide();
this.fireEvent(BI.Popover.EVENT_CLOSE);
this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
},
setZindex: function (zindex) {
@ -52997,8 +52997,10 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
break;
}
};
if (isFunction(upload.onloadstart)) {
upload.onloadstart();
}
}
var boundary = "AjaxUploadBoundary" + (new Date).getTime();
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
if (handler.file.getAsBinary) {
@ -84780,7 +84782,9 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
},
setValue: function (vals) {
this.trigger.setText(this._digest(vals, this.options.items));
var formatValue = this._digest(vals, this.options.items);
this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
this.trigger.setText(formatValue.text);
},
populate: function (items) {
@ -89152,7 +89156,11 @@ BI.MonthCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.popup.getValue();
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
@ -90453,6 +90461,421 @@ BI.YearCard = BI.inherit(BI.MultiDateCard, {
BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.yearcard", BI.YearCard);
/**
* Created by roy on 15/8/14.
*/
BI.DownListCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multilayer-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {}
});
},
_init: function () {
BI.DownListCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popupview = BI.createWidget({
type: "bi.multi_layer_down_list_popup",
items: o.items,
chooseType: o.chooseType,
value: o.value
});
this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
});
this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
});
this.downlistcombo = BI.createWidget({
element: this,
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "pull-down-font",
width: o.width,
height: o.height
}),
popup: {
el: this.popupview,
stopPropagation: true,
maxHeight: 1000
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
});
},
hideView: function () {
this.downlistcombo.hideView();
},
showView: function () {
this.downlistcombo.showView();
},
populate: function (items) {
this.popupview.populate(items);
},
setValue: function (v) {
this.popupview.setValue(v);
},
getValue: function () {
return this.popupview.getValue();
}
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/**
* Created by roy on 15/9/8.
* 处理popup中的item分组样式
* 一个item分组中的成员大于一时该分组设置为单选并且默认状态第一个成员设置为已选择项
*/
BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
constants: {
nextIcon: "pull-right-e-font",
height: 25,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1
},
_defaultConfig: function () {
var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: BI.Selection.Multi
});
},
_init: function () {
BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
var self = this, o = this.options, children = this._createPopupItems(o.items);
this.popup = BI.createWidget({
type: "bi.button_tree",
items: BI.createItems(children,
{}, {
adjustLength: -2
}
),
layouts: [{
type: "bi.vertical",
hgap: this.constants.hgap,
vgap: this.constants.vgap
}],
value: this._digest(o.value),
chooseType: o.chooseType
});
this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
var changedValue = value;
if (BI.isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
var fatherValue = self.fatherValueMap[value];
var fatherArrayValue = (fatherValue + "").split("_");
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue);
} else {
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object);
}
if (!self.singleValues.contains(changedValue)) {
var item = self.getValue();
var result = [];
BI.each(item, function (i, valueObject) {
if (valueObject.value != changedValue) {
result.push(valueObject);
}
});
self.setValue(result);
}
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.popup]
});
},
_createPopupItems: function (items) {
var self = this, result = [];
BI.each(items, function (i, it) {
var item_done = {
type: "bi.down_list_group",
items: []
};
BI.each(it, function (i, item) {
if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
item.type = "bi.combo_group";
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el.title = item.el.title || item.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true
};
item.el.height = self.constants.height;
item.el.iconCls2 = self.constants.nextIcon;
item.popup = {
lgap: 4,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
};
item.el.childValues = [];
BI.each(item.children, function (i, child) {
child = child.el ? BI.extend(child.el, {children: child.children}) : child;
var fatherValue = BI.deepClone(item.el.value);
var childValue = BI.deepClone(child.value);
self.singleValues.push(child.value);
child.type = "bi.down_list_item";
child.extraCls = " child-down-list-item";
child.title = child.title || child.text;
child.textRgap = 10;
child.isNeedAdjustWidth = false;
child.logic = {
dynamic: true
};
child.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
child.value = self._createChildValue(fatherValue, childValue);
item.el.childValues.push(child.value);
if (BI.isNotEmptyArray(child.children)) {
child.type = "bi.down_list_group_item";
self._createChildren(child);
child.height = self.constants.height;
child.iconCls2 = self.constants.nextIcon;
item.el.childValues = BI.concat(item.el.childValues, child.childValues);
}
});
} else {
item.type = "bi.down_list_item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true
};
}
var el_done = {};
el_done.el = item;
item_done.items.push(el_done);
});
if (self._isGroup(item_done.items)) {
BI.each(item_done.items, function (i, item) {
self.singleValues.push(item.el.value);
});
}
result.push(item_done);
if (self._needSpliter(i, items.length)) {
var spliter_container = BI.createWidget({
type: "bi.vertical",
items: [{
el: {
type: "bi.layout",
cls: "bi-down-list-spliter bi-border-top cursor-pointer",
height: 0
}
}],
cls: "bi-down-list-spliter-container cursor-pointer",
lgap: 10,
rgap: 10
});
result.push(spliter_container);
}
});
return result;
},
_createChildren: function (child) {
var self = this;
child.childValues = [];
BI.each(child.children, function (i, c) {
var fatherValue = BI.deepClone(child.value);
var childValue = BI.deepClone(c.value);
c.type = "bi.down_list_item";
c.title = c.title || c.text;
c.textRgap = 10;
c.isNeedAdjustWidth = false;
c.logic = {
dynamic: true
};
c.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
c.value = self._createChildValue(fatherValue, childValue);
child.childValues.push(c.value);
});
},
_isGroup: function (i) {
return i.length > 1;
},
_needSpliter: function (i, itemLength) {
return i < itemLength - 1;
},
_createChildValue: function (fatherValue, childValue) {
var fValue = fatherValue;
if(BI.isArray(fatherValue)) {
fValue = fatherValue.join("_");
}
return fValue + "_" + childValue;
},
_digest: function (valueItem) {
var self = this;
var valueArray = [];
BI.each(valueItem, function (i, item) {
var value;
if (BI.isNotNull(item.childValue)) {
value = self._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
}
);
return valueArray;
},
_checkValues: function (values) {
var self = this, o = this.options;
var value = [];
BI.each(o.items, function (idx, itemGroup) {
BI.each(itemGroup, function (id, item) {
if(BI.isNotNull(item.children)) {
var childValues = getChildrenValue(item);
var v = joinValue(childValues, values[idx]);
if(BI.isNotEmptyString(v)) {
value.push(v);
}
}else{
if(item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
return value;
function joinValue (sources, targets) {
var value = "";
BI.some(sources, function (idx, s) {
return BI.some(targets, function (id, t) {
if(s === t) {
value = s;
return true;
}
});
});
return value;
}
function getChildrenValue (item) {
var children = [];
if(BI.isNotNull(item.children)) {
BI.each(item.children, function (idx, child) {
children = BI.concat(children, getChildrenValue(child));
});
} else {
children.push(item.value);
}
return children;
}
},
populate: function (items) {
BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments);
var self = this;
self.childValueMap = {};
self.fatherValueMap = {};
self.singleValues = [];
var children = self._createPopupItems(items);
var popupItem = BI.createItems(children,
{}, {
adjustLength: -2
}
);
self.popup.populate(popupItem);
},
setValue: function (valueItem) {
this.popup.setValue(this._digest(valueItem));
},
_getValue: function () {
var v = [];
BI.each(this.popup.getAllButtons(), function (i, item) {
i % 2 === 0 && v.push(item.getValue());
});
return v;
},
getValue: function () {
var self = this, result = [];
var values = this._checkValues(this._getValue());
BI.each(values, function (i, value) {
var valueItem = {};
if (BI.isNotNull(self.childValueMap[value])) {
var fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
var fatherArrayValue = (fartherValue + "").split("_");
valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
});
BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/**
* @class BI.MultiLayerSelectTreeCombo
* @extends BI.Widget
*/
@ -96802,8 +97225,12 @@ BI.QuarterCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
@ -102316,8 +102743,12 @@ BI.YearCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value;
} else {
return this.popup.getValue();
}
}
});
BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
@ -102576,6 +103007,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, {
});
this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
self.getValue();
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
});
this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {

46
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

4
dist/case.js vendored

@ -14322,7 +14322,9 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
},
setValue: function (vals) {
this.trigger.setText(this._digest(vals, this.options.items));
var formatValue = this._digest(vals, this.options.items);
this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
this.trigger.setText(formatValue.text);
},
populate: function (items) {

22
dist/core.js vendored

@ -19488,7 +19488,7 @@ if (!window.BI) {
});
// 集合相关方法
_.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
_.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI[name] = _apply(name);
});
_.each(["get", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
@ -26573,14 +26573,15 @@ BI.LayerController = BI.inherit(BI.Controller, {
});
},
make: function (name, container, op) {
make: function (name, container, op, context) {
if (BI.isWidget(container)) {
op = op || {};
op.container = container;
} else {
context = op;
op = container;
}
return this.create(name, null, op);
return this.create(name, null, op, context);
},
create: function (name, from, op, context) {
@ -26599,10 +26600,9 @@ BI.LayerController = BI.inherit(BI.Controller, {
if (this.has(name)) {
return this.get(name);
}
var widget = BI.createWidget((op.render || {}), {
type: "bi.layout",
cls: op.cls
}, context);
var widget = BI.createWidget((op.render || {}), BI.extend({
type: "bi.layout"
}, op), context);
var layout = BI.createWidget({
type: "bi.absolute",
items: [{
@ -26629,16 +26629,16 @@ BI.LayerController = BI.inherit(BI.Controller, {
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
});
}

233
dist/demo.js vendored

@ -5483,6 +5483,10 @@ Demo.COMPONENT_CONFIG = [{
pId: 102,
id: 10202,
text: "弹出层"
}, {
pId: 10202,
text: "layer",
value: "demo.layer"
}, {
pId: 10202,
text: "bi.popover",
@ -8461,6 +8465,73 @@ Demo.VtapeLayout = BI.inherit(BI.Widget, {
BI.shortcut("demo.vtape", Demo.VtapeLayout);/**
* Created by Windy on 2017/12/13.
*/
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
var self = this, id1 = BI.UUID(), id2 = BI.UUID();
return {
type: "bi.vertical",
vgap: 10,
items: [{
type: "bi.button",
text: "create形式创建layer, 遮住当前面板, 返回创建的面板对象",
height: 30,
handler: function () {
BI.Layers.create(id1, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
handler: function () {
BI.Layers.hide(id1);
}
}]
});
BI.Layers.show(id1);
}
}, {
type: "bi.button",
text: "make形式创建layer,可以指定放到哪个面板内,这里指定当前面板(默认放在body下撑满), 返回创建的面板对象",
height: 30,
handler: function () {
BI.Layers.make(id2, self, {
//偏移量
offset: {
left: 10,
right: 10,
top: 10,
bottom: 10
},
type: "bi.center_adapt",
cls: "bi-card",
items: [{
type: "bi.button",
text: "点击关闭",
handler: function () {
BI.Layers.remove(id2);
}
}]
});
BI.Layers.show(id2);
}
}]
};
}
});
BI.shortcut("demo.layer", Demo.Func);/**
* Created by Windy on 2017/12/13.
*/
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
@ -8468,10 +8539,12 @@ Demo.Func = BI.inherit(BI.Widget, {
render: function () {
var id = BI.UUID();
return {
type: "bi.vertical",
vgap: 10,
items: [{
type: "bi.text_button",
text: "点击弹出Popover",
width: 200,
height: 80,
height: 30,
handler: function () {
BI.Popovers.remove(id);
BI.Popovers.create(id, {
@ -8490,6 +8563,7 @@ Demo.Func = BI.inherit(BI.Widget, {
// }
}).open(id);
}
}]
};
}
});
@ -12059,6 +12133,10 @@ Demo.Downlist = BI.inherit(BI.Widget, {
mounted: function () {
var downlist = this.downlist;
var label = this.label;
this.downlist.setValue([{
value: [11, 6],
childValue: 67
}]);
downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) {
label.setValue(JSON.stringify(downlist.getValue()));
});
@ -12079,95 +12157,106 @@ Demo.Downlist = BI.inherit(BI.Widget, {
self.downlist = _ref;
},
cls: "layout-bg3",
value: [{"childValue":22,"value":11},{"value":18},{"value":20}],
// value: [{"childValue":22,"value":11},{"value":18},{"value":20}],
height: 30,
width: 100,
items: [[{text: "temp", value: 1111111}],
items: [
[{
el: {
text: "column 1111",
iconCls1: "check-mark-e-font",
value: 11
iconCls1: "dot-e-font",
value: 12
},
children: [{
text: "column 1.1",
value: 21,
cls: "dot-e-font"
}, {
text: "column 1.222222222222222222222222222222222222",
cls: "dot-e-font",
value: 22
text: "column 1.2",
value: 22,
cls: "dot-e-font"
}]
}],
[{
el: {
type: "bi.icon_text_icon_item",
text: "column 2",
iconCls1: "chart-type-e-font",
cls: "dot-e-font",
value: 12
text: "column 1111",
iconCls1: "dot-e-font",
value: 11
},
children: [{
type: "bi.icon_text_item",
cls: "dot-e-font",
height: 25,
text: "column 2.1",
value: 11
text: "column 1.1",
value: 21,
cls: "dot-e-font"
}, {
text: "column 2.2",
value: 12,
text: "column 1.2",
value: 22,
cls: "dot-e-font"
}]
}],
[{
text: "column 8",
value: 18,
cls: "dot-e-font"
},
{
text: "column 9",
cls: "dot-e-font",
value: 19
}
],
[{
text: "column 10",
value: 20,
cls: "dot-e-font"
},
{
text: "column 11",
cls: "dot-e-font",
value: 21
},
{
text: "column 12",
cls: "dot-e-font",
value: 22
},
{
text: "column 13",
cls: "dot-e-font",
value: 23
},
{
text: "column 14",
cls: "dot-e-font",
value: 24
},
{
text: "column 15",
cls: "dot-e-font",
value: 25,
bubble: "hahahaha"
}
]
// children: [{
// text: BI.i18nText("BI-Basic_None"),
// cls: "dot-e-font",
// value: 1
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Period"),
// cls: "dot-e-font",
// value: 2
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Ring"),
// cls: "dot-e-font",
// value: 3
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Period_Rate"),
// cls: "dot-e-font",
// value: 4
// }, {
// text: BI.i18nText("BI-Basic_Calculate_Same_Ring_Rate"),
// cls: "dot-e-font",
// value: 5
// }, {
// el: {
// text: BI.i18nText("BI-Basic_Rank"),
// iconCls1: "dot-e-font",
// value: 6
// },
// children: [{
// text: "test1",
// cls: "dot-e-font",
// value: 67
// }, {
// text: "test2",
// cls: "dot-e-font",
// value: 68
// }]
// }, {
// text: BI.i18nText("BI-Basic_Rank_In_Group"),
// cls: "dot-e-font",
// value: 7
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_All"),
// cls: "dot-e-font",
// value: 8
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_All_In_Group"),
// cls: "dot-e-font",
// value: 9
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_Above"),
// cls: "dot-e-font",
// value: 10
// }, {
// text: BI.i18nText("BI-Basic_Sum_Of_Above_In_Group"),
// cls: "dot-e-font",
// value: 11
// }, {
// text: BI.i18nText("BI-Design_Current_Dimension_Percent"),
// cls: "dot-e-font",
// value: 12
// }, {
// text: BI.i18nText("BI-Design_Current_Target_Percent"),
// cls: "dot-e-font",
// value: 13
// }]
}]
]
}, {
@ -12181,7 +12270,7 @@ Demo.Downlist = BI.inherit(BI.Widget, {
}],
vgap: 20
};
}
},
});
BI.shortcut("demo.down_list", Demo.Downlist);/**

451
dist/fineui.js vendored

@ -26816,14 +26816,15 @@ BI.LayerController = BI.inherit(BI.Controller, {
});
},
make: function (name, container, op) {
make: function (name, container, op, context) {
if (BI.isWidget(container)) {
op = op || {};
op.container = container;
} else {
context = op;
op = container;
}
return this.create(name, null, op);
return this.create(name, null, op, context);
},
create: function (name, from, op, context) {
@ -26842,10 +26843,9 @@ BI.LayerController = BI.inherit(BI.Controller, {
if (this.has(name)) {
return this.get(name);
}
var widget = BI.createWidget((op.render || {}), {
type: "bi.layout",
cls: op.cls
}, context);
var widget = BI.createWidget((op.render || {}), BI.extend({
type: "bi.layout"
}, op), context);
var layout = BI.createWidget({
type: "bi.absolute",
items: [{
@ -26872,16 +26872,16 @@ BI.LayerController = BI.inherit(BI.Controller, {
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
});
}
@ -51051,12 +51051,12 @@ BI.Popover = BI.inherit(BI.Widget, {
open: function () {
this.show();
this.fireEvent(BI.Popover.EVENT_OPEN);
this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
},
close: function () {
this.hide();
this.fireEvent(BI.Popover.EVENT_CLOSE);
this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
},
setZindex: function (zindex) {
@ -90958,7 +90958,11 @@ BI.MonthCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.popup.getValue();
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
@ -92259,6 +92263,418 @@ BI.YearCard = BI.inherit(BI.MultiDateCard, {
BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.yearcard", BI.YearCard);
/**
* Created by roy on 15/8/14.
*/
BI.DownListCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multilayer-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {}
});
},
_init: function () {
BI.DownListCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popupview = BI.createWidget({
type: "bi.multi_layer_down_list_popup",
items: o.items,
chooseType: o.chooseType,
value: o.value
});
this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
});
this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
});
this.downlistcombo = BI.createWidget({
element: this,
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "pull-down-font",
width: o.width,
height: o.height
}),
popup: {
el: this.popupview,
stopPropagation: true,
maxHeight: 1000
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
});
},
hideView: function () {
this.downlistcombo.hideView();
},
showView: function () {
this.downlistcombo.showView();
},
populate: function (items) {
this.popupview.populate(items);
},
setValue: function (v) {
this.popupview.setValue(v);
},
getValue: function () {
return this.popupview.getValue();
}
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/**
* Created by roy on 15/9/8.
* 处理popup中的item分组样式
* 一个item分组中的成员大于一时该分组设置为单选并且默认状态第一个成员设置为已选择项
*/
BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
constants: {
nextIcon: "pull-right-e-font",
height: 25,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1
},
_defaultConfig: function () {
var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: BI.Selection.Multi
});
},
_init: function () {
BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
var self = this, o = this.options, children = this._createPopupItems(o.items);
this.popup = BI.createWidget({
type: "bi.button_tree",
items: BI.createItems(children,
{}, {
adjustLength: -2
}
),
layouts: [{
type: "bi.vertical",
hgap: this.constants.hgap,
vgap: this.constants.vgap
}],
value: this._digest(o.value),
chooseType: o.chooseType
});
this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
var changedValue = value;
if (BI.isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]);
} else {
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object);
}
if (!self.singleValues.contains(changedValue)) {
var item = self.getValue();
var result = [];
BI.each(item, function (i, valueObject) {
if (valueObject.value != changedValue) {
result.push(valueObject);
}
});
self.setValue(result);
}
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.popup]
});
},
_createPopupItems: function (items) {
var self = this, result = [];
BI.each(items, function (i, it) {
var item_done = {
type: "bi.down_list_group",
items: []
};
BI.each(it, function (i, item) {
if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
item.type = "bi.combo_group";
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el.title = item.el.title || item.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true
};
item.el.height = self.constants.height;
item.el.iconCls2 = self.constants.nextIcon;
item.popup = {
lgap: 4,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
};
item.el.childValues = [];
BI.each(item.children, function (i, child) {
child = child.el ? BI.extend(child.el, {children: child.children}) : child;
var fatherValue = BI.deepClone(item.el.value);
var childValue = BI.deepClone(child.value);
self.singleValues.push(child.value);
child.type = "bi.down_list_item";
child.extraCls = " child-down-list-item";
child.title = child.title || child.text;
child.textRgap = 10;
child.isNeedAdjustWidth = false;
child.logic = {
dynamic: true
};
child.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
child.value = self._createChildValue(fatherValue, childValue);
item.el.childValues.push(child.value);
if (BI.isNotEmptyArray(child.children)) {
child.type = "bi.down_list_group_item";
self._createChildren(child);
child.height = self.constants.height;
child.iconCls2 = self.constants.nextIcon;
item.el.childValues = BI.concat(item.el.childValues, child.childValues);
}
});
} else {
item.type = "bi.down_list_item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true
};
}
var el_done = {};
el_done.el = item;
item_done.items.push(el_done);
});
if (self._isGroup(item_done.items)) {
BI.each(item_done.items, function (i, item) {
self.singleValues.push(item.el.value);
});
}
result.push(item_done);
if (self._needSpliter(i, items.length)) {
var spliter_container = BI.createWidget({
type: "bi.vertical",
items: [{
el: {
type: "bi.layout",
cls: "bi-down-list-spliter bi-border-top cursor-pointer",
height: 0
}
}],
cls: "bi-down-list-spliter-container cursor-pointer",
lgap: 10,
rgap: 10
});
result.push(spliter_container);
}
});
return result;
},
_createChildren: function (child) {
var self = this;
child.childValues = [];
BI.each(child.children, function (i, c) {
var fatherValue = BI.deepClone(child.value);
var childValue = BI.deepClone(c.value);
c.type = "bi.down_list_item";
c.title = c.title || c.text;
c.textRgap = 10;
c.isNeedAdjustWidth = false;
c.logic = {
dynamic: true
};
c.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
c.value = self._createChildValue(fatherValue, childValue);
child.childValues.push(c.value);
});
},
_isGroup: function (i) {
return i.length > 1;
},
_needSpliter: function (i, itemLength) {
return i < itemLength - 1;
},
_createChildValue: function (fatherValue, childValue) {
var fValue = fatherValue;
if(BI.isArray(fatherValue)) {
fValue = fatherValue.join("_");
}
return fValue + "_" + childValue;
},
_digest: function (valueItem) {
var self = this;
var valueArray = [];
BI.each(valueItem, function (i, item) {
var value;
if (BI.isNotNull(item.childValue)) {
value = self._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
}
);
return valueArray;
},
_checkValues: function (values) {
var self = this, o = this.options;
var value = [];
BI.each(o.items, function (idx, itemGroup) {
BI.each(itemGroup, function (id, item) {
if(BI.isNotNull(item.children)) {
var childValues = getChildrenValue(item);
var v = joinValue(childValues, values[idx]);
if(BI.isNotEmptyString(v)) {
value.push(v);
}
}else{
if(item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
return value;
function joinValue (sources, targets) {
var value = "";
BI.some(sources, function (idx, s) {
return BI.some(targets, function (id, t) {
if(s === t) {
value = s;
return true;
}
});
});
return value;
}
function getChildrenValue (item) {
var children = [];
if(BI.isNotNull(item.children)) {
BI.each(item.children, function (idx, child) {
children = BI.concat(children, getChildrenValue(child));
});
} else {
children.push(item.value);
}
return children;
}
},
populate: function (items) {
BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments);
var self = this;
self.childValueMap = {};
self.fatherValueMap = {};
self.singleValues = [];
var children = self._createPopupItems(items);
var popupItem = BI.createItems(children,
{}, {
adjustLength: -2
}
);
self.popup.populate(popupItem);
},
setValue: function (valueItem) {
this.popup.setValue(this._digest(valueItem));
},
_getValue: function () {
var v = [];
BI.each(this.popup.getAllButtons(), function (i, item) {
i % 2 === 0 && v.push(item.getValue());
});
return v;
},
getValue: function () {
var self = this, result = [];
var values = this._checkValues(this._getValue());
BI.each(values, function (i, value) {
var valueItem = {};
if (BI.isNotNull(self.childValueMap[value])) {
var fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
valueItem.value = fartherValue.split("_");
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
});
BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/**
* @class BI.MultiLayerSelectTreeCombo
* @extends BI.Widget
*/
@ -98608,8 +99024,12 @@ BI.QuarterCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
@ -104122,8 +104542,12 @@ BI.YearCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value;
} else {
return this.popup.getValue();
}
}
});
BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
@ -104382,6 +104806,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, {
});
this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
self.getValue();
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
});
this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {

323
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

430
dist/widget.js vendored

@ -4307,7 +4307,11 @@ BI.MonthCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.popup.getValue();
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
@ -5608,6 +5612,421 @@ BI.YearCard = BI.inherit(BI.MultiDateCard, {
BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.yearcard", BI.YearCard);
/**
* Created by roy on 15/8/14.
*/
BI.DownListCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multilayer-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {}
});
},
_init: function () {
BI.DownListCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popupview = BI.createWidget({
type: "bi.multi_layer_down_list_popup",
items: o.items,
chooseType: o.chooseType,
value: o.value
});
this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
});
this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
});
this.downlistcombo = BI.createWidget({
element: this,
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "pull-down-font",
width: o.width,
height: o.height
}),
popup: {
el: this.popupview,
stopPropagation: true,
maxHeight: 1000
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
});
},
hideView: function () {
this.downlistcombo.hideView();
},
showView: function () {
this.downlistcombo.showView();
},
populate: function (items) {
this.popupview.populate(items);
},
setValue: function (v) {
this.popupview.setValue(v);
},
getValue: function () {
return this.popupview.getValue();
}
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/**
* Created by roy on 15/9/8.
* 处理popup中的item分组样式
* 一个item分组中的成员大于一时该分组设置为单选并且默认状态第一个成员设置为已选择项
*/
BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
constants: {
nextIcon: "pull-right-e-font",
height: 25,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1
},
_defaultConfig: function () {
var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: BI.Selection.Multi
});
},
_init: function () {
BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
var self = this, o = this.options, children = this._createPopupItems(o.items);
this.popup = BI.createWidget({
type: "bi.button_tree",
items: BI.createItems(children,
{}, {
adjustLength: -2
}
),
layouts: [{
type: "bi.vertical",
hgap: this.constants.hgap,
vgap: this.constants.vgap
}],
value: this._digest(o.value),
chooseType: o.chooseType
});
this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
var changedValue = value;
if (BI.isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
var fatherValue = self.fatherValueMap[value];
var fatherArrayValue = (fatherValue + "").split("_");
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue);
} else {
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object);
}
if (!self.singleValues.contains(changedValue)) {
var item = self.getValue();
var result = [];
BI.each(item, function (i, valueObject) {
if (valueObject.value != changedValue) {
result.push(valueObject);
}
});
self.setValue(result);
}
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.popup]
});
},
_createPopupItems: function (items) {
var self = this, result = [];
BI.each(items, function (i, it) {
var item_done = {
type: "bi.down_list_group",
items: []
};
BI.each(it, function (i, item) {
if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
item.type = "bi.combo_group";
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el.title = item.el.title || item.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true
};
item.el.height = self.constants.height;
item.el.iconCls2 = self.constants.nextIcon;
item.popup = {
lgap: 4,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
};
item.el.childValues = [];
BI.each(item.children, function (i, child) {
child = child.el ? BI.extend(child.el, {children: child.children}) : child;
var fatherValue = BI.deepClone(item.el.value);
var childValue = BI.deepClone(child.value);
self.singleValues.push(child.value);
child.type = "bi.down_list_item";
child.extraCls = " child-down-list-item";
child.title = child.title || child.text;
child.textRgap = 10;
child.isNeedAdjustWidth = false;
child.logic = {
dynamic: true
};
child.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
child.value = self._createChildValue(fatherValue, childValue);
item.el.childValues.push(child.value);
if (BI.isNotEmptyArray(child.children)) {
child.type = "bi.down_list_group_item";
self._createChildren(child);
child.height = self.constants.height;
child.iconCls2 = self.constants.nextIcon;
item.el.childValues = BI.concat(item.el.childValues, child.childValues);
}
});
} else {
item.type = "bi.down_list_item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true
};
}
var el_done = {};
el_done.el = item;
item_done.items.push(el_done);
});
if (self._isGroup(item_done.items)) {
BI.each(item_done.items, function (i, item) {
self.singleValues.push(item.el.value);
});
}
result.push(item_done);
if (self._needSpliter(i, items.length)) {
var spliter_container = BI.createWidget({
type: "bi.vertical",
items: [{
el: {
type: "bi.layout",
cls: "bi-down-list-spliter bi-border-top cursor-pointer",
height: 0
}
}],
cls: "bi-down-list-spliter-container cursor-pointer",
lgap: 10,
rgap: 10
});
result.push(spliter_container);
}
});
return result;
},
_createChildren: function (child) {
var self = this;
child.childValues = [];
BI.each(child.children, function (i, c) {
var fatherValue = BI.deepClone(child.value);
var childValue = BI.deepClone(c.value);
c.type = "bi.down_list_item";
c.title = c.title || c.text;
c.textRgap = 10;
c.isNeedAdjustWidth = false;
c.logic = {
dynamic: true
};
c.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
c.value = self._createChildValue(fatherValue, childValue);
child.childValues.push(c.value);
});
},
_isGroup: function (i) {
return i.length > 1;
},
_needSpliter: function (i, itemLength) {
return i < itemLength - 1;
},
_createChildValue: function (fatherValue, childValue) {
var fValue = fatherValue;
if(BI.isArray(fatherValue)) {
fValue = fatherValue.join("_");
}
return fValue + "_" + childValue;
},
_digest: function (valueItem) {
var self = this;
var valueArray = [];
BI.each(valueItem, function (i, item) {
var value;
if (BI.isNotNull(item.childValue)) {
value = self._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
}
);
return valueArray;
},
_checkValues: function (values) {
var self = this, o = this.options;
var value = [];
BI.each(o.items, function (idx, itemGroup) {
BI.each(itemGroup, function (id, item) {
if(BI.isNotNull(item.children)) {
var childValues = getChildrenValue(item);
var v = joinValue(childValues, values[idx]);
if(BI.isNotEmptyString(v)) {
value.push(v);
}
}else{
if(item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
return value;
function joinValue (sources, targets) {
var value = "";
BI.some(sources, function (idx, s) {
return BI.some(targets, function (id, t) {
if(s === t) {
value = s;
return true;
}
});
});
return value;
}
function getChildrenValue (item) {
var children = [];
if(BI.isNotNull(item.children)) {
BI.each(item.children, function (idx, child) {
children = BI.concat(children, getChildrenValue(child));
});
} else {
children.push(item.value);
}
return children;
}
},
populate: function (items) {
BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments);
var self = this;
self.childValueMap = {};
self.fatherValueMap = {};
self.singleValues = [];
var children = self._createPopupItems(items);
var popupItem = BI.createItems(children,
{}, {
adjustLength: -2
}
);
self.popup.populate(popupItem);
},
setValue: function (valueItem) {
this.popup.setValue(this._digest(valueItem));
},
_getValue: function () {
var v = [];
BI.each(this.popup.getAllButtons(), function (i, item) {
i % 2 === 0 && v.push(item.getValue());
});
return v;
},
getValue: function () {
var self = this, result = [];
var values = this._checkValues(this._getValue());
BI.each(values, function (i, value) {
var valueItem = {};
if (BI.isNotNull(self.childValueMap[value])) {
var fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
var fatherArrayValue = (fartherValue + "").split("_");
valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
});
BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/**
* @class BI.MultiLayerSelectTreeCombo
* @extends BI.Widget
*/
@ -11957,8 +12376,12 @@ BI.QuarterCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
@ -17471,8 +17894,12 @@ BI.YearCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value;
} else {
return this.popup.getValue();
}
}
});
BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
@ -17731,6 +18158,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, {
});
this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
self.getValue();
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
});
this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {

3
package.json

@ -18,7 +18,8 @@
"scripts": {
"grunt": "grunt",
"start": "node server.js",
"uglify": "grunt min"
"uglify": "grunt min",
"build": "grunt build"
},
"repository": {
"type": "git",

4
src/base/layer/layer.popover.js

@ -115,12 +115,12 @@ BI.Popover = BI.inherit(BI.Widget, {
open: function () {
this.show();
this.fireEvent(BI.Popover.EVENT_OPEN);
this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
},
close: function () {
this.hide();
this.fireEvent(BI.Popover.EVENT_CLOSE);
this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
},
setZindex: function (zindex) {

2
src/base/single/input/file.js

@ -214,8 +214,10 @@
break;
}
};
if (isFunction(upload.onloadstart)) {
upload.onloadstart();
}
}
var boundary = "AjaxUploadBoundary" + (new Date).getTime();
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
if (handler.file.getAsBinary) {

4
src/case/trigger/trigger.text.select.small.js

@ -52,7 +52,9 @@ BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
},
setValue: function (vals) {
this.trigger.setText(this._digest(vals, this.options.items));
var formatValue = this._digest(vals, this.options.items);
this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
this.trigger.setText(formatValue.text);
},
populate: function (items) {

20
src/core/controller/controller.layer.js

@ -27,14 +27,15 @@ BI.LayerController = BI.inherit(BI.Controller, {
});
},
make: function (name, container, op) {
make: function (name, container, op, context) {
if (BI.isWidget(container)) {
op = op || {};
op.container = container;
} else {
context = op;
op = container;
}
return this.create(name, null, op);
return this.create(name, null, op, context);
},
create: function (name, from, op, context) {
@ -53,10 +54,9 @@ BI.LayerController = BI.inherit(BI.Controller, {
if (this.has(name)) {
return this.get(name);
}
var widget = BI.createWidget((op.render || {}), {
type: "bi.layout",
cls: op.cls
}, context);
var widget = BI.createWidget((op.render || {}), BI.extend({
type: "bi.layout"
}, op), context);
var layout = BI.createWidget({
type: "bi.absolute",
items: [{
@ -83,16 +83,16 @@ BI.LayerController = BI.inherit(BI.Controller, {
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.bottom || 0)) || ""
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
});
}

6
src/widget/month/combo.month.js

@ -78,7 +78,11 @@ BI.MonthCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
return this.popup.getValue();
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});

90
src/widget/multilayerdownlist/combo.downlist.js

@ -0,0 +1,90 @@
/**
* Created by roy on 15/8/14.
*/
BI.DownListCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multilayer-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {}
});
},
_init: function () {
BI.DownListCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popupview = BI.createWidget({
type: "bi.multi_layer_down_list_popup",
items: o.items,
chooseType: o.chooseType,
value: o.value
});
this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
});
this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
});
this.downlistcombo = BI.createWidget({
element: this,
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "pull-down-font",
width: o.width,
height: o.height
}),
popup: {
el: this.popupview,
stopPropagation: true,
maxHeight: 1000
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
});
},
hideView: function () {
this.downlistcombo.hideView();
},
showView: function () {
this.downlistcombo.showView();
},
populate: function (items) {
this.popupview.populate(items);
},
setValue: function (v) {
this.popupview.setValue(v);
},
getValue: function () {
return this.popupview.getValue();
}
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);

327
src/widget/multilayerdownlist/popup.downlist.js

@ -0,0 +1,327 @@
/**
* Created by roy on 15/9/8.
* 处理popup中的item分组样式
* 一个item分组中的成员大于一时该分组设置为单选并且默认状态第一个成员设置为已选择项
*/
BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
constants: {
nextIcon: "pull-right-e-font",
height: 25,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1
},
_defaultConfig: function () {
var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: BI.Selection.Multi
});
},
_init: function () {
BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
var self = this, o = this.options, children = this._createPopupItems(o.items);
this.popup = BI.createWidget({
type: "bi.button_tree",
items: BI.createItems(children,
{}, {
adjustLength: -2
}
),
layouts: [{
type: "bi.vertical",
hgap: this.constants.hgap,
vgap: this.constants.vgap
}],
value: this._digest(o.value),
chooseType: o.chooseType
});
this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
var changedValue = value;
if (BI.isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
var fatherValue = self.fatherValueMap[value];
var fatherArrayValue = (fatherValue + "").split("_");
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue);
} else {
self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object);
}
if (!self.singleValues.contains(changedValue)) {
var item = self.getValue();
var result = [];
BI.each(item, function (i, valueObject) {
if (valueObject.value != changedValue) {
result.push(valueObject);
}
});
self.setValue(result);
}
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.popup]
});
},
_createPopupItems: function (items) {
var self = this, result = [];
BI.each(items, function (i, it) {
var item_done = {
type: "bi.down_list_group",
items: []
};
BI.each(it, function (i, item) {
if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
item.type = "bi.combo_group";
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el.title = item.el.title || item.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true
};
item.el.height = self.constants.height;
item.el.iconCls2 = self.constants.nextIcon;
item.popup = {
lgap: 4,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}
};
item.el.childValues = [];
BI.each(item.children, function (i, child) {
child = child.el ? BI.extend(child.el, {children: child.children}) : child;
var fatherValue = BI.deepClone(item.el.value);
var childValue = BI.deepClone(child.value);
self.singleValues.push(child.value);
child.type = "bi.down_list_item";
child.extraCls = " child-down-list-item";
child.title = child.title || child.text;
child.textRgap = 10;
child.isNeedAdjustWidth = false;
child.logic = {
dynamic: true
};
child.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
child.value = self._createChildValue(fatherValue, childValue);
item.el.childValues.push(child.value);
if (BI.isNotEmptyArray(child.children)) {
child.type = "bi.down_list_group_item";
self._createChildren(child);
child.height = self.constants.height;
child.iconCls2 = self.constants.nextIcon;
item.el.childValues = BI.concat(item.el.childValues, child.childValues);
}
});
} else {
item.type = "bi.down_list_item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true
};
}
var el_done = {};
el_done.el = item;
item_done.items.push(el_done);
});
if (self._isGroup(item_done.items)) {
BI.each(item_done.items, function (i, item) {
self.singleValues.push(item.el.value);
});
}
result.push(item_done);
if (self._needSpliter(i, items.length)) {
var spliter_container = BI.createWidget({
type: "bi.vertical",
items: [{
el: {
type: "bi.layout",
cls: "bi-down-list-spliter bi-border-top cursor-pointer",
height: 0
}
}],
cls: "bi-down-list-spliter-container cursor-pointer",
lgap: 10,
rgap: 10
});
result.push(spliter_container);
}
});
return result;
},
_createChildren: function (child) {
var self = this;
child.childValues = [];
BI.each(child.children, function (i, c) {
var fatherValue = BI.deepClone(child.value);
var childValue = BI.deepClone(c.value);
c.type = "bi.down_list_item";
c.title = c.title || c.text;
c.textRgap = 10;
c.isNeedAdjustWidth = false;
c.logic = {
dynamic: true
};
c.father = fatherValue;
self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
c.value = self._createChildValue(fatherValue, childValue);
child.childValues.push(c.value);
});
},
_isGroup: function (i) {
return i.length > 1;
},
_needSpliter: function (i, itemLength) {
return i < itemLength - 1;
},
_createChildValue: function (fatherValue, childValue) {
var fValue = fatherValue;
if(BI.isArray(fatherValue)) {
fValue = fatherValue.join("_");
}
return fValue + "_" + childValue;
},
_digest: function (valueItem) {
var self = this;
var valueArray = [];
BI.each(valueItem, function (i, item) {
var value;
if (BI.isNotNull(item.childValue)) {
value = self._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
}
);
return valueArray;
},
_checkValues: function (values) {
var self = this, o = this.options;
var value = [];
BI.each(o.items, function (idx, itemGroup) {
BI.each(itemGroup, function (id, item) {
if(BI.isNotNull(item.children)) {
var childValues = getChildrenValue(item);
var v = joinValue(childValues, values[idx]);
if(BI.isNotEmptyString(v)) {
value.push(v);
}
}else{
if(item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
return value;
function joinValue (sources, targets) {
var value = "";
BI.some(sources, function (idx, s) {
return BI.some(targets, function (id, t) {
if(s === t) {
value = s;
return true;
}
});
});
return value;
}
function getChildrenValue (item) {
var children = [];
if(BI.isNotNull(item.children)) {
BI.each(item.children, function (idx, child) {
children = BI.concat(children, getChildrenValue(child));
});
} else {
children.push(item.value);
}
return children;
}
},
populate: function (items) {
BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments);
var self = this;
self.childValueMap = {};
self.fatherValueMap = {};
self.singleValues = [];
var children = self._createPopupItems(items);
var popupItem = BI.createItems(children,
{}, {
adjustLength: -2
}
);
self.popup.populate(popupItem);
},
setValue: function (valueItem) {
this.popup.setValue(this._digest(valueItem));
},
_getValue: function () {
var v = [];
BI.each(this.popup.getAllButtons(), function (i, item) {
i % 2 === 0 && v.push(item.getValue());
});
return v;
},
getValue: function () {
var self = this, result = [];
var values = this._checkValues(this._getValue());
BI.each(values, function (i, value) {
var valueItem = {};
if (BI.isNotNull(self.childValueMap[value])) {
var fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
var fatherArrayValue = (fartherValue + "").split("_");
valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
});
BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);

4
src/widget/quarter/combo.quarter.js

@ -78,8 +78,12 @@ BI.QuarterCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";

4
src/widget/year/combo.year.js

@ -97,8 +97,12 @@ BI.YearCombo = BI.inherit(BI.Widget, {
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value;
} else {
return this.popup.getValue();
}
}
});
BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";

1
src/widget/yearmonth/combo.yearmonth.js

@ -39,6 +39,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, {
});
this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
self.getValue();
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
});
this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {

2
utils/utils.js

@ -10696,7 +10696,7 @@ if (!window.BI) {
});
// 集合相关方法
_.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
_.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI[name] = _apply(name);
});
_.each(["get", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",

Loading…
Cancel
Save