diff --git a/assets/iview.png b/assets/iview.png
index 5943b53..3485561 100644
Binary files a/assets/iview.png and b/assets/iview.png differ
diff --git a/src/components/date-picker/panel/time-range.vue b/src/components/date-picker/panel/time-range.vue
new file mode 100644
index 0000000..6fe4af9
--- /dev/null
+++ b/src/components/date-picker/panel/time-range.vue
@@ -0,0 +1,158 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue
index c8956f5..0ed5e9f 100644
--- a/src/components/date-picker/picker.vue
+++ b/src/components/date-picker/picker.vue
@@ -201,7 +201,7 @@
},
iconType () {
let icon = 'ios-calendar-outline';
- if (this.type === 'time') icon = 'ios-clock-outline';
+ if (this.type === 'time' || this.type === 'timerange') icon = 'ios-clock-outline';
if (this.showClose) icon = 'ios-close';
return icon;
},
@@ -408,14 +408,16 @@
this.picker.resetView && this.picker.resetView();
},
emitChange (date) {
- const format = this.format || DEFAULT_FORMATS[this.type];
+ const type = this.type;
+ const format = this.format || DEFAULT_FORMATS[type];
const formatter = (
- TYPE_VALUE_RESOLVER_MAP[this.type] ||
+ TYPE_VALUE_RESOLVER_MAP[type] ||
TYPE_VALUE_RESOLVER_MAP['default']
).formatter;
let newDate = formatter(date, format);
- if (this.type === 'daterange') {
+ if (type === 'daterange' || type === 'timerange') {
+ console.log(newDate);
newDate = [newDate.split(RANGE_SEPARATOR)[0], newDate.split(RANGE_SEPARATOR)[1]];
}
@@ -443,12 +445,12 @@
immediate: true,
handler (val) {
const type = this.type;
- if (type === 'time') {
+ if (type === 'time' || type === 'timerange') {
const parser = (
TYPE_VALUE_RESOLVER_MAP[type] ||
TYPE_VALUE_RESOLVER_MAP['default']
).parser;
-
+ if (type === 'timerange') val = val.join(RANGE_SEPARATOR);
val = parser(val, this.format || DEFAULT_FORMATS[type]);
}
this.internalValue = val;
diff --git a/src/components/date-picker/picker/time-picker.js b/src/components/date-picker/picker/time-picker.js
index 4a35a68..b0f77c0 100644
--- a/src/components/date-picker/picker/time-picker.js
+++ b/src/components/date-picker/picker/time-picker.js
@@ -1,18 +1,36 @@
import Picker from '../picker.vue';
import TimePanel from '../panel/time.vue';
+import TimeRangePanel from '../panel/time-range.vue';
import Options from '../time-mixins';
+const getPanel = function (type) {
+ if (type === 'timerange') {
+ return TimeRangePanel;
+ }
+ return TimePanel;
+};
+
+import { oneOf } from '../../../utils/assist';
+
export default {
mixins: [Picker, Options],
props: {
+ type: {
+ validator (value) {
+ return oneOf(value, ['time', 'timerange']);
+ },
+ default: 'time'
+ },
value: {}
},
- data () {
- return {
- type: 'time'
- };
- },
created () {
- this.panel = TimePanel;
+ if (!this.value) {
+ if (this.type === 'timerange') {
+ this.value = ['',''];
+ } else {
+ this.value = '';
+ }
+ }
+ this.panel = getPanel(this.type);
}
};
\ No newline at end of file
diff --git a/src/styles/components/time-picker.less b/src/styles/components/time-picker.less
index 22fa29a..e506a41 100644
--- a/src/styles/components/time-picker.less
+++ b/src/styles/components/time-picker.less
@@ -1,9 +1,12 @@
@time-picker-prefix-cls: ~"@{css-prefix}time-picker";
+@time-picker-cells-width: 112px;
+@time-picker-cells-width-with-seconds: @time-picker-cells-width + 56px;
+
.@{time-picker-prefix-cls} {
&-cells{
- min-width: 112px;
+ min-width: @time-picker-cells-width;
&-with-seconds{
- min-width: 168px;
+ min-width: @time-picker-cells-width-with-seconds;
}
&-list{
@@ -61,4 +64,59 @@
}
}
}
+
+ &-header{
+ height: 32px;
+ line-height: 32px;
+ text-align: center;
+ border-bottom: 1px solid @border-color-split;
+ }
+
+ &-with-range{
+ .@{picker-prefix-cls}-panel{
+ &-body{
+ min-width: @time-picker-cells-width * 2 + 4px;
+ }
+ &-content{
+ float: left;
+ position: relative;
+
+ &:after{
+ content: '';
+ display: block;
+ width: 2px;
+ position: absolute;
+ top: 31px;
+ bottom: 0;
+ right: -2px;
+ background: @border-color-split
+ }
+
+ &-right{
+ float: right;
+ &:after{
+ right: auto;
+ left: -2px;
+ }
+ }
+ }
+ }
+ .@{time-picker-prefix-cls}-cells{
+ &-list{
+ &:first-child{
+ border-radius: 0;
+ }
+ &:last-child{
+ border-radius: 0;
+ }
+ }
+ }
+ }
+ &-with-range&-with-seconds{
+ .@{picker-prefix-cls}-panel{
+ &-body{
+ min-width: @time-picker-cells-width-with-seconds * 2 + 4px;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/test/routers/date.vue b/test/routers/date.vue
index 438a8b9..bdaed4a 100644
--- a/test/routers/date.vue
+++ b/test/routers/date.vue
@@ -6,19 +6,29 @@
-
+
-
+
- 123,{{value}},456
+
+
+