guy 7 years ago
parent
commit
3e38960fde
  1. 244
      bi/case.js
  2. 8
      demo/js/config/widget.js
  3. 31
      demo/js/widget/combo/demo.formula_combo.js
  4. 244
      dist/bundle.js
  5. 30
      dist/bundle.min.js
  6. 244
      dist/case.js
  7. 38
      dist/demo.js
  8. 99
      src/case/combo/formulacombo/combo.formula.js
  9. 89
      src/case/combo/formulacombo/popup.formulacombo.js
  10. 59
      src/case/combo/formulacombo/trigger.formulacombo.js

244
bi/case.js

@ -5203,250 +5203,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
});
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
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.
*
* @class BI.IconCombo

8
demo/js/config/widget.js

@ -186,14 +186,6 @@ Demo.WIDGET_CONFIG = [{
pId: 413,
text: "bi.number_interval",
value: "demo.number_interval"
}, {
pId: 4,
id: 414,
text: "公式下拉框"
}, {
pId: 414,
text: "bi.formula_combo",
value: "demo.formula_combo"
}, {
pId: 4,
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);

244
dist/bundle.js vendored

@ -70876,250 +70876,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
});
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
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.
*
* @class BI.IconCombo

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.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.
*
* @class BI.IconCombo

38
dist/demo.js vendored

@ -4174,14 +4174,6 @@ Demo.COMPONENT_CONFIG = [{
pId: 413,
text: "bi.number_interval",
value: "demo.number_interval"
}, {
pId: 4,
id: 414,
text: "公式下拉框"
}, {
pId: 414,
text: "bi.formula_combo",
value: "demo.formula_combo"
}, {
pId: 4,
id: 415,
@ -7430,36 +7422,6 @@ Demo.Tips = BI.inherit(BI.Widget, {
}
});
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.
*/
Demo.Date = BI.inherit(BI.Widget, {

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);
Loading…
Cancel
Save