guy
7 years ago
16 changed files with 127 additions and 1285 deletions
@ -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); |
File diff suppressed because one or more lines are too long
@ -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); |
@ -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); |
@ -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…
Reference in new issue