@kyfe/fms-vue2-components 0.0.2 → 0.0.4
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/assets/css/fms-ks-clamp-text.css +1 -0
- package/dist/assets/css/fms-ks-components.css +1 -0
- package/dist/assets/css/fms-ks-popover.css +1 -0
- package/dist/assets/css/fms-ks-search-tips-new.css +1 -0
- package/dist/assets/css/fms-ks-search-tips.css +1 -0
- package/dist/assets/css/fms-ks-select-box.css +1 -0
- package/dist/assets/css/fms-ks-select.css +1 -0
- package/dist/date-picker-bottom.17e75dc0.js +45 -0
- package/dist/date-picker-dropdown.1d8e9f00.js +34 -0
- package/dist/date-picker-right.b939e886.js +23 -0
- package/dist/date-picker-top.c38046f7.js +23 -0
- package/dist/date-range-select.647edaf6.js +69 -0
- package/dist/date-select.96eb3a9d.js +60 -0
- package/dist/date-week-month.169b98bc.js +57 -0
- package/dist/datetime-popup/index.js +411 -0
- package/dist/filter.c93f4ddb.js +45 -0
- package/dist/fms-copy-box/index.js +1 -1
- package/dist/fms-ks-block-title/index.js +38 -0
- package/dist/fms-ks-block-title/style.css +1 -0
- package/dist/fms-ks-clamp-text/index.js +9 -0
- package/dist/fms-ks-clamp-text.24eb5e8d.js +53 -0
- package/dist/fms-ks-components/index.js +9 -0
- package/dist/fms-ks-components.a5d9329b.js +4392 -0
- package/dist/fms-ks-decrypt/index.js +2 -2
- package/dist/fms-ks-decrypt.2f88e659.js +312 -0
- package/dist/fms-ks-file-upload/index.js +32 -31
- package/dist/fms-ks-file-upload/style.css +1 -1
- package/dist/fms-ks-form-grid/index.js +101 -0
- package/dist/fms-ks-form-grid/style.css +1 -0
- package/dist/fms-ks-more-lines/index.js +31 -0
- package/dist/fms-ks-more-lines/style.css +1 -0
- package/dist/fms-ks-page-popup/index.js +68 -0
- package/dist/fms-ks-page-popup/style.css +1 -0
- package/dist/fms-ks-picker/index.js +9 -0
- package/dist/fms-ks-picker.766b55f9.js +61 -0
- package/dist/fms-ks-popover/index.js +9 -0
- package/dist/fms-ks-popover.55ab4b82.js +95 -0
- package/dist/fms-ks-search-tips/index.js +9 -0
- package/dist/fms-ks-search-tips-new/index.js +9 -0
- package/dist/fms-ks-search-tips-new.7d08f710.js +125 -0
- package/dist/fms-ks-search-tips.d36859c3.js +142 -0
- package/dist/fms-ks-select/index.js +9 -0
- package/dist/fms-ks-select-box/index.js +9 -0
- package/dist/fms-ks-select-box.a00f0f08.js +43 -0
- package/dist/fms-ks-select.59416fd8.js +157 -0
- package/dist/fms-ks-warn-drawer/index.js +37 -0
- package/dist/fms-ks-warn-drawer/style.css +1 -0
- package/dist/fms-scroll-list/index.js +3 -1
- package/dist/index.js +30 -30
- package/dist/mixin.f4bc60f0.js +59 -0
- package/dist/month-range-select.374653da.js +97 -0
- package/dist/month-select.30ae7335.js +71 -0
- package/dist/oa-datetime-picker-new/style.css +1 -0
- package/dist/quarter-select.b6256880.js +73 -0
- package/dist/utils.159fba19.js +64 -0
- package/dist/week-select.27efca5c.js +70 -0
- package/package.json +31 -31
- package/src/assets/images/attachment/icon_default.svg +23 -0
- package/src/assets/images/attachment/icon_default_new.png +0 -0
- package/src/assets/images/attachment/icon_excel.svg +20 -0
- package/src/assets/images/attachment/icon_excel_new.png +0 -0
- package/src/assets/images/attachment/icon_file.png +0 -0
- package/src/assets/images/attachment/icon_pdf_new.png +0 -0
- package/src/assets/images/attachment/icon_ppt.svg +20 -0
- package/src/assets/images/attachment/icon_ppt_new.png +0 -0
- package/src/assets/images/attachment/icon_preview_file.png +0 -0
- package/src/assets/images/attachment/icon_txt.png +0 -0
- package/src/assets/images/attachment/icon_word.svg +19 -0
- package/src/assets/images/attachment/icon_word_new.png +0 -0
- package/src/assets/images/attachment/icon_xmind.png +0 -0
- package/src/assets/images/icon-arrow.png +0 -0
- package/src/assets/images/icon-forewarning.svg +1 -0
- package/src/components/date-picker/index.vue +205 -0
- package/src/components/datetime-picker-general/index.vue +161 -0
- package/src/components/datetime-popup/date-picker.js +217 -0
- package/src/components/datetime-popup/index.js +37 -0
- package/src/components/datetime-popup/index.vue +111 -0
- package/src/components/datetime-popup/mixin.js +125 -0
- package/src/components/datetime-popup/time-picker.js +102 -0
- package/src/components/datetime-popup/utils.js +124 -0
- package/src/components/datetime-popup//347/244/272/344/276/213/345/233/276.png +0 -0
- package/src/components/decrypt/README.md +0 -0
- package/src/components/decrypt/index.vue +73 -0
- package/src/components/fms-ks-block-title/fms-ks-block-title.vue +75 -0
- package/src/components/fms-ks-block-title/index.js +7 -0
- package/src/components/fms-ks-block-title//346/240/207/351/242/230.md +0 -0
- package/src/components/fms-ks-clamp-text/fms-ks-clamp-text.vue +66 -0
- package/src/components/fms-ks-clamp-text/images/icon-clamp.png +0 -0
- package/src/components/fms-ks-clamp-text/index.js +7 -0
- package/src/components/fms-ks-clamp-text//346/226/207/346/234/254/346/224/266/350/265/267/345/261/225/345/274/200.md +0 -0
- package/src/components/fms-ks-components/fms-ks-components.vue +699 -0
- package/src/components/fms-ks-components/index.js +7 -0
- package/src/components/fms-ks-components/money-directive.js +73 -0
- package/src/components/fms-ks-components//350/241/250/345/215/225/351/205/215/347/275/256/347/273/204/344/273/266/350/257/264/346/230/216.md +10 -0
- package/src/components/fms-ks-file-upload/fms-ks-file-upload.vue +8 -1
- package/src/components/fms-ks-form-grid/fields-conversion.js +107 -0
- package/src/components/fms-ks-form-grid/fms-ks-form-grid.vue +127 -0
- package/src/components/fms-ks-form-grid/index.js +7 -0
- package/src/components/fms-ks-more-lines/fms-ks-more-lines.vue +108 -0
- package/src/components/fms-ks-more-lines/index.js +7 -0
- package/src/components/fms-ks-more-lines//346/233/264/345/244/232.md +0 -0
- package/src/components/fms-ks-page-popup/fms-ks-page-popup.vue +153 -0
- package/src/components/fms-ks-page-popup/index.js +7 -0
- package/src/components/fms-ks-page-popup//345/274/271/345/207/272/345/261/202.md +0 -0
- package/src/components/fms-ks-picker/fms-ks-picker.vue +67 -0
- package/src/components/fms-ks-picker/index.js +7 -0
- package/src/components/fms-ks-picker//351/200/211/346/213/251/345/274/271/345/207/272/345/261/202.md +0 -0
- package/src/components/fms-ks-popover/click-outside.js +68 -0
- package/src/components/fms-ks-popover/fms-ks-popover.vue +89 -0
- package/src/components/fms-ks-popover/index.js +7 -0
- package/src/components/fms-ks-popover//345/274/271/345/207/272/345/261/202.md +0 -0
- package/src/components/fms-ks-search-tips/fms-ks-search-tips.vue +296 -0
- package/src/components/fms-ks-search-tips/index.js +7 -0
- package/src/components/fms-ks-search-tips//350/277/234/347/250/213/346/220/234/347/264/242.md +118 -0
- package/src/components/fms-ks-search-tips-new/fms-ks-search-tips-new.vue +242 -0
- package/src/components/fms-ks-search-tips-new/index.js +7 -0
- package/src/components/fms-ks-search-tips-new/style.less +137 -0
- package/src/components/fms-ks-search-tips-new//350/277/234/347/250/213/346/220/234/347/264/242-/346/226/260.md +118 -0
- package/src/components/fms-ks-select/fms-ks-select.vue +421 -0
- package/src/components/fms-ks-select/index.js +7 -0
- package/src/components/fms-ks-select//351/200/211/346/213/251/346/241/206.md +0 -0
- package/src/components/fms-ks-select-box/fms-ks-select-box.vue +84 -0
- package/src/components/fms-ks-select-box/index.js +7 -0
- package/src/components/fms-ks-select-box//344/270/215/351/234/200/350/246/201popup/347/232/204select.md +0 -0
- package/src/components/fms-ks-warn-drawer/fms-ks-warn-drawer.vue +111 -0
- package/src/components/fms-ks-warn-drawer/index.js +7 -0
- package/src/components/fms-ks-warn-drawer//351/242/204/350/255/246/346/217/220/347/244/272.md +0 -0
- package/src/components/ks-decrypt/README.md +140 -0
- package/src/components/ks-decrypt/index.vue +155 -0
- package/src/components/ks-popover/index.vue +483 -0
- package/src/components/ks-popover/mixin.js +28 -0
- package/src/components/ks-popover/utils.js +60 -0
- package/src/components/oa-datetime-picker/index.vue +169 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/README.md +21 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-picker-bottom.vue +121 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-picker-dropdown.vue +78 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-picker-right.vue +86 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-picker-top.vue +82 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-picker.js +12 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-range-select.vue +106 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-select.vue +66 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/date-week-month.vue +131 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/index.js +39 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/mixin.js +85 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/month-range-select.vue +127 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/month-select.vue +87 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/quarter-select.vue +95 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/style.less +117 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/utils.js +109 -0
- package/src/components/oa-datetime-picker-new/components/date-picker/week-select.vue +100 -0
- package/src/components/oa-datetime-picker-new/index.vue +212 -0
- package/src/index.js +8 -2
- package/vite.config.js +12 -1
- package/dist/fms-ks-decrypt.bcc12f44.js +0 -335
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// 旧版本的日期选择组件
|
|
2
|
+
// 09-15: 增加displayFormat属性可以自定义显示的格式,如果没传,默认根据type进行格式化,统一处理为/间隔
|
|
3
|
+
<template>
|
|
4
|
+
<div class="oa-datetime-picker">
|
|
5
|
+
<van-field readonly
|
|
6
|
+
name="datetimePicker"
|
|
7
|
+
input-align="right"
|
|
8
|
+
error-message-align="right"
|
|
9
|
+
:required="required"
|
|
10
|
+
:rules="[{ required: required, message: `请选择${label}` }]"
|
|
11
|
+
:value="displayValue"
|
|
12
|
+
:label="label"
|
|
13
|
+
v-bind="$attrs"
|
|
14
|
+
:placeholder="placeholder"
|
|
15
|
+
@click="show">
|
|
16
|
+
<template #label>
|
|
17
|
+
<slot name="label" />
|
|
18
|
+
</template>\
|
|
19
|
+
</van-field>
|
|
20
|
+
|
|
21
|
+
<van-popup v-model="showPicker"
|
|
22
|
+
get-container="body"
|
|
23
|
+
position="bottom">
|
|
24
|
+
<van-datetime-picker v-model="timeVal"
|
|
25
|
+
:type="type"
|
|
26
|
+
:formatter="formatter"
|
|
27
|
+
@confirm="onConfirm"
|
|
28
|
+
v-bind="$attrs"
|
|
29
|
+
@cancel="showPicker = false" />
|
|
30
|
+
</van-popup>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import moment from 'dayjs'
|
|
36
|
+
|
|
37
|
+
const DEFAULT_FORMATS = {
|
|
38
|
+
'year-month': 'YYYY/MM',
|
|
39
|
+
date: 'YYYY/MM/DD',
|
|
40
|
+
datetime: 'YYYY/MM/DD HH:mm',
|
|
41
|
+
// months: 'yyyy-MM',
|
|
42
|
+
// time: 'HH:mm:ss',
|
|
43
|
+
// week: 'yyyywWW',
|
|
44
|
+
// timerange: 'HH:mm:ss',
|
|
45
|
+
// daterange: 'yyyy-MM-dd',
|
|
46
|
+
// monthrange: 'yyyy-MM',
|
|
47
|
+
// datetimerange: 'yyyy-MM-dd HH:mm:ss',
|
|
48
|
+
// year: 'yyyy',
|
|
49
|
+
// years: 'yyyy'
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const formatAsFormatAndType = (value, customFormat, type) => {
|
|
53
|
+
if (!value) return null
|
|
54
|
+
const format = customFormat || DEFAULT_FORMATS[type]
|
|
55
|
+
return momentFormatUtil(value, format)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const momentFormatUtil = (value, format) => {
|
|
59
|
+
return moment(value).format(format)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
name: 'oa-datetime-picker',
|
|
64
|
+
props: {
|
|
65
|
+
type: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: 'datetime'
|
|
68
|
+
},
|
|
69
|
+
value: [String, Number],
|
|
70
|
+
label: String,
|
|
71
|
+
placeholder: String,
|
|
72
|
+
required: Boolean,
|
|
73
|
+
disabled: Boolean,
|
|
74
|
+
// 提交的数据格式是否需要为时间戳
|
|
75
|
+
isTimestamp: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
displayFormat: String // 显示的格式
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
// 用于页面显示的值
|
|
83
|
+
displayValue () {
|
|
84
|
+
console.log(formatAsFormatAndType)
|
|
85
|
+
const formattedValue = formatAsFormatAndType(this.parsedValue, this.displayFormat, this.type)
|
|
86
|
+
// return this.value.replace(/-/g, '/')
|
|
87
|
+
return formattedValue
|
|
88
|
+
},
|
|
89
|
+
// 兜底逻辑,支持更多的传入类型,不至于报错
|
|
90
|
+
parsedValue () {
|
|
91
|
+
if (!this.value) return this.value
|
|
92
|
+
// 兼容问题:这里不要用new Date(),IOS机型如果传入'2020-01',会变成invalid date
|
|
93
|
+
// return new Date(this.value)
|
|
94
|
+
return moment(this.value)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
data () {
|
|
98
|
+
return {
|
|
99
|
+
showPicker: false,
|
|
100
|
+
timeVal: new Date()
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
methods: {
|
|
104
|
+
show () {
|
|
105
|
+
// 禁用选择
|
|
106
|
+
if (this.disabled) {
|
|
107
|
+
return false
|
|
108
|
+
}
|
|
109
|
+
this.showPicker = true
|
|
110
|
+
},
|
|
111
|
+
formatter (type, val) {
|
|
112
|
+
if (type === 'year') {
|
|
113
|
+
return `${val}年`
|
|
114
|
+
} else if (type === 'month') {
|
|
115
|
+
return `${val}月`
|
|
116
|
+
} else if (type === 'day') {
|
|
117
|
+
return `${val}日`
|
|
118
|
+
} else if (type === 'hour') {
|
|
119
|
+
return `${val}时`
|
|
120
|
+
} else if (type === 'minute') {
|
|
121
|
+
return `${val}分`
|
|
122
|
+
}
|
|
123
|
+
return val
|
|
124
|
+
},
|
|
125
|
+
onConfirm () {
|
|
126
|
+
// 恢复之前的日期格式
|
|
127
|
+
let formatMap = [
|
|
128
|
+
{
|
|
129
|
+
label: 'year-month',
|
|
130
|
+
value: 'YYYY-MM'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
label: 'date',
|
|
134
|
+
value: 'YYYY-MM-DD'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'datetime',
|
|
138
|
+
value: 'YYYY-MM-DD HH:mm'
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
let format = formatMap.find(t => t.label === this.type) || {}
|
|
142
|
+
console.log('format---', format, this.timeVal, format.value)
|
|
143
|
+
// 这里不要修改父组件传进来的值,this.value
|
|
144
|
+
// const newValue = moment(this.timeVal).format(format ? format.value : 'YYYY-MM-DD HH:mm')
|
|
145
|
+
const newValue = momentFormatUtil(this.timeVal, format ? format.value : 'YYYY-MM-DD HH:mm')
|
|
146
|
+
console.log('newValue', newValue)
|
|
147
|
+
this.showPicker = false
|
|
148
|
+
this.$emit('input', this.isTimestamp ? new Date(newValue).getTime() : newValue)
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
}
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<style scoped lang="less">
|
|
155
|
+
.oa-datetime-picker {
|
|
156
|
+
.van-cell:after {
|
|
157
|
+
position: absolute;
|
|
158
|
+
content: " ";
|
|
159
|
+
pointer-events: none;
|
|
160
|
+
right: 0;
|
|
161
|
+
bottom: 0;
|
|
162
|
+
left: 16px;
|
|
163
|
+
right: 16px;
|
|
164
|
+
border-bottom: 1px solid #d9d9d9;
|
|
165
|
+
-webkit-transform: scaleY(0.5);
|
|
166
|
+
transform: scaleY(0.5);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## 日期选择组件
|
|
2
|
+
|
|
3
|
+
### 参数
|
|
4
|
+
参数名 | 类型 | 说明 | 可选值 | 默认值
|
|
5
|
+
--------|-----|--------|--------|--------
|
|
6
|
+
v-model | boolean | 是否显示 | true、false | false
|
|
7
|
+
horizontal | boolean | 是否横屏 | true、false | false
|
|
8
|
+
position | string | 弹出位置 | top、bottom、dropdown | bottom
|
|
9
|
+
top | number | position为dropdown时需传入距屏幕顶部高度 | |
|
|
10
|
+
default-value | date、number、string、array(范围) | 默认时间 | |
|
|
11
|
+
year-range | array | 可选时间年限范围 | |
|
|
12
|
+
min | date、number、string | 最小可选日期(月份) | |
|
|
13
|
+
max | date、number、string | 最大可选日期(月份) | |
|
|
14
|
+
showConfirm | boolean | 是否显示确认按钮 | true、false | true
|
|
15
|
+
type | string | 时间控件类型 | date、daterange、month、monthrange、week、quarter、dateweekmonth | date
|
|
16
|
+
|
|
17
|
+
### 事件
|
|
18
|
+
事件名 | 说明
|
|
19
|
+
-----------|--------
|
|
20
|
+
select | 选中日期或月份等触发,返回时间对象、范围选择返回数组
|
|
21
|
+
confirm | 点击确认按钮触发,返回时间对象、范围选择返回数组
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-popup :value="value"
|
|
3
|
+
position="bottom"
|
|
4
|
+
get-container="body"
|
|
5
|
+
class="ks-date-picker-bottom-popup"
|
|
6
|
+
duration="0.2"
|
|
7
|
+
:closeable="true"
|
|
8
|
+
:close-on-click-overlay="false"
|
|
9
|
+
@input="handleClosePopup"
|
|
10
|
+
@open="handleOpenPopup">
|
|
11
|
+
<div class="ks-date-picker ks-date-picker-bottom">
|
|
12
|
+
<div class="ks-date-picker-bottom__header">
|
|
13
|
+
<div class="ks-date-picker-bottom__header-title">
|
|
14
|
+
<span class="ks-date-picker-bottom__header-title-text">{{title}}</span>
|
|
15
|
+
<span class="ks-date-picker-bottom__header-title-start">{{startText}}</span>
|
|
16
|
+
<span v-show="type.includes('range') && startText"
|
|
17
|
+
class="ks-date-picker-bottom__header-title-split"> - </span>
|
|
18
|
+
<span v-show="type.includes('range') && startText"
|
|
19
|
+
class="ks-date-picker-bottom__header-title-end"
|
|
20
|
+
:class="{'ks-date-picker-bottom__header-title-end-not': startText && !endText}">
|
|
21
|
+
{{endText || (type === 'monthrange' ? '结束月份' : '结束时间')}}
|
|
22
|
+
</span>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="ks-date-picker__body">
|
|
26
|
+
<component ref="selector"
|
|
27
|
+
:is="currentCom"
|
|
28
|
+
v-bind="$attrs"
|
|
29
|
+
@select="handleSelect"
|
|
30
|
+
@change-type="changeType" />
|
|
31
|
+
</div>
|
|
32
|
+
<div v-if="showConfirm"
|
|
33
|
+
class="ks-date-picker-bottom__footer">
|
|
34
|
+
<van-button type="primary"
|
|
35
|
+
:disabled="!currentSelectedValue"
|
|
36
|
+
block
|
|
37
|
+
class="van-calendar__confirm"
|
|
38
|
+
@click="handleConfirm">确定</van-button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</van-popup>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import Mixins from './mixin.js'
|
|
46
|
+
|
|
47
|
+
const titleMap = {
|
|
48
|
+
'date': '日期选择',
|
|
49
|
+
'daterange': '日期选择',
|
|
50
|
+
'month': '月份选择',
|
|
51
|
+
'monthrange': '月份选择',
|
|
52
|
+
'week': '周选择',
|
|
53
|
+
'quarter': '季度选择',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
name: 'date-picker-bottom',
|
|
58
|
+
mixins: [Mixins],
|
|
59
|
+
data () {
|
|
60
|
+
return {
|
|
61
|
+
dateweekmonthType: 'date'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
computed: {
|
|
65
|
+
title () {
|
|
66
|
+
if (this.type === 'dateweekmonth') {
|
|
67
|
+
return titleMap[this.dateweekmonthType]
|
|
68
|
+
} else {
|
|
69
|
+
return titleMap[this.type]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
methods: {
|
|
74
|
+
changeType (e) {
|
|
75
|
+
this.dateweekmonthType = e
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<style lang="less">
|
|
82
|
+
@import url("./style.less");
|
|
83
|
+
.ks-date-picker-bottom-popup {
|
|
84
|
+
height: 82%;
|
|
85
|
+
border-radius: 6px 6px 0 0;
|
|
86
|
+
.ks-date-picker-bottom__footer {
|
|
87
|
+
height: auto;
|
|
88
|
+
padding: 16px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
.ipx {
|
|
92
|
+
.ks-date-picker-bottom__footer {
|
|
93
|
+
padding-bottom: 25px;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
.ks-date-picker-bottom {
|
|
97
|
+
height: 82vh;
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
&__header {
|
|
102
|
+
height: 54px;
|
|
103
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
104
|
+
box-shadow: 0 3px 8px 0 rgba(235, 235, 235, 0.3);
|
|
105
|
+
&-title {
|
|
106
|
+
position: relative;
|
|
107
|
+
.header-title-text(54px);
|
|
108
|
+
&-text {
|
|
109
|
+
font-size: 18px;
|
|
110
|
+
font-weight: bold;
|
|
111
|
+
position: absolute;
|
|
112
|
+
left: 16px;
|
|
113
|
+
color: #333;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
&__footer {
|
|
118
|
+
.footer-btn();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="value" ref="datepickerDropdown" class="ks-date-picker-dropdown-warpper" :style="{top: `${top}px`}">
|
|
3
|
+
<van-popup
|
|
4
|
+
:value="value"
|
|
5
|
+
position="top"
|
|
6
|
+
:overlay-style="{position: 'absolute'}"
|
|
7
|
+
:get-container="getContainer"
|
|
8
|
+
class="ks-date-picker-dropdown-popup"
|
|
9
|
+
duration="0.2"
|
|
10
|
+
:closeable="false"
|
|
11
|
+
:close-on-click-overlay="false"
|
|
12
|
+
@input="handleClosePopup"
|
|
13
|
+
@open="handleOpenPopup"
|
|
14
|
+
>
|
|
15
|
+
<div class="ks-date-picker ks-date-picker-dropdown">
|
|
16
|
+
<div class="ks-date-picker__body">
|
|
17
|
+
<component
|
|
18
|
+
ref="selector"
|
|
19
|
+
:is="currentCom"
|
|
20
|
+
v-bind="$attrs"
|
|
21
|
+
@select="handleSelect"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
<div v-if="showConfirm" class="ks-date-picker-dropdown__footer">
|
|
25
|
+
<van-button type="primary" :disabled="!currentSelectedValue" block class="van-calendar__confirm" @click="handleConfirm">确定</van-button>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</van-popup>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
import Mixins from './mixin.js'
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
name: 'date-picker-dropdown',
|
|
37
|
+
mixins: [Mixins],
|
|
38
|
+
props: {
|
|
39
|
+
top: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
getContainer () {
|
|
46
|
+
return this.$refs.datepickerDropdown
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style lang="less">
|
|
53
|
+
@import url("./style.less");
|
|
54
|
+
.ks-date-picker-dropdown-warpper {
|
|
55
|
+
position: fixed;
|
|
56
|
+
left: 0;
|
|
57
|
+
right: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
z-index: 10;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
}
|
|
62
|
+
.ks-date-picker-dropdown-popup {
|
|
63
|
+
position: absolute;
|
|
64
|
+
height: 88%;
|
|
65
|
+
.van-popup__close-icon--top-left {
|
|
66
|
+
top: 10px;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
.ks-date-picker-dropdown {
|
|
70
|
+
height: 100%;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
&__footer {
|
|
75
|
+
.footer-btn();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-popup
|
|
3
|
+
:value="value"
|
|
4
|
+
position="right"
|
|
5
|
+
get-container="body"
|
|
6
|
+
class="ks-date-picker-right-popup"
|
|
7
|
+
duration="0.2"
|
|
8
|
+
:closeable="true"
|
|
9
|
+
:close-on-click-overlay="false"
|
|
10
|
+
close-icon-position="top-left"
|
|
11
|
+
close-icon="arrow-left"
|
|
12
|
+
@input="handleClosePopup"
|
|
13
|
+
@open="handleOpenPopup"
|
|
14
|
+
>
|
|
15
|
+
<div class="ks-date-picker ks-date-picker-right">
|
|
16
|
+
<div class="ks-date-picker-right__header">
|
|
17
|
+
<div class="ks-date-picker-right__header-title">
|
|
18
|
+
<span class="ks-date-picker-right__header-title-start">{{startText}}</span>
|
|
19
|
+
<span v-show="type.includes('range') && startText" class="ks-date-picker-right__header-title-split"> - </span>
|
|
20
|
+
<span
|
|
21
|
+
v-show="type.includes('range') && startText"
|
|
22
|
+
class="ks-date-picker-right__header-title-end"
|
|
23
|
+
:class="{'ks-date-picker-right__header-title-end-not': startText && !endText}"
|
|
24
|
+
>
|
|
25
|
+
{{endText || (type === 'monthrange' ? '结束月份' : '结束时间')}}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="ks-date-picker__body">
|
|
30
|
+
<component
|
|
31
|
+
ref="selector"
|
|
32
|
+
:is="currentCom"
|
|
33
|
+
v-bind="$attrs"
|
|
34
|
+
@select="handleSelect"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
<div v-if="showConfirm" class="ks-date-picker-right__footer">
|
|
38
|
+
<van-button type="primary" :disabled="!currentSelectedValue" block class="van-calendar__confirm" @click="handleConfirm">确定</van-button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</van-popup>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import Mixins from './mixin.js'
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
name: 'date-picker-right',
|
|
49
|
+
mixins: [Mixins]
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<style lang="less">
|
|
54
|
+
@import url("./style.less");
|
|
55
|
+
.ks-date-picker-right-popup {
|
|
56
|
+
width: 70%;
|
|
57
|
+
.van-popup__close-icon--top-left {
|
|
58
|
+
top: 10px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
.ks-date-picker-right {
|
|
62
|
+
height: 100vh;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
&__header {
|
|
67
|
+
height: 40px;
|
|
68
|
+
width: 375px;
|
|
69
|
+
margin: 0 auto;
|
|
70
|
+
&-title {
|
|
71
|
+
.header-title-text();
|
|
72
|
+
box-shadow: 0 3px 10px 0 rgba(235,235,235,0.30);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
.ks-date-picker__body {
|
|
76
|
+
width: 375px;
|
|
77
|
+
margin: 0 auto;
|
|
78
|
+
}
|
|
79
|
+
&__footer {
|
|
80
|
+
height: 60px;
|
|
81
|
+
padding: 16px 80px 0 80px;
|
|
82
|
+
box-shadow: 0 0 4px 0 rgba(158,155,218,0.22);
|
|
83
|
+
z-index: 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-popup
|
|
3
|
+
:value="value"
|
|
4
|
+
position="top"
|
|
5
|
+
get-container="body"
|
|
6
|
+
class="ks-date-picker-top-popup"
|
|
7
|
+
duration="0.2"
|
|
8
|
+
:closeable="false"
|
|
9
|
+
:close-on-click-overlay="false"
|
|
10
|
+
close-icon-position="top-left"
|
|
11
|
+
close-icon="arrow-left"
|
|
12
|
+
@input="handleClosePopup"
|
|
13
|
+
@open="handleOpenPopup"
|
|
14
|
+
>
|
|
15
|
+
<div class="ks-date-picker ks-date-picker-top">
|
|
16
|
+
<div class="ks-date-picker-top__header">
|
|
17
|
+
<div class="ks-date-picker-top__header-title">
|
|
18
|
+
<span class="ks-date-picker-top__header-title-start">{{startText}}</span>
|
|
19
|
+
<span v-show="type.includes('range') && startText" class="ks-date-picker-top__header-title-split"> - </span>
|
|
20
|
+
<span
|
|
21
|
+
v-show="type.includes('range') && startText"
|
|
22
|
+
class="ks-date-picker-top__header-title-end"
|
|
23
|
+
:class="{'ks-date-picker-top__header-title-end-not': startText && !endText}"
|
|
24
|
+
>
|
|
25
|
+
{{endText || (type === 'monthrange' ? '结束月份' : '结束时间')}}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="ks-date-picker__body">
|
|
30
|
+
<component
|
|
31
|
+
ref="selector"
|
|
32
|
+
:is="currentCom"
|
|
33
|
+
v-bind="$attrs"
|
|
34
|
+
@select="handleSelect"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
<div v-if="showConfirm" class="ks-date-picker-top__footer">
|
|
38
|
+
<van-button type="primary" :disabled="!currentSelectedValue" block class="van-calendar__confirm" @click="handleConfirm">确定</van-button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</van-popup>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import Mixins from './mixin.js'
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
name: 'date-picker-top',
|
|
49
|
+
mixins: [Mixins]
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<style lang="less">
|
|
54
|
+
@import url("./style.less");
|
|
55
|
+
.ks-date-picker-top-popup {
|
|
56
|
+
height: 85%;
|
|
57
|
+
.van-popup__close-icon--top-left {
|
|
58
|
+
top: 10px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
.ks-date-picker-top {
|
|
62
|
+
height: 85vh;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
&__header {
|
|
67
|
+
height: 40px;
|
|
68
|
+
&-title {
|
|
69
|
+
.header-title-text();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
&__footer {
|
|
73
|
+
.footer-btn();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
.ios .ks-date-picker-top-popup {
|
|
77
|
+
padding-top: 20px;
|
|
78
|
+
}
|
|
79
|
+
.ipx .ks-date-picker-top-popup {
|
|
80
|
+
padding-top: 44px;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DatePickerBottom, DatePickerTop, DatePickerRight, DatePickerDropdown } from './index.js'
|
|
2
|
+
export default {
|
|
3
|
+
functional: true,
|
|
4
|
+
name: 'date-picker',
|
|
5
|
+
render (h, ctx) {
|
|
6
|
+
if (ctx.props.horizontal) {
|
|
7
|
+
return h(DatePickerRight, ctx.data)
|
|
8
|
+
} else {
|
|
9
|
+
return h(ctx.props.position === 'dropdown' ? DatePickerDropdown : ctx.props.position === 'top' ? DatePickerTop : DatePickerBottom, ctx.data)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-calendar class="ks-daterange-select"
|
|
3
|
+
:default-date="currentDate"
|
|
4
|
+
:poppable="false"
|
|
5
|
+
:show-confirm="false"
|
|
6
|
+
:show-title="false"
|
|
7
|
+
:show-subtitle="false"
|
|
8
|
+
:min-date="currentMin"
|
|
9
|
+
:max-date="currentMax"
|
|
10
|
+
:lazy-render="false"
|
|
11
|
+
:allow-same-day="true"
|
|
12
|
+
:safe-area-inset-bottom="true"
|
|
13
|
+
row-height="44"
|
|
14
|
+
type="range"
|
|
15
|
+
@select="handleSelect" />
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { formatToDate, formatToString } from './utils'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'date-range-select',
|
|
23
|
+
props: {
|
|
24
|
+
defaultValue: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: () => ([])
|
|
27
|
+
},
|
|
28
|
+
min: [String, Number, Date],
|
|
29
|
+
max: [String, Number, Date],
|
|
30
|
+
},
|
|
31
|
+
data () {
|
|
32
|
+
return {
|
|
33
|
+
currentDate: [],
|
|
34
|
+
currentMin: new Date(),
|
|
35
|
+
currentMax: new Date()
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
created () {
|
|
39
|
+
this.init()
|
|
40
|
+
this.handleSelect(this.currentDate)
|
|
41
|
+
|
|
42
|
+
// 重新定位一下选中日期
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
this.$nextTick(() => {
|
|
45
|
+
let top = this.$el.querySelector('.van-calendar__day--start')
|
|
46
|
+
if (top) {
|
|
47
|
+
top.scrollIntoView()
|
|
48
|
+
} else {
|
|
49
|
+
const end = this.$el.querySelector('.van-calendar__day--start-end')
|
|
50
|
+
end && end.scrollIntoView()
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
init () {
|
|
57
|
+
if (this.defaultValue.length) {
|
|
58
|
+
this.currentDate = [formatToDate(this.defaultValue[0]), formatToDate(this.defaultValue[1])]
|
|
59
|
+
}
|
|
60
|
+
if (!this.min) {
|
|
61
|
+
let _date = new Date()
|
|
62
|
+
let y = _date.getFullYear()
|
|
63
|
+
let m = _date.getMonth() + 1
|
|
64
|
+
this.currentMin = (m - 6) < 1 ? new Date(y - 1, 12 + m - 5, 1) : new Date(y, m - 5, 1)
|
|
65
|
+
} else {
|
|
66
|
+
this.currentMin = formatToDate(this.min)
|
|
67
|
+
}
|
|
68
|
+
if (!this.max) {
|
|
69
|
+
let _date = new Date()
|
|
70
|
+
let y = _date.getFullYear()
|
|
71
|
+
let m = _date.getMonth() + 1
|
|
72
|
+
this.currentMax = (m + 6) > 12 ? new Date(y + 1, m + 6 - 12, 0) : new Date(y, m + 6, 0)
|
|
73
|
+
} else {
|
|
74
|
+
this.currentMax = formatToDate(this.max)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
handleSelect (e) {
|
|
78
|
+
this.$emit('select', { date: e, str: [formatToString(e[0]), formatToString(e[1])] })
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style lang="less">
|
|
85
|
+
.ks-daterange-select {
|
|
86
|
+
.van-calendar__day {
|
|
87
|
+
margin: 3px 0;
|
|
88
|
+
}
|
|
89
|
+
.van-calendar__day--middle {
|
|
90
|
+
color: #7972fe !important;
|
|
91
|
+
&::after {
|
|
92
|
+
top: 0 !important;
|
|
93
|
+
bottom: 0 !important;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
.van-calendar__day--start,
|
|
97
|
+
.van-calendar__day--end {
|
|
98
|
+
margin-left: calc((14.285% - 44px) / 2);
|
|
99
|
+
margin-right: calc((14.285% - 44px) / 2);
|
|
100
|
+
}
|
|
101
|
+
.van-calendar__day--start-end {
|
|
102
|
+
margin-left: calc((14.285% - 54px) / 2);
|
|
103
|
+
margin-right: calc((14.285% - 54px) / 2);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</style>
|