Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
8783c3e9
Commit
8783c3e9
authored
Oct 26, 2016
by
cinwell.li
Committed by
FuryBean
Oct 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatePicker: improve test (#659)
parent
32d3ad53
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
502 additions
and
185 deletions
+502
-185
packages/date-picker/src/panel/date-range.vue
packages/date-picker/src/panel/date-range.vue
+9
-59
packages/date-picker/src/panel/date.vue
packages/date-picker/src/panel/date.vue
+13
-53
packages/date-picker/src/picker.vue
packages/date-picker/src/picker.vue
+1
-5
test/unit/specs/date-picker.spec.js
test/unit/specs/date-picker.spec.js
+479
-68
No files found.
packages/date-picker/src/panel/date-range.vue
View file @
8783c3e9
...
...
@@ -24,7 +24,7 @@
<input
placeholder=
"开始日期"
class=
"el-date-range-picker__editor"
v-model.lazy
=
"leftVisibleDate"
:value
=
"leftVisibleDate"
@
input=
"handleDateInput($event, 'min')"
@
change=
"handleDateChange($event, 'min')"
/>
</span>
...
...
@@ -32,7 +32,7 @@
<input
placeholder=
"开始时间"
class=
"el-date-range-picker__editor"
v-model.lazy
=
"leftVisibleTime"
:value
=
"leftVisibleTime"
@
focus=
"leftTimePickerVisible = !leftTimePickerVisible"
@
change=
"handleTimeChange($event, 'min')"
/>
<time-picker
...
...
@@ -51,7 +51,7 @@
ref=
"leftInput"
placeholder=
"结束日期"
class=
"el-date-range-picker__editor"
v-model.lazy
=
"rightVisibleDate"
:value
=
"rightVisibleDate"
:readonly=
"!minDate"
@
input=
"handleDateInput($event, 'max')"
@
change=
"handleDateChange($event, 'max')"
/>
...
...
@@ -61,7 +61,7 @@
ref=
"rightInput"
placeholder=
"结束时间"
class=
"el-date-range-picker__editor"
v-model.lazy
=
"rightVisibleTime"
:value
=
"rightVisibleTime"
@
focus=
"minDate && (rightTimePickerVisible = !rightTimePickerVisible)"
:readonly=
"!minDate"
@
change=
"handleTimeChange($event, 'max')"
/>
...
...
@@ -177,7 +177,7 @@
},
rightVisibleDate
()
{
return
formatDate
(
this
.
maxDate
);
return
formatDate
(
this
.
maxDate
||
this
.
minDate
);
},
leftVisibleTime
()
{
...
...
@@ -188,60 +188,6 @@
return
formatDate
(
this
.
maxDate
,
'
HH:mm:ss
'
);
},
leftHours
:
{
get
()
{
return
this
.
date
.
getHours
();
},
set
(
hours
)
{
this
.
date
.
setHours
(
hours
);
}
},
leftMinutes
:
{
get
()
{
return
this
.
date
.
getMinutes
();
},
set
(
minutes
)
{
this
.
date
.
setMinutes
(
minutes
);
}
},
leftSeconds
:
{
get
()
{
return
this
.
date
.
getSeconds
();
},
set
(
seconds
)
{
this
.
date
.
setSeconds
(
seconds
);
}
},
rightHours
:
{
get
()
{
return
this
.
rightDate
.
getHours
();
},
set
(
hours
)
{
this
.
rightDate
.
setHours
(
hours
);
}
},
rightMinutes
:
{
get
()
{
return
this
.
rightDate
.
getMinutes
();
},
set
(
minutes
)
{
this
.
rightDate
.
setMinutes
(
minutes
);
}
},
rightSeconds
:
{
get
()
{
return
this
.
rightDate
.
getSeconds
();
},
set
(
seconds
)
{
this
.
rightDate
.
setSeconds
(
seconds
);
}
},
rightDate
()
{
const
newDate
=
new
Date
(
this
.
date
);
const
month
=
newDate
.
getMonth
();
...
...
@@ -396,6 +342,10 @@
this
.
maxDate
=
new
Date
(
target
.
getTime
());
}
}
const
l2r
=
type
===
'
min
'
?
'
left
'
:
'
right
'
;
this
.
$refs
[
l2r
+
'
timepicker
'
].
value
=
target
;
this
[
l2r
+
'
TimePickerVisible
'
]
=
false
;
}
},
...
...
packages/date-picker/src/panel/date.vue
View file @
8783c3e9
...
...
@@ -111,7 +111,7 @@
<a
href=
"JavaScript:"
class=
"el-picker-panel__link-btn"
@
click=
"changeTo
Today
"
>
{{
$t
(
'
datepicker.now
'
)
}}
</a>
@
click=
"changeTo
Now
"
>
{{
$t
(
'
datepicker.now
'
)
}}
</a>
<button
type=
"button"
class=
"el-picker-panel__btn"
...
...
@@ -127,6 +127,7 @@
export
default
{
watch
:
{
showTime
(
val
)
{
/* istanbul ignore if */
if
(
!
val
)
return
;
this
.
$nextTick
(
_
=>
{
const
inputElm
=
this
.
$refs
.
input
;
...
...
@@ -156,6 +157,7 @@
selectionMode
(
newVal
)
{
if
(
newVal
===
'
month
'
)
{
/* istanbul ignore next */
if
(
this
.
currentView
!==
'
year
'
||
this
.
currentView
!==
'
month
'
)
{
this
.
currentView
=
'
month
'
;
}
...
...
@@ -163,6 +165,7 @@
},
date
(
newVal
)
{
/* istanbul ignore next */
if
(
!
this
.
year
)
{
this
.
year
=
newVal
.
getFullYear
();
this
.
month
=
newVal
.
getMonth
();
...
...
@@ -187,13 +190,14 @@
this
.
currentView
=
'
year
'
;
},
handleLabelClick
()
{
if
(
this
.
currentView
===
'
date
'
)
{
this
.
showMonthPicker
();
}
else
if
(
this
.
currentView
===
'
month
'
)
{
this
.
showYearPicker
();
}
},
// XXX: 没用到
// handleLabelClick() {
// if (this.currentView === 'date') {
// this.showMonthPicker();
// } else if (this.currentView === 'month') {
// this.showYearPicker();
// }
// },
prevMonth
()
{
this
.
month
--
;
...
...
@@ -301,7 +305,7 @@
this
.
resetDate
();
},
changeTo
Today
()
{
changeTo
Now
()
{
this
.
date
.
setTime
(
+
new
Date
());
this
.
$emit
(
'
pick
'
,
new
Date
(
this
.
date
.
getTime
()));
this
.
resetDate
();
...
...
@@ -416,50 +420,6 @@
return
startYear
+
'
'
+
yearTranslation
+
'
-
'
+
(
startYear
+
9
)
+
'
'
+
yearTranslation
;
}
return
this
.
year
+
'
'
+
yearTranslation
;
},
hours
:
{
get
()
{
return
this
.
date
.
getHours
();
},
set
(
hours
)
{
this
.
date
.
setHours
(
hours
);
}
},
minutes
:
{
get
()
{
return
this
.
date
.
getMinutes
();
},
set
(
minutes
)
{
this
.
date
.
setMinutes
(
minutes
);
}
},
seconds
:
{
get
()
{
return
this
.
date
.
getSeconds
();
},
set
(
seconds
)
{
this
.
date
.
setSeconds
(
seconds
);
}
},
timeText
()
{
const
hours
=
this
.
hours
;
const
minutes
=
this
.
minutes
;
return
(
hours
<
10
?
'
0
'
+
hours
:
hours
)
+
'
:
'
+
(
minutes
<
10
?
'
0
'
+
minutes
:
minutes
);
},
label
()
{
const
year
=
this
.
year
;
const
month
=
this
.
month
+
1
;
if
(
this
.
currentView
===
'
date
'
)
{
return
year
+
'
/
'
+
month
;
}
return
year
;
}
}
};
...
...
packages/date-picker/src/picker.vue
View file @
8783c3e9
...
...
@@ -20,7 +20,7 @@
v-model.lazy=
"visualValue"
/>
<span
@
click=
"
togglePicker
"
@
click=
"
pickerVisible = !pickerVisible
"
class=
"el-date-editor__trigger el-icon"
:class=
"[triggerClass]"
v-if=
"haveTrigger"
>
...
...
@@ -353,10 +353,6 @@ export default {
}
},
togglePicker
()
{
!
this
.
pickerVisible
?
this
.
showPicker
()
:
this
.
hidePicker
();
},
hidePicker
()
{
if
(
this
.
picker
)
{
this
.
picker
.
resetView
&&
this
.
picker
.
resetView
();
...
...
test/unit/specs/date-picker.spec.js
View file @
8783c3e9
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment