Browse Source

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

* commit '86f10a15ab864068637c123eaf7ec0cbf57c144c':
  性能优化
  add
  update
  BI-7322 日期 时分秒基本控件  日期格式打印方式修改
  add
  少改了
  add
  add
es6
guy 7 years ago
parent
commit
e7e8183775
  1. 4
      bi/base.js
  2. 4
      bi/case.js
  3. 40
      bi/core.js
  4. 108
      bi/widget.js
  5. 14
      demo/js/widget/demo.datetime.js
  6. 4
      docs/base.js
  7. 4
      docs/case.js
  8. 40
      docs/core.js
  9. 14
      docs/demo.js
  10. 108
      docs/widget.js
  11. 4
      src/base/table/table.js
  12. 4
      src/case/list/list.select.js
  13. 36
      src/core/model.js
  14. 4
      src/core/utils/load.js
  15. 32
      src/widget/datetime/datetime.combo.js
  16. 6
      src/widget/datetime/datetime.js
  17. 34
      src/widget/datetime/datetime.popup.js
  18. 30
      src/widget/datetime/datetime.trigger.js

4
bi/base.js

@ -31366,8 +31366,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) {
mergeCol(i, j);
preCol[j] = preRow[j - 1];
preCW[j] = preRW[j - 1];
preCol[j] = preRow[i];
preCW[j] = preRW[i];
} else {
createOneEl(i, j);
}

4
bi/case.js

@ -8791,9 +8791,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected();
},
_setEnable: function () {
_setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments);
this.toolbar.setEnable(enable);
},
resetHeight: function (h) {

40
bi/core.js

@ -4904,7 +4904,41 @@ BI.Widget = BI.inherit(BI.OB, {
},
_change: function (child) {
this.set(this._map(child));
var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this;
},
@ -9178,12 +9212,12 @@ $.extend(BI, {
must: false
}, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must);
this.$import(config.url, config.type, config.must);
},
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) {
var $scripts = $("head script");
var $scripts = $("head script, body script");
$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
_LOADED[src] = true;

108
bi/widget.js

@ -3264,30 +3264,26 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-combo',
baseCls: 'bi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.DateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger'
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
@ -3299,17 +3295,18 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.storeValue = self.popup.getValue();
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.trigger.setValue(self.popup.getValue());
self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE);
});
this.combo = BI.createWidget({
type: 'bi.combo',
@ -3332,9 +3329,9 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "chart-date-normal-font bi-border-left bi-border-top bi-border-bottom",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 25
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
@ -3370,10 +3367,11 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.trigger.setValue(v);
},
getValue: function () {
return {
value: this.storeValue,
text: this.trigger.getValue()
};
return this.storeValue;
},
hidePopupView: function () {
this.combo.hideView();
}
});
@ -3400,12 +3398,18 @@ BI.CustomDateTimeCombo = BI.inherit(BI.Widget, {
element: this
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CANCEL);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CONFIRM);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
});
},
getValue: function () {
@ -3424,18 +3428,6 @@ BI.shortcut("bi.custom_date_time_combo", BI.CustomDateTimeCombo);
* Created by Urthur on 2017/7/14.
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
constants: {
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-popup',
@ -3445,7 +3437,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
@ -3531,6 +3523,16 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}]
});
var date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
@ -3551,10 +3553,8 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
var value = v, date;
if (BI.isNull(value)) {
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
@ -3574,12 +3574,10 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
@ -3588,13 +3586,11 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
second: this.second.getValue()
}
}
}
});
BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.date_time_popup', BI.DateTimePopup);
/**
* Created by Urthur on 2017/7/14.
*/
@ -3700,22 +3696,22 @@ BI.DateTimeSelect = BI.inherit(BI.Widget, {
});
BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_select", BI.DateTimeSelect);
/**
BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/**
* Created by Urthur on 2017/7/14.
*/
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
height: 25,
width: 180
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 24,
width: 200
});
},
_init: function () {
@ -3723,19 +3719,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "bi-border",
textAlign: "left",
height: o.height,
width: o.width,
hgap: c.hgap,
vgap: c.vgap
hgap: c.hgap
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
width: c.triggerWidth
}, {
el: this.text
}]
@ -3748,28 +3743,21 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
var value = v, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
dateStr = value.print("%Y-%X-%d %H:%M:%S");
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
}
this.text.setText(dateStr);
this.text.setTitle(dateStr);
}
},
getValue: function () {
return this.text.getText();
}
});
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
/**
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/**
* 带有方向的pathchooser
*
* Created by GUY on 2016/4/21.

14
demo/js/widget/demo.datetime.js

@ -2,7 +2,8 @@
* Created by Urthur on 2017/7/18.
*/
Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: {},
props: {
},
render: function () {
var self = this;
return {
@ -12,11 +13,18 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
type: "bi.custom_date_time_combo",
ref: function (_ref) {
self.customDateTime = _ref;
var value, date, dateStr;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text);
value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
});
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () {
BI.Msg.alert("日期", this.getValue().text);
value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
});
}
},

