refector: 更新部分库
This commit is contained in:
parent
2fe064fe9c
commit
c0812efdda
|
@ -41,7 +41,8 @@ const store = new Vuex.Store({
|
||||||
vuex_login: 'http://qyjy.ctc-zc.com/h5/',
|
vuex_login: 'http://qyjy.ctc-zc.com/h5/',
|
||||||
vuex_version: '1.00.08',
|
vuex_version: '1.00.08',
|
||||||
vuex_host: 'http://222.222.144.147:6013',
|
vuex_host: 'http://222.222.144.147:6013',
|
||||||
vuex_api: 'http://222.222.144.147:6013/api',
|
// vuex_api: 'http://222.222.144.147:6013/api',
|
||||||
|
vuex_api: 'http://49.232.14.174:2226/api',
|
||||||
vuex_apifile: 'http://222.222.144.147:6013/api/file/',
|
vuex_apifile: 'http://222.222.144.147:6013/api/file/',
|
||||||
// vuex_api: 'http://127.0.0.1:8000/api',
|
// vuex_api: 'http://127.0.0.1:8000/api',
|
||||||
// vuex_host: 'http://10.99.5.79:20309',
|
// vuex_host: 'http://10.99.5.79:20309',
|
||||||
|
|
|
@ -1,31 +1,71 @@
|
||||||
|
## 2.2.22(2023-03-30)
|
||||||
|
- 修复 日历 picker 修改年月后,自动选中当月1日 [详情](https://ask.dcloud.net.cn/question/165937)
|
||||||
|
- 修复 小程序端 低版本 ios NaN [详情](https://ask.dcloud.net.cn/question/162979)
|
||||||
|
## 2.2.21(2023-02-20)
|
||||||
|
- 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362)
|
||||||
|
## 2.2.20(2023-02-17)
|
||||||
|
- 优化 值为空依然选中当天问题
|
||||||
|
- 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间
|
||||||
|
- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
|
||||||
|
- 优化 字节小程序日期时间范围选择,底部日期换行问题
|
||||||
|
## 2.2.19(2023-02-09)
|
||||||
|
- 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686)
|
||||||
|
## 2.2.18(2023-02-08)
|
||||||
|
- 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684)
|
||||||
|
- 优化 PC端输入日期格式错误时返回当前日期时间
|
||||||
|
- 优化 PC端输入日期时间超出 start、end 限制的Bug
|
||||||
|
- 优化 移动端日期时间范围用法时间展示不完整问题
|
||||||
|
## 2.2.17(2023-02-04)
|
||||||
|
- 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679)
|
||||||
|
- 修复 vue3 time-picker 无法显示绑定时分秒的Bug
|
||||||
|
## 2.2.16(2023-02-02)
|
||||||
|
- 修复 字节小程序报错的Bug
|
||||||
|
## 2.2.15(2023-02-02)
|
||||||
|
- 修复 某些情况切换月份错误的Bug
|
||||||
|
## 2.2.14(2023-01-30)
|
||||||
|
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033)
|
||||||
|
## 2.2.13(2023-01-10)
|
||||||
|
- 修复 多次加载组件造成内存占用的Bug
|
||||||
|
## 2.2.12(2022-12-01)
|
||||||
|
- 修复 vue3 下 i18n 国际化初始值不正确的Bug
|
||||||
|
## 2.2.11(2022-09-19)
|
||||||
|
- 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861)
|
||||||
|
## 2.2.10(2022-09-19)
|
||||||
|
- 修复 反向选择日期范围,日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
|
||||||
|
## 2.2.9(2022-09-16)
|
||||||
|
- 可以使用 uni-scss 控制主题色
|
||||||
|
## 2.2.8(2022-09-08)
|
||||||
|
- 修复 close事件无效的Bug
|
||||||
|
## 2.2.7(2022-09-05)
|
||||||
|
- 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824)
|
||||||
## 2.2.6(2022-06-30)
|
## 2.2.6(2022-06-30)
|
||||||
- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致
|
- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致
|
||||||
## 2.2.5(2022-06-24)
|
## 2.2.5(2022-06-24)
|
||||||
- 修复 日历顶部年月及底部确认未国际化 bug
|
- 修复 日历顶部年月及底部确认未国际化的Bug
|
||||||
## 2.2.4(2022-03-31)
|
## 2.2.4(2022-03-31)
|
||||||
- 修复 Vue3 下动态赋值,单选类型未响应的 bug
|
- 修复 Vue3 下动态赋值,单选类型未响应的Bug
|
||||||
## 2.2.3(2022-03-28)
|
## 2.2.3(2022-03-28)
|
||||||
- 修复 Vue3 下动态赋值未响应的 bug
|
- 修复 Vue3 下动态赋值未响应的Bug
|
||||||
## 2.2.2(2021-12-10)
|
## 2.2.2(2021-12-10)
|
||||||
- 修复 clear-icon 属性在小程序平台不生效的 bug
|
- 修复 clear-icon 属性在小程序平台不生效的Bug
|
||||||
## 2.2.1(2021-12-10)
|
## 2.2.1(2021-12-10)
|
||||||
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的 bug
|
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug
|
||||||
## 2.2.0(2021-11-19)
|
## 2.2.0(2021-11-19)
|
||||||
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
|
- 优化 组件UI,并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource)
|
||||||
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
|
- 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
|
||||||
## 2.1.5(2021-11-09)
|
## 2.1.5(2021-11-09)
|
||||||
- 新增 提供组件设计资源,组件样式调整
|
- 新增 提供组件设计资源,组件样式调整
|
||||||
## 2.1.4(2021-09-10)
|
## 2.1.4(2021-09-10)
|
||||||
- 修复 hide-second 在移动端的 bug
|
- 修复 hide-second 在移动端的Bug
|
||||||
- 修复 单选赋默认值时,赋值日期未高亮的 bug
|
- 修复 单选赋默认值时,赋值日期未高亮的Bug
|
||||||
- 修复 赋默认值时,移动端未正确显示时间的 bug
|
- 修复 赋默认值时,移动端未正确显示时间的Bug
|
||||||
## 2.1.3(2021-09-09)
|
## 2.1.3(2021-09-09)
|
||||||
- 新增 hide-second 属性,支持只使用时分,隐藏秒
|
- 新增 hide-second 属性,支持只使用时分,隐藏秒
|
||||||
## 2.1.2(2021-09-03)
|
## 2.1.2(2021-09-03)
|
||||||
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
|
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
|
||||||
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
|
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
|
||||||
- 优化 调整字号大小,美化日历界面
|
- 优化 调整字号大小,美化日历界面
|
||||||
- 修复 因国际化导致的 placeholder 失效的 bug
|
- 修复 因国际化导致的 placeholder 失效的Bug
|
||||||
## 2.1.1(2021-08-24)
|
## 2.1.1(2021-08-24)
|
||||||
- 新增 支持国际化
|
- 新增 支持国际化
|
||||||
- 优化 范围选择器在 pc 端过宽的问题
|
- 优化 范围选择器在 pc 端过宽的问题
|
||||||
|
@ -33,50 +73,50 @@
|
||||||
- 新增 适配 vue3
|
- 新增 适配 vue3
|
||||||
## 2.0.19(2021-08-09)
|
## 2.0.19(2021-08-09)
|
||||||
- 新增 支持作为 uni-forms 子组件相关功能
|
- 新增 支持作为 uni-forms 子组件相关功能
|
||||||
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的 bug
|
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug
|
||||||
## 2.0.18(2021-08-05)
|
## 2.0.18(2021-08-05)
|
||||||
- 修复 type 属性动态赋值无效的 bug
|
- 修复 type 属性动态赋值无效的Bug
|
||||||
- 修复 ‘确认’按钮被 tabbar 遮盖 bug
|
- 修复 ‘确认’按钮被 tabbar 遮盖 bug
|
||||||
- 修复 组件未赋值时范围选左、右日历相同的 bug
|
- 修复 组件未赋值时范围选左、右日历相同的Bug
|
||||||
## 2.0.17(2021-08-04)
|
## 2.0.17(2021-08-04)
|
||||||
- 修复 范围选未正确显示当前值的 bug
|
- 修复 范围选未正确显示当前值的Bug
|
||||||
- 修复 h5 平台(移动端)报错 'cale' of undefined 的 bug
|
- 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug
|
||||||
## 2.0.16(2021-07-21)
|
## 2.0.16(2021-07-21)
|
||||||
- 新增 return-type 属性支持返回 date 日期对象
|
- 新增 return-type 属性支持返回 date 日期对象
|
||||||
## 2.0.15(2021-07-14)
|
## 2.0.15(2021-07-14)
|
||||||
- 修复 单选日期类型,初始赋值后不在当前日历的 bug
|
- 修复 单选日期类型,初始赋值后不在当前日历的Bug
|
||||||
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
|
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
|
||||||
- 优化 移动端移除显示框的清空按钮,无实际用途
|
- 优化 移动端移除显示框的清空按钮,无实际用途
|
||||||
## 2.0.14(2021-07-14)
|
## 2.0.14(2021-07-14)
|
||||||
- 修复 组件赋值为空,界面未更新的 bug
|
- 修复 组件赋值为空,界面未更新的Bug
|
||||||
- 修复 start 和 end 不能动态赋值的 bug
|
- 修复 start 和 end 不能动态赋值的Bug
|
||||||
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的 bug
|
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug
|
||||||
## 2.0.13(2021-07-08)
|
## 2.0.13(2021-07-08)
|
||||||
- 修复 范围选择不能动态赋值的 bug
|
- 修复 范围选择不能动态赋值的Bug
|
||||||
## 2.0.12(2021-07-08)
|
## 2.0.12(2021-07-08)
|
||||||
- 修复 范围选择的初始时间在一个月内时,造成无法选择的bug
|
- 修复 范围选择的初始时间在一个月内时,造成无法选择的bug
|
||||||
## 2.0.11(2021-07-08)
|
## 2.0.11(2021-07-08)
|
||||||
- 优化 弹出层在超出视窗边缘定位不准确的问题
|
- 优化 弹出层在超出视窗边缘定位不准确的问题
|
||||||
## 2.0.10(2021-07-08)
|
## 2.0.10(2021-07-08)
|
||||||
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的 bug
|
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug
|
||||||
- 优化 弹出层在超出视窗边缘被遮盖的问题
|
- 优化 弹出层在超出视窗边缘被遮盖的问题
|
||||||
## 2.0.9(2021-07-07)
|
## 2.0.9(2021-07-07)
|
||||||
- 新增 maskClick 事件
|
- 新增 maskClick 事件
|
||||||
- 修复 特殊情况日历 rpx 布局错误的 bug,rpx -> px
|
- 修复 特殊情况日历 rpx 布局错误的Bug,rpx -> px
|
||||||
- 修复 范围选择时清空返回值不合理的bug,['', ''] -> []
|
- 修复 范围选择时清空返回值不合理的bug,['', ''] -> []
|
||||||
## 2.0.8(2021-07-07)
|
## 2.0.8(2021-07-07)
|
||||||
- 新增 日期时间显示框支持插槽
|
- 新增 日期时间显示框支持插槽
|
||||||
## 2.0.7(2021-07-01)
|
## 2.0.7(2021-07-01)
|
||||||
- 优化 添加 uni-icons 依赖
|
- 优化 添加 uni-icons 依赖
|
||||||
## 2.0.6(2021-05-22)
|
## 2.0.6(2021-05-22)
|
||||||
- 修复 图标在小程序上不显示的 bug
|
- 修复 图标在小程序上不显示的Bug
|
||||||
- 优化 重命名引用组件,避免潜在组件命名冲突
|
- 优化 重命名引用组件,避免潜在组件命名冲突
|
||||||
## 2.0.5(2021-05-20)
|
## 2.0.5(2021-05-20)
|
||||||
- 优化 代码目录扁平化
|
- 优化 代码目录扁平化
|
||||||
## 2.0.4(2021-05-12)
|
## 2.0.4(2021-05-12)
|
||||||
- 新增 组件示例地址
|
- 新增 组件示例地址
|
||||||
## 2.0.3(2021-05-10)
|
## 2.0.3(2021-05-10)
|
||||||
- 修复 ios 下不识别 '-' 日期格式的 bug
|
- 修复 ios 下不识别 '-' 日期格式的Bug
|
||||||
- 优化 pc 下弹出层添加边框和阴影
|
- 优化 pc 下弹出层添加边框和阴影
|
||||||
## 2.0.2(2021-05-08)
|
## 2.0.2(2021-05-08)
|
||||||
- 修复 在 admin 中获取弹出层定位错误的bug
|
- 修复 在 admin 中获取弹出层定位错误的bug
|
||||||
|
@ -87,7 +127,7 @@
|
||||||
> 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)
|
> 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)
|
||||||
## 1.0.6(2021-03-18)
|
## 1.0.6(2021-03-18)
|
||||||
- 新增 hide-second 属性,时间支持仅选择时、分
|
- 新增 hide-second 属性,时间支持仅选择时、分
|
||||||
- 修复 选择跟显示的日期不一样的 bug
|
- 修复 选择跟显示的日期不一样的Bug
|
||||||
- 修复 chang事件触发2次的 bug
|
- 修复 chang事件触发2次的Bug
|
||||||
- 修复 分、秒 end 范围错误的 bug
|
- 修复 分、秒 end 范围错误的Bug
|
||||||
- 优化 更好的 nvue 适配
|
- 优化 更好的 nvue 适配
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
|
<text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
|
||||||
<text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
|
<text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view>
|
<view :class="{'uni-calendar-item--today': weeks.isToday}"></view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -41,10 +41,6 @@
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lunar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
checkHover: {
|
checkHover: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
@ -62,6 +58,8 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" >
|
<style lang="scss" >
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
.uni-calendar-item__weeks-box {
|
.uni-calendar-item__weeks-box {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
|
@ -78,12 +76,7 @@
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
// font-family: Lato-Bold, Lato;
|
// font-family: Lato-Bold, Lato;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #455997;
|
color: darken($color: $uni-primary, $amount: 40%);
|
||||||
}
|
|
||||||
|
|
||||||
.uni-calendar-item__weeks-lunar-text {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #333;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-calendar-item__weeks-box-item {
|
.uni-calendar-item__weeks-box-item {
|
||||||
|
@ -114,7 +107,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-calendar-item__weeks-box .uni-calendar-item--disable {
|
.uni-calendar-item__weeks-box .uni-calendar-item--disable {
|
||||||
// background-color: rgba(249, 249, 249, $uni-opacity-disabled);
|
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +114,7 @@
|
||||||
color: #D1D1D1;
|
color: #D1D1D1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-calendar-item--isDay {
|
.uni-calendar-item--today {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
right: 17%;
|
right: 17%;
|
||||||
|
@ -138,7 +130,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-calendar-item__weeks-box .uni-calendar-item--checked {
|
.uni-calendar-item__weeks-box .uni-calendar-item--checked {
|
||||||
background-color: #007aff;
|
background-color: $uni-primary;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 3px solid #fff;
|
border: 3px solid #fff;
|
||||||
|
@ -159,7 +151,7 @@
|
||||||
|
|
||||||
.uni-calendar-item--multiple .uni-calendar-item--before-checked,
|
.uni-calendar-item--multiple .uni-calendar-item--before-checked,
|
||||||
.uni-calendar-item--multiple .uni-calendar-item--after-checked {
|
.uni-calendar-item--multiple .uni-calendar-item--after-checked {
|
||||||
background-color: #409eff;
|
background-color: $uni-primary;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 3px solid #F6F7FC;
|
border: 3px solid #F6F7FC;
|
||||||
|
|
|
@ -1,31 +1,37 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="uni-calendar" @mouseleave="leaveCale">
|
<view class="uni-calendar" @mouseleave="leaveCale">
|
||||||
|
|
||||||
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
||||||
@click="clean"></view>
|
@click="maskClick"></view>
|
||||||
|
|
||||||
<view v-if="insert || show" class="uni-calendar__content"
|
<view v-if="insert || show" class="uni-calendar__content"
|
||||||
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
|
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
|
||||||
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
|
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
|
||||||
<view v-if="left" class="uni-calendar__header-btn-box" @click.stop="pre">
|
|
||||||
|
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
|
||||||
<view class="uni-calendar__header-btn uni-calendar--left"></view>
|
<view class="uni-calendar__header-btn uni-calendar--left"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
||||||
<text
|
<text
|
||||||
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
|
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
|
||||||
</picker>
|
</picker>
|
||||||
<view v-if="right" class="uni-calendar__header-btn-box" @click.stop="next">
|
|
||||||
|
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
|
||||||
<view class="uni-calendar__header-btn uni-calendar--right"></view>
|
<view class="uni-calendar__header-btn uni-calendar--right"></view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="!insert" class="dialog-close" @click="clean">
|
|
||||||
|
<view v-if="!insert" class="dialog-close" @click="close">
|
||||||
<view class="dialog-close-plus" data-id="close"></view>
|
<view class="dialog-close-plus" data-id="close"></view>
|
||||||
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
|
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <text class="uni-calendar__backtoday" @click="backtoday">回到今天</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
<view class="uni-calendar__box">
|
<view class="uni-calendar__box">
|
||||||
|
|
||||||
<view v-if="showMonth" class="uni-calendar__box-bg">
|
<view v-if="showMonth" class="uni-calendar__box-bg">
|
||||||
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
|
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="uni-calendar__weeks" style="padding-bottom: 7px;">
|
<view class="uni-calendar__weeks" style="padding-bottom: 7px;">
|
||||||
<view class="uni-calendar__weeks-day">
|
<view class="uni-calendar__weeks-day">
|
||||||
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
|
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
|
||||||
|
@ -49,43 +55,45 @@
|
||||||
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
|
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
|
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
|
||||||
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
|
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
|
||||||
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
|
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
|
||||||
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate"
|
:selected="selected" :checkHover="range" @change="choiceDate"
|
||||||
@handleMouse="handleMouse">
|
@handleMouse="handleMouse">
|
||||||
</calendar-item>
|
</calendar-item>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="!insert && !range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"
|
|
||||||
|
<view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
|
||||||
style="padding: 0 80px;">
|
style="padding: 0 80px;">
|
||||||
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
|
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
|
||||||
<time-picker type="time" :start="reactStartTime" :end="reactEndTime" v-model="time"
|
<time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
|
||||||
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
|
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
|
||||||
</time-picker>
|
</time-picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="!insert && range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top">
|
<view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
|
||||||
<view class="uni-date-changed--time-start">
|
<view class="uni-date-changed--time-start">
|
||||||
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
|
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
|
||||||
</view>
|
</view>
|
||||||
<time-picker type="time" :start="reactStartTime" v-model="timeRange.startTime" :border="false"
|
<time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
|
||||||
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
|
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
|
||||||
</time-picker>
|
</time-picker>
|
||||||
</view>
|
</view>
|
||||||
<uni-icons type="arrowthinright" color="#999" style="line-height: 50px;"></uni-icons>
|
<view style="line-height: 50px;">
|
||||||
|
<uni-icons type="arrowthinright" color="#999"></uni-icons>
|
||||||
|
</view>
|
||||||
<view class="uni-date-changed--time-end">
|
<view class="uni-date-changed--time-end">
|
||||||
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
|
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
|
||||||
<time-picker type="time" :end="reactEndTime" v-model="timeRange.endTime" :border="false"
|
<time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
|
||||||
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
|
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
|
||||||
</time-picker>
|
</time-picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
|
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
|
||||||
<!-- <view class="uni-calendar__header-btn-box">
|
|
||||||
<text class="uni-calendar__button-text uni-calendar--fixed-width">{{okText}}</text>
|
|
||||||
</view> -->
|
|
||||||
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
|
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -93,22 +101,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Calendar from './util.js';
|
import { Calendar, getDate, getTime } from './util.js';
|
||||||
import calendarItem from './calendar-item.vue'
|
import calendarItem from './calendar-item.vue'
|
||||||
import timePicker from './time-picker.vue'
|
import timePicker from './time-picker.vue'
|
||||||
import {
|
|
||||||
initVueI18n
|
import { initVueI18n } from '@dcloudio/uni-i18n'
|
||||||
} from '@dcloudio/uni-i18n'
|
import i18nMessages from './i18n/index.js'
|
||||||
import messages from './i18n/index.js'
|
const { t } = initVueI18n(i18nMessages)
|
||||||
const {
|
|
||||||
t
|
|
||||||
} = initVueI18n(messages)
|
|
||||||
/**
|
/**
|
||||||
* Calendar 日历
|
* Calendar 日历
|
||||||
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
|
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
|
||||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
||||||
* @property {String} date 自定义当前时间,默认为今天
|
* @property {String} date 自定义当前时间,默认为今天
|
||||||
* @property {Boolean} lunar 显示农历
|
|
||||||
* @property {String} startDate 日期选择范围-开始日期
|
* @property {String} startDate 日期选择范围-开始日期
|
||||||
* @property {String} endDate 日期选择范围-结束日期
|
* @property {String} endDate 日期选择范围-结束日期
|
||||||
* @property {Boolean} range 范围选择
|
* @property {Boolean} range 范围选择
|
||||||
|
@ -118,10 +123,11 @@
|
||||||
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
|
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
|
||||||
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
|
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
|
||||||
* @property {Boolean} showMonth 是否选择月份为背景
|
* @property {Boolean} showMonth 是否选择月份为背景
|
||||||
|
* @property {[String} defaultValue 选择器打开时默认显示的时间
|
||||||
* @event {Function} change 日期改变,`insert :ture` 时生效
|
* @event {Function} change 日期改变,`insert :ture` 时生效
|
||||||
* @event {Function} confirm 确认选择`insert :false` 时生效
|
* @event {Function} confirm 确认选择`insert :false` 时生效
|
||||||
* @event {Function} monthSwitch 切换月份时触发
|
* @event {Function} monthSwitch 切换月份时触发
|
||||||
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
* @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -149,10 +155,6 @@
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lunar: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
startDate: {
|
startDate: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
@ -161,11 +163,19 @@
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
|
startPlaceholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
endPlaceholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
range: {
|
range: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
typeHasTime: {
|
hasTime: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
@ -181,14 +191,6 @@
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
left: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
right: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
checkHover: {
|
checkHover: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
@ -207,6 +209,10 @@
|
||||||
fulldate: ''
|
fulldate: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
defaultValue: {
|
||||||
|
type: [String, Object, Array],
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -214,7 +220,7 @@
|
||||||
show: false,
|
show: false,
|
||||||
weeks: [],
|
weeks: [],
|
||||||
calendar: {},
|
calendar: {},
|
||||||
nowDate: '',
|
nowDate: {},
|
||||||
aniMaskShow: false,
|
aniMaskShow: false,
|
||||||
firstEnter: true,
|
firstEnter: true,
|
||||||
time: '',
|
time: '',
|
||||||
|
@ -232,7 +238,7 @@
|
||||||
watch: {
|
watch: {
|
||||||
date: {
|
date: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(newVal, oldVal) {
|
handler(newVal) {
|
||||||
if (!this.range) {
|
if (!this.range) {
|
||||||
this.tempSingleDate = newVal
|
this.tempSingleDate = newVal
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -243,33 +249,44 @@
|
||||||
},
|
},
|
||||||
defTime: {
|
defTime: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(newVal, oldVal) {
|
handler(newVal) {
|
||||||
if (!this.range) {
|
if (!this.range) {
|
||||||
this.time = newVal
|
this.time = newVal
|
||||||
} else {
|
} else {
|
||||||
// console.log('-----', newVal);
|
|
||||||
this.timeRange.startTime = newVal.start
|
this.timeRange.startTime = newVal.start
|
||||||
this.timeRange.endTime = newVal.end
|
this.timeRange.endTime = newVal.end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startDate(val) {
|
startDate(val) {
|
||||||
this.cale.resetSatrtDate(val)
|
// 字节小程序 watch 早于 created
|
||||||
|
if(!this.cale){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setStartDate(val)
|
||||||
this.cale.setDate(this.nowDate.fullDate)
|
this.cale.setDate(this.nowDate.fullDate)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
},
|
},
|
||||||
endDate(val) {
|
endDate(val) {
|
||||||
this.cale.resetEndDate(val)
|
// 字节小程序 watch 早于 created
|
||||||
|
if(!this.cale){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setEndDate(val)
|
||||||
this.cale.setDate(this.nowDate.fullDate)
|
this.cale.setDate(this.nowDate.fullDate)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
},
|
},
|
||||||
selected(newVal) {
|
selected(newVal) {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if(!this.cale){
|
||||||
|
return
|
||||||
|
}
|
||||||
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
|
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
},
|
},
|
||||||
pleStatus: {
|
pleStatus: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(newVal, oldVal) {
|
handler(newVal) {
|
||||||
const {
|
const {
|
||||||
before,
|
before,
|
||||||
after,
|
after,
|
||||||
|
@ -292,11 +309,16 @@
|
||||||
this.cale.lastHover = false
|
this.cale.lastHover = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if(!this.cale){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.cale.setDefaultMultiple(before, after)
|
this.cale.setDefaultMultiple(before, after)
|
||||||
if (which === 'left') {
|
if (which === 'left' && before) {
|
||||||
this.setDate(before)
|
this.setDate(before)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
} else {
|
} else if(after) {
|
||||||
this.setDate(after)
|
this.setDate(after)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
}
|
}
|
||||||
|
@ -307,15 +329,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
reactStartTime() {
|
timepickerStartTime() {
|
||||||
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
|
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
|
||||||
const res = activeDate === this.startDate ? this.selectableTimes.start : ''
|
return activeDate === this.startDate ? this.selectableTimes.start : ''
|
||||||
return res
|
|
||||||
},
|
},
|
||||||
reactEndTime() {
|
timepickerEndTime() {
|
||||||
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
|
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
|
||||||
const res = activeDate === this.endDate ? this.selectableTimes.end : ''
|
return activeDate === this.endDate ? this.selectableTimes.end : ''
|
||||||
return res
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* for i18n
|
* for i18n
|
||||||
|
@ -366,17 +386,13 @@
|
||||||
created() {
|
created() {
|
||||||
// 获取日历方法实例
|
// 获取日历方法实例
|
||||||
this.cale = new Calendar({
|
this.cale = new Calendar({
|
||||||
// date: new Date(),
|
|
||||||
selected: this.selected,
|
selected: this.selected,
|
||||||
startDate: this.startDate,
|
startDate: this.startDate,
|
||||||
endDate: this.endDate,
|
endDate: this.endDate,
|
||||||
range: this.range,
|
range: this.range,
|
||||||
// multipleStatus: this.pleStatus
|
|
||||||
})
|
})
|
||||||
// 选中某一天
|
// 选中某一天
|
||||||
// this.cale.setDate(this.date)
|
|
||||||
this.init(this.date)
|
this.init(this.date)
|
||||||
// this.setDay
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
leaveCale() {
|
leaveCale() {
|
||||||
|
@ -405,10 +421,10 @@
|
||||||
const [yearB, monthB] = B.split('-')
|
const [yearB, monthB] = B.split('-')
|
||||||
return yearA === yearB && monthA === monthB
|
return yearA === yearB && monthA === monthB
|
||||||
},
|
},
|
||||||
|
// 蒙版点击事件
|
||||||
// 取消穿透
|
maskClick() {
|
||||||
clean() {
|
|
||||||
this.close()
|
this.close()
|
||||||
|
this.$emit('maskClose')
|
||||||
},
|
},
|
||||||
|
|
||||||
clearCalender() {
|
clearCalender() {
|
||||||
|
@ -426,33 +442,49 @@
|
||||||
this.tempSingleDate = ''
|
this.tempSingleDate = ''
|
||||||
}
|
}
|
||||||
this.calendar.fullDate = ''
|
this.calendar.fullDate = ''
|
||||||
this.setDate()
|
this.setDate(new Date())
|
||||||
},
|
},
|
||||||
|
|
||||||
bindDateChange(e) {
|
bindDateChange(e) {
|
||||||
const value = e.detail.value + '-1'
|
const value = e.detail.value + '-1'
|
||||||
this.init(value)
|
this.setDate(value)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 初始化日期显示
|
* 初始化日期显示
|
||||||
* @param {Object} date
|
* @param {Object} date
|
||||||
*/
|
*/
|
||||||
init(date) {
|
init(date) {
|
||||||
this.cale.setDate(date)
|
// 字节小程序 watch 早于 created
|
||||||
|
if(!this.cale){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setDate(date || new Date())
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
this.nowDate = this.calendar = this.cale.getInfo(date)
|
this.nowDate = this.cale.getInfo(date)
|
||||||
|
this.calendar = {...this.nowDate}
|
||||||
|
if(!date){
|
||||||
|
// 优化date为空默认不选中今天
|
||||||
|
this.calendar.fullDate = ''
|
||||||
|
if(this.defaultValue && !this.range){
|
||||||
|
// 暂时只支持移动端非范围选择
|
||||||
|
const defaultDate = new Date(this.defaultValue)
|
||||||
|
const fullDate = getDate(defaultDate)
|
||||||
|
const year = defaultDate.getFullYear()
|
||||||
|
const month = defaultDate.getMonth()+1
|
||||||
|
const date = defaultDate.getDate()
|
||||||
|
const day = defaultDate.getDay()
|
||||||
|
this.calendar = {
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
day
|
||||||
|
},
|
||||||
|
this.tempSingleDate = fullDate
|
||||||
|
this.time = getTime(defaultDate, this.hideSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// choiceDate(weeks) {
|
|
||||||
// if (weeks.disable) return
|
|
||||||
// this.calendar = weeks
|
|
||||||
// // 设置多选
|
|
||||||
// this.cale.setMultiple(this.calendar.fullDate, true)
|
|
||||||
// this.weeks = this.cale.weeks
|
|
||||||
// this.tempSingleDate = this.calendar.fullDate
|
|
||||||
// this.tempRange.before = this.cale.multipleStatus.before
|
|
||||||
// this.tempRange.after = this.cale.multipleStatus.after
|
|
||||||
// this.change()
|
|
||||||
// },
|
|
||||||
/**
|
/**
|
||||||
* 打开日历弹窗
|
* 打开日历弹窗
|
||||||
*/
|
*/
|
||||||
|
@ -460,7 +492,6 @@
|
||||||
// 弹窗模式并且清理数据
|
// 弹窗模式并且清理数据
|
||||||
if (this.clearDate && !this.insert) {
|
if (this.clearDate && !this.insert) {
|
||||||
this.cale.cleanMultipleStatus()
|
this.cale.cleanMultipleStatus()
|
||||||
// this.cale.setDate(this.date)
|
|
||||||
this.init(this.date)
|
this.init(this.date)
|
||||||
}
|
}
|
||||||
this.show = true
|
this.show = true
|
||||||
|
@ -514,12 +545,20 @@
|
||||||
* @param {Object} name
|
* @param {Object} name
|
||||||
*/
|
*/
|
||||||
setEmit(name) {
|
setEmit(name) {
|
||||||
|
if(!this.range){
|
||||||
|
if(!this.calendar.fullDate){
|
||||||
|
this.calendar = this.cale.getInfo(new Date())
|
||||||
|
this.tempSingleDate = this.calendar.fullDate
|
||||||
|
}
|
||||||
|
if(this.hasTime && !this.time) {
|
||||||
|
this.time = getTime(new Date(), this.hideSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
let {
|
let {
|
||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
date,
|
date,
|
||||||
fullDate,
|
fullDate,
|
||||||
lunar,
|
|
||||||
extraInfo
|
extraInfo
|
||||||
} = this.calendar
|
} = this.calendar
|
||||||
this.$emit(name, {
|
this.$emit(name, {
|
||||||
|
@ -530,7 +569,6 @@
|
||||||
time: this.time,
|
time: this.time,
|
||||||
timeRange: this.timeRange,
|
timeRange: this.timeRange,
|
||||||
fulldate: fullDate,
|
fulldate: fullDate,
|
||||||
lunar,
|
|
||||||
extraInfo: extraInfo || {}
|
extraInfo: extraInfo || {}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -546,48 +584,26 @@
|
||||||
this.cale.setMultiple(this.calendar.fullDate, true)
|
this.cale.setMultiple(this.calendar.fullDate, true)
|
||||||
this.weeks = this.cale.weeks
|
this.weeks = this.cale.weeks
|
||||||
this.tempSingleDate = this.calendar.fullDate
|
this.tempSingleDate = this.calendar.fullDate
|
||||||
|
const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
|
||||||
|
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
|
||||||
|
if (beforeDate > afterDate && afterDate) {
|
||||||
|
this.tempRange.before = this.cale.multipleStatus.after
|
||||||
|
this.tempRange.after = this.cale.multipleStatus.before
|
||||||
|
} else {
|
||||||
this.tempRange.before = this.cale.multipleStatus.before
|
this.tempRange.before = this.cale.multipleStatus.before
|
||||||
this.tempRange.after = this.cale.multipleStatus.after
|
this.tempRange.after = this.cale.multipleStatus.after
|
||||||
this.change()
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 回到今天
|
|
||||||
*/
|
|
||||||
backtoday() {
|
|
||||||
let date = this.cale.getDate(new Date()).fullDate
|
|
||||||
// this.cale.setDate(date)
|
|
||||||
this.init(date)
|
|
||||||
this.change()
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 比较时间大小
|
|
||||||
*/
|
|
||||||
dateCompare(startDate, endDate) {
|
|
||||||
// 计算截止时间
|
|
||||||
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
|
|
||||||
// 计算详细项的截止时间
|
|
||||||
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
|
|
||||||
if (startDate <= endDate) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
this.change()
|
||||||
},
|
},
|
||||||
/**
|
changeMonth(type) {
|
||||||
* 上个月
|
let newDate
|
||||||
*/
|
if(type === 'pre') {
|
||||||
pre() {
|
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
|
||||||
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
|
} else if(type === 'next') {
|
||||||
this.setDate(preDate)
|
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
|
||||||
this.monthSwitch()
|
}
|
||||||
|
|
||||||
},
|
this.setDate(newDate)
|
||||||
/**
|
|
||||||
* 下个月
|
|
||||||
*/
|
|
||||||
next() {
|
|
||||||
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
|
|
||||||
this.setDate(nextDate)
|
|
||||||
this.monthSwitch()
|
this.monthSwitch()
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -604,6 +620,8 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" >
|
<style lang="scss" >
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
.uni-calendar {
|
.uni-calendar {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -714,7 +732,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #007aff;
|
color: $uni-primary;
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
letter-spacing: 3px;
|
letter-spacing: 3px;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
@ -845,6 +863,9 @@
|
||||||
.uni-date-changed--time-date {
|
.uni-date-changed--time-date {
|
||||||
color: #999;
|
color: #999;
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
|
/* #ifdef MP-TOUTIAO */
|
||||||
|
font-size: 16px;
|
||||||
|
/* #endif */
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
// opacity: 0.6;
|
// opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
@ -893,7 +914,7 @@
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
background-color: #007aff;
|
background-color: $uni-primary;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
letter-spacing: 2px;
|
letter-spacing: 2px;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"uni-datetime-picker.selectDate": "select date",
|
"uni-datetime-picker.selectDate": "select date",
|
||||||
"uni-datetime-picker.selectTime": "select time",
|
"uni-datetime-picker.selectTime": "select time",
|
||||||
"uni-datetime-picker.selectDateTime": "select datetime",
|
"uni-datetime-picker.selectDateTime": "select date and time",
|
||||||
"uni-datetime-picker.startDate": "start date",
|
"uni-datetime-picker.startDate": "start date",
|
||||||
"uni-datetime-picker.endDate": "end date",
|
"uni-datetime-picker.endDate": "end date",
|
||||||
"uni-datetime-picker.startTime": "start time",
|
"uni-datetime-picker.startTime": "start time",
|
||||||
|
|
|
@ -77,21 +77,14 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #ifdef H5 -->
|
|
||||||
<!-- <keypress v-if="visible" @esc="tiggerTimePicker" @enter="setTime" /> -->
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// #ifdef H5
|
import { initVueI18n } from '@dcloudio/uni-i18n'
|
||||||
import keypress from './keypress'
|
import i18nMessages from './i18n/index.js'
|
||||||
// #endif
|
const { t } = initVueI18n(i18nMessages)
|
||||||
import {
|
import { fixIosDateFormat } from './util'
|
||||||
initVueI18n
|
|
||||||
} from '@dcloudio/uni-i18n'
|
|
||||||
import messages from './i18n/index.js'
|
|
||||||
const { t } = initVueI18n(messages)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatetimePicker 时间选择器
|
* DatetimePicker 时间选择器
|
||||||
|
@ -108,11 +101,6 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UniDatetimePicker',
|
name: 'UniDatetimePicker',
|
||||||
components: {
|
|
||||||
// #ifdef H5
|
|
||||||
keypress
|
|
||||||
// #endif
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
indicatorStyle: `height: 50px;`,
|
indicatorStyle: `height: 50px;`,
|
||||||
|
@ -185,10 +173,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
// #ifndef VUE3
|
||||||
value: {
|
value: {
|
||||||
handler(newVal, oldVal) {
|
handler(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this.parseValue(this.fixIosDateFormat(newVal)) //兼容 iOS、safari 日期格式
|
this.parseValue(fixIosDateFormat(newVal))
|
||||||
this.initTime(false)
|
this.initTime(false)
|
||||||
} else {
|
} else {
|
||||||
this.time = ''
|
this.time = ''
|
||||||
|
@ -197,6 +186,21 @@
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.parseValue(fixIosDateFormat(newVal))
|
||||||
|
this.initTime(false)
|
||||||
|
} else {
|
||||||
|
this.time = ''
|
||||||
|
this.parseValue(Date.now())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
type: {
|
type: {
|
||||||
handler(newValue) {
|
handler(newValue) {
|
||||||
if (newValue === 'date') {
|
if (newValue === 'date') {
|
||||||
|
@ -217,13 +221,13 @@
|
||||||
},
|
},
|
||||||
start: {
|
start: {
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'start') //兼容 iOS、safari 日期格式
|
this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') //兼容 iOS、safari 日期格式
|
this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
|
@ -527,7 +531,7 @@
|
||||||
const day = now.getDate()
|
const day = now.getDate()
|
||||||
dateBase = year + '/' + month + '/' + day + ' '
|
dateBase = year + '/' + month + '/' + day + ' '
|
||||||
}
|
}
|
||||||
if (Number(value) && typeof value !== NaN) {
|
if (Number(value)) {
|
||||||
value = parseInt(value)
|
value = parseInt(value)
|
||||||
dateBase = 0
|
dateBase = 0
|
||||||
}
|
}
|
||||||
|
@ -598,7 +602,7 @@
|
||||||
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
|
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (Number(point) && Number(point) !== NaN) {
|
if (Number(point)) {
|
||||||
point = parseInt(point)
|
point = parseInt(point)
|
||||||
}
|
}
|
||||||
// datetime 的 end 没有时分秒, 则不限制
|
// datetime 的 end 没有时分秒, 则不限制
|
||||||
|
@ -736,7 +740,7 @@
|
||||||
*/
|
*/
|
||||||
initTimePicker() {
|
initTimePicker() {
|
||||||
if (this.disabled) return
|
if (this.disabled) return
|
||||||
const value = this.fixIosDateFormat(this.value)
|
const value = fixIosDateFormat(this.time)
|
||||||
this.initPickerValue(value)
|
this.initPickerValue(value)
|
||||||
this.visible = !this.visible
|
this.visible = !this.visible
|
||||||
},
|
},
|
||||||
|
@ -770,7 +774,9 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
.uni-datetime-picker {
|
.uni-datetime-picker {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
/* width: 100%; */
|
/* width: 100%; */
|
||||||
|
@ -804,7 +810,7 @@
|
||||||
|
|
||||||
.uni-datetime-picker-btn-text {
|
.uni-datetime-picker-btn-text {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #007AFF;
|
color: $uni-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-datetime-picker-btn-group {
|
.uni-datetime-picker-btn-group {
|
||||||
|
@ -889,6 +895,7 @@
|
||||||
|
|
||||||
.uni-datetime-picker-text {
|
.uni-datetime-picker-text {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
line-height: 50px
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-datetime-picker-sign {
|
.uni-datetime-picker-sign {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,27 +1,24 @@
|
||||||
class Calendar {
|
class Calendar {
|
||||||
constructor({
|
constructor({
|
||||||
date,
|
|
||||||
selected,
|
selected,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
range,
|
range,
|
||||||
// multipleStatus
|
|
||||||
} = {}) {
|
} = {}) {
|
||||||
// 当前日期
|
// 当前日期
|
||||||
this.date = this.getDate(new Date()) // 当前初入日期
|
this.date = this.getDateObj(new Date()) // 当前初入日期
|
||||||
// 打点信息
|
// 打点信息
|
||||||
this.selected = selected || [];
|
this.selected = selected || [];
|
||||||
// 范围开始
|
// 起始时间
|
||||||
this.startDate = startDate
|
this.startDate = startDate
|
||||||
// 范围结束
|
// 终止时间
|
||||||
this.endDate = endDate
|
this.endDate = endDate
|
||||||
|
// 是否范围选择
|
||||||
this.range = range
|
this.range = range
|
||||||
// 多选状态
|
// 多选状态
|
||||||
this.cleanMultipleStatus()
|
this.cleanMultipleStatus()
|
||||||
// 每周日期
|
// 每周日期
|
||||||
this.weeks = {}
|
this.weeks = {}
|
||||||
// this._getWeek(this.date.fullDate)
|
|
||||||
// this.multipleStatus = multipleStatus
|
|
||||||
this.lastHover = false
|
this.lastHover = false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +26,8 @@ class Calendar {
|
||||||
* @param {Object} date
|
* @param {Object} date
|
||||||
*/
|
*/
|
||||||
setDate(date) {
|
setDate(date) {
|
||||||
this.selectDate = this.getDate(date)
|
const selectDate = this.getDateObj(date)
|
||||||
this._getWeek(this.selectDate.fullDate)
|
this.getWeeks(selectDate.fullDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,93 +41,82 @@ class Calendar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
setStartDate(startDate) {
|
||||||
* 重置开始日期
|
|
||||||
*/
|
|
||||||
resetSatrtDate(startDate) {
|
|
||||||
// 范围开始
|
|
||||||
this.startDate = startDate
|
this.startDate = startDate
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
setEndDate(endDate) {
|
||||||
* 重置结束日期
|
|
||||||
*/
|
|
||||||
resetEndDate(endDate) {
|
|
||||||
// 范围结束
|
|
||||||
this.endDate = endDate
|
this.endDate = endDate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPreMonthObj(date){
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
|
||||||
|
const oldMonth = date.getMonth()
|
||||||
|
date.setMonth(oldMonth - 1)
|
||||||
|
const newMonth = date.getMonth()
|
||||||
|
if(oldMonth !== 0 && newMonth - oldMonth === 0){
|
||||||
|
date.setMonth(newMonth - 1)
|
||||||
|
}
|
||||||
|
return this.getDateObj(date)
|
||||||
|
}
|
||||||
|
getNextMonthObj(date){
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
|
||||||
|
const oldMonth = date.getMonth()
|
||||||
|
date.setMonth(oldMonth + 1)
|
||||||
|
const newMonth = date.getMonth()
|
||||||
|
if(newMonth - oldMonth > 1){
|
||||||
|
date.setMonth(newMonth - 1)
|
||||||
|
}
|
||||||
|
return this.getDateObj(date)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任意时间
|
* 获取指定格式Date对象
|
||||||
*/
|
*/
|
||||||
getDate(date, AddDayCount = 0, str = 'day') {
|
getDateObj(date) {
|
||||||
if (!date) {
|
date = fixIosDateFormat(date)
|
||||||
date = new Date()
|
date = new Date(date)
|
||||||
}
|
|
||||||
if (typeof date !== 'object') {
|
|
||||||
date = date.replace(/-/g, '/')
|
|
||||||
}
|
|
||||||
const dd = new Date(date)
|
|
||||||
switch (str) {
|
|
||||||
case 'day':
|
|
||||||
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
|
|
||||||
break
|
|
||||||
case 'month':
|
|
||||||
if (dd.getDate() === 31) {
|
|
||||||
dd.setDate(dd.getDate() + AddDayCount)
|
|
||||||
} else {
|
|
||||||
dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'year':
|
|
||||||
dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const y = dd.getFullYear()
|
|
||||||
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
|
|
||||||
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
|
|
||||||
return {
|
return {
|
||||||
fullDate: y + '-' + m + '-' + d,
|
fullDate: getDate(date),
|
||||||
year: y,
|
year: date.getFullYear(),
|
||||||
month: m,
|
month: addZero(date.getMonth() + 1),
|
||||||
date: d,
|
date: addZero(date.getDate()),
|
||||||
day: dd.getDay()
|
day: date.getDay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取上月剩余天数
|
* 获取上一个月日期集合
|
||||||
*/
|
*/
|
||||||
_getLastMonthDays(firstDay, full) {
|
getPreMonthDays(amount, dateObj) {
|
||||||
let dateArr = []
|
const result = []
|
||||||
for (let i = firstDay; i > 0; i--) {
|
for (let i = amount - 1; i >= 0; i--) {
|
||||||
const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
|
const month = dateObj.month - 1
|
||||||
dateArr.push({
|
result.push({
|
||||||
date: beforeDate,
|
date: new Date(dateObj.year, month, -i).getDate(),
|
||||||
month: full.month - 1,
|
month,
|
||||||
disable: true
|
disable: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return dateArr
|
return result
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取本月天数
|
* 获取本月日期集合
|
||||||
*/
|
*/
|
||||||
_currentMonthDys(dateData, full) {
|
getCurrentMonthDays(amount, dateObj) {
|
||||||
let dateArr = []
|
const result = []
|
||||||
let fullDate = this.date.fullDate
|
const fullDate = this.date.fullDate
|
||||||
for (let i = 1; i <= dateData; i++) {
|
for (let i = 1; i <= amount; i++) {
|
||||||
let isinfo = false
|
const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
|
||||||
let nowDate = full.year + '-' + (full.month < 10 ?
|
const isToday = fullDate === currentDate
|
||||||
full.month : full.month) + '-' + (i < 10 ?
|
|
||||||
'0' + i : i)
|
|
||||||
// 是否今天
|
|
||||||
let isDay = fullDate === nowDate
|
|
||||||
// 获取打点信息
|
// 获取打点信息
|
||||||
let info = this.selected && this.selected.find((item) => {
|
const info = this.selected && this.selected.find((item) => {
|
||||||
if (this.dateEqual(nowDate, item.date)) {
|
if (this.dateEqual(currentDate, item.date)) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -139,62 +125,52 @@ class Calendar {
|
||||||
let disableBefore = true
|
let disableBefore = true
|
||||||
let disableAfter = true
|
let disableAfter = true
|
||||||
if (this.startDate) {
|
if (this.startDate) {
|
||||||
// let dateCompBefore = this.dateCompare(this.startDate, fullDate)
|
disableBefore = dateCompare(this.startDate, currentDate)
|
||||||
// disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
|
|
||||||
disableBefore = this.dateCompare(this.startDate, nowDate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.endDate) {
|
if (this.endDate) {
|
||||||
// let dateCompAfter = this.dateCompare(fullDate, this.endDate)
|
disableAfter = dateCompare(currentDate, this.endDate)
|
||||||
// disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
|
|
||||||
disableAfter = this.dateCompare(nowDate, this.endDate)
|
|
||||||
}
|
|
||||||
let multiples = this.multipleStatus.data
|
|
||||||
let checked = false
|
|
||||||
let multiplesStatus = -1
|
|
||||||
if (this.range) {
|
|
||||||
if (multiples) {
|
|
||||||
multiplesStatus = multiples.findIndex((item) => {
|
|
||||||
return this.dateEqual(item, nowDate)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (multiplesStatus !== -1) {
|
|
||||||
checked = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let data = {
|
|
||||||
fullDate: nowDate,
|
|
||||||
year: full.year,
|
|
||||||
date: i,
|
|
||||||
multiple: this.range ? checked : false,
|
|
||||||
beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after),
|
|
||||||
afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after),
|
|
||||||
month: full.month,
|
|
||||||
disable: !(disableBefore && disableAfter),
|
|
||||||
isDay,
|
|
||||||
userChecked: false
|
|
||||||
}
|
|
||||||
if (info) {
|
|
||||||
data.extraInfo = info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dateArr.push(data)
|
let multiples = this.multipleStatus.data
|
||||||
|
let multiplesStatus = -1
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, currentDate)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return dateArr
|
const checked = multiplesStatus !== -1
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
fullDate: currentDate,
|
||||||
|
year: dateObj.year,
|
||||||
|
date: i,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
month: dateObj.month,
|
||||||
|
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)),
|
||||||
|
isToday,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo: info
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取下月天数
|
* 获取下一个月日期集合
|
||||||
*/
|
*/
|
||||||
_getNextMonthDays(surplus, full) {
|
_getNextMonthDays(amount, dateObj) {
|
||||||
let dateArr = []
|
const result = []
|
||||||
for (let i = 1; i < surplus + 1; i++) {
|
const month = dateObj.month + 1
|
||||||
dateArr.push({
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
result.push({
|
||||||
date: i,
|
date: i,
|
||||||
month: Number(full.month) + 1,
|
month,
|
||||||
disable: true
|
disable: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return dateArr
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,58 +181,37 @@ class Calendar {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
date = new Date()
|
date = new Date()
|
||||||
}
|
}
|
||||||
const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
|
|
||||||
return dateInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
|
||||||
* 比较时间大小
|
|
||||||
*/
|
|
||||||
dateCompare(startDate, endDate) {
|
|
||||||
// 计算截止时间
|
|
||||||
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
|
|
||||||
// 计算详细项的截止时间
|
|
||||||
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
|
|
||||||
if (startDate <= endDate) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较时间是否相等
|
* 比较时间是否相等
|
||||||
*/
|
*/
|
||||||
dateEqual(before, after) {
|
dateEqual(before, after) {
|
||||||
// 计算截止时间
|
before = new Date(fixIosDateFormat(before))
|
||||||
before = new Date(before.replace('-', '/').replace('-', '/'))
|
after = new Date(fixIosDateFormat(after))
|
||||||
// 计算详细项的截止时间
|
return before.valueOf() === after.valueOf()
|
||||||
after = new Date(after.replace('-', '/').replace('-', '/'))
|
|
||||||
if (before.getTime() - after.getTime() === 0) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较真实起始日期
|
* 比较真实起始日期
|
||||||
*/
|
*/
|
||||||
|
|
||||||
isLogicBefore(currentDay, before, after) {
|
isLogicBefore(currentDate, before, after) {
|
||||||
let logicBefore = before
|
let logicBefore = before
|
||||||
if (before && after) {
|
if (before && after) {
|
||||||
logicBefore = this.dateCompare(before, after) ? before : after
|
logicBefore = dateCompare(before, after) ? before : after
|
||||||
}
|
}
|
||||||
return this.dateEqual(logicBefore, currentDay)
|
return this.dateEqual(logicBefore, currentDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
isLogicAfter(currentDay, before, after) {
|
isLogicAfter(currentDate, before, after) {
|
||||||
let logicAfter = after
|
let logicAfter = after
|
||||||
if (before && after) {
|
if (before && after) {
|
||||||
logicAfter = this.dateCompare(before, after) ? after : before
|
logicAfter = dateCompare(before, after) ? after : before
|
||||||
}
|
}
|
||||||
return this.dateEqual(logicAfter, currentDay)
|
return this.dateEqual(logicAfter, currentDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,7 +231,7 @@ class Calendar {
|
||||||
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
|
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
|
||||||
for (var k = unixDb; k <= unixDe;) {
|
for (var k = unixDb; k <= unixDe;) {
|
||||||
k = k + 24 * 60 * 60 * 1000
|
k = k + 24 * 60 * 60 * 1000
|
||||||
arr.push(this.getDate(new Date(parseInt(k))).fullDate)
|
arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
|
||||||
}
|
}
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
@ -285,11 +240,12 @@ class Calendar {
|
||||||
* 获取多选状态
|
* 获取多选状态
|
||||||
*/
|
*/
|
||||||
setMultiple(fullDate) {
|
setMultiple(fullDate) {
|
||||||
|
if (!this.range) return
|
||||||
|
|
||||||
let {
|
let {
|
||||||
before,
|
before,
|
||||||
after
|
after
|
||||||
} = this.multipleStatus
|
} = this.multipleStatus
|
||||||
if (!this.range) return
|
|
||||||
if (before && after) {
|
if (before && after) {
|
||||||
if (!this.lastHover) {
|
if (!this.lastHover) {
|
||||||
this.lastHover = true
|
this.lastHover = true
|
||||||
|
@ -306,7 +262,7 @@ class Calendar {
|
||||||
this.lastHover = false
|
this.lastHover = false
|
||||||
} else {
|
} else {
|
||||||
this.multipleStatus.after = fullDate
|
this.multipleStatus.after = fullDate
|
||||||
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
||||||
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
|
||||||
.after);
|
.after);
|
||||||
} else {
|
} else {
|
||||||
|
@ -316,32 +272,28 @@ class Calendar {
|
||||||
this.lastHover = true
|
this.lastHover = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._getWeek(fullDate)
|
this.getWeeks(fullDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 鼠标 hover 更新多选状态
|
* 鼠标 hover 更新多选状态
|
||||||
*/
|
*/
|
||||||
setHoverMultiple(fullDate) {
|
setHoverMultiple(fullDate) {
|
||||||
let {
|
if (!this.range || this.lastHover) return
|
||||||
before,
|
|
||||||
after
|
|
||||||
} = this.multipleStatus
|
|
||||||
|
|
||||||
if (!this.range) return
|
const { before } = this.multipleStatus
|
||||||
if (this.lastHover) return
|
|
||||||
|
|
||||||
if (!before) {
|
if (!before) {
|
||||||
this.multipleStatus.before = fullDate
|
this.multipleStatus.before = fullDate
|
||||||
} else {
|
} else {
|
||||||
this.multipleStatus.after = fullDate
|
this.multipleStatus.after = fullDate
|
||||||
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
||||||
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
|
||||||
} else {
|
} else {
|
||||||
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._getWeek(fullDate)
|
this.getWeeks(fullDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -351,12 +303,12 @@ class Calendar {
|
||||||
this.multipleStatus.before = before
|
this.multipleStatus.before = before
|
||||||
this.multipleStatus.after = after
|
this.multipleStatus.after = after
|
||||||
if (before && after) {
|
if (before && after) {
|
||||||
if (this.dateCompare(before, after)) {
|
if (dateCompare(before, after)) {
|
||||||
this.multipleStatus.data = this.geDateAll(before, after);
|
this.multipleStatus.data = this.geDateAll(before, after);
|
||||||
this._getWeek(after)
|
this.getWeeks(after)
|
||||||
} else {
|
} else {
|
||||||
this.multipleStatus.data = this.geDateAll(after, before);
|
this.multipleStatus.data = this.geDateAll(after, before);
|
||||||
this._getWeek(before)
|
this.getWeeks(before)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,46 +317,87 @@ class Calendar {
|
||||||
* 获取每周数据
|
* 获取每周数据
|
||||||
* @param {Object} dateData
|
* @param {Object} dateData
|
||||||
*/
|
*/
|
||||||
_getWeek(dateData) {
|
getWeeks(dateData) {
|
||||||
const {
|
const {
|
||||||
fullDate,
|
|
||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
date,
|
} = this.getDateObj(dateData)
|
||||||
day
|
|
||||||
} = this.getDate(dateData)
|
const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
|
||||||
let firstDay = new Date(year, month - 1, 1).getDay()
|
const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
|
||||||
let currentDay = new Date(year, month, 0).getDate()
|
|
||||||
let dates = {
|
const currentMonthDayAmount = new Date(year, month, 0).getDate()
|
||||||
lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
|
const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
|
||||||
currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
|
|
||||||
nextMonthDays: [], // 下个月开始几天
|
const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
|
||||||
weeks: []
|
const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
|
||||||
|
|
||||||
|
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
|
||||||
|
|
||||||
|
const weeks = new Array(6)
|
||||||
|
for (let i = 0; i < calendarDays.length; i++) {
|
||||||
|
const index = Math.floor(i / 7)
|
||||||
|
if(!weeks[index]){
|
||||||
|
weeks[index] = new Array(7)
|
||||||
}
|
}
|
||||||
let canlender = []
|
weeks[index][i % 7] = calendarDays[i]
|
||||||
const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
|
|
||||||
dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
|
|
||||||
canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
|
|
||||||
let weeks = {}
|
|
||||||
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
|
|
||||||
for (let i = 0; i < canlender.length; i++) {
|
|
||||||
if (i % 7 === 0) {
|
|
||||||
weeks[parseInt(i / 7)] = new Array(7)
|
|
||||||
}
|
}
|
||||||
weeks[parseInt(i / 7)][i % 7] = canlender[i]
|
|
||||||
}
|
this.calendar = calendarDays
|
||||||
this.canlender = canlender
|
|
||||||
this.weeks = weeks
|
this.weeks = weeks
|
||||||
}
|
}
|
||||||
|
|
||||||
//静态方法
|
|
||||||
// static init(date) {
|
|
||||||
// if (!this.instance) {
|
|
||||||
// this.instance = new Calendar(date);
|
|
||||||
// }
|
|
||||||
// return this.instance;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDateTime(date, hideSecond){
|
||||||
|
return `${getDate(date)} ${getTime(date, hideSecond)}`
|
||||||
|
}
|
||||||
|
|
||||||
export default Calendar
|
function getDate(date) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth()+1
|
||||||
|
const day = date.getDate()
|
||||||
|
return `${year}-${addZero(month)}-${addZero(day)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTime(date, hideSecond){
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function addZero(num) {
|
||||||
|
if(num < 10){
|
||||||
|
num = `0${num}`
|
||||||
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDefaultSecond(hideSecond) {
|
||||||
|
return hideSecond ? '00:00' : '00:00:00'
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateCompare(startDate, endDate) {
|
||||||
|
startDate = new Date(fixIosDateFormat(startDate))
|
||||||
|
endDate = new Date(fixIosDateFormat(endDate))
|
||||||
|
return startDate <= endDate
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDate(date){
|
||||||
|
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
|
||||||
|
return date.match(dateReg)
|
||||||
|
}
|
||||||
|
|
||||||
|
const dateTimeReg = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( [0-5][0-9]:[0-5][0-9]:[0-5][0-9])?$/
|
||||||
|
function fixIosDateFormat(value) {
|
||||||
|
if (typeof value === 'string' && dateTimeReg.test(value)) {
|
||||||
|
value = value.replace(/-/g, '/')
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "uni-datetime-picker",
|
"id": "uni-datetime-picker",
|
||||||
"displayName": "uni-datetime-picker 日期选择器",
|
"displayName": "uni-datetime-picker 日期选择器",
|
||||||
"version": "2.2.6",
|
"version": "2.2.22",
|
||||||
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
|
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"uni-datetime-picker",
|
"uni-datetime-picker",
|
||||||
|
@ -18,10 +18,6 @@
|
||||||
"example": "../../temps/example_temps"
|
"example": "../../temps/example_temps"
|
||||||
},
|
},
|
||||||
"dcloudext": {
|
"dcloudext": {
|
||||||
"category": [
|
|
||||||
"前端组件",
|
|
||||||
"通用组件"
|
|
||||||
],
|
|
||||||
"sale": {
|
"sale": {
|
||||||
"regular": {
|
"regular": {
|
||||||
"price": "0.00"
|
"price": "0.00"
|
||||||
|
@ -38,7 +34,8 @@
|
||||||
"data": "无",
|
"data": "无",
|
||||||
"permissions": "无"
|
"permissions": "无"
|
||||||
},
|
},
|
||||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
|
||||||
|
"type": "component-vue"
|
||||||
},
|
},
|
||||||
"uni_modules": {
|
"uni_modules": {
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
|
@ -24,9 +24,9 @@ function resetData(params) {
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default resetData;
|
export default resetData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,5 +83,6 @@ function dateTimePicker(startYear,endYear,date) {
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
dateTimePicker: dateTimePicker,
|
dateTimePicker: dateTimePicker,
|
||||||
|
getNewDateArry: getNewDateArry,
|
||||||
getMonthDay: getMonthDay
|
getMonthDay: getMonthDay
|
||||||
}
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
import {getNewDateArry} from './dateTimePicker.js'
|
||||||
|
function getStartAndEnd() {
|
||||||
|
const date_l = getNewDateArry()
|
||||||
|
const NowTime = new Date().getTime()
|
||||||
|
// 今日结束时间戳
|
||||||
|
const todayEndTime = new Date(new Date().setHours(23,59,59,999)).getTime()
|
||||||
|
return [`${date_l[0]}-${date_l[1]}-${date_l[2]} ${date_l[3]}:${date_l[4]}:00`, `${date_l[0]}-${date_l[1]}-${date_l[2]} 23:59:59`]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getStartAndEnd;
|
Loading…
Reference in New Issue