feat(DatetimePicker): some props can be string type

This commit is contained in:
陈嘉涵 2020-01-29 10:52:34 +08:00
parent ecdaf3f837
commit 6d0714de3e
5 changed files with 87 additions and 59 deletions

View File

@ -60,16 +60,16 @@ Set `columns-num` with 2, you'll have a 2 level picker.
|------|------|------|------|
| value | the `code` of selected area | *string* | - |
| title | Toolbar title | *string* | - |
| area-list | Area data | *object* | - |
| columns-num | level of picker | *number \| string* | `3` |
| columns-placeholder `v2.2.5` | placeholder of columns | *string[]* | `[]` |
| item-height | Option height | *number* | `44` |
| loading | Whether to show loading prompt | *boolean* | `false` |
| visible-item-count | Count of visible columns | *number* | `5` |
| confirm-button-text | Text of confirm button | *string* | `Confirm` |
| cancel-button-text | Text of cancel button | *string* | `Cancel` |
| area-list | Area list data | *object* | - |
| columns-placeholder `v2.2.5` | Placeholder of columns | *string[]* | `[]` |
| loading | Whether to show loading prompt | *boolean* | `false` |
| item-height | Option height | *number \| string* | `44` |
| columns-num | Level of picker | *number \| string* | `3` |
| visible-item-count | Count of visible columns | *number \| string* | `5` |
| swipe-duration `v2.2.13` | Duration of the momentum animationunit `ms` | *number \| string* | `1000` |
| is-oversea-code `v2.1.4` | The method to validate oversea code | *() => boolean* | - |
| swipe-duration `v2.2.13` | Duration of the momentum animationunit `ms` | *number* | `1000` |
### Events

View File