4
docs/base.js

@ -31366,8 +31366,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) {
mergeCol(i, j);
preCol[j] = preRow[j - 1];
preCW[j] = preRW[j - 1];
preCol[j] = preRow[i];
preCW[j] = preRW[i];
} else {
createOneEl(i, j);
}

4
docs/case.js

@ -8791,9 +8791,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected();
},
_setEnable: function () {
_setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments);
this.toolbar.setEnable(enable);
},
resetHeight: function (h) {

40
docs/core.js

@ -14900,7 +14900,41 @@ BI.Widget = BI.inherit(BI.OB, {
},
_change: function (child) {
this.set(this._map(child));
var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this;
},
@ -17625,12 +17659,12 @@ $.extend(BI, {
must: false
}, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must);
this.$import(config.url, config.type, config.must);
},
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) {
var $scripts = $("head script");
var $scripts = $("head script, body script");
$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
_LOADED[src] = true;

14
docs/demo.js

@ -7275,7 +7275,8 @@ BI.shortcut("demo.date_pane_widget", Demo.DatePane);/**
* Created by Urthur on 2017/7/18.
*/
Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: {},
props: {
},
render: function () {
var self = this;
return {
@ -7285,11 +7286,18 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
type: "bi.custom_date_time_combo",
ref: function (_ref) {
self.customDateTime = _ref;
var value, date, dateStr;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text);
value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
});
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () {
BI.Msg.alert("日期", this.getValue().text);
value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
});
}
},

108
docs/widget.js

