Skip to content

Commit

Permalink
DatePicker: add monthrange for type attribute (ElemeFE#4204) (ElemeFE…
Browse files Browse the repository at this point in the history
  • Loading branch information
zxyRealm authored and iamkun committed Mar 4, 2019
1 parent 92c0f7a commit 2f5a489
Show file tree
Hide file tree
Showing 12 changed files with 1,138 additions and 72 deletions.
71 changes: 70 additions & 1 deletion examples/docs/en-US/date-picker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## DatePicker

Use Date Picker for date input.
Expand Down Expand Up @@ -202,6 +203,74 @@ Picking a date range is supported.

:::

### Month Range

Picking a month range is supported.

:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute.
```html
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker
v-model="value15"
type="monthrange"
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">With quick options</span>
<el-date-picker
v-model="value16"
type="monthrange"
align="right"
unlink-panels
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month"
:picker-options="pickerOptions3">
</el-date-picker>
</div>
</template>

<script>
export default {
data() {
return {
pickerOptions3: {
shortcuts: [{
text: 'This month',
onClick(picker) {
picker.$emit('pick', [new Date(), new Date()]);
}
}, {
text: 'This year',
onClick(picker) {
const end = new Date();
const start = new Date(new Date().getFullYear(), 0);
picker.$emit('pick', [start, end]);
}
}, {
text: 'Last 6 months',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 6);
picker.$emit('pick', [start, end]);
}
}]
},
value15: '',
value16: ''
};
}
};
</script>
```
:::

### Default Value

If user hasn't picked a date, shows today's calendar by default. You can use `default-value` to set another date. Its value should be parsable by `new Date()`.
Expand Down Expand Up @@ -372,7 +441,7 @@ When picking a date range, you can assign the time part for start date and end d
| placeholder | placeholder in non-range mode | string |||
| start-placeholder | placeholder for the start date in range mode | string |||
| end-placeholder | placeholder for the end date in range mode | string |||
| type | type of the picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date |
| type | type of the picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date |
| format | format of the displayed value in the input box | string | see [date formats](#/en-US/component/date-picker#date-formats) | yyyy-MM-dd |
| align | alignment | left/center/right | left |
| popper-class | custom class name for DatePicker's dropdown | string |||
Expand Down
71 changes: 70 additions & 1 deletion examples/docs/es/date-picker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## DatePicker

Utilice Date Picker para introducir la fecha.
Expand Down Expand Up @@ -204,6 +205,74 @@ Se soporta la selección de un rango de fechas.

:::

### Month Range

Picking a month range is supported.

:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute.
```html
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker
v-model="value15"
type="monthrange"
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">With quick options</span>
<el-date-picker
v-model="value16"
type="monthrange"
align="right"
unlink-panels
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month"
:picker-options="pickerOptions3">
</el-date-picker>
</div>
</template>

<script>
export default {
data() {
return {
pickerOptions3: {
shortcuts: [{
text: 'This month',
onClick(picker) {
picker.$emit('pick', [new Date(), new Date()]);
}
}, {
text: 'This year',
onClick(picker) {
const end = new Date();
const start = new Date(new Date().getFullYear(), 0);
picker.$emit('pick', [start, end]);
}
}, {
text: 'Last 6 months',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 6);
picker.$emit('pick', [start, end]);
}
}]
},
value15: '',
value16: ''
};
}
};
</script>
```
:::

### Valor por defecto

Si el usuario no ha escogido una fecha, muestra el calendario de hoy por defecto. Puede utilizar `default-value` para fijar otra fecha. Su valor debe ser definido por `new Date()`.
Expand Down Expand Up @@ -373,7 +442,7 @@ Al seleccionar un intervalo de fechas, puede asignar la hora para la fecha de in
| placeholder | placeholder cuando el modo NO es rango | string |||
| start-placeholder | placeholder para la fecha de inicio en modo rango | string |||
| end-placeholder | placeholder para la fecha final en modo rango | string |||
| type | tipo de picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date |
| type | tipo de picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date |
| format | formato en que se muestra el valor en el input | string | ver [date formats](#/es/component/date-picker#date-formats) | yyyy-MM-dd |
| align | alineación | left/center/right | left | |
| popper-class | nombre de clase personalizada para el dropdown de DatePicker | string |||
Expand Down
71 changes: 70 additions & 1 deletion examples/docs/fr-FR/date-picker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## DatePicker

Utilisez le DatePicker pour les champs de dates.
Expand Down Expand Up @@ -202,6 +203,74 @@ Vous pouvez sélectionner une plage de dates.

:::

### Month Range

Picking a month range is supported.

:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute.
```html
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker
v-model="value15"
type="monthrange"
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">With quick options</span>
<el-date-picker
v-model="value16"
type="monthrange"
align="right"
unlink-panels
range-separator="To"
start-placeholder="Start month"
end-placeholder="End month"
:picker-options="pickerOptions3">
</el-date-picker>
</div>
</template>

<script>
export default {
data() {
return {
pickerOptions3: {
shortcuts: [{
text: 'This month',
onClick(picker) {
picker.$emit('pick', [new Date(), new Date()]);
}
}, {
text: 'This year',
onClick(picker) {
const end = new Date();
const start = new Date(new Date().getFullYear(), 0);
picker.$emit('pick', [start, end]);
}
}, {
text: 'Last 6 months',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 6);
picker.$emit('pick', [start, end]);
}
}]
},
value15: '',
value16: ''
};
}
};
</script>
```
:::

### Valeur par défaut

Si l'utilisateur n'a pas sélectionné de date, vous pouvez montrer la date d'aujourd'hui par défaut. Utilisez `default-value` pour montrer une autre date. Sa valeur doit être parsable par `new Date()`.
Expand Down Expand Up @@ -373,7 +442,7 @@ Lorsque vous choisissez une plage de dates, vous pouvez assigner l'horaire de d
| placeholder | Le placeholder en mode normal. | string |||
| start-placeholder | Le placeholder pour la date de début en mode plage de dates. | string |||
| end-placeholder | Le placeholder pour la date de fin en mode plage de dates. | string |||
| type | Type du picker. | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date |
| type | Type du picker. | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date |
| format | Format d'affichage dans le champ. | string | Voir [formats de date](#/fr-FR/component/date-picker#formats-de-date). | yyyy-MM-dd |
| align | Alignement. | left/center/right | left |
| popper-class | Nom de classe pour le menu déroulant du DatePicker. | string |||
Expand Down
73 changes: 72 additions & 1 deletion examples/docs/zh-CN/date-picker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## DatePicker 日期选择器

用于选择或输入日期
Expand Down Expand Up @@ -198,6 +199,76 @@
```
:::


### 选择月份范围

可在一个选择器中便捷地选择一个月份范围

:::demo 在选择月份范围时,默认情况下左右面板会联动。如果希望两个面板各自独立切换当前年份,可以使用`unlink-panels`属性解除联动。
```html
<template>
<div class="block">
<span class="demonstration">默认</span>
<el-date-picker
v-model="value15"
type="monthrange"
range-separator=""
start-placeholder="开始月份"
end-placeholder="结束月份">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">带快捷选项</span>
<el-date-picker
v-model="value16"
type="monthrange"
align="right"
unlink-panels
range-separator=""
start-placeholder="开始月份"
end-placeholder="结束月份"
:picker-options="pickerOptions3">
</el-date-picker>
</div>
</template>

<script>
export default {
data() {
return {
pickerOptions3: {
shortcuts: [{
text: '本月',
onClick(picker) {
picker.$emit('pick', [new Date(), new Date()]);
}
}, {
text: '今年至今',
onClick(picker) {
const end = new Date();
const start = new Date(new Date().getFullYear(), 0);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近六个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 6);
picker.$emit('pick', [start, end]);
}
}]
},
value15: '',
value16: ''
};
}
};
</script>
```
:::


### 日期格式

使用`format`指定输入框的格式;使用`value-format`指定绑定值的格式。
Expand Down Expand Up @@ -323,7 +394,7 @@
| placeholder | 非范围选择时的占位内容 | string |||
| start-placeholder | 范围选择时开始日期的占位内容 | string |||
| end-placeholder | 范围选择时结束日期的占位内容 | string |||
| type | 显示类型 | string | year/month/date/dates/ week/datetime/datetimerange/daterange | date |
| type | 显示类型 | string | year/month/date/dates/ week/datetime/datetimerange/ daterange/monthrange | date |
| format | 显示在输入框中的格式 | string |[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | yyyy-MM-dd |
| align | 对齐方式 | string | left, center, right | left |
| popper-class | DatePicker 下拉框的类名 | string |||
Expand Down
Loading

0 comments on commit 2f5a489

Please sign in to comment.