Skip to content

Commit

Permalink
Merge pull request #244 from kaola-fed/feature_datepicker_20180829
Browse files Browse the repository at this point in the history
datepicker添加确定按钮
  • Loading branch information
nupthale authored Aug 29, 2017
2 parents 2d6fefb + 2d61be0 commit 148bc20
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/js/components/form/KLDatePicker/Calendar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<div class="calendar_bd">
<div class="calendar_week"><span class="calendar_item">{this.$trans('CAL_SUNDAY')}</span><span class="calendar_item">{this.$trans('CAL_MONDAY')}</span><span class="calendar_item">{this.$trans('CAL_TUESDAY')}</span><span class="calendar_item">{this.$trans('CAL_WENSDAY')}</span><span class="calendar_item">{this.$trans('CAL_THURSDAY')}</span><span class="calendar_item">{this.$trans('CAL_FRIDAY')}</span><span class="calendar_item">{this.$trans('CAL_SATURDAY')}</span></div>
<div class="calendar_day">{#list _days as day}<span class="calendar_item" z-sel={date.toDateString() === day.toDateString()} z-dis={!!this.isOutOfRange(day)} r-class={ {'z-muted': date.getMonth() !== day.getMonth()} } on-click={this.select(day)}>{day | format: 'dd'}</span>{/list}</div>
<div class="calendar_day">{#list _days as day}<span class="calendar_item" z-sel={date.toDateString() === day.toDateString()} z-dis={!!this.isOutOfRange(day)} r-class={ {'z-muted': date.getMonth() !== day.getMonth()} } on-click={this.select(day, $event)}>{day | format: 'dd'}</span>{/list}</div>
{#inc this.$body}
</div>
</div>
5 changes: 2 additions & 3 deletions src/js/components/form/KLDatePicker/Calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ const Calendar = Component.extend({
*/
_update() {
this.data._days = [];

const date = this.data.date;
const month = date.getMonth();
const mfirst = new Date(date);
Expand Down Expand Up @@ -210,11 +209,11 @@ const Calendar = Component.extend({
* @param {Date} date 选择的日期
* @return {void}
*/
select(date) {
select(date, e) {
e.stopPropagation();
if (this.data.readonly || this.data.disabled || this.isOutOfRange(date)) {
return;
}

this.data.date = new Date(date);

/**
Expand Down
3 changes: 3 additions & 0 deletions src/js/components/form/KLDatePicker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
{#if showTime}
<time-picker size="sm" time={_time} on-change={this._onDateTimeChange(_date, _time)} />
{/if}
<div class="dropdown_ft">
<a class="u-btn u-btn-sm" on-click={this.onConfirm()}>{this.$trans('CONFIRM')}</a>
</div>
</calendar>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions src/js/components/form/KLDatePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,18 @@ const KLDatePicker = Dropdown.extend({
return;
}
this._onDateTimeChange(date, time);

},
onConfirm() {
if (this.data.readonly || this.data.disabled || this.isOutOfRange(this.date)) {
return;
}
this._onOk();

// this.toggle(false);
},
_onClose() {
this.toggle(false);
},
_onOk() {
this.date || this._onDateTimeChange(this.data._date);
this.data.date = this.date;
this.data.time = this.time;
/**
Expand All @@ -196,7 +199,6 @@ const KLDatePicker = Dropdown.extend({
_onInput($event) {
const value = $event.target.value;
const date = value ? new Date(value) : null;

if (date !== 'Invalid Date') this.data.date = date;
else {
$event.target.value = filter.format(
Expand Down
10 changes: 10 additions & 0 deletions src/js/components/form/KLDatePicker/index.mcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@
.btns {
margin-top: 10px;
}
.dropdown_ft {
display: flex;
padding: 4px 0 0;
margin-top: 4px;
justify-content: flex-end;
border-top: 1px solid #ddd;
a {
color: #333;
}
}
}

0 comments on commit 148bc20

Please sign in to comment.