@ -3264,30 +3264,26 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-combo',
baseCls: 'bi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.DateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger'
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
@ -3299,17 +3295,18 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.storeValue = self.popup.getValue();
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.trigger.setValue(self.popup.getValue());
self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE);
});
this.combo = BI.createWidget({
type: 'bi.combo',
@ -3332,9 +3329,9 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "chart-date-normal-font bi-border-left bi-border-top bi-border-bottom",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 25
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
@ -3370,10 +3367,11 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.trigger.setValue(v);
},
getValue: function () {
return {
value: this.storeValue,
text: this.trigger.getValue()
};
return this.storeValue;
},
hidePopupView: function () {
this.combo.hideView();
}
});
@ -3400,12 +3398,18 @@ BI.CustomDateTimeCombo = BI.inherit(BI.Widget, {
element: this
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CANCEL);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CONFIRM);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
});
},
getValue: function () {
@ -3424,18 +3428,6 @@ BI.shortcut("bi.custom_date_time_combo", BI.CustomDateTimeCombo);
* Created by Urthur on 2017/7/14.
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
constants: {
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-popup',
@ -3445,7 +3437,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
@ -3531,6 +3523,16 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}]
});
var date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
@ -3551,10 +3553,8 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
var value = v, date;
if (BI.isNull(value)) {
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
@ -3574,12 +3574,10 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
@ -3588,13 +3586,11 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
second: this.second.getValue()
}
}
}
});
BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.date_time_popup', BI.DateTimePopup);
/**
* Created by Urthur on 2017/7/14.
*/
@ -3700,22 +3696,22 @@ BI.DateTimeSelect = BI.inherit(BI.Widget, {
});
BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_select", BI.DateTimeSelect);
/**
BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/**
* Created by Urthur on 2017/7/14.
*/
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
height: 25,
width: 180
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 24,
width: 200
});
},
_init: function () {
@ -3723,19 +3719,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "bi-border",
textAlign: "left",
height: o.height,
width: o.width,
hgap: c.hgap,
vgap: c.vgap
hgap: c.hgap
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
width: c.triggerWidth
}, {
el: this.text
}]
@ -3748,28 +3743,21 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
var value = v, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
dateStr = value.print("%Y-%X-%d %H:%M:%S");
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
}
this.text.setText(dateStr);
this.text.setTitle(dateStr);
}
},
getValue: function () {
return this.text.getText();
}
});
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
/**
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/**
* 带有方向的pathchooser
*
* Created by GUY on 2016/4/21.

4
src/base/table/table.js

@ -418,8 +418,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) {
mergeCol(i, j);
preCol[j] = preRow[j - 1];
preCW[j] = preRW[j - 1];
preCol[j] = preRow[i];
preCW[j] = preRW[i];
} else {
createOneEl(i, j);
}

4
src/case/list/list.select.js

@ -158,9 +158,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected();
},
_setEnable: function () {
_setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments);
this.toolbar.setEnable(enable);
},
resetHeight: function (h) {

36
src/core/model.js

@ -117,7 +117,41 @@ BI.Model = BI.inherit(BI.M, {
},
_change: function (child) {
this.set(this._map(child));
var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this;
},

4
src/core/utils/load.js

@ -9,12 +9,12 @@ $.extend(BI, {
must: false
}, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must);
this.$import(config.url, config.type, config.must);
},
$import: function () {
var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) {
var $scripts = $("head script");
var $scripts = $("head script, body script");
$.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) {
_LOADED[src] = true;

32
src/widget/datetime/datetime.combo.js

@ -12,30 +12,26 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-combo',
baseCls: 'bi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.DateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger'
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
@ -47,17 +43,18 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.storeValue = self.popup.getValue();
self.setValue(self.storeValue);
self.combo.hideView();
self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.trigger.setValue(self.popup.getValue());
self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE);
});
this.combo = BI.createWidget({
type: 'bi.combo',
@ -80,9 +77,9 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "chart-date-normal-font bi-border-left bi-border-top bi-border-bottom",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 25
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
@ -118,10 +115,11 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.trigger.setValue(v);
},
getValue: function () {
return {
value: this.storeValue,
text: this.trigger.getValue()
};
return this.storeValue;
},
hidePopupView: function () {
this.combo.hideView();
}
});

6
src/widget/datetime/datetime.js

@ -16,12 +16,18 @@ BI.CustomDateTimeCombo = BI.inherit(BI.Widget, {
element: this
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CANCEL);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CONFIRM);
});
this.DateTime.on(BI.DateTimeCombo.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
});
},
getValue: function () {

34
src/widget/datetime/datetime.popup.js

@ -2,18 +2,6 @@
* Created by Urthur on 2017/7/14.
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
constants: {
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-popup',
@ -23,7 +11,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this;
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
@ -109,6 +97,16 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}]
});
var date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
@ -129,10 +127,8 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
var value = v, date;
if (BI.isNull(value)) {
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
@ -152,12 +148,10 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
@ -166,10 +160,8 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
second: this.second.getValue()
}
}
}
});
BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.date_time_popup', BI.DateTimePopup);

30
src/widget/datetime/datetime.trigger.js

@ -4,15 +4,16 @@
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
height: 25,
width: 180
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 24,
width: 200
});
},
_init: function () {
@ -20,19 +21,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "bi-border",
textAlign: "left",
height: o.height,
width: o.width,
hgap: c.hgap,
vgap: c.vgap
hgap: c.hgap
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
width: c.triggerWidth
}, {
el: this.text
}]
@ -45,24 +45,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
var value = v, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
dateStr = value.print("%Y-%X-%d %H:%M:%S");
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
}
this.text.setText(dateStr);
this.text.setTitle(dateStr);
}
},
getValue: function () {
return this.text.getText();
}
});
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
Loading…
Cancel
Save