Browse Source

Merge pull request #131 in FUI/fineui from ~GUY/fineui:master to master

* commit '69ac3d8a47e038659cdb230bacb9713800a86beb':
  update
  update
  update
es6
guy 7 years ago
parent
commit
67b826c49e
  1. 244
      bi/case.js
  2. 2
      bi/widget.js
  3. 88
      demo/js/case/demo.calendar.js
  4. 8
      demo/js/config/widget.js
  5. 31
      demo/js/widget/combo/demo.formula_combo.js
  6. 15
      demo/js/widget/date/demo.datepane.js
  7. 6
      demo/js/widget/numberinterval/demo.number_interval.js
  8. 246
      dist/bundle.js
  9. 30
      dist/bundle.min.js
  10. 244
      dist/case.js
  11. 147
      dist/demo.js
  12. 2
      dist/widget.js
  13. 99
      src/case/combo/formulacombo/combo.formula.js
  14. 89
      src/case/combo/formulacombo/popup.formulacombo.js
  15. 59
      src/case/combo/formulacombo/trigger.formulacombo.js
  16. 2
      src/widget/datepane/datepane.js

244
bi/case.js

@ -5203,250 +5203,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
}); });
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/** BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaCombo
* @extend BI.Widget
*/
BI.FormulaCombo = BI.inherit(BI.Widget, {
_constant: {
POPUP_HEIGHT: 450,
POPUP_WIDTH: 600,
POPUP_V_GAP: 10,
POPUP_H_GAP: 10,
ADJUST_LENGTH: 2,
HEIGHT_MAX: 10000,
MAX_HEIGHT: 500,
MAX_WIDTH: 600,
COMBO_TRIGGER_WIDTH: 300
},
_defaultConfig: function () {
return BI.extend(BI.FormulaCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.formula_ids = [];
this.input = BI.createWidget({
type: "bi.formula_combo_trigger",
height: o.height,
items: o.items
});
this.formulaPopup = BI.createWidget({
type: "bi.formula_combo_popup",
fieldItems: o.items
});
this.formulaInputCombo = BI.createWidget({
type: "bi.combo",
element: this,
isNeedAdjustHeight: true,
isNeedAdjustWidth: false,
adjustLength: this._constant.ADJUST_LENGTH,
el: this.input,
popup: {
el: {
type: "bi.absolute",
height: this._constant.HEIGHT_MAX,
width: this._constant.POPUP_WIDTH,
items: [{
el: this.formulaPopup,
top: this._constant.POPUP_V_GAP,
left: this._constant.POPUP_H_GAP,
right: this._constant.POPUP_V_GAP,
bottom: 0
}]
},
stopPropagation: false,
maxHeight: this._constant.MAX_HEIGHT,
width: this._constant.MAX_WIDTH
}
});
this.formulaInputCombo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
self.formulaPopup.setValue(self.input.getValue());
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_CHANGE, function () {
self.setValue(self.formulaPopup.getValue());
self.formulaInputCombo.hideView();
self.fireEvent(BI.FormulaCombo.EVENT_CHANGE);
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_VALUE_CANCEL, function () {
self.formulaInputCombo.hideView();
});
},
setValue: function (v) {
if (this.formulaInputCombo.isViewVisible()) {
this.formulaInputCombo.hideView();
}
this.input.setValue(v);
this.input.setText(BI.Func.getFormulaStringFromFormulaValue(v));
this.formulaPopup.setValue(this.input.getValue());
},
getFormulaTargetIds: function() {
return this.formulaPopup.getFormulaTargetIds();
},
getValue: function () {
return this.input.getValue();
}
});
BI.FormulaCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.formula_combo", BI.FormulaCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboPopup
* @extend BI.Widget
*/
BI.FormulaComboPopup = BI.inherit(BI.Widget, {
_constant: {
BUTTON_HEIGHT: 30,
SOUTH_HEIGHT: 60,
SOUTH_H_GAP: 10
},
_defaultConfig: function () {
return BI.extend(BI.FormulaComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-pane-popup"
})
},
_init: function () {
BI.FormulaComboPopup.superclass._init.apply(this, arguments);
this.populate();
},
populate: function () {
var self = this, fieldItems = this.options.fieldItems;
this.formula = BI.createWidget({
type: "bi.formula_insert"
});
this.formula.populate(fieldItems);
var confirmButton = BI.createWidget({
type: "bi.button",
level: "common",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_OK")
});
var cancelButton = BI.createWidget({
type: "bi.button",
level: "ignore",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_Cancel")
});
this.formula.on(BI.FormulaInsert.EVENT_CHANGE, function () {
confirmButton.setEnable(self.formula.checkValidation());
});
confirmButton.on(BI.Button.EVENT_CHANGE, function () {
self.fireEvent(BI.FormulaComboPopup.EVENT_CHANGE);
});
cancelButton.on(BI.Button.EVENT_CHANGE, function () {
self.setValue(self.oldValue);
self.fireEvent(BI.FormulaComboPopup.EVENT_VALUE_CANCEL);
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.formula,
height: "fill"
}, {
el: {
type: "bi.right_vertical_adapt",
height: this._constant.SOUTH_HEIGHT,
items: [cancelButton, confirmButton],
hgap: this._constant.SOUTH_H_GAP
},
height: this._constant.SOUTH_HEIGHT
}]
})
},
getFormulaTargetIds: function(){
return this.formula.getUsedFields();
},
getValue: function () {
return this.formula.getValue();
},
setValue: function (v) {
this.oldValue = v;
this.formula.setValue(v);
}
});
BI.FormulaComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaComboPopup.EVENT_VALUE_CANCEL = "EVENT_VALUE_CANCEL";
BI.shortcut("bi.formula_combo_popup", BI.FormulaComboPopup);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboTrigger
* @extend BI.Widget
*/
BI.FormulaComboTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FormulaComboTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo-trigger",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaComboTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.label = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
textHeight: this.options.height,
lgap: 10
});
},
_getTextFromFormulaValue: function (formulaValue) {
var self = this;
var formulaString = "";
var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g;
var result = formulaValue.match(regx);
BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) {
var id = str[0].substring(2, item.length - 1);
var item = BI.find(BI.flatten(self.options.items), function (i, item) {
return id === item.value;
});
formulaString = formulaString + item.text;
} else {
formulaString = formulaString + item;
}
});
return formulaString;
},
getValue: function () {
return this.options.value;
},
setValue: function (v) {
this.options.value = v;
this.label.setText(this._getTextFromFormulaValue(v));
}
});
BI.shortcut("bi.formula_combo_trigger", BI.FormulaComboTrigger);/**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.IconCombo * @class BI.IconCombo

2
bi/widget.js

@ -2639,7 +2639,7 @@ BI.DatePaneWidget = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: "bi-date-pane-widget", baseCls: "bi-date-pane",
min: '1900-01-01', //最小日期 min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期 max: '2099-12-31', //最大日期
selectedTime: null selectedTime: null

88
demo/js/case/demo.calendar.js

@ -2,83 +2,31 @@ Demo.Func = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-func" baseCls: "demo-func"
}, },
_createNav: function(v){
var m = this.MONTH, y = this.YEAR; render: function () {
m += v; var self = this;
while(m < 0){ var date = new Date();
y--; return {
m += 12;
}
while(m > 11){
y++;
m -= 12;
}
var calendar = BI.createWidget({
type: "bi.calendar", type: "bi.calendar",
ref: function () {
self.calendar = this;
},
logic: { logic: {
dynamic: false dynamic: false
}, },
year: y, year: date.getFullYear(),
month: m, month: date.getMonth(),
day: this.DAY day: date.getDate()
}) }
calendar.setValue(this.selectedTime);
return calendar;
},
_stringfyTimeObject: function(timeOb){
return timeOb.year + "-" + (timeOb.month + 1) + "-" + timeOb.day;
},
render: function () {
var self = this, d = new Date();
this.YEAR = d.getFullYear();
this.MONTH = d.getMonth();
this.DAY = d.getDate();
this.selectedTime = {
year: this.YEAR,
month: this.MONTH,
day: this.DAY
};
var tip = BI.createWidget({
type: "bi.label"
});
var nav = BI.createWidget({
type: "bi.navigation",
element: this,
tab: {
height: 30,
items: [{
once: false,
text: "后退",
value: -1,
cls: "mvc-button layout-bg3"
},tip, {
once: false,
text: "前进",
value: 1,
cls: "mvc-button layout-bg4"
}]
},
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function(){
}, },
afterCardShow: function(){ mounted: function () {
this.setValue(self.selectedTime); var date = new Date();
} this.calendar.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
}) })
nav.on(BI.Navigation.EVENT_CHANGE, function(){
self.selectedTime = nav.getValue();
tip.setText(self._stringfyTimeObject(self.selectedTime));
});
tip.setText(this._stringfyTimeObject(this.selectedTime));
} }
}); });
BI.shortcut("demo.calendar", Demo.Func); BI.shortcut("demo.calendar", Demo.Func);

8
demo/js/config/widget.js

@ -186,14 +186,6 @@ Demo.WIDGET_CONFIG = [{
pId: 413, pId: 413,
text: "bi.number_interval", text: "bi.number_interval",
value: "demo.number_interval" value: "demo.number_interval"
}, {
pId: 4,
id: 414,
text: "公式下拉框"
}, {
pId: 414,
text: "bi.formula_combo",
value: "demo.formula_combo"
}, { }, {
pId: 4, pId: 4,
id: 415, id: 415,

31
demo/js/widget/combo/demo.formula_combo.js

@ -1,31 +0,0 @@
/**
* Created by Dailer on 2017/7/12.
*/
Demo.FormulaCombo = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.formula_combo",
fieldItems: [{
text: "A",
value: "A",
fieldType: 16
}],
width: 200,
height: 30
}],
vgap: 20
}
}
})
BI.shortcut("demo.formula_combo", Demo.FormulaCombo);

15
demo/js/widget/date/demo.datepane.js

@ -12,9 +12,9 @@ Demo.DatePane = BI.inherit(BI.Widget, {
items: [{ items: [{
type: "bi.label", type: "bi.label",
cls: "layout-bg2", cls: "layout-bg2",
text: "bi.date_pane_widget" text: "bi.date_pane"
}, { }, {
type: "bi.date_pane_widget", type: "bi.date_pane",
selectedTime: { selectedTime: {
year: 2017, year: 2017,
month: 12, month: 12,
@ -24,8 +24,7 @@ Demo.DatePane = BI.inherit(BI.Widget, {
self.datepane = _ref; self.datepane = _ref;
}, },
height: 300 height: 300
}, }, {
{
type: "bi.button", type: "bi.button",
text: "getValue", text: "getValue",
handler: function () { handler: function () {
@ -33,7 +32,7 @@ Demo.DatePane = BI.inherit(BI.Widget, {
} }
}, { }, {
type: "bi.button", type: "bi.button",
text: "setVlaue '2017-12-31'", text: "setValue '2017-12-31'",
handler: function () { handler: function () {
self.datepane.setValue({ self.datepane.setValue({
year: 2017, year: 2017,
@ -46,7 +45,11 @@ Demo.DatePane = BI.inherit(BI.Widget, {
width: "50%" width: "50%"
}] }]
} }
},
mounted: function () {
this.datepane.setValue();//不设value值表示当前时间
} }
}) })
BI.shortcut("demo.date_pane_widget", Demo.DatePane); BI.shortcut("demo.date_pane", Demo.DatePane);

6
demo/js/widget/numberinterval/demo.number_interval.js

@ -9,7 +9,7 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
mounted: function () { mounted: function () {
var numerical = this.numerical; var numerical = this.numerical;
var label = this.label; var label = this.label;
numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () { numerical.on(BI.NumberInterval.EVENT_CHANGE, function () {
var temp = numerical.getValue(); var temp = numerical.getValue();
var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max; var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max;
label.setValue(res); label.setValue(res);
@ -17,8 +17,6 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -41,4 +39,4 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
} }
}) })
BI.shortcut("demo.numberical_interval", Demo.NumericalInterval); BI.shortcut("demo.number_interval", Demo.NumericalInterval);

246
dist/bundle.js vendored

@ -70876,250 +70876,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
}); });
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/** BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaCombo
* @extend BI.Widget
*/
BI.FormulaCombo = BI.inherit(BI.Widget, {
_constant: {
POPUP_HEIGHT: 450,
POPUP_WIDTH: 600,
POPUP_V_GAP: 10,
POPUP_H_GAP: 10,
ADJUST_LENGTH: 2,
HEIGHT_MAX: 10000,
MAX_HEIGHT: 500,
MAX_WIDTH: 600,
COMBO_TRIGGER_WIDTH: 300
},
_defaultConfig: function () {
return BI.extend(BI.FormulaCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.formula_ids = [];
this.input = BI.createWidget({
type: "bi.formula_combo_trigger",
height: o.height,
items: o.items
});
this.formulaPopup = BI.createWidget({
type: "bi.formula_combo_popup",
fieldItems: o.items
});
this.formulaInputCombo = BI.createWidget({
type: "bi.combo",
element: this,
isNeedAdjustHeight: true,
isNeedAdjustWidth: false,
adjustLength: this._constant.ADJUST_LENGTH,
el: this.input,
popup: {
el: {
type: "bi.absolute",
height: this._constant.HEIGHT_MAX,
width: this._constant.POPUP_WIDTH,
items: [{
el: this.formulaPopup,
top: this._constant.POPUP_V_GAP,
left: this._constant.POPUP_H_GAP,
right: this._constant.POPUP_V_GAP,
bottom: 0
}]
},
stopPropagation: false,
maxHeight: this._constant.MAX_HEIGHT,
width: this._constant.MAX_WIDTH
}
});
this.formulaInputCombo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
self.formulaPopup.setValue(self.input.getValue());
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_CHANGE, function () {
self.setValue(self.formulaPopup.getValue());
self.formulaInputCombo.hideView();
self.fireEvent(BI.FormulaCombo.EVENT_CHANGE);
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_VALUE_CANCEL, function () {
self.formulaInputCombo.hideView();
});
},
setValue: function (v) {
if (this.formulaInputCombo.isViewVisible()) {
this.formulaInputCombo.hideView();
}
this.input.setValue(v);
this.input.setText(BI.Func.getFormulaStringFromFormulaValue(v));
this.formulaPopup.setValue(this.input.getValue());
},
getFormulaTargetIds: function() {
return this.formulaPopup.getFormulaTargetIds();
},
getValue: function () {
return this.input.getValue();
}
});
BI.FormulaCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.formula_combo", BI.FormulaCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboPopup
* @extend BI.Widget
*/
BI.FormulaComboPopup = BI.inherit(BI.Widget, {
_constant: {
BUTTON_HEIGHT: 30,
SOUTH_HEIGHT: 60,
SOUTH_H_GAP: 10
},
_defaultConfig: function () {
return BI.extend(BI.FormulaComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-pane-popup"
})
},
_init: function () {
BI.FormulaComboPopup.superclass._init.apply(this, arguments);
this.populate();
},
populate: function () {
var self = this, fieldItems = this.options.fieldItems;
this.formula = BI.createWidget({
type: "bi.formula_insert"
});
this.formula.populate(fieldItems);
var confirmButton = BI.createWidget({
type: "bi.button",
level: "common",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_OK")
});
var cancelButton = BI.createWidget({
type: "bi.button",
level: "ignore",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_Cancel")
});
this.formula.on(BI.FormulaInsert.EVENT_CHANGE, function () {
confirmButton.setEnable(self.formula.checkValidation());
});
confirmButton.on(BI.Button.EVENT_CHANGE, function () {
self.fireEvent(BI.FormulaComboPopup.EVENT_CHANGE);
});
cancelButton.on(BI.Button.EVENT_CHANGE, function () {
self.setValue(self.oldValue);
self.fireEvent(BI.FormulaComboPopup.EVENT_VALUE_CANCEL);
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.formula,
height: "fill"
}, {
el: {
type: "bi.right_vertical_adapt",
height: this._constant.SOUTH_HEIGHT,
items: [cancelButton, confirmButton],
hgap: this._constant.SOUTH_H_GAP
},
height: this._constant.SOUTH_HEIGHT
}]
})
},
getFormulaTargetIds: function(){
return this.formula.getUsedFields();
},
getValue: function () {
return this.formula.getValue();
},
setValue: function (v) {
this.oldValue = v;
this.formula.setValue(v);
}
});
BI.FormulaComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaComboPopup.EVENT_VALUE_CANCEL = "EVENT_VALUE_CANCEL";
BI.shortcut("bi.formula_combo_popup", BI.FormulaComboPopup);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboTrigger
* @extend BI.Widget
*/
BI.FormulaComboTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FormulaComboTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo-trigger",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaComboTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.label = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
textHeight: this.options.height,
lgap: 10
});
},
_getTextFromFormulaValue: function (formulaValue) {
var self = this;
var formulaString = "";
var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g;
var result = formulaValue.match(regx);
BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) {
var id = str[0].substring(2, item.length - 1);
var item = BI.find(BI.flatten(self.options.items), function (i, item) {
return id === item.value;
});
formulaString = formulaString + item.text;
} else {
formulaString = formulaString + item;
}
});
return formulaString;
},
getValue: function () {
return this.options.value;
},
setValue: function (v) {
this.options.value = v;
this.label.setText(this._getTextFromFormulaValue(v));
}
});
BI.shortcut("bi.formula_combo_trigger", BI.FormulaComboTrigger);/**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.IconCombo * @class BI.IconCombo
@ -81267,7 +81023,7 @@ BI.DatePaneWidget = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: "bi-date-pane-widget", baseCls: "bi-date-pane",
min: '1900-01-01', //最小日期 min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期 max: '2099-12-31', //最大日期
selectedTime: null selectedTime: null

30
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

244
dist/case.js vendored

@ -5203,250 +5203,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
}); });
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/** BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaCombo
* @extend BI.Widget
*/
BI.FormulaCombo = BI.inherit(BI.Widget, {
_constant: {
POPUP_HEIGHT: 450,
POPUP_WIDTH: 600,
POPUP_V_GAP: 10,
POPUP_H_GAP: 10,
ADJUST_LENGTH: 2,
HEIGHT_MAX: 10000,
MAX_HEIGHT: 500,
MAX_WIDTH: 600,
COMBO_TRIGGER_WIDTH: 300
},
_defaultConfig: function () {
return BI.extend(BI.FormulaCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.formula_ids = [];
this.input = BI.createWidget({
type: "bi.formula_combo_trigger",
height: o.height,
items: o.items
});
this.formulaPopup = BI.createWidget({
type: "bi.formula_combo_popup",
fieldItems: o.items
});
this.formulaInputCombo = BI.createWidget({
type: "bi.combo",
element: this,
isNeedAdjustHeight: true,
isNeedAdjustWidth: false,
adjustLength: this._constant.ADJUST_LENGTH,
el: this.input,
popup: {
el: {
type: "bi.absolute",
height: this._constant.HEIGHT_MAX,
width: this._constant.POPUP_WIDTH,
items: [{
el: this.formulaPopup,
top: this._constant.POPUP_V_GAP,
left: this._constant.POPUP_H_GAP,
right: this._constant.POPUP_V_GAP,
bottom: 0
}]
},
stopPropagation: false,
maxHeight: this._constant.MAX_HEIGHT,
width: this._constant.MAX_WIDTH
}
});
this.formulaInputCombo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
self.formulaPopup.setValue(self.input.getValue());
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_CHANGE, function () {
self.setValue(self.formulaPopup.getValue());
self.formulaInputCombo.hideView();
self.fireEvent(BI.FormulaCombo.EVENT_CHANGE);
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_VALUE_CANCEL, function () {
self.formulaInputCombo.hideView();
});
},
setValue: function (v) {
if (this.formulaInputCombo.isViewVisible()) {
this.formulaInputCombo.hideView();
}
this.input.setValue(v);
this.input.setText(BI.Func.getFormulaStringFromFormulaValue(v));
this.formulaPopup.setValue(this.input.getValue());
},
getFormulaTargetIds: function() {
return this.formulaPopup.getFormulaTargetIds();
},
getValue: function () {
return this.input.getValue();
}
});
BI.FormulaCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.formula_combo", BI.FormulaCombo);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboPopup
* @extend BI.Widget
*/
BI.FormulaComboPopup = BI.inherit(BI.Widget, {
_constant: {
BUTTON_HEIGHT: 30,
SOUTH_HEIGHT: 60,
SOUTH_H_GAP: 10
},
_defaultConfig: function () {
return BI.extend(BI.FormulaComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-pane-popup"
})
},
_init: function () {
BI.FormulaComboPopup.superclass._init.apply(this, arguments);
this.populate();
},
populate: function () {
var self = this, fieldItems = this.options.fieldItems;
this.formula = BI.createWidget({
type: "bi.formula_insert"
});
this.formula.populate(fieldItems);
var confirmButton = BI.createWidget({
type: "bi.button",
level: "common",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_OK")
});
var cancelButton = BI.createWidget({
type: "bi.button",
level: "ignore",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_Cancel")
});
this.formula.on(BI.FormulaInsert.EVENT_CHANGE, function () {
confirmButton.setEnable(self.formula.checkValidation());
});
confirmButton.on(BI.Button.EVENT_CHANGE, function () {
self.fireEvent(BI.FormulaComboPopup.EVENT_CHANGE);
});
cancelButton.on(BI.Button.EVENT_CHANGE, function () {
self.setValue(self.oldValue);
self.fireEvent(BI.FormulaComboPopup.EVENT_VALUE_CANCEL);
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.formula,
height: "fill"
}, {
el: {
type: "bi.right_vertical_adapt",
height: this._constant.SOUTH_HEIGHT,
items: [cancelButton, confirmButton],
hgap: this._constant.SOUTH_H_GAP
},
height: this._constant.SOUTH_HEIGHT
}]
})
},
getFormulaTargetIds: function(){
return this.formula.getUsedFields();
},
getValue: function () {
return this.formula.getValue();
},
setValue: function (v) {
this.oldValue = v;
this.formula.setValue(v);
}
});
BI.FormulaComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaComboPopup.EVENT_VALUE_CANCEL = "EVENT_VALUE_CANCEL";
BI.shortcut("bi.formula_combo_popup", BI.FormulaComboPopup);/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboTrigger
* @extend BI.Widget
*/
BI.FormulaComboTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FormulaComboTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo-trigger",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaComboTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.label = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
textHeight: this.options.height,
lgap: 10
});
},
_getTextFromFormulaValue: function (formulaValue) {
var self = this;
var formulaString = "";
var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g;
var result = formulaValue.match(regx);
BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) {
var id = str[0].substring(2, item.length - 1);
var item = BI.find(BI.flatten(self.options.items), function (i, item) {
return id === item.value;
});
formulaString = formulaString + item.text;
} else {
formulaString = formulaString + item;
}
});
return formulaString;
},
getValue: function () {
return this.options.value;
},
setValue: function (v) {
this.options.value = v;
this.label.setText(this._getTextFromFormulaValue(v));
}
});
BI.shortcut("bi.formula_combo_trigger", BI.FormulaComboTrigger);/**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.IconCombo * @class BI.IconCombo

147
dist/demo.js vendored

@ -2021,83 +2021,31 @@ BI.shortcut("demo.text_value_check_combo", Demo.TextValueCheckCombo);Demo.Func =
props: { props: {
baseCls: "demo-func" baseCls: "demo-func"
}, },
_createNav: function(v){
var m = this.MONTH, y = this.YEAR; render: function () {
m += v; var self = this;
while(m < 0){ var date = new Date();
y--; return {
m += 12;
}
while(m > 11){
y++;
m -= 12;
}
var calendar = BI.createWidget({
type: "bi.calendar", type: "bi.calendar",
ref: function () {
self.calendar = this;
},
logic: { logic: {
dynamic: false dynamic: false
}, },
year: y, year: date.getFullYear(),
month: m, month: date.getMonth(),
day: this.DAY day: date.getDate()
}) }
calendar.setValue(this.selectedTime);
return calendar;
},
_stringfyTimeObject: function(timeOb){
return timeOb.year + "-" + (timeOb.month + 1) + "-" + timeOb.day;
},
render: function () {
var self = this, d = new Date();
this.YEAR = d.getFullYear();
this.MONTH = d.getMonth();
this.DAY = d.getDate();
this.selectedTime = {
year: this.YEAR,
month: this.MONTH,
day: this.DAY
};
var tip = BI.createWidget({
type: "bi.label"
});
var nav = BI.createWidget({
type: "bi.navigation",
element: this,
tab: {
height: 30,
items: [{
once: false,
text: "后退",
value: -1,
cls: "mvc-button layout-bg3"
},tip, {
once: false,
text: "前进",
value: 1,
cls: "mvc-button layout-bg4"
}]
},
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function(){
}, },
afterCardShow: function(){ mounted: function () {
this.setValue(self.selectedTime); var date = new Date();
} this.calendar.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
}) })
nav.on(BI.Navigation.EVENT_CHANGE, function(){
self.selectedTime = nav.getValue();
tip.setText(self._stringfyTimeObject(self.selectedTime));
});
tip.setText(this._stringfyTimeObject(this.selectedTime));
} }
}); });
BI.shortcut("demo.calendar", Demo.Func);Demo.Func = BI.inherit(BI.Widget, { BI.shortcut("demo.calendar", Demo.Func);Demo.Func = BI.inherit(BI.Widget, {
@ -4174,14 +4122,6 @@ Demo.COMPONENT_CONFIG = [{
pId: 413, pId: 413,
text: "bi.number_interval", text: "bi.number_interval",
value: "demo.number_interval" value: "demo.number_interval"
}, {
pId: 4,
id: 414,
text: "公式下拉框"
}, {
pId: 414,
text: "bi.formula_combo",
value: "demo.formula_combo"
}, { }, {
pId: 4, pId: 4,
id: 415, id: 415,
@ -7430,36 +7370,6 @@ Demo.Tips = BI.inherit(BI.Widget, {
} }
}); });
BI.shortcut("demo.tips", Demo.Tips);/** BI.shortcut("demo.tips", Demo.Tips);/**
* Created by Dailer on 2017/7/12.
*/
Demo.FormulaCombo = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.formula_combo",
fieldItems: [{
text: "A",
value: "A",
fieldType: 16
}],
width: 200,
height: 30
}],
vgap: 20
}
}
})
BI.shortcut("demo.formula_combo", Demo.FormulaCombo);/**
* Created by Dailer on 2017/7/11. * Created by Dailer on 2017/7/11.
*/ */
Demo.Date = BI.inherit(BI.Widget, { Demo.Date = BI.inherit(BI.Widget, {
@ -7519,9 +7429,9 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, {
items: [{ items: [{
type: "bi.label", type: "bi.label",
cls: "layout-bg2", cls: "layout-bg2",
text: "bi.date_pane_widget" text: "bi.date_pane"
}, { }, {
type: "bi.date_pane_widget", type: "bi.date_pane",
selectedTime: { selectedTime: {
year: 2017, year: 2017,
month: 12, month: 12,
@ -7531,8 +7441,7 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, {
self.datepane = _ref; self.datepane = _ref;
}, },
height: 300 height: 300
}, }, {
{
type: "bi.button", type: "bi.button",
text: "getValue", text: "getValue",
handler: function () { handler: function () {
@ -7540,7 +7449,7 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, {
} }
}, { }, {
type: "bi.button", type: "bi.button",
text: "setVlaue '2017-12-31'", text: "setValue '2017-12-31'",
handler: function () { handler: function () {
self.datepane.setValue({ self.datepane.setValue({
year: 2017, year: 2017,
@ -7553,10 +7462,14 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, {
width: "50%" width: "50%"
}] }]
} }
},
mounted: function () {
this.datepane.setValue();//不设value值表示当前时间
} }
}) })
BI.shortcut("demo.date_pane_widget", Demo.DatePane);/** BI.shortcut("demo.date_pane", Demo.DatePane);/**
* Created by Urthur on 2017/7/18. * Created by Urthur on 2017/7/18.
*/ */
Demo.CustomDateTime = BI.inherit(BI.Widget, { Demo.CustomDateTime = BI.inherit(BI.Widget, {
@ -8080,7 +7993,7 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
mounted: function () { mounted: function () {
var numerical = this.numerical; var numerical = this.numerical;
var label = this.label; var label = this.label;
numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () { numerical.on(BI.NumberInterval.EVENT_CHANGE, function () {
var temp = numerical.getValue(); var temp = numerical.getValue();
var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max; var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max;
label.setValue(res); label.setValue(res);
@ -8088,8 +8001,6 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -8112,7 +8023,7 @@ Demo.NumericalInterval = BI.inherit(BI.Widget, {
} }
}) })
BI.shortcut("demo.numberical_interval", Demo.NumericalInterval); BI.shortcut("demo.number_interval", Demo.NumericalInterval);
Demo.DirectionPathChooser = BI.inherit(BI.Widget, { Demo.DirectionPathChooser = BI.inherit(BI.Widget, {

2
dist/widget.js vendored

@ -2639,7 +2639,7 @@ BI.DatePaneWidget = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: "bi-date-pane-widget", baseCls: "bi-date-pane",
min: '1900-01-01', //最小日期 min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期 max: '2099-12-31', //最大日期
selectedTime: null selectedTime: null

99
src/case/combo/formulacombo/combo.formula.js

@ -1,99 +0,0 @@
/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaCombo
* @extend BI.Widget
*/
BI.FormulaCombo = BI.inherit(BI.Widget, {
_constant: {
POPUP_HEIGHT: 450,
POPUP_WIDTH: 600,
POPUP_V_GAP: 10,
POPUP_H_GAP: 10,
ADJUST_LENGTH: 2,
HEIGHT_MAX: 10000,
MAX_HEIGHT: 500,
MAX_WIDTH: 600,
COMBO_TRIGGER_WIDTH: 300
},
_defaultConfig: function () {
return BI.extend(BI.FormulaCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.formula_ids = [];
this.input = BI.createWidget({
type: "bi.formula_combo_trigger",
height: o.height,
items: o.items
});
this.formulaPopup = BI.createWidget({
type: "bi.formula_combo_popup",
fieldItems: o.items
});
this.formulaInputCombo = BI.createWidget({
type: "bi.combo",
element: this,
isNeedAdjustHeight: true,
isNeedAdjustWidth: false,
adjustLength: this._constant.ADJUST_LENGTH,
el: this.input,
popup: {
el: {
type: "bi.absolute",
height: this._constant.HEIGHT_MAX,
width: this._constant.POPUP_WIDTH,
items: [{
el: this.formulaPopup,
top: this._constant.POPUP_V_GAP,
left: this._constant.POPUP_H_GAP,
right: this._constant.POPUP_V_GAP,
bottom: 0
}]
},
stopPropagation: false,
maxHeight: this._constant.MAX_HEIGHT,
width: this._constant.MAX_WIDTH
}
});
this.formulaInputCombo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
self.formulaPopup.setValue(self.input.getValue());
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_CHANGE, function () {
self.setValue(self.formulaPopup.getValue());
self.formulaInputCombo.hideView();
self.fireEvent(BI.FormulaCombo.EVENT_CHANGE);
});
this.formulaPopup.on(BI.FormulaComboPopup.EVENT_VALUE_CANCEL, function () {
self.formulaInputCombo.hideView();
});
},
setValue: function (v) {
if (this.formulaInputCombo.isViewVisible()) {
this.formulaInputCombo.hideView();
}
this.input.setValue(v);
this.input.setText(BI.Func.getFormulaStringFromFormulaValue(v));
this.formulaPopup.setValue(this.input.getValue());
},
getFormulaTargetIds: function() {
return this.formulaPopup.getFormulaTargetIds();
},
getValue: function () {
return this.input.getValue();
}
});
BI.FormulaCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.formula_combo", BI.FormulaCombo);

89
src/case/combo/formulacombo/popup.formulacombo.js

@ -1,89 +0,0 @@
/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboPopup
* @extend BI.Widget
*/
BI.FormulaComboPopup = BI.inherit(BI.Widget, {
_constant: {
BUTTON_HEIGHT: 30,
SOUTH_HEIGHT: 60,
SOUTH_H_GAP: 10
},
_defaultConfig: function () {
return BI.extend(BI.FormulaComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-pane-popup"
})
},
_init: function () {
BI.FormulaComboPopup.superclass._init.apply(this, arguments);
this.populate();
},
populate: function () {
var self = this, fieldItems = this.options.fieldItems;
this.formula = BI.createWidget({
type: "bi.formula_insert"
});
this.formula.populate(fieldItems);
var confirmButton = BI.createWidget({
type: "bi.button",
level: "common",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_OK")
});
var cancelButton = BI.createWidget({
type: "bi.button",
level: "ignore",
height: this._constant.BUTTON_HEIGHT,
text: BI.i18nText("BI-Basic_Cancel")
});
this.formula.on(BI.FormulaInsert.EVENT_CHANGE, function () {
confirmButton.setEnable(self.formula.checkValidation());
});
confirmButton.on(BI.Button.EVENT_CHANGE, function () {
self.fireEvent(BI.FormulaComboPopup.EVENT_CHANGE);
});
cancelButton.on(BI.Button.EVENT_CHANGE, function () {
self.setValue(self.oldValue);
self.fireEvent(BI.FormulaComboPopup.EVENT_VALUE_CANCEL);
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.formula,
height: "fill"
}, {
el: {
type: "bi.right_vertical_adapt",
height: this._constant.SOUTH_HEIGHT,
items: [cancelButton, confirmButton],
hgap: this._constant.SOUTH_H_GAP
},
height: this._constant.SOUTH_HEIGHT
}]
})
},
getFormulaTargetIds: function(){
return this.formula.getUsedFields();
},
getValue: function () {
return this.formula.getValue();
},
setValue: function (v) {
this.oldValue = v;
this.formula.setValue(v);
}
});
BI.FormulaComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.FormulaComboPopup.EVENT_VALUE_CANCEL = "EVENT_VALUE_CANCEL";
BI.shortcut("bi.formula_combo_popup", BI.FormulaComboPopup);

59
src/case/combo/formulacombo/trigger.formulacombo.js

@ -1,59 +0,0 @@
/**
* Created by GUY on 2016/4/25.
*
* @class BI.FormulaComboTrigger
* @extend BI.Widget
*/
BI.FormulaComboTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.FormulaComboTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-formula-combo-trigger",
height: 30,
items: []
})
},
_init: function () {
BI.FormulaComboTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.label = BI.createWidget({
type: "bi.label",
element: this,
textAlign: "left",
textHeight: this.options.height,
lgap: 10
});
},
_getTextFromFormulaValue: function (formulaValue) {
var self = this;
var formulaString = "";
var regx = /\$[\{][^\}]*[\}]|\w*\w|\$\{[^\$\(\)\+\-\*\/)\$,]*\w\}|\$\{[^\$\(\)\+\-\*\/]*\w\}|\$\{[^\$\(\)\+\-\*\/]*[\u4e00-\u9fa5]\}|\w|(.)/g;
var result = formulaValue.match(regx);
BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) {
var id = str[0].substring(2, item.length - 1);
var item = BI.find(BI.flatten(self.options.items), function (i, item) {
return id === item.value;
});
formulaString = formulaString + item.text;
} else {
formulaString = formulaString + item;
}
});
return formulaString;
},
getValue: function () {
return this.options.value;
},
setValue: function (v) {
this.options.value = v;
this.label.setText(this._getTextFromFormulaValue(v));
}
});
BI.shortcut("bi.formula_combo_trigger", BI.FormulaComboTrigger);

2
src/widget/datepane/datepane.js

@ -5,7 +5,7 @@ BI.DatePaneWidget = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: "bi-date-pane-widget", baseCls: "bi-date-pane",
min: '1900-01-01', //最小日期 min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期 max: '2099-12-31', //最大日期
selectedTime: null selectedTime: null

Loading…
Cancel
Save