Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~claire.tang/fineui

es6
Tangjinxia 4 years ago
parent
commit
ef5a6ea054
  1. 1
      changelog.md
  2. 8
      demo/js/config/widget.js
  3. 51
      demo/js/widget/yearinterval/demo.year_interval.js
  4. 52
      demo/js/widget/yearquarterinterval/demo.yearquarterinterval.js
  5. 4
      dist/2.0/fineui.css
  6. 4
      dist/2.0/fineui.ie.min.js
  7. 2
      dist/2.0/fineui.ie.min.js.map
  8. 2793
      dist/2.0/fineui.js
  9. 2
      dist/2.0/fineui.js.map
  10. 4
      dist/2.0/fineui.min.css
  11. 4
      dist/2.0/fineui.min.js
  12. 2
      dist/2.0/fineui.min.js.map
  13. 4
      dist/2.0/fineui_without_normalize.css
  14. 4
      dist/2.0/fineui_without_normalize.min.css
  15. 4
      dist/core.css
  16. 2759
      dist/core.js
  17. 2
      dist/core.js.map
  18. 4
      dist/demo.css
  19. 3230
      dist/demo.js
  20. 2
      dist/demo.js.map
  21. 4
      dist/fineui.css
  22. 4
      dist/fineui.ie.min.js
  23. 2
      dist/fineui.ie.min.js.map
  24. 2799
      dist/fineui.js
  25. 2
      dist/fineui.js.map
  26. 4
      dist/fineui.min.css
  27. 4
      dist/fineui.min.js
  28. 2
      dist/fineui.min.js.map
  29. 1883
      dist/fineui_without_jquery_polyfill.js
  30. 2
      dist/fineui_without_jquery_polyfill.js.map
  31. 2
      dist/font.css
  32. 2
      dist/resource.css
  33. 20
      dist/utils.js
  34. 2
      dist/utils.js.map
  35. 4
      dist/utils.min.js
  36. 2
      dist/utils.min.js.map
  37. 2
      package.json
  38. 5
      src/core/base.js
  39. 1
      src/core/func/date.js
  40. 10
      src/less/widget/yearinterval/yearinterval.less
  41. 10
      src/less/widget/yearquarterinterval/yearquarterinterval.less
  42. 20
      src/widget/year/combo.year.js
  43. 4
      src/widget/year/trigger.year.js
  44. 213
      src/widget/yearinterval/yearinterval.js
  45. 2
      src/widget/yearmonth/combo.yearmonth.js
  46. 20
      src/widget/yearquarter/combo.yearquarter.js
  47. 17
      src/widget/yearquarter/trigger.yearquarter.js
  48. 211
      src/widget/yearquarterinterval/yearquarterinterval.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志
2.0(2021-01)
- 新增年区间和年季度区间控件
- 日期类型控件不操作下拉面板收起不发Confirm事件
- 日期类型控件全系列可设置是否显示动态日期
- 日期类型控件全系列可设置最大最小日期

8
demo/js/config/widget.js

@ -174,6 +174,14 @@ Demo.WIDGET_CONFIG = [{
pId: 412,
text: "bi.year_month_interval",
value: "demo.year_month_interval"
}, {
pId: 412,
text: "bi.year_quarter_interval",
value: "demo.year_quarter_interval"
}, {
pId: 412,
text: "bi.year_interval",
value: "demo.year_interval"
}, {
pId: 4,
id: 413,

51
demo/js/widget/yearinterval/demo.year_interval.js

@ -0,0 +1,51 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2021/1/25
*/
Demo.YearInterval = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.year_interval",
ref: function (_ref) {
self.widget = _ref;
},
width: 300,
minDate: "2012-01-01",
maxDate: "2013-12-31",
value: {
type: 1,
value: {
year: 2012
}
}
}, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.toast(JSON.stringify(self.widget.getValue()));
},
width: 300
}, {
type: "bi.button",
text: "setValue '2017-12'",
width: 300,
handler: function () {
self.widget.setValue({
year: 2017
});
}
}],
vgap: 20
};
}
});
BI.shortcut("demo.year_interval", Demo.YearInterval);

52
demo/js/widget/yearquarterinterval/demo.yearquarterinterval.js

