@kyfe/hroa-ui 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hroa-ui.common.js +133 -2576
- package/dist/hroa-ui.css +1 -1
- package/dist/hroa-ui.umd.js +133 -2576
- package/dist/hroa-ui.umd.min.js +2 -2
- package/lib/hr-add-list/index.js +1 -1
- package/lib/hr-bottom-button/index.js +1 -1
- package/lib/hr-breadcrumb/index.js +1 -1
- package/lib/hr-button/index.js +1 -1
- package/lib/hr-checkbox/index.js +1 -1
- package/lib/hr-checkbox-group/index.js +1 -1
- package/lib/hr-clipboard/index.js +1 -1
- package/lib/hr-collapse-card/index.js +1 -1
- package/lib/hr-condition-filtrate/index.js +1 -1
- package/lib/hr-condition-filtrate-popup/index.js +1 -1
- package/lib/hr-date-filter/index.css +1 -1
- package/lib/hr-date-filter/index.js +1 -1
- package/lib/hr-dropdown-date/index.css +1 -1
- package/lib/hr-dropdown-date/index.js +1 -1
- package/lib/hr-elasticity-box/index.js +1 -1
- package/lib/hr-elasticity-box-item/index.js +1 -1
- package/lib/hr-emotional-picture/index.js +1 -1
- package/lib/hr-employee-choose/index.js +1 -1
- package/lib/hr-file-list/index.js +1 -1
- package/lib/hr-full-screen/index.js +1 -1
- package/lib/hr-img-list/index.css +1 -1
- package/lib/hr-img-list/index.js +1 -1
- package/lib/hr-info-card/index.js +1 -1
- package/lib/hr-information/index.js +1 -1
- package/lib/hr-license-plate-number/index.js +1 -1
- package/lib/hr-module-card/index.js +1 -1
- package/lib/hr-multiterm-choose/index.css +1 -1
- package/lib/hr-multiterm-choose/index.js +1 -1
- package/lib/hr-no-data/index.js +1 -1
- package/lib/hr-notice-bar/index.js +1 -1
- package/lib/hr-notification-dialog/index.js +1 -1
- package/lib/hr-open-ks/index.js +1 -1
- package/lib/hr-pager/index.js +1 -1
- package/lib/hr-popup/index.js +1 -1
- package/lib/hr-preview-file/index.js +1 -1
- package/lib/hr-radiobox/index.js +1 -1
- package/lib/hr-radiobox-group/index.js +1 -1
- package/lib/hr-rate/index.js +1 -1
- package/lib/hr-reason-textarea/index.js +1 -1
- package/lib/hr-search-input/index.js +1 -1
- package/lib/hr-search-tips/index.js +1 -1
- package/lib/hr-select/index.js +1 -1
- package/lib/hr-select-list/index.js +1 -1
- package/lib/hr-single-choose/index.css +1 -1
- package/lib/hr-single-choose/index.js +1 -1
- package/lib/hr-slide-pager/index.js +1 -1
- package/lib/hr-sort/index.js +1 -1
- package/lib/hr-stack-image/index.js +1 -1
- package/lib/hr-tab-nav/index.js +1 -1
- package/lib/hr-time-picker/index.js +1 -1
- package/lib/hr-view-item/index.js +1 -1
- package/lib/hr-virtual-list/index.js +1 -1
- package/lib/index/index.css +1 -1
- package/lib/index/index.js +2 -2
- package/lib/utils/index.js +1 -1
- package/package.json +12 -9
- package/lib/getJsModule/index.css +0 -1
- package/lib/getJsModule/index.js +0 -9
- package/packages/getJsModule.js +0 -11
- package/packages/hr-add-list/image/add.svg +0 -1
- package/packages/hr-add-list/image/close.svg +0 -1
- package/packages/hr-add-list/index.js +0 -7
- package/packages/hr-add-list/src/index.vue +0 -125
- package/packages/hr-add-list//346/226/260/345/242/236/345/244/232/347/254/224/346/225/260/346/215/256.md +0 -0
- package/packages/hr-bottom-button/index.js +0 -7
- package/packages/hr-bottom-button/src/index.vue +0 -128
- package/packages/hr-breadcrumb/index.js +0 -3
- package/packages/hr-breadcrumb/src/index.vue +0 -87
- package/packages/hr-breadcrumb//351/235/242/345/214/205/345/261/221.md +0 -0
- package/packages/hr-button/index.js +0 -13
- package/packages/hr-button/src/hr-button.vue +0 -39
- package/packages/hr-checkbox/index.js +0 -8
- package/packages/hr-checkbox/src/active-icon.png +0 -0
- package/packages/hr-checkbox/src/checkbox-group.vue +0 -74
- package/packages/hr-checkbox/src/checkbox.vue +0 -226
- package/packages/hr-checkbox/src/data.js +0 -46
- package/packages/hr-checkbox//345/244/215/351/200/211/346/241/206-/345/215/225/351/200/211/346/241/206.md +0 -0
- package/packages/hr-checkbox-group/index.js +0 -8
- package/packages/hr-clipboard/index.js +0 -8
- package/packages/hr-clipboard/src/index.vue +0 -46
- package/packages/hr-clipboard/src/util.js +0 -9
- package/packages/hr-collapse-card/index.js +0 -3
- package/packages/hr-collapse-card/src/images/icon_up.png +0 -0
- package/packages/hr-collapse-card/src/index.vue +0 -151
- package/packages/hr-collapse-card//346/212/230/345/217/240/345/215/241/347/211/207.md +0 -0
- package/packages/hr-condition-filtrate/enum/index.js +0 -11
- package/packages/hr-condition-filtrate/image/arrow-right.png +0 -0
- package/packages/hr-condition-filtrate/index.js +0 -7
- package/packages/hr-condition-filtrate/src/employee-choose/index.vue +0 -101
- package/packages/hr-condition-filtrate/src/index.vue +0 -246
- package/packages/hr-condition-filtrate/src/multiterm-choose/index.vue +0 -167
- package/packages/hr-condition-filtrate/src/org-tree-choose/index.vue +0 -102
- package/packages/hr-condition-filtrate/src/single-choose/index.vue +0 -144
- package/packages/hr-condition-filtrate/src/text-input/index.vue +0 -60
- package/packages/hr-condition-filtrate/src/time-selector/date-range-select.vue +0 -154
- package/packages/hr-condition-filtrate/src/time-selector/images/date-icon.png +0 -0
- package/packages/hr-condition-filtrate/src/time-selector/index.vue +0 -380
- package/packages/hr-condition-filtrate/src/time-selector/utils/constant.js +0 -30
- package/packages/hr-condition-filtrate/src/time-selector/utils/tools.js +0 -213
- package/packages/hr-condition-filtrate-popup/index.js +0 -7
- package/packages/hr-condition-filtrate-popup/src/index.vue +0 -236
- package/packages/hr-date-filter/index.js +0 -7
- package/packages/hr-date-filter/src/date-select.vue +0 -153
- package/packages/hr-date-filter/src/index.vue +0 -243
- package/packages/hr-date-filter/src/style.less +0 -130
- package/packages/hr-date-filter/src/utils.js +0 -109
- package/packages/hr-dropdown-date/index.js +0 -7
- package/packages/hr-dropdown-date/src/calendar/calendar.js +0 -128
- package/packages/hr-dropdown-date/src/calendar/calendar.vue +0 -485
- package/packages/hr-dropdown-date/src/calendar/images/arrow@3x.png +0 -0
- package/packages/hr-dropdown-date/src/calendar/index.js +0 -5
- package/packages/hr-dropdown-date/src/date-picker/date-range-select.vue +0 -92
- package/packages/hr-dropdown-date/src/date-picker/month-range-select.vue +0 -128
- package/packages/hr-dropdown-date/src/date-picker/month-select.vue +0 -98
- package/packages/hr-dropdown-date/src/date-picker/style.less +0 -120
- package/packages/hr-dropdown-date/src/date-picker/utils.js +0 -109
- package/packages/hr-dropdown-date/src/index.vue +0 -482
- package/packages/hr-dropdown-date/src/week.js +0 -194
- package/packages/hr-elasticity-box/index.js +0 -7
- package/packages/hr-elasticity-box/src/elasticity-box-item.vue +0 -61
- package/packages/hr-elasticity-box/src/index.vue +0 -52
- package/packages/hr-elasticity-box-item/index.js +0 -7
- package/packages/hr-emotional-picture/index.js +0 -7
- package/packages/hr-emotional-picture/src/index.vue +0 -66
- package/packages/hr-emotional-picture//346/203/205/346/204/237/345/233/276/347/273/204/344/273/266.md +0 -0
- package/packages/hr-employee-choose/index.js +0 -7
- package/packages/hr-employee-choose/src/image/arrow-right.png +0 -0
- package/packages/hr-employee-choose/src/index.vue +0 -119
- package/packages/hr-file-list/index.js +0 -3
- package/packages/hr-file-list/src/file-type/other.vue +0 -45
- package/packages/hr-file-list/src/file-type/picture.vue +0 -38
- package/packages/hr-file-list/src/file-type/video.vue +0 -60
- package/packages/hr-file-list/src/index.vue +0 -246
- package/packages/hr-file-list/src/utils/enum.js +0 -95
- package/packages/hr-file-list/src/utils/fun.js +0 -16
- package/packages/hr-file-list//346/226/207/344/273/266/345/210/227/350/241/250.md +0 -0
- package/packages/hr-full-screen/index.js +0 -7
- package/packages/hr-full-screen/src/index.vue +0 -117
- package/packages/hr-img-list/index.js +0 -3
- package/packages/hr-img-list/src/index.vue +0 -144
- package/packages/hr-img-list//345/244/232/345/233/276/345/210/227/350/241/250.md +0 -0
- package/packages/hr-info-card/index.js +0 -7
- package/packages/hr-info-card/src/index.vue +0 -67
- package/packages/hr-information/index.js +0 -7
- package/packages/hr-information/src/index.vue +0 -72
- package/packages/hr-license-plate-number/index.js +0 -8
- package/packages/hr-license-plate-number/src/enum.js +0 -44
- package/packages/hr-license-plate-number/src/index.vue +0 -164
- package/packages/hr-license-plate-number/src/vnp-keyboard.vue +0 -182
- package/packages/hr-license-plate-number//350/275/246/347/211/214/345/217/267/345/274/271/347/252/227.md +0 -0
- package/packages/hr-module-card/index.js +0 -13
- package/packages/hr-module-card/src/index.vue +0 -132
- package/packages/hr-module-card//346/250/241/345/235/227/345/215/241/347/211/207/347/273/204/344/273/266.md +0 -29
- package/packages/hr-multiterm-choose/index.js +0 -8
- package/packages/hr-multiterm-choose/src/active-icon.png +0 -0
- package/packages/hr-multiterm-choose/src/index.vue +0 -224
- package/packages/hr-multiterm-choose//345/244/232/351/200/211/346/241/206.md +0 -0
- package/packages/hr-no-data/index.js +0 -7
- package/packages/hr-no-data/src/index.vue +0 -48
- package/packages/hr-notice-bar/index.js +0 -7
- package/packages/hr-notice-bar/src/bem.js +0 -38
- package/packages/hr-notice-bar/src/index.js +0 -52
- package/packages/hr-notice-bar//351/200/232/347/237/245/346/240/217/347/273/204/344/273/266.md +0 -3
- package/packages/hr-notification-dialog/images/header.png +0 -0
- package/packages/hr-notification-dialog/index.js +0 -7
- package/packages/hr-notification-dialog/src/index.vue +0 -293
- package/packages/hr-notification-dialog//345/274/271/347/252/227/346/217/220/347/244/272/347/273/204/344/273/266.md +0 -0
- package/packages/hr-open-ks/index.js +0 -7
- package/packages/hr-open-ks/src/icon.png +0 -0
- package/packages/hr-open-ks/src/index.vue +0 -97
- package/packages/hr-open-ks/src/util.js +0 -31
- package/packages/hr-pager/images/next-page.png +0 -0
- package/packages/hr-pager/images/prev-page.png +0 -0
- package/packages/hr-pager/index.js +0 -7
- package/packages/hr-pager/src/index.vue +0 -120
- package/packages/hr-pager//346/214/211/351/222/256/347/277/273/351/241/265/347/273/204/344/273/266.md +0 -0
- package/packages/hr-popup/index.js +0 -3
- package/packages/hr-popup/src/index.vue +0 -64
- package/packages/hr-popup//345/274/271/345/207/272/345/261/202.md +0 -0
- package/packages/hr-preview-file/index.js +0 -7
- package/packages/hr-preview-file/src/index.vue +0 -58
- package/packages/hr-preview-file/src/util.js +0 -50
- package/packages/hr-radiobox/index.js +0 -8
- package/packages/hr-radiobox/src/data.js +0 -46
- package/packages/hr-radiobox/src/radiobox-group.vue +0 -64
- package/packages/hr-radiobox/src/radiobox.vue +0 -191
- package/packages/hr-radiobox-group/index.js +0 -8
- package/packages/hr-rate/index.js +0 -7
- package/packages/hr-rate/src/index.vue +0 -42
- package/packages/hr-rate//350/257/204/345/210/206/347/273/204/344/273/266/357/274/210/345/270/246/346/226/207/346/241/210/357/274/211.md +0 -0
- package/packages/hr-reason-textarea/index.js +0 -7
- package/packages/hr-reason-textarea/src/index.vue +0 -128
- package/packages/hr-search-input/image/input-close-icon.png +0 -0
- package/packages/hr-search-input/image/search-icon.png +0 -0
- package/packages/hr-search-input/index.js +0 -8
- package/packages/hr-search-input/src/index.vue +0 -144
- package/packages/hr-search-tips/index.js +0 -3
- package/packages/hr-search-tips/src/index.vue +0 -213
- package/packages/hr-search-tips//350/277/234/347/250/213/346/250/241/347/263/212/346/220/234/347/264/242.md +0 -0
- package/packages/hr-select/index.js +0 -7
- package/packages/hr-select/src/index.vue +0 -41
- package/packages/hr-select-list/index.js +0 -3
- package/packages/hr-select-list/src/index.vue +0 -214
- package/packages/hr-select-list//344/270/213/346/213/211/351/200/211/346/213/251(/351/273/230/350/256/244/345/244/232/351/200/211).md +0 -0
- package/packages/hr-single-choose/index.js +0 -8
- package/packages/hr-single-choose/src/index.vue +0 -195
- package/packages/hr-single-choose//345/215/225/351/200/211/346/241/206.md +0 -0
- package/packages/hr-slide-pager/guide/image/turn-left.png +0 -0
- package/packages/hr-slide-pager/guide/image/turn-right.png +0 -0
- package/packages/hr-slide-pager/guide/index.vue +0 -59
- package/packages/hr-slide-pager/guide//346/226/260/346/211/213/346/214/207/345/274/225.md +0 -0
- package/packages/hr-slide-pager/index.js +0 -7
- package/packages/hr-slide-pager/src/index.vue +0 -374
- package/packages/hr-slide-pager//346/273/221/345/212/250/347/277/273/351/241/265/347/273/204/344/273/266.md +0 -0
- package/packages/hr-sort/index.js +0 -3
- package/packages/hr-sort/src/main.vue +0 -133
- package/packages/hr-sort//346/216/222/345/272/217.md +0 -0
- package/packages/hr-stack-image/index.js +0 -3
- package/packages/hr-stack-image/src/main.vue +0 -77
- package/packages/hr-stack-image//345/261/202/345/217/240/345/233/276/347/211/207/347/273/204/344/273/266.md +0 -0
- package/packages/hr-tab-nav/index.js +0 -8
- package/packages/hr-tab-nav/src/index.vue +0 -190
- package/packages/hr-time-picker/index.js +0 -3
- package/packages/hr-time-picker/src/index.vue +0 -85
- package/packages/hr-time-picker//346/227/266/351/227/264/351/200/211/346/213/251/345/231/250.md +0 -0
- package/packages/hr-view-item/index.js +0 -13
- package/packages/hr-view-item/src/index.vue +0 -89
- package/packages/hr-view-item//350/241/250/345/215/225/351/241/271item/345/261/225/347/244/272.md +0 -0
- package/packages/hr-virtual-list/index.js +0 -7
- package/packages/hr-virtual-list/src/cc-item.vue +0 -105
- package/packages/hr-virtual-list/src/index.vue +0 -227
- package/packages/hr-virtual-list//350/231/232/346/213/237/345/210/227/350/241/250.md +0 -0
- package/packages/index.js +0 -23
- package/packages/utils/directive/common.js +0 -0
- package/packages/utils/directive/index.js +0 -2
- package/packages/utils/directive/specific.js +0 -54
- package/packages/utils/index.js +0 -7
- package/packages/utils/tool/common.js +0 -65
- package/packages/utils/tool/index.js +0 -2
- package/packages/utils/tool/specific.js +0 -0
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="tab-filter"
|
|
3
|
-
id="tab-filter">
|
|
4
|
-
<van-dropdown-menu>
|
|
5
|
-
<van-dropdown-item :title="resultTitle"
|
|
6
|
-
class="tab-filter-dropdown"
|
|
7
|
-
:class="type"
|
|
8
|
-
@closed="showCalendar = false"
|
|
9
|
-
@open="doDropdown"
|
|
10
|
-
ref="item">
|
|
11
|
-
<div class="dropdown-wrap">
|
|
12
|
-
<!-- 快捷操作栏 -->
|
|
13
|
-
<div class="hot-bar"
|
|
14
|
-
v-if="isShowHotKey">
|
|
15
|
-
<template v-for="item in timeHotkeyList">
|
|
16
|
-
<div :key="item.value"
|
|
17
|
-
class="btn-item"
|
|
18
|
-
:class="{'active': activeValue === item.value}"
|
|
19
|
-
@click="selected(item)">{{ item.label }}</div>
|
|
20
|
-
</template>
|
|
21
|
-
</div>
|
|
22
|
-
<!-- 日历动态组件 -->
|
|
23
|
-
<div class="dropdown-center-box"
|
|
24
|
-
:class="{'month-type': type === 'month'}">
|
|
25
|
-
<component :is="dateComponent"
|
|
26
|
-
ref="componentRef"
|
|
27
|
-
v-if="showCalendar"
|
|
28
|
-
v-bind="$attrs"
|
|
29
|
-
:min="min"
|
|
30
|
-
:max="max"
|
|
31
|
-
:weekRange="{
|
|
32
|
-
monday: timeRange.startTime,
|
|
33
|
-
sunday: timeRange.endTime
|
|
34
|
-
}"
|
|
35
|
-
:defaultValue="defaultValueComputed"
|
|
36
|
-
@select="dateRangeSelect"
|
|
37
|
-
@confirm="handleConfrim"></component>
|
|
38
|
-
</div>
|
|
39
|
-
<!-- 确认按钮 -->
|
|
40
|
-
<div class="dropdown-footer-box"
|
|
41
|
-
v-if="['dateRange', 'monthRange'].includes(type)">
|
|
42
|
-
<van-button @click="dateRangeConfrim"
|
|
43
|
-
type="primary"
|
|
44
|
-
size="large">
|
|
45
|
-
确定
|
|
46
|
-
</van-button>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
</van-dropdown-item>
|
|
50
|
-
</van-dropdown-menu>
|
|
51
|
-
<!-- 右边插槽 -->
|
|
52
|
-
<slot name="right"></slot>
|
|
53
|
-
</div>
|
|
54
|
-
</template>
|
|
55
|
-
<script>
|
|
56
|
-
// 周选择器弹窗组件
|
|
57
|
-
import Calender from './calendar/index.js'
|
|
58
|
-
// 月份选择
|
|
59
|
-
import Month from './date-picker/month-select.vue'
|
|
60
|
-
// 月份范围
|
|
61
|
-
import MonthRange from './date-picker/month-range-select.vue'
|
|
62
|
-
// 日期范围
|
|
63
|
-
import DateRangeSelect from './date-picker/date-range-select.vue'
|
|
64
|
-
import { getDayForMill } from './week.js'
|
|
65
|
-
|
|
66
|
-
const dayjs = require('dayjs')
|
|
67
|
-
// 导入中文语言包
|
|
68
|
-
require('dayjs/locale/zh-cn')
|
|
69
|
-
// 设置Day.js的语言环境为中文
|
|
70
|
-
dayjs.locale('zh-cn')
|
|
71
|
-
|
|
72
|
-
export default {
|
|
73
|
-
name: 'hr-dropdown-date',
|
|
74
|
-
components: {
|
|
75
|
-
Calender,
|
|
76
|
-
Month,
|
|
77
|
-
DateRangeSelect,
|
|
78
|
-
MonthRange
|
|
79
|
-
},
|
|
80
|
-
props: {
|
|
81
|
-
// 周选择器组件\日期组件的时间范围
|
|
82
|
-
timeRange: {
|
|
83
|
-
type: Object,
|
|
84
|
-
default: () => ({})
|
|
85
|
-
},
|
|
86
|
-
// 月份选择器组件的时间值
|
|
87
|
-
defaultValue: {
|
|
88
|
-
type: [Date, String, Number],
|
|
89
|
-
default: () => new Date()
|
|
90
|
-
},
|
|
91
|
-
// 是否展示快捷键
|
|
92
|
-
isShowHotKey: {
|
|
93
|
-
type: Boolean,
|
|
94
|
-
default: true
|
|
95
|
-
},
|
|
96
|
-
// 日历类型 week month dateRange monthRange
|
|
97
|
-
type: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: 'week'
|
|
100
|
-
},
|
|
101
|
-
min: {
|
|
102
|
-
type: [String, Number, Date],
|
|
103
|
-
default: +new Date() - getDayForMill(365 * 5)
|
|
104
|
-
},
|
|
105
|
-
max: {
|
|
106
|
-
type: [String, Number, Date],
|
|
107
|
-
default: +new Date() + getDayForMill(31)
|
|
108
|
-
},
|
|
109
|
-
// 时间快捷键列表
|
|
110
|
-
timeHotkeyList: {
|
|
111
|
-
type: Array,
|
|
112
|
-
default: () => {
|
|
113
|
-
return [
|
|
114
|
-
{
|
|
115
|
-
label: '近三周',
|
|
116
|
-
value: '1',
|
|
117
|
-
dateValue: [dayjs().startOf('week').subtract(2, 'week').format('YYYY/MM/DD'), dayjs().endOf('week').format('YYYY/MM/DD')]
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
label: '本月',
|
|
121
|
-
value: '2',
|
|
122
|
-
dateValue: [dayjs().startOf('month').format('YYYY/MM/DD'), dayjs().endOf('month').format('YYYY/MM/DD')],
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
label: '上月',
|
|
126
|
-
value: '3',
|
|
127
|
-
dateValue: [dayjs().subtract(1, 'month').startOf('month').format('YYYY/MM/DD'), dayjs().subtract(1, 'month').endOf('month').format('YYYY/MM/DD')],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
label: '近一个月',
|
|
131
|
-
value: '4',
|
|
132
|
-
dateValue: [dayjs().subtract(1, 'month').format('YYYY/MM/DD'), dayjs().format('YYYY/MM/DD')]
|
|
133
|
-
},
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
data () {
|
|
139
|
-
return {
|
|
140
|
-
dateRangeVal: [], // 范围选择 日期值
|
|
141
|
-
showCalendar: false,
|
|
142
|
-
dateComponent: 'Calender',
|
|
143
|
-
// timeHotkeyList 快捷键列表高亮值
|
|
144
|
-
activeValue: '1',
|
|
145
|
-
resultTitle: ''
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
created () {
|
|
149
|
-
this.setComponent()
|
|
150
|
-
this.getResultLabel()
|
|
151
|
-
},
|
|
152
|
-
watch: {
|
|
153
|
-
showCalendar () {
|
|
154
|
-
// 打开日期范围选择组件
|
|
155
|
-
if (this.showCalendar && ['dateRange'].includes(this.type)) {
|
|
156
|
-
// 打开日期选择控件给dateRangeVal赋值
|
|
157
|
-
this.dateRangeVal = [this.timeRange.startTime, this.timeRange.endTime]
|
|
158
|
-
this.setHotKeyActive(this.dateRangeVal)
|
|
159
|
-
// 滚动下日历,以解决白屏问题
|
|
160
|
-
setTimeout(() => {
|
|
161
|
-
this.$refs.componentRef.$el.querySelector('.van-calendar__body').scrollTop += 50
|
|
162
|
-
}, 10)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// 月份选择器打开时初始化
|
|
166
|
-
if (this.showCalendar && ['month', 'monthRange'].includes(this.type)) {
|
|
167
|
-
if (this.timeRange && this.timeRange.startTime && this.timeRange.endTime) {
|
|
168
|
-
this.setHotKeyActive([this.timeRange.startTime, this.timeRange.endTime])
|
|
169
|
-
}
|
|
170
|
-
this.$nextTick(() => {
|
|
171
|
-
this.$refs.componentRef.init()
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
// 监听日期范围值变化 高亮选中快捷键
|
|
176
|
-
dateRangeVal () {
|
|
177
|
-
if (this.dateRangeVal[0] && this.dateRangeVal[1]) {
|
|
178
|
-
this.setHotKeyActive(this.dateRangeVal)
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
timeRange () {
|
|
182
|
-
this.getResultLabel()
|
|
183
|
-
},
|
|
184
|
-
activeValue () {
|
|
185
|
-
this.getResultLabel()
|
|
186
|
-
},
|
|
187
|
-
defaultValue () {
|
|
188
|
-
this.getResultLabel()
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
computed: {
|
|
192
|
-
// 用于区分月份和日期范围的默认值类型
|
|
193
|
-
defaultValueComputed () {
|
|
194
|
-
if (this.type === 'dateRange') {
|
|
195
|
-
// 日期范围选择类型时,需将timeRange转为数组
|
|
196
|
-
let { startTime, endTime } = this.timeRange || {}
|
|
197
|
-
return [startTime, endTime]
|
|
198
|
-
} if (this.type === 'monthRange') {
|
|
199
|
-
// 日期范围选择类型时,需将timeRange转为数组
|
|
200
|
-
let { startTime, endTime } = this.timeRange || {}
|
|
201
|
-
return [startTime, endTime]
|
|
202
|
-
} else {
|
|
203
|
-
return this.defaultValue
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
methods: {
|
|
208
|
-
/**
|
|
209
|
-
* 日期过滤器
|
|
210
|
-
* @param {date} d
|
|
211
|
-
* @param {string} fmt
|
|
212
|
-
*/
|
|
213
|
-
datetime (d, fmt = 'YYYY-MM-DD') {
|
|
214
|
-
let str = d || ''
|
|
215
|
-
return str ? dayjs(str).format(fmt) : str
|
|
216
|
-
},
|
|
217
|
-
monthDay (d, fmt = 'MM-DD') {
|
|
218
|
-
let str = d || ''
|
|
219
|
-
return str ? this.datetime(d, fmt) : str
|
|
220
|
-
},
|
|
221
|
-
getResultLabel () {
|
|
222
|
-
let { startTime, endTime } = this.timeRange || {}
|
|
223
|
-
|
|
224
|
-
let timeStr = ''
|
|
225
|
-
if (startTime && endTime) {
|
|
226
|
-
timeStr = this.monthDay(startTime, 'MM/DD') + ' ~ ' + this.monthDay(endTime, 'MM/DD')
|
|
227
|
-
} else if (this.type === 'month') {
|
|
228
|
-
// 月份选择器回显title
|
|
229
|
-
timeStr = dayjs(this.defaultValue).format('YYYY-MM周报')
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
this.setHotKeyActive([startTime, endTime])
|
|
233
|
-
timeStr = this.setHotKeyTimeLabel(timeStr)
|
|
234
|
-
|
|
235
|
-
this.resultTitle = timeStr
|
|
236
|
-
},
|
|
237
|
-
/**
|
|
238
|
-
* @description 设置快捷键 时间范围lable
|
|
239
|
-
* @param {*} str
|
|
240
|
-
*/
|
|
241
|
-
setHotKeyTimeLabel (str) {
|
|
242
|
-
let res = this.timeHotkeyList.find(item => item.value === this.activeValue)
|
|
243
|
-
if (res) {
|
|
244
|
-
str = `${res.label}(${str})`
|
|
245
|
-
}
|
|
246
|
-
return str
|
|
247
|
-
},
|
|
248
|
-
// 根据日期范围设置快捷键高亮
|
|
249
|
-
setHotKeyActive (arr) {
|
|
250
|
-
let res = this.timeHotkeyList.some(timeItem => {
|
|
251
|
-
let { dateValue } = timeItem
|
|
252
|
-
if (dayjs(arr[0]).format('YYYY/MM/DD') === dayjs(dateValue[0]).format('YYYY/MM/DD') && dayjs(arr[1]).format('YYYY/MM/DD') === dayjs(dateValue[1]).format('YYYY/MM/DD')) {
|
|
253
|
-
this.activeValue = timeItem.value
|
|
254
|
-
return true
|
|
255
|
-
}
|
|
256
|
-
})
|
|
257
|
-
if (!res) {
|
|
258
|
-
this.activeValue = ''
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
doDropdown () {
|
|
262
|
-
this.showCalendar = true
|
|
263
|
-
},
|
|
264
|
-
/**
|
|
265
|
-
* @description 日历组件选择回调
|
|
266
|
-
* @param {*} data 选中的值
|
|
267
|
-
*/
|
|
268
|
-
dateRangeSelect (data) {
|
|
269
|
-
if (['dateRange', 'monthRange'].includes(this.type)) {
|
|
270
|
-
this.dateRangeVal = data.date
|
|
271
|
-
} else if (this.type === 'month') {
|
|
272
|
-
console.log('dateRangeSelect----', data)
|
|
273
|
-
|
|
274
|
-
this.handleConfrim(data)
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
/**
|
|
278
|
-
* @description 根据type选择要使用的日历组件
|
|
279
|
-
*/
|
|
280
|
-
setComponent () {
|
|
281
|
-
switch (this.type) {
|
|
282
|
-
case 'week':
|
|
283
|
-
this.dateComponent = 'Calender'
|
|
284
|
-
break
|
|
285
|
-
case 'month':
|
|
286
|
-
this.dateComponent = 'Month'
|
|
287
|
-
break
|
|
288
|
-
case 'dateRange':
|
|
289
|
-
this.dateComponent = 'DateRangeSelect'
|
|
290
|
-
break
|
|
291
|
-
case 'monthRange':
|
|
292
|
-
this.dateComponent = 'MonthRange'
|
|
293
|
-
break
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
/**
|
|
297
|
-
* @description 快捷键选中事件
|
|
298
|
-
*/
|
|
299
|
-
selected (item) {
|
|
300
|
-
let { dateValue, value } = item
|
|
301
|
-
this.activeValue = value
|
|
302
|
-
this.dateRangeVal = dateValue
|
|
303
|
-
|
|
304
|
-
this.$emit('confirm', {
|
|
305
|
-
startTime: +new Date(this.dateRangeVal[0]),
|
|
306
|
-
endTime: +new Date(this.dateRangeVal[1])
|
|
307
|
-
})
|
|
308
|
-
this.$refs.item.toggle(false)
|
|
309
|
-
// 这里加延时的原因是等收起动画执行完了再销毁子组件
|
|
310
|
-
setTimeout(() => {
|
|
311
|
-
this.showCalendar = false
|
|
312
|
-
}, 300)
|
|
313
|
-
},
|
|
314
|
-
/**
|
|
315
|
-
* @description 日期范围选中确认回调(dataRange类型)
|
|
316
|
-
*/
|
|
317
|
-
dateRangeConfrim () {
|
|
318
|
-
// 校验 dateRangeVal
|
|
319
|
-
if (!this.dateRangeVal || (this.dateRangeVal && this.dateRangeVal.filter(v => v).length < 2)) {
|
|
320
|
-
vant.Toast('请选择完整日期范围')
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
this.$emit('confirm', {
|
|
325
|
-
startTime: +new Date(this.dateRangeVal[0]),
|
|
326
|
-
endTime: +new Date(this.dateRangeVal[1])
|
|
327
|
-
})
|
|
328
|
-
this.$refs.item.toggle(false)
|
|
329
|
-
// 这里加延时的原因是等收起动画执行完了再销毁子组件
|
|
330
|
-
setTimeout(() => {
|
|
331
|
-
this.showCalendar = false
|
|
332
|
-
}, 300)
|
|
333
|
-
},
|
|
334
|
-
/**
|
|
335
|
-
* @description 周\月份选择器选中确认回调(week、month类型)
|
|
336
|
-
* @param {*} val 选中值
|
|
337
|
-
*/
|
|
338
|
-
handleConfrim (val) {
|
|
339
|
-
let { monday, sunday, date, str } = val
|
|
340
|
-
let res = {}
|
|
341
|
-
|
|
342
|
-
if (this.type === 'month') {
|
|
343
|
-
// 月份选择器
|
|
344
|
-
res = {
|
|
345
|
-
date,
|
|
346
|
-
str
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
// 周选择器
|
|
350
|
-
res = {
|
|
351
|
-
startTime: monday,
|
|
352
|
-
endTime: sunday
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
this.$emit('confirm', res)
|
|
357
|
-
|
|
358
|
-
this.$refs.item.toggle(false)
|
|
359
|
-
// 这里加延时的原因是等收起动画执行完了再销毁子组件
|
|
360
|
-
setTimeout(() => {
|
|
361
|
-
this.showCalendar = false
|
|
362
|
-
}, 300)
|
|
363
|
-
},
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
</script>
|
|
367
|
-
<style lang="less" scoped>
|
|
368
|
-
.tab-filter {
|
|
369
|
-
display: flex;
|
|
370
|
-
align-items: center;
|
|
371
|
-
flex-shrink: 0;
|
|
372
|
-
justify-content: space-between;
|
|
373
|
-
padding-right: 28px;
|
|
374
|
-
.van-dropdown-menu {
|
|
375
|
-
height: 48px;
|
|
376
|
-
margin: 0 4px;
|
|
377
|
-
background-color: unset;
|
|
378
|
-
|
|
379
|
-
&::after {
|
|
380
|
-
border: none;
|
|
381
|
-
}
|
|
382
|
-
/deep/.van-dropdown-menu__item {
|
|
383
|
-
flex: unset;
|
|
384
|
-
justify-content: flex-start;
|
|
385
|
-
.van-dropdown-menu__title {
|
|
386
|
-
font-size: 12px;
|
|
387
|
-
color: #475073;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/deep/.van-dropdown-menu__title:after {
|
|
392
|
-
width: 5px;
|
|
393
|
-
height: 5px;
|
|
394
|
-
top: 50%;
|
|
395
|
-
border: 0;
|
|
396
|
-
border-left: 1px solid;
|
|
397
|
-
border-bottom: 1px solid;
|
|
398
|
-
color: #475073;
|
|
399
|
-
}
|
|
400
|
-
/deep/.van-dropdown-menu__title--active {
|
|
401
|
-
color: #7970fe;
|
|
402
|
-
.van-ellipsis {
|
|
403
|
-
color: #7970fe;
|
|
404
|
-
}
|
|
405
|
-
&:after {
|
|
406
|
-
border-color: #7970fe;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
/deep/.van-popup {
|
|
411
|
-
border-radius: 0px 0px 12px 12px;
|
|
412
|
-
box-shadow: 0px 7px 8px 0px undefined;
|
|
413
|
-
}
|
|
414
|
-
.tab-filter-right {
|
|
415
|
-
position: relative;
|
|
416
|
-
font-size: 24px;
|
|
417
|
-
color: #7972fe;
|
|
418
|
-
.red-dot {
|
|
419
|
-
position: absolute;
|
|
420
|
-
right: -4px;
|
|
421
|
-
top: 0;
|
|
422
|
-
width: 10px;
|
|
423
|
-
height: 10px;
|
|
424
|
-
background: #f25b4c;
|
|
425
|
-
border-radius: 50%;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
.tab-filter-dropdown {
|
|
431
|
-
.dropdown-wrap {
|
|
432
|
-
height: 100%;
|
|
433
|
-
display: flex;
|
|
434
|
-
flex-direction: column;
|
|
435
|
-
.dropdown-center-box {
|
|
436
|
-
height: 100%;
|
|
437
|
-
flex-grow: 1;
|
|
438
|
-
overflow-y: scroll;
|
|
439
|
-
-webkit-overflow-scrolling: touch;
|
|
440
|
-
&.month-type {
|
|
441
|
-
padding-bottom: 20px;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
.dropdown-footer-box {
|
|
445
|
-
padding: 26px;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
.hot-bar {
|
|
449
|
-
display: flex;
|
|
450
|
-
align-items: center;
|
|
451
|
-
padding: 10px 16px 10px 16px;
|
|
452
|
-
height: 54px;
|
|
453
|
-
background: #ffffff;
|
|
454
|
-
box-shadow: 0px 1px 4px 0px rgba(235, 235, 235, 0.6);
|
|
455
|
-
.btn-item {
|
|
456
|
-
display: flex;
|
|
457
|
-
align-items: center;
|
|
458
|
-
justify-content: center;
|
|
459
|
-
padding: 0 15px;
|
|
460
|
-
height: 28px;
|
|
461
|
-
border-radius: 8px;
|
|
462
|
-
font-size: 14px;
|
|
463
|
-
color: #1b2240;
|
|
464
|
-
background-color: #f7f8fa;
|
|
465
|
-
margin-right: 10px;
|
|
466
|
-
&.active {
|
|
467
|
-
background: rgba(121, 114, 254, 0.08);
|
|
468
|
-
border: 1px solid rgba(121, 114, 254, 0.8);
|
|
469
|
-
color: #7972fe;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
/deep/.van-dropdown-item__content {
|
|
474
|
-
height: 78%;
|
|
475
|
-
}
|
|
476
|
-
&.week {
|
|
477
|
-
/deep/.van-dropdown-item__content {
|
|
478
|
-
height: unset;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
</style>
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
const dayjs = require('dayjs')
|
|
2
|
-
// 导入中文语言包
|
|
3
|
-
require('dayjs/locale/zh-cn')
|
|
4
|
-
// 设置Day.js的语言环境为中文
|
|
5
|
-
dayjs.locale('zh-cn')
|
|
6
|
-
const millisecond = 1000
|
|
7
|
-
const second = 60
|
|
8
|
-
const hour = 24
|
|
9
|
-
|
|
10
|
-
// 获取整点 2020-7-15 00:00:00
|
|
11
|
-
export function getWholeHour (date) {
|
|
12
|
-
if (typeof date === 'number') {
|
|
13
|
-
date = new Date(date)
|
|
14
|
-
}
|
|
15
|
-
return date.getTime() - ((date.getHours() * second + date.getMinutes()) * second + date.getSeconds()) * millisecond - date.getMilliseconds()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 当前时间距离此周星期一的毫秒差
|
|
19
|
-
export function getMonday (date) {
|
|
20
|
-
let week = date.getDay()
|
|
21
|
-
if (week === 0) {
|
|
22
|
-
return getDayForMill(6)
|
|
23
|
-
} else if (week === 1) {
|
|
24
|
-
return 0
|
|
25
|
-
} else {
|
|
26
|
-
return getDayForMill(week - 1)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// 当前时间距离此周星期日的毫秒差
|
|
30
|
-
export function getSunday (date) {
|
|
31
|
-
let week = date.getDay()
|
|
32
|
-
if (week === 0) {
|
|
33
|
-
return getDayForMill(1)
|
|
34
|
-
} else {
|
|
35
|
-
return getDayForMill(8 - week)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// 某一天的时间戳
|
|
39
|
-
export function getDayForMill (val) {
|
|
40
|
-
return val * hour * second * second * millisecond
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// 获取周一和周日的时间戳
|
|
45
|
-
export function getWeekRange (date = new Date()) {
|
|
46
|
-
if (typeof date === 'number') {
|
|
47
|
-
date = new Date(date)
|
|
48
|
-
}
|
|
49
|
-
let wholeHourMill = getWholeHour(date)
|
|
50
|
-
return {
|
|
51
|
-
monday: wholeHourMill - getMonday(date),
|
|
52
|
-
sunday: wholeHourMill + getSunday(date) - 1
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @description 获取上一周或者下一周的某一天
|
|
58
|
-
* @param { Date } date 参照时间点
|
|
59
|
-
* @param { Boolean } isPreOrNextWeek true:上一周 false:下一周
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
export function getDayForLastWeek (date, isPreOrNextWeek = true) {
|
|
63
|
-
if (isPreOrNextWeek) {
|
|
64
|
-
return date.getTime() - getDayForMill(7)
|
|
65
|
-
}
|
|
66
|
-
return date.getTime() + getDayForMill(7)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 获取【近两周】周一和周日的时间戳
|
|
70
|
-
export function getTwoWeekRange () {
|
|
71
|
-
return {
|
|
72
|
-
monday: dayjs().startOf('week').subtract(1, 'week').valueOf(),
|
|
73
|
-
sunday: dayjs().endOf('week').valueOf()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 获取【近三周】周一和周日的时间戳
|
|
78
|
-
export function getThreeWeekRange () {
|
|
79
|
-
return {
|
|
80
|
-
monday: dayjs().startOf('week').subtract(2, 'week').valueOf(),
|
|
81
|
-
sunday: dayjs().endOf('week').valueOf()
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 获取当前月的第一天
|
|
87
|
-
* @returns {string}
|
|
88
|
-
*/
|
|
89
|
-
export function getCurrentMonthFirst (d) {
|
|
90
|
-
// var date = null
|
|
91
|
-
// if (typeof (d) === 'string') {
|
|
92
|
-
// date = new Date(d)
|
|
93
|
-
// } else {
|
|
94
|
-
// date = d
|
|
95
|
-
// }
|
|
96
|
-
// // date.setDate(1)
|
|
97
|
-
// var month = parseInt(date.getMonth() + 1)
|
|
98
|
-
// var day = date.getDate()
|
|
99
|
-
// if (month < 10) {
|
|
100
|
-
// month = '0' + month
|
|
101
|
-
// }
|
|
102
|
-
// if (day < 10) {
|
|
103
|
-
// day = '0' + day
|
|
104
|
-
// }
|
|
105
|
-
// return date.getFullYear() + '-' + month + '-' + day
|
|
106
|
-
return dayjs(d).startOf('month').format('YYYY-MM-DD')
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* 获取当前月的最后一天
|
|
110
|
-
* @returns {Date}
|
|
111
|
-
*/
|
|
112
|
-
export function getCurrentMonthLast (d) {
|
|
113
|
-
// var date = null
|
|
114
|
-
// if (typeof (d) === 'string') {
|
|
115
|
-
// date = new Date(d)
|
|
116
|
-
// } else {
|
|
117
|
-
// date = d
|
|
118
|
-
// }
|
|
119
|
-
// var currentMonth = date.getMonth()
|
|
120
|
-
// var nextMonth = ++currentMonth
|
|
121
|
-
// var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1)
|
|
122
|
-
// var oneDay = 1000 * 60 * 60 * 24
|
|
123
|
-
// var lastTime = new Date(nextMonthFirstDay - oneDay)
|
|
124
|
-
// var month = parseInt(lastTime.getMonth() + 1)
|
|
125
|
-
// var day = lastTime.getDate()
|
|
126
|
-
// if (month < 10) {
|
|
127
|
-
// month = '0' + month
|
|
128
|
-
// }
|
|
129
|
-
// if (day < 10) {
|
|
130
|
-
// day = '0' + day
|
|
131
|
-
// }
|
|
132
|
-
// return date.getFullYear() + '-' + month + '-' + day
|
|
133
|
-
return dayjs(d).endOf('month').format('YYYY-MM-DD')
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 获取上个月份的第一天
|
|
138
|
-
* @returns {String} YYYY-MM-DD
|
|
139
|
-
*/
|
|
140
|
-
export function preMonth (date) {
|
|
141
|
-
let curMonth = new Date(date).getMonth()
|
|
142
|
-
// console.log('dayjs().month(curMonth - 1).date(1)', dayjs().month(curMonth - 1).date(1).format('YYYY-MM-DD'))
|
|
143
|
-
return dayjs().month(curMonth - 1).date(1).format('YYYY-MM-DD')
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* 获取下个月份的第一天
|
|
147
|
-
* @returns {String} YYYY-MM-DD
|
|
148
|
-
*/
|
|
149
|
-
export function nextMonth (date) {
|
|
150
|
-
let curMonth = new Date(date).getMonth()
|
|
151
|
-
// console.log('dayjs().month(curMonth + 1).date(1)', dayjs().month(curMonth + 1).date(1).format('YYYY-MM-DD'))
|
|
152
|
-
return dayjs().month(curMonth + 1).date(1).format('YYYY-MM-DD')
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @description 获取当前周的前后两周,返回头尾时间MM-DD格式
|
|
157
|
-
* @param {Boolean} containYear 是否包含年份返回
|
|
158
|
-
* @returns {Object} {monday, sunday}
|
|
159
|
-
*/
|
|
160
|
-
export function get5Weeks (containYear = false) {
|
|
161
|
-
// 获取当前周的周一和周日
|
|
162
|
-
let currMonday = dayjs(getWeekRange(new Date()).monday).format('YYYY-MM-DD')
|
|
163
|
-
let currSunday = dayjs(getWeekRange(new Date()).sunday).format('YYYY-MM-DD')
|
|
164
|
-
// 获取当前周的前后两周
|
|
165
|
-
let val = {
|
|
166
|
-
monday: containYear ? dayjs(currMonday).subtract(14, 'day').format('YYYY-MM-DD') : dayjs(currMonday).subtract(14, 'day').format('MM-DD'),
|
|
167
|
-
sunday: containYear ? dayjs(currSunday).add(14, 'day').format('YYYY-MM-DD') : dayjs(currSunday).add(14, 'day').format('MM-DD')
|
|
168
|
-
}
|
|
169
|
-
return val
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @description 获取传入时间戳是当月的第几周
|
|
174
|
-
* @param { Number, Date } 时间戳 或 时间对象
|
|
175
|
-
* @returns { Number } 1 2 3 4 5
|
|
176
|
-
*/
|
|
177
|
-
export function getWeekNoInMonth (str) {
|
|
178
|
-
// 将字符串转为标准时间格式
|
|
179
|
-
str = new Date(str)
|
|
180
|
-
|
|
181
|
-
// 获取当前时间所在周的周一
|
|
182
|
-
str = new Date(getWeekRange(str).monday)
|
|
183
|
-
|
|
184
|
-
// 先计算出该日期为第几周
|
|
185
|
-
let week = Math.ceil(str.getDate() / 7)
|
|
186
|
-
// 判断这个月前7天是周几,如果不是周一,则计入上个月
|
|
187
|
-
if (str.getDate() < 7) {
|
|
188
|
-
if (str.getDay() !== 1) {
|
|
189
|
-
week = 5
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return week
|
|
194
|
-
}
|