Skip to content

Commit aa18cb6

Browse files
committed
chore(release): Merge branch 'dev' into master
2 parents d85b1fa + 4124d63 commit aa18cb6

File tree

7 files changed

+77
-15
lines changed

7 files changed

+77
-15
lines changed

demos/components/date-picker/index.html

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,25 @@ <h1>DEMO: 1 date-picker</h1>
2222
max-date="app.maxDate"
2323
required="true"
2424
date-only="false"
25-
disabled="false"
25+
disabled-input="true"
2626
on-calendar-open="app.onCalendarOpen()"
2727
on-calendar-close="app.onCalendarClose()"
2828
is-festival="true"
2929
custom-festivals="app.customFestivals"
3030
></cc-date-picker>
31+
<cc-date-picker ng-if="!app.hideDates"
32+
ng-model="app.dateValue"
33+
min-date="app.minDate"
34+
max-date="app.maxDate"
35+
required="true"
36+
date-only="false"
37+
disabled="true"
38+
disabled-input="true"
39+
on-calendar-open="app.onCalendarOpen()"
40+
on-calendar-close="app.onCalendarClose()"
41+
is-festival="true"
42+
custom-festivals="app.customFestivals"
43+
></cc-date-picker>
3144

3245
<cc-date-range ng-if="!app.hideDates"
3346
opts="app.anotherRange"
@@ -131,7 +144,7 @@ <h1>DEMO: 8 disableYear, disableMonth and range</h1>
131144
<cc-date-range opts="app.disableRange"></cc-date-range>
132145
</p>
133146

134-
<h1>DEMO: 9 DisplayFormat: MMDD and DD </h1>
147+
<h1>DEMO: 9 DisplayFormat: MMDD and DD (有 bug 暂时不要用)</h1>
135148
<p>
136149
<cc-date-picker
137150
ng-model="app.MMDDValue"
@@ -157,6 +170,35 @@ <h1>DEMO: 9 DisplayFormat: MMDD and DD </h1>
157170
display-format="DD"
158171
></cc-date-picker>
159172
</p>
173+
174+
<h1>DEMO: 10 disabledInput DisplayFormat: MMDD and DD </h1>
175+
<p>
176+
<cc-date-picker
177+
ng-model="app.MMDDValue"
178+
required="true"
179+
date-only="true"
180+
disabled="false"
181+
disabled-input="true"
182+
on-calendar-open="app.onCalendarOpen()"
183+
on-calendar-close="app.onCalendarClose()"
184+
is-festival="true"
185+
custom-festivals="app.customFestivals"
186+
display-format="MMDD"
187+
></cc-date-picker>
188+
189+
<cc-date-picker
190+
ng-model="app.DDValue"
191+
required="true"
192+
date-only="true"
193+
disabled="false"
194+
disabled-input="true"
195+
on-calendar-open="app.onCalendarOpen()"
196+
on-calendar-close="app.onCalendarClose()"
197+
is-festival="true"
198+
custom-festivals="app.customFestivals"
199+
display-format="DD"
200+
></cc-date-picker>
201+
</p>
160202
</main>
161203

162204
<script src="/components.js"></script>

src/components/calendar/CalendarCtrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const lunnarFestivals = {
5050

5151

5252
const yearList = (function() {
53-
const end = new Date().getFullYear() + 10,
53+
const end = new Date().getFullYear() + 30,
5454
result = [];
5555

5656
for (let i = 1900; i <= end; i += 1) {

src/components/calendar/calendar.tpl.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<input class="calendar-time-input"
2626
name="hour"
2727
ng-model="ctrl.parts.hour"
28+
autocomplete="off"
2829
maxlength="2"
2930
ng-min="0"
3031
ng-max="23"
@@ -33,6 +34,7 @@
3334
<input class="calendar-time-input"
3435
name="minute"
3536
ng-model="ctrl.parts.minute"
37+
autocomplete="off"
3638
maxlength="2"
3739
ng-min="0"
3840
ng-max="59"
@@ -41,6 +43,7 @@
4143
<input class="calendar-time-input"
4244
name="second"
4345
ng-model="ctrl.parts.second"
46+
autocomplete="off"
4447
maxlength="2"
4548
ng-min="0"
4649
ng-max="59"

src/components/date-picker/DatePicker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
scope: {
2121
dateOnly: '=',
2222
disabled: '=',
23+
disabledInput: '=',
2324
minDate: '=',
2425
maxDate: '=',
2526
rangeStart: '=',

src/components/date-picker/DatePickerCtrl.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import angular from 'angular';
66

7-
import {Debounce, Inject} from 'angular-es-utils/decorators';
7+
import {Inject} from 'angular-es-utils/decorators';
88

99
import { DISPLAY_FORMAT } from '../../common/bases/constant';
1010

@@ -258,7 +258,6 @@ export default class DatePickerCtrl {
258258
* 输入/修改年月日值时, 验证合法性
259259
* @param $event
260260
*/
261-
@Debounce(300)
262261
validateValue($event) {
263262
const input = $event.target,
264263
value = +input.value,
@@ -316,6 +315,14 @@ export default class DatePickerCtrl {
316315

317316
// 判断是否输入完成, 跳到下一个单元格
318317
if (input.value.length === +input.maxLength) {
318+
// 校验年的范围
319+
if (input.name === 'year') {
320+
if (input.value < 1900 || input.value > new Date().getFullYear() + 30) {
321+
this.parts[input.name] = '';
322+
setTextWidth(input);
323+
return;
324+
}
325+
}
319326
this.focusNextInput(input, 1);
320327
}
321328

src/components/date-picker/_date-picker.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ $normal-color: #c9c9c9;
4646
color: #999;
4747
}
4848

49+
&.disabledInput .date-picker-input {
50+
background: #fff;
51+
color: #3d3d3d;
52+
}
53+
4954
.date-picker-input-year {
5055
padding-left: 8px;
5156
width: 28px;

src/components/date-picker/date-picker.tpl.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="date-picker-holder">
22
<form name="datePicker"
3-
ng-class="{'date-picker': true, 'disabled': ctrl.disabled}"
3+
ng-class="{'date-picker': true, 'disabled': ctrl.disabled, 'disabledInput': !ctrl.disabled && ctrl.disabledInput}"
44
ng-mouseover="onMouseover = true"
55
ng-mouseout="onMouseover = false"
66
ng-click="ctrl.toggleCalendar($event)">
@@ -12,9 +12,10 @@
1212
ondragstart="return false;"
1313
ondrop="return false;"
1414
ng-model="ctrl.parts.year"
15-
ng-min="1900"
15+
autocomplete="off"
16+
ng-min="0"
1617
ng-max="9999"
17-
ng-disabled="ctrl.disabled"
18+
ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
1819
ng-keydown="ctrl.setInputLength($event)"
1920
ng-keyup="ctrl.validateValue($event)"
2021
ng-focus="ctrl.focusInput($event)"
@@ -28,9 +29,10 @@
2829
ondragstart="return false;"
2930
ondrop="return false;"
3031
ng-model="ctrl.parts.month"
32+
autocomplete="off"
3133
ng-min="1"
3234
ng-max="12"
33-
ng-disabled="ctrl.disabled"
35+
ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
3436
ng-keydown="ctrl.setInputLength($event)"
3537
ng-keyup="ctrl.validateValue($event)"
3638
ng-focus="ctrl.focusInput($event)"
@@ -43,9 +45,10 @@
4345
ondragstart="return false;"
4446
ondrop="return false;"
4547
ng-model="ctrl.parts.date"
48+
autocomplete="off"
4649
ng-min="1"
4750
ng-max="ctrl.calDateMax()"
48-
ng-disabled="ctrl.disabled"
51+
ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
4952
ng-keydown="ctrl.setInputLength($event)"
5053
ng-keyup="ctrl.validateValue($event)"
5154
ng-focus="ctrl.focusInput($event)"
@@ -59,9 +62,10 @@
5962
ondragstart="return false;"
6063
ondrop="return false;"
6164
ng-model="ctrl.parts.hour"
65+
autocomplete="off"
6266
ng-min="0"
6367
ng-max="23"
64-
ng-disabled="ctrl.disabled"
68+
ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
6569
ng-keydown="ctrl.setInputLength($event)"
6670
ng-keyup="ctrl.validateValue($event)"
6771
ng-focus="ctrl.focusInput($event)"
@@ -72,9 +76,9 @@
7276
ondragstart="return false;"
7377
ondrop="return false;"
7478
ng-model="ctrl.parts.minute"
79+
autocomplete="off"
7580
ng-min="0"
76-
ng-max="59"
77-
ng-disabled="ctrl.disabled"
81+
ng-max="59" ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
7882
ng-keydown="ctrl.setInputLength($event)"
7983
ng-keyup="ctrl.validateValue($event)"
8084
ng-focus="ctrl.focusInput($event)"
@@ -85,9 +89,9 @@
8589
ondragstart="return false;"
8690
ondrop="return false;"
8791
ng-model="ctrl.parts.second"
92+
autocomplete="off"
8893
ng-min="0"
89-
ng-max="59"
90-
ng-disabled="ctrl.disabled"
94+
ng-max="59" ng-disabled="{{ctrl.disabled || ctrl.disabledInput}}"
9195
ng-keydown="ctrl.setInputLength($event)"
9296
ng-keyup="ctrl.validateValue($event)"
9397
ng-focus="ctrl.focusInput($event)"

0 commit comments

Comments
 (0)