@ -0,0 +1,52 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2021/1/25
*/
Demo.YearQuarterInterval = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.year_quarter_interval",
ref: function (_ref) {
self.interval = _ref;
},
minDate: "2012-07-01",
maxDate: "2012-12-31",
value: {
start: {
type: 2,
value: {
year: -1,
month: 1
}
},
end: {
type: 1,
value: {
year: 2018,
month: 1
}
}
},
width: 400
}, {
type: "bi.button",
text: "getValue",
handler: function () {
BI.Msg.toast(JSON.stringify(self.interval.getValue()));
},
width: 300
}],
vgap: 20
};
}
});
BI.shortcut("demo.year_quarter_interval", Demo.YearQuarterInterval);

4
dist/2.0/fineui.css vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

2793
dist/2.0/fineui.js vendored

File diff suppressed because it is too large Load Diff

2
dist/2.0/fineui.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/2.0/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui_without_normalize.css vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui_without_normalize.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/core.css vendored

File diff suppressed because one or more lines are too long

2759
dist/core.js vendored

File diff suppressed because it is too large Load Diff

2
dist/core.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/demo.css vendored

File diff suppressed because one or more lines are too long

3230
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.css vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

2799
dist/fineui.js vendored

File diff suppressed because it is too large Load Diff

2
dist/fineui.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.min.css vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

1883
dist/fineui_without_jquery_polyfill.js vendored

File diff suppressed because it is too large Load Diff

2
dist/fineui_without_jquery_polyfill.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/font.css vendored

File diff suppressed because one or more lines are too long

2
dist/resource.css vendored

File diff suppressed because one or more lines are too long

20
dist/utils.js vendored

