Browse Source

REPORT-28235 fix: timeCombo %M:%S问题

es6
windy 4 years ago
parent
commit
edfd125b40
  1. 1
      changelog.md
  2. 23
      src/widget/time/__test__/time.combo.test.js
  3. 18
      src/widget/time/time.trigger.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志
2.0(2020-03)
- 修复了time_combo设置格式为%M:%S后value设置大于30分钟的值时标红的问题
- 复选下拉树系列展开节点性能优化
2.0(2020-02)

23
src/widget/time/__test__/time.combo.test.js

@ -168,4 +168,27 @@ describe("TimeCombo", function () {
})
});
/**
* test_author_windy
*/
it("测试%M:%S", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
format: "%M:%S", // mm:ss
value: {
hour: 12,
minute: 45,
second: 0
},
});
BI.nextTick(function () {
expect(timeCombo.element.find(".bi-time-trigger .bi-label").text()).to.equal("45:00");
timeCombo.destroy();
done();
});
});
});

18
src/widget/time/time.trigger.js

@ -19,7 +19,8 @@
"%H:%M", // HH:mm
"%M:%S" // mm:ss
],
DEFAULT_DATE_STRING: "2000-01-01"
DEFAULT_DATE_STRING: "2000-01-01",
DEFAULT_HOUR: "00"
},
props: {
@ -135,11 +136,24 @@
_dateCheck: function (date) {
var c = this._const;
var self = this;
return BI.any(c.FORMAT_ARRAY, function (idx, format) {
return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + date, c.COMPLETE_COMPARE_FORMAT), format) === date;
return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + self._getCompleteHMS(date, format), c.COMPLETE_COMPARE_FORMAT), format) === date;
});
},
_getCompleteHMS: function (str, format) {
var c = this._const;
switch (format) {
case "%M:%S":
str = c.DEFAULT_HOUR + ":" + str;
break;
default:
break;
}
return str;
},
_getTitle: function () {
var storeValue = this.storeValue || {};
var date = BI.getDate();

Loading…
Cancel
Save