@ -2,7 +2,7 @@
### 介绍
省市区选择组件通常与 [弹出层](#/zh-CN/popup) 组件配合使用
省市区三级联动选择,通常与 [弹出层](#/zh-CN/popup) 组件配合使用
### 引入
@ -59,16 +59,16 @@ Vue.use(Area);
|------|------|------|------|
| value | 当前选中的省市区`code` | *string* | - |
| title | 顶部栏标题 | *string* | - |
| area-list | 省市区数据,格式见下方 | *object* | - |
| columns-num | 显示列数3-省市区2-省市1-省 | *number \| string* | `3` |
| columns-placeholder `v2.2.5` | 列占位提示文字 | *string[]* | `[]` |
| loading | 是否显示加载状态 | *boolean* | `false` |
| item-height | 选项高度 | *number* | `44` |
| visible-item-count | 可见的选项个数 | *number* | `5` |
| confirm-button-text | 确认按钮文字 | *string* | `确认` |
| cancel-button-text | 取消按钮文字 | *string* | `取消` |
| area-list | 省市区数据,格式见下方 | *object* | - |
| columns-placeholder `v2.2.5` | 列占位提示文字 | *string[]* | `[]` |
| loading | 是否显示加载状态 | *boolean* | `false` |
| item-height | 选项高度 | *number \| string* | `44` |
| columns-num | 显示列数3-省市区2-省市1-省 | *number \| string* | `3` |
| visible-item-count | 可见的选项个数 | *number \| string* | `5` |
| swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | *number \| string* | `1000` |
| is-oversea-code `v2.1.4` | 根据`code`校验海外地址,海外地址会划分至单独的分类 | *() => boolean* | - |
| swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | *number* | `1000` |
### Events

View File

@ -84,13 +84,13 @@ export default {
},
methods: {
formatter(type, value) {
formatter(type, val) {
if (type === 'year') {
return `${value} Year`;
return `${val} Year`;
} else if (type === 'month') {
return `${value} Month`
return `${val} Month`
}
return value;
return val;
}
}
}
@ -154,28 +154,42 @@ export default {
| Attribute | Description | Type | Default |
|------|------|------|------|
| type | Can be set to `date` `time`<br> `year-month` | *string* | `datetime` |
| min-date | Min date | *Date* | Ten years ago on January 1 |
| max-date | Max date | *Date* | Ten years later on December 31 |
| min-hour | Min hour for `time` type | *number* | `0` |
| max-hour | Max hour for `time` type | *number* | `23` |
| min-minute | Max minute for `time` type | *number* | `0` |
| max-minute | Max minute for `time` type | *number* | `59` |
| filter | Option filter | *(type, values) => values* | - |
| formatter | Option text formatter | *(type, value) => value* | - |
| title | Toolbar title | *string* | `''` |
| show-toolbar | Whether to show toolbar | *boolean* | `true` |
| loading | Whether to show loading prompt | *boolean* | `false` |
| item-height | Option height | *number* | `44` |
| confirm-button-text | Text of confirm button | *string* | `Confirm` |
| cancel-button-text | Text of cancel button | *string* | `Cancel` |
| visible-item-count | Count of visible columns | *number* | `5` |
| swipe-duration `v2.2.13` | Duration of the momentum animationunit `ms` | *number* | `1000` |
| show-toolbar | Whether to show toolbar | *boolean* | `true` |
| loading | Whether to show loading prompt | *boolean* | `false` |
| filter | Option filter | *(type, vals) => vals* | - |
| formatter | Option text formatter | *(type, val) => val* | - |
| item-height | Option height | *number \| string* | `44` |
| visible-item-count | Count of visible columns | *number \| string* | `5` |
| swipe-duration `v2.2.13` | Duration of the momentum animationunit `ms` | *number \| string* | `1000` |
### DatePicker Props
Following props are supported when the type is date or datetime
| Attribute | Description | Type | Default |
|------|------|------|------|
| min-date | Min date | *Date* | Ten years ago on January 1 |
| max-date | Max date | *Date* | Ten years later on December 31 |
### TimePicker Props
Following props are supported when the type is time
| Attribute | Description | Type | Default |
|------|------|------|------|
| min-hour | Min hour for `time` type | *number \| string* | `0` |
| max-hour | Max hour for `time` type | *number \| string* | `23` |
| min-minute | Max minute for `time` type | *number \| string* | `0` |
| max-minute | Max minute for `time` type | *number \| string* | `59` |
### Events
| Event | Description | Arguments |
|------|------|------|
| change | Triggered when value changed | picker: picker instance |
| change | Triggered when value changed | picker: Picker instance |
| confirm | Triggered when click confirm button | value: current value |
| cancel | Triggered when click cancel button | - |

View File

@ -2,7 +2,7 @@
### 介绍
用于选择时间,支持日期、时分等时间维度,通常与 [弹出层](#/zh-CN/popup) 组件配合使用
时间选择器,支持日期、年月、时分等维度,通常与 [弹出层](#/zh-CN/popup) 组件配合使用
### 引入
@ -86,13 +86,13 @@ export default {
},
methods: {
formatter(type, value) {
formatter(type, val) {
if (type === 'year') {
return `${value}年`;
return `${val}年`;
} else if (type === 'month') {
return `${value}月`
return `${val}月`
}
return value;
return val;
}
}
}
@ -158,29 +158,43 @@ export default {
| 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------|
| type | 类型,可选值为 `date` <br> `time` `year-month` | *string* | `datetime` |
| min-date | 可选的最小时间,精确到分钟 | *Date* | 十年前 |
| max-date | 可选的最大时间,精确到分钟 | *Date* | 十年后 |
| min-hour | 可选的最小小时,针对 time 类型 | *number* | `0` |
| max-hour | 可选的最大小时,针对 time 类型 | *number* | `23` |
| min-minute | 可选的最小分钟,针对 time 类型 | *number* | `0` |
| max-minute | 可选的最大分钟,针对 time 类型 | *number* | `59` |
| filter | 选项过滤函数 | *(type, values) => values* | - |
| formatter | 选项格式化函数 | *(type, value) => value* | - |
| title | 顶部栏标题 | *string* | `''` |
| show-toolbar | 是否显示顶部栏 | *boolean* | `true` |
| loading | 是否显示加载状态 | *boolean* | `false` |
| item-height | 选项高度 | *number* | `44` |
| confirm-button-text | 确认按钮文字 | *string* | `确认` |
| cancel-button-text | 取消按钮文字 | *string* | `取消` |
| visible-item-count | 可见的选项个数 | *number* | `5` |
| swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | *number* | `1000` |
| show-toolbar | 是否显示顶部栏 | *boolean* | `true` |
| loading | 是否显示加载状态 | *boolean* | `false` |
| filter | 选项过滤函数 | *(type, vals) => vals* | - |
| formatter | 选项格式化函数 | *(type, val) => val* | - |
| item-height | 选项高度 | *number \| string* | `44` |
| visible-item-count | 可见的选项个数 | *number \| string* | `5` |
| swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | *number \| string* | `1000` |
### DatePicker Props
当时间选择器类型为 date 或 datetime 时,支持以下 props
| 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------|
| min-date | 可选的最小时间,精确到分钟 | *Date* | 十年前 |
| max-date | 可选的最大时间,精确到分钟 | *Date* | 十年后 |
### TimePicker Props
当时间选择器类型为 time 时,支持以下 props
| 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------|
| min-hour | 可选的最小小时 | *number \| string* | `0` |
| max-hour | 可选的最大小时 | *number \| string* | `23` |
| min-minute | 可选的最小分钟 | *number \| string* | `0` |
| max-minute | 可选的最大分钟 | *number \| string* | `59` |
### Events
| 事件名 | 说明 | 回调参数 |
|------|------|------|
| change | 当值变化时触发的事件 | picker 实例 |
| confirm | 点击完成按钮时触发的事件 | 当前 value |
| change | 当值变化时触发的事件 | picker: Picker 实例 |
| confirm | 点击完成按钮时触发的事件 | value: 当前选中的时间 |
| cancel | 点击取消按钮时触发的事件 | - |
### 方法

View File

@ -11,19 +11,19 @@ export default createComponent({
props: {
...sharedProps,
minHour: {
type: Number,
type: [Number, String],
default: 0,
},
maxHour: {
type: Number,
type: [Number, String],
default: 23,
},
minMinute: {
type: Number,
type: [Number, String],
default: 0,
},
maxMinute: {
type: Number,
type: [Number, String],
default: 59,
},
},
@ -33,11 +33,11 @@ export default createComponent({
return [
{
type: 'hour',
range: [this.minHour, this.maxHour],
range: [+this.minHour, +this.maxHour],
},
{
type: 'minute',
range: [this.minMinute, this.maxMinute],
range: [+this.minMinute, +this.maxMinute],
},
];
},