@ -1,4 +1,4 @@
/*! time: 2021-1-22 17:00:30 */
/*! time: 2021-1-26 09:30:24 */
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
@ -82,12 +82,12 @@
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1232);
/******/ return __webpack_require__(__webpack_require__.s = 1236);
/******/ })
/************************************************************************/
/******/ ({
/***/ 1093:
/***/ 1097:
/***/ (function(module, exports) {
BI.i18n = {
@ -320,7 +320,7 @@ if(_global.BI.prepares == null) {
/***/ }),
/***/ 1232:
/***/ 1236:
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(123);
@ -350,8 +350,8 @@ __webpack_require__(140);
__webpack_require__(141);
__webpack_require__(142);
__webpack_require__(143);
__webpack_require__(1093);
__webpack_require__(1233);
__webpack_require__(1097);
__webpack_require__(1237);
__webpack_require__(153);
__webpack_require__(154);
module.exports = __webpack_require__(155);
@ -359,7 +359,7 @@ module.exports = __webpack_require__(155);
/***/ }),
/***/ 1233:
/***/ 1237:
/***/ (function(module, exports) {
/**
@ -1615,7 +1615,10 @@ if (!_global.BI) {
hr -= 12;
}
break;
case "%Q":
case "%q":
m = (parseInt(a[i], 10) - 1) * 3;
break;
case "%M":
min = parseInt(a[i], 10);
break;
@ -7997,6 +8000,7 @@ _.extend(BI, {
s["%y"] = yWith4number.substr(2, 2); // year without the century (range 00 to 99)
s["%Y"] = yWith4number; // year with the century
s["%%"] = "%"; // a literal '%' character
s["%q"] = "0" + qr;
s["%Q"] = qr;
var re = /%./g;

2
dist/utils.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/utils.min.js.map vendored

File diff suppressed because one or more lines are too long

2
package.json

@ -1,6 +1,6 @@
{
"name": "fineui",
"version": "2.0.20210122170226",
"version": "2.0.20210126093211",
"description": "fineui",
"main": "dist/fineui.min.js",
"types": "dist/lib/index.d.ts",

5
src/core/base.js

@ -1129,7 +1129,10 @@ if (!_global.BI) {
hr -= 12;
}
break;
case "%Q":
case "%q":
m = (parseInt(a[i], 10) - 1) * 3;
break;
case "%M":
min = parseInt(a[i], 10);
break;

1
src/core/func/date.js

@ -193,6 +193,7 @@ _.extend(BI, {
s["%y"] = yWith4number.substr(2, 2); // year without the century (range 00 to 99)
s["%Y"] = yWith4number; // year with the century
s["%%"] = "%"; // a literal '%' character
s["%q"] = "0" + qr;
s["%Q"] = qr;
var re = /%./g;

10
src/less/widget/yearinterval/yearinterval.less

@ -0,0 +1,10 @@
@import "../../index";
.bi-year-interval{
&.time-error .bi-input{
color:@color-bi-text-failure
}
&.time-error .sign-editor-text{
color:@color-bi-text-failure
}
}

10
src/less/widget/yearquarterinterval/yearquarterinterval.less

@ -0,0 +1,10 @@
@import "../../index";
.bi-year-quarter-interval{
&.time-error .bi-input{
color:@color-bi-text-failure
}
&.time-error .sign-editor-text{
color:@color-bi-text-failure
}
}

20
src/widget/year/combo.year.js

@ -27,6 +27,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () {
self.storeTriggerValue = this.getKey();
self.fireEvent(BI.DynamicYearCombo.EVENT_FOCUS);
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
@ -36,6 +37,10 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
self.fireEvent(BI.DynamicYearCombo.EVENT_ERROR);
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_VALID, function () {
self.fireEvent(BI.DynamicYearCombo.EVENT_VALID);
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
@ -166,6 +171,14 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
this.popup && this.popup.setMaxDate(maxDate);
},
hideView: function () {
this.combo.hideView();
},
getKey: function () {
return this.trigger.getKey() + "";
},
setValue: function (v) {
this.storeValue = v;
this.trigger.setValue(v);
@ -174,11 +187,18 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
getValue: function () {
return this.storeValue;
},
isStateValid: function () {
return this.trigger.isValid();
}
});
BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.DynamicYearCombo.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearCombo.EVENT_VALID = "EVENT_VALID";
BI.DynamicYearCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo);
BI.extend(BI.DynamicYearCombo, {

4
src/widget/year/trigger.year.js

@ -75,6 +75,9 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_VALID);
});
BI.createWidget({
element: this,
type: "bi.htape",
@ -183,4 +186,5 @@ BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearTrigger.EVENT_START = "EVENT_START";
BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP";
BI.DynamicYearTrigger.EVENT_VALID = "EVENT_VALID";
BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);

213
src/widget/yearinterval/yearinterval.js

@ -0,0 +1,213 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2021/1/25
*/
BI.YearInterval = BI.inherit(BI.Single, {
constants: {
height: 24,
width: 25,
lgap: 15,
offset: -15,
timeErrorCls: "time-error"
},
props: {
extraCls: "bi-year-interval",
minDate: "1900-01-01",
maxDate: "2099-12-31",
supportDynamic: true,
},
render: function () {
var self = this, o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
return [{
type: "bi.center",
hgap: 15,
height: this.constants.height,
items: [{
type: "bi.absolute",
items: [{
el: self.left,
left: this.constants.offset,
right: 0,
top: 0,
bottom: 0
}]
}, {
type: "bi.absolute",
items: [{
el: self.right,
left: 0,
right: this.constants.offset,
top: 0,
bottom: 0
}]
}]
}, {
type: "bi.horizontal_auto",
items: [{
type: "bi.label",
height: this.constants.height,
width: this.constants.width,
text: "-",
ref: function (_ref) {
self.label = _ref;
}
}]
}]
},
_createCombo: function (v) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_year_combo",
supportDynamic: o.supportDynamic,
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors,
value: v,
listeners: [{
eventName: BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.fireEvent(BI.YearInterval.EVENT_BEFORE_POPUPVIEW);
}
}]
});
combo.on(BI.DynamicYearCombo.EVENT_ERROR, function () {
self._clearTitle();
BI.Bubbles.hide("error");
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearInterval.EVENT_ERROR);
});
combo.on(BI.DynamicYearCombo.EVENT_VALID, function () {
self._checkValid();
});
combo.on(BI.DynamicYearCombo.EVENT_FOCUS, function () {
self._checkValid();
});
combo.on(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.left.hideView();
self.right.hideView();
});
combo.on(BI.DynamicYearCombo.EVENT_CONFIRM, function () {
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self.left.isStateValid() && self.right.isStateValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearInterval.EVENT_ERROR);
}else{
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearInterval.EVENT_CHANGE);
}
});
return combo;
},
_dateCheck: function (date) {
return BI.print(BI.parseDateTime(date, "%Y"), "%Y") === date || BI.print(BI.parseDateTime(date, "%Y"), "%Y") === date;
},
// 判是否在最大最小之间
_checkVoid: function (obj) {
var o = this.options;
return !BI.checkDateVoid(obj.year, 1, 1, o.minDate, o.maxDate)[0];
},
// 判格式合法
_check: function (smallDate, bigDate) {
var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
var smallDate4Check = "";
if (BI.isNotNull(smallObj)) {
smallDate4Check = smallObj[0] || "";
}
var bigDate4Check = "";
if (BI.isNotNull(bigObj)) {
bigDate4Check = bigObj[0] || "";
}
return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate4Check) && this._checkVoid({
year: smallObj[0],
month: 1,
day: 1
}) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate4Check) && this._checkVoid({
year: bigObj[0],
month: 12,
day: 1
});
},
_compare: function (smallDate, bigDate) {
smallDate = BI.print(BI.parseDateTime(smallDate, "%Y"), "%Y");
bigDate = BI.print(BI.parseDateTime(bigDate, "%Y"), "%Y");
return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
},
_setTitle: function (v) {
this.setTitle(v);
},
_clearTitle: function () {
this.setTitle("");
},
_checkValid: function () {
var self = this;
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
offsetStyle: "center"
});
self.fireEvent(BI.YearInterval.EVENT_ERROR);
} else {
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
}
},
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
},
setValue: function (date) {
date = date || {};
this.left.setValue(date.start);
this.right.setValue(date.end);
this._checkValid();
},
getValue: function () {
return {start: this.left.getValue(), end: this.right.getValue()};
}
});
BI.YearInterval.EVENT_VALID = "EVENT_VALID";
BI.YearInterval.EVENT_ERROR = "EVENT_ERROR";
BI.YearInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.YearInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_interval", BI.YearInterval);

2
src/widget/yearmonth/combo.yearmonth.js

@ -188,7 +188,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
},
isStateValid: function () {
return this.trigger.isValid();
return this.trigger.isStateValid();
}
});

20
src/widget/yearquarter/combo.yearquarter.js

@ -32,6 +32,10 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_ERROR);
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_VALID, function () {
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () {
var dateStore = self.storeTriggerValue;
@ -48,6 +52,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_FOCUS, function () {
self.storeTriggerValue = self.trigger.getKey();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_FOCUS);
});
this.combo = BI.createWidget({
@ -164,6 +169,14 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
this.popup && this.popup.setMaxDate(maxDate);
},
hideView: function () {
this.combo.hideView();
},
getKey: function () {
return this.trigger.getKey();
},
setValue: function (v) {
this.storeValue = v;
this.trigger.setValue(v);
@ -172,11 +185,18 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
getValue: function () {
return this.storeValue;
},
isStateValid: function () {
return this.trigger.isStateValid();
}
});
BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.DynamicYearQuarterCombo.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearQuarterCombo.EVENT_VALID = "EVENT_VALID";
BI.DynamicYearQuarterCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo);
BI.extend(BI.DynamicYearQuarterCombo, {

17
src/widget/yearquarter/trigger.yearquarter.js

@ -60,12 +60,13 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
_createEditor: function (isYear) {
var self = this, o = this.options, c = this._const;
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
if(isYear) {
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, parseInt(v, 10) === minDate.getFullYear() ? minDate.getMonth() + 1 : 1, 1, o.min, o.max)[0]);
}
return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(self.yearEditor.getValue(), (v - 1) * 3 + 1, 1, o.min, o.max)[0]);
},
@ -105,6 +106,15 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR);
});
editor.on(BI.SignEditor.EVENT_VALID, function () {
var year = self.yearEditor.getValue();
var quarter = self.quarterEditor.getValue();
if(BI.isNotEmptyString(year) && BI.isNotEmptyString(quarter)) {
if(BI.isPositiveInteger(year) && quarter >= 1 && quarter <= 4 && !BI.checkDateVoid(year, (quarter - 1) * 3 + 1, 1, o.min, o.max)[0]) {
self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID);
}
}
});
editor.on(BI.SignEditor.EVENT_CHANGE, function () {
if(isYear) {
self._autoSwitch(editor);
@ -230,6 +240,10 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
getKey: function () {
return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue();
},
isStateValid: function () {
return this.yearEditor.isValid() && this.quarterEditor.isValid();
}
});
BI.DynamicYearQuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
@ -238,4 +252,5 @@ BI.DynamicYearQuarterTrigger.EVENT_START = "EVENT_START";
BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP";
BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.DynamicYearQuarterTrigger.EVENT_VALID = "EVENT_VALID";
BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);

211
src/widget/yearquarterinterval/yearquarterinterval.js

@ -0,0 +1,211 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2021/1/25
*/
BI.YearQuarterInterval = BI.inherit(BI.Single, {
constants: {
height: 24,
width: 25,
lgap: 15,
offset: -15,
timeErrorCls: "time-error"
},
props: {
extraCls: "bi-year-quarter-interval",
minDate: "1900-01-01",
maxDate: "2099-12-31",
supportDynamic: true,
},
render: function () {
var self = this, o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
return [{
type: "bi.center",
hgap: 15,
height: this.constants.height,
items: [{
type: "bi.absolute",
items: [{
el: self.left,
left: this.constants.offset,
right: 0,
top: 0,
bottom: 0
}]
}, {
type: "bi.absolute",
items: [{
el: self.right,
left: 0,
right: this.constants.offset,
top: 0,
bottom: 0
}]
}]
}, {
type: "bi.horizontal_auto",
items: [{
type: "bi.label",
height: this.constants.height,
width: this.constants.width,
text: "-",
ref: function (_ref) {
self.label = _ref;
}
}]
}]
},
_createCombo: function (v) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_year_quarter_combo",
supportDynamic: o.supportDynamic,
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors,
value: v,
listeners: [{
eventName: BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.fireEvent(BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW);
}
}]
});
combo.on(BI.DynamicYearQuarterCombo.EVENT_ERROR, function () {
self._clearTitle();
BI.Bubbles.hide("error");
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
});
combo.on(BI.DynamicYearQuarterCombo.EVENT_VALID, function () {
self._checkValid();
});
combo.on(BI.DynamicYearQuarterCombo.EVENT_FOCUS, function () {
self._checkValid();
});
combo.on(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.left.hideView();
self.right.hideView();
});
combo.on(BI.DynamicYearQuarterCombo.EVENT_CONFIRM, function () {
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self.left.isStateValid() && self.right.isStateValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
}else{
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.YearQuarterInterval.EVENT_CHANGE);
}
});
return combo;
},
_dateCheck: function (date) {
return BI.print(BI.parseDateTime(date, "%Y-%Q"), "%Y-%Q") === date || BI.print(BI.parseDateTime(date, "%Y-%q"), "%Y-%q") === date;
},
// 判是否在最大最小之间
_checkVoid: function (obj) {
var o = this.options;
return !BI.checkDateVoid(obj.year, (obj.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
},
// 判格式合法
_check: function (smallDate, bigDate) {
var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
var smallDate4Check = "";
if (BI.isNotNull(smallObj)) {
smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1);
}
var bigDate4Check = "";
if (BI.isNotNull(bigObj)) {
bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1);
}
return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate4Check) && this._checkVoid({
year: smallObj[0],
quarter: smallObj[1] || 1
}) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate4Check) && this._checkVoid({
year: bigObj[0],
quarter: bigObj[1] || 1
});
},
_compare: function (smallDate, bigDate) {
smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%Q"), "%Y-%Q");
bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%Q"), "%Y-%Q");
return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
},
_setTitle: function (v) {
this.setTitle(v);
},
_clearTitle: function () {
this.setTitle("");
},
_checkValid: function () {
var self = this;
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
offsetStyle: "center"
});
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
} else {
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
}
},
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
},
setValue: function (date) {
date = date || {};
this.left.setValue(date.start);
this.right.setValue(date.end);
this._checkValid();
},
getValue: function () {
return {start: this.left.getValue(), end: this.right.getValue()};
}
});
BI.YearQuarterInterval.EVENT_VALID = "EVENT_VALID";
BI.YearQuarterInterval.EVENT_ERROR = "EVENT_ERROR";
BI.YearQuarterInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval);
Loading…
Cancel
Save