sadais-piui 1.2.7-beta2 → 1.2.7-beta22
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/components/pi-calendar-panel/components/calendar-days/index.vue +371 -0
- package/components/pi-calendar-panel/index.vue +173 -151
- package/components/pi-checkbox/index.vue +2 -2
- package/components/pi-checkbox-group/index.vue +4 -0
- package/components/pi-circle-progress/index.vue +65 -9
- package/components/pi-collapse/index.vue +114 -0
- package/components/pi-collapse-item/index.vue +347 -0
- package/components/pi-date-picker/index.vue +20 -6
- package/components/pi-dropdown/components/dropdown-tab.vue +33 -24
- package/components/pi-dropdown/index.vue +39 -20
- package/components/pi-dropdown-item/index.vue +15 -8
- package/components/pi-form/index.vue +5 -4
- package/components/pi-form-item/index.vue +4 -1
- package/components/pi-input/index.vue +2 -2
- package/components/pi-radio/index.vue +2 -2
- package/components/pi-radio-group/index.vue +4 -0
- package/components/pi-steps/index.vue +85 -33
- package/components/pi-tabs/index.vue +4 -3
- package/components/pi-tag/index.vue +488 -0
- package/config/calendarPanel.js +3 -1
- package/config/circleProgress.js +7 -8
- package/config/collapse.js +7 -0
- package/config/collapseItem.js +11 -0
- package/config/datePicker.js +1 -0
- package/config/dropdown.js +3 -1
- package/config/steps.js +1 -1
- package/config/tag.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: zhangzhenfei
|
|
3
|
+
* @Date: 2022-06-28 16:53:54
|
|
4
|
+
* @LastEditTime: 2022-07-01 10:01:43
|
|
5
|
+
* @LastEditors: zhangzhenfei
|
|
6
|
+
* @Description: 日历日期数据
|
|
7
|
+
* @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-calendar-panel/components/calendar-days/index.vue
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<view class="pi-rela pi-align-center pi-flex-wrap pi-pd-24">
|
|
12
|
+
<view
|
|
13
|
+
v-for="day in days"
|
|
14
|
+
:key="day.key"
|
|
15
|
+
class="date-item"
|
|
16
|
+
style="cursor: pointer;"
|
|
17
|
+
:class="[{ 'pi-disabled': day.disabled || day.type === 'disabled' }, { range: day.range }]"
|
|
18
|
+
@tap.stop="handleSelectDate(day)"
|
|
19
|
+
>
|
|
20
|
+
<view class="pi-square">
|
|
21
|
+
<view class="pi-rela date-item-inner">
|
|
22
|
+
<view
|
|
23
|
+
class="pi-w-100P pi-h-100P pi-flex-column-center pi-lh-28"
|
|
24
|
+
:style="[day.rangeStyle, day.nowStyle, day.activeStyle]"
|
|
25
|
+
>
|
|
26
|
+
<text>{{ day.date }}</text>
|
|
27
|
+
<text v-if="day.tip" class=" pi-text-nowrap pi-fz-18 pi-mg-top-6">
|
|
28
|
+
{{ day.tip }}
|
|
29
|
+
</text>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
<!-- 日历蒙层 -->
|
|
35
|
+
<view
|
|
36
|
+
class="pi-abso-center pi-fw-500 pi-light-gray pi-text-nowrap"
|
|
37
|
+
style="
|
|
38
|
+
z-index: -1;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
opacity: 0.15;"
|
|
41
|
+
:style="[
|
|
42
|
+
{ fontSize: weekView ? '32rpx' : '300rpx' },
|
|
43
|
+
{ marginTop: weekView ? '30rpx' : '0' }
|
|
44
|
+
]"
|
|
45
|
+
>
|
|
46
|
+
{{ getBgTip }}
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
import { getConfig } from '../../../../config'
|
|
53
|
+
const { calendarPanel } = getConfig()
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
name: 'PiCalendarDays',
|
|
57
|
+
props: {
|
|
58
|
+
calendarValue: {
|
|
59
|
+
type: [String, Object, Array],
|
|
60
|
+
default: ''
|
|
61
|
+
},
|
|
62
|
+
year: {
|
|
63
|
+
type: [String, Number],
|
|
64
|
+
default: ''
|
|
65
|
+
},
|
|
66
|
+
month: {
|
|
67
|
+
type: [String, Number],
|
|
68
|
+
default: ''
|
|
69
|
+
},
|
|
70
|
+
// 当前展示周
|
|
71
|
+
week: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: 0
|
|
74
|
+
},
|
|
75
|
+
// 日历类型
|
|
76
|
+
type: {
|
|
77
|
+
// `'date'-单个日期`, `'range'-范围日期`
|
|
78
|
+
type: String,
|
|
79
|
+
// 'date'
|
|
80
|
+
default: calendarPanel.type,
|
|
81
|
+
validator: function(value) {
|
|
82
|
+
return ['date', 'range'].includes(value)
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
// 最小可选日期(不在范围内日期禁用不可选,默认'',不作限制)
|
|
86
|
+
minDate: {
|
|
87
|
+
type: [Number, String, Date],
|
|
88
|
+
// ''
|
|
89
|
+
default: calendarPanel.minDate
|
|
90
|
+
},
|
|
91
|
+
// 最大可选日期(不在范围内日期禁用不可选,默认'',不作限制)
|
|
92
|
+
maxDate: {
|
|
93
|
+
type: [Number, String, Date],
|
|
94
|
+
// ''
|
|
95
|
+
default: calendarPanel.maxDate
|
|
96
|
+
},
|
|
97
|
+
// 是否显示回到今日
|
|
98
|
+
showBackToday: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
// true
|
|
101
|
+
default: calendarPanel.showBackToday
|
|
102
|
+
},
|
|
103
|
+
// 今日日期激活边框颜色
|
|
104
|
+
todayActiveBorderColor: {
|
|
105
|
+
type: String,
|
|
106
|
+
// '#ff6a00'
|
|
107
|
+
default: calendarPanel.todayActiveBorderColor
|
|
108
|
+
},
|
|
109
|
+
// 选中|起始结束日期字体颜色
|
|
110
|
+
activeColor: {
|
|
111
|
+
type: String,
|
|
112
|
+
// '#ffffff'
|
|
113
|
+
default: calendarPanel.activeColor
|
|
114
|
+
},
|
|
115
|
+
// 选中|起始结束日期背景,默认
|
|
116
|
+
activeBg: {
|
|
117
|
+
type: String,
|
|
118
|
+
// '#ff6a00'
|
|
119
|
+
default: calendarPanel.activeBg
|
|
120
|
+
},
|
|
121
|
+
// 选中圆角效果
|
|
122
|
+
activeBorderRadius: {
|
|
123
|
+
type: [String, Number],
|
|
124
|
+
// '0 0 0 0'
|
|
125
|
+
default: calendarPanel.activeBorderRadius
|
|
126
|
+
},
|
|
127
|
+
// 范围内日期字体颜色默认
|
|
128
|
+
rangeColor: {
|
|
129
|
+
type: String,
|
|
130
|
+
// '#ff6a00'
|
|
131
|
+
default: calendarPanel.rangeColor
|
|
132
|
+
},
|
|
133
|
+
// 范围内日期背景色
|
|
134
|
+
rangeBg: {
|
|
135
|
+
type: String,
|
|
136
|
+
// 'rgba(254, 106, 0, 0.1)'
|
|
137
|
+
default: calendarPanel.rangeBg
|
|
138
|
+
},
|
|
139
|
+
// type=range时生效,起始日期自定义文案
|
|
140
|
+
startText: {
|
|
141
|
+
type: String,
|
|
142
|
+
// '开始'
|
|
143
|
+
default: calendarPanel.startText
|
|
144
|
+
},
|
|
145
|
+
// type=range时生效,结束日期自定义文案
|
|
146
|
+
endText: {
|
|
147
|
+
type: String,
|
|
148
|
+
// '结束'
|
|
149
|
+
default: calendarPanel.endText
|
|
150
|
+
},
|
|
151
|
+
weekView: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
// '是否显示周视图'
|
|
154
|
+
default: calendarPanel.defalutWeekView
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
data() {
|
|
158
|
+
const now = this.$pi.date.parseDate()
|
|
159
|
+
return {
|
|
160
|
+
now: now // 当前时间
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
computed: {
|
|
164
|
+
getActiveBorderRadius() {
|
|
165
|
+
return this.$pi.common.addUnit(this.activeBorderRadius)
|
|
166
|
+
},
|
|
167
|
+
// 获取上个月最后一天
|
|
168
|
+
getPreMonthLastDay() {
|
|
169
|
+
let year = this.year
|
|
170
|
+
let month = this.month - 1
|
|
171
|
+
if (month === 0) {
|
|
172
|
+
year = year - 1
|
|
173
|
+
month = 12
|
|
174
|
+
}
|
|
175
|
+
return new Date(year, month, '0')
|
|
176
|
+
},
|
|
177
|
+
getNexMonthFirstDay() {
|
|
178
|
+
let year = this.year
|
|
179
|
+
let month = this.month + 1
|
|
180
|
+
if (month === 13) {
|
|
181
|
+
year = year + 1
|
|
182
|
+
month = 1
|
|
183
|
+
}
|
|
184
|
+
return new Date(year, month - 1, '1')
|
|
185
|
+
},
|
|
186
|
+
// 第一天
|
|
187
|
+
firstDay() {
|
|
188
|
+
const firstDays = []
|
|
189
|
+
const preMonthLastDay = this.getPreMonthLastDay
|
|
190
|
+
const lastDay = preMonthLastDay.getDate()
|
|
191
|
+
const firstDay = new Date(`${this.year}/${this.month}/01 00:00:00`).getDay()
|
|
192
|
+
for (let i = 0; i < firstDay; i++) {
|
|
193
|
+
const day = preMonthLastDay.setDate(lastDay - firstDay + i + 1)
|
|
194
|
+
firstDays.push(new Date(day))
|
|
195
|
+
}
|
|
196
|
+
return firstDays
|
|
197
|
+
},
|
|
198
|
+
getMinDate() {
|
|
199
|
+
return this.minDate ? this.$pi.date.parseDate(this.minDate) : ''
|
|
200
|
+
},
|
|
201
|
+
getMaxDate() {
|
|
202
|
+
return this.maxDate ? this.$pi.date.parseDate(this.maxDate) : ''
|
|
203
|
+
},
|
|
204
|
+
// 总天数
|
|
205
|
+
days() {
|
|
206
|
+
const days = []
|
|
207
|
+
const dayCount = 7 * 6 // 固定显示6周
|
|
208
|
+
const monthDays = new Date(this.year, this.month, 0).getDate()
|
|
209
|
+
const firstDayCount = this.firstDay.length
|
|
210
|
+
const nextMonthFirstDay = this.getNexMonthFirstDay
|
|
211
|
+
for (let i = 1; i <= dayCount; i++) {
|
|
212
|
+
let day = {
|
|
213
|
+
key: 'pi-calander-day-item-' + i,
|
|
214
|
+
index: i
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 上月数据
|
|
218
|
+
if (i <= firstDayCount) {
|
|
219
|
+
day = {
|
|
220
|
+
...day,
|
|
221
|
+
...this.$pi.date.parseDate(this.firstDay[i - 1]),
|
|
222
|
+
type: this.weekView ? '' : 'disabled'
|
|
223
|
+
}
|
|
224
|
+
} else if (i > monthDays + firstDayCount) {
|
|
225
|
+
// 下月数据
|
|
226
|
+
day = {
|
|
227
|
+
...day,
|
|
228
|
+
...this.$pi.date.parseDate(
|
|
229
|
+
new Date(nextMonthFirstDay.setDate(i - monthDays - firstDayCount))
|
|
230
|
+
),
|
|
231
|
+
type: this.weekView ? '' : 'disabled'
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
// 当月数据
|
|
235
|
+
day = {
|
|
236
|
+
...day,
|
|
237
|
+
...this.$pi.date.parseDate(`${this.year}/${this.month}/${i - firstDayCount}`)
|
|
238
|
+
}
|
|
239
|
+
const isDisabled = this.isDisabled(day)
|
|
240
|
+
// 禁用
|
|
241
|
+
if (isDisabled) {
|
|
242
|
+
day.disabled = true
|
|
243
|
+
}
|
|
244
|
+
// 单选选中样式
|
|
245
|
+
if (this.type === 'date' && this.isSameDay(this.calendarValue, day)) {
|
|
246
|
+
const activeStyle = {
|
|
247
|
+
color: this.activeColor,
|
|
248
|
+
borderRadius: this.getActiveBorderRadius
|
|
249
|
+
}
|
|
250
|
+
if (this.activeBg) activeStyle.background = this.activeBg
|
|
251
|
+
day.activeStyle = activeStyle
|
|
252
|
+
}
|
|
253
|
+
// 范围选中样式
|
|
254
|
+
if (this.type === 'range') {
|
|
255
|
+
const start = this.calendarValue[0]
|
|
256
|
+
const end = this.calendarValue[1]
|
|
257
|
+
const isBegin = this.isSameDay(start, day)
|
|
258
|
+
const isEnd = this.isSameDay(end, day)
|
|
259
|
+
const inRange =
|
|
260
|
+
start && end && day.timestamp > start.timestamp && day.timestamp < end.timestamp
|
|
261
|
+
const rangeStyle = {}
|
|
262
|
+
// 处理中间范围的样式
|
|
263
|
+
if (inRange) {
|
|
264
|
+
rangeStyle.color = this.rangeColor
|
|
265
|
+
rangeStyle.background = this.rangeBg
|
|
266
|
+
}
|
|
267
|
+
// 处理两端
|
|
268
|
+
if (isBegin || isEnd) {
|
|
269
|
+
rangeStyle.color = this.activeColor
|
|
270
|
+
rangeStyle.borderRadius = isBegin
|
|
271
|
+
? `${this.getActiveBorderRadius} 0 0 0`
|
|
272
|
+
: `0 0 ${this.getActiveBorderRadius} 0`
|
|
273
|
+
if (this.activeBg) rangeStyle.background = this.activeBg
|
|
274
|
+
}
|
|
275
|
+
day.range = true
|
|
276
|
+
day.rangeStyle = rangeStyle
|
|
277
|
+
// type 为 range 开始和结束的提示
|
|
278
|
+
if (isBegin) day.tip = this.startText
|
|
279
|
+
if (isEnd) day.tip = this.endText
|
|
280
|
+
if (isBegin && isEnd) {
|
|
281
|
+
day.tip = this.startText + '-' + this.endText
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// 当天样式
|
|
286
|
+
if (this.isSameDay(this.now, day)) {
|
|
287
|
+
day.today = true
|
|
288
|
+
if (this.showBackToday) {
|
|
289
|
+
day.nowStyle = {
|
|
290
|
+
color: this.todayActiveBorderColor,
|
|
291
|
+
border: '1px solid ' + this.todayActiveBorderColor,
|
|
292
|
+
borderRadius: this.getActiveBorderRadius
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
days.push(day)
|
|
297
|
+
}
|
|
298
|
+
if (this.weekView) {
|
|
299
|
+
days.splice(0, (this.week - 1) * 7)
|
|
300
|
+
days.splice(7, days.length - 7)
|
|
301
|
+
}
|
|
302
|
+
return days
|
|
303
|
+
},
|
|
304
|
+
getBgTip() {
|
|
305
|
+
if (!this.days.length) return ''
|
|
306
|
+
const startDay = this.days[0]
|
|
307
|
+
const endDay = this.days[this.days.length - 1]
|
|
308
|
+
return this.weekView
|
|
309
|
+
? `${startDay.month}月 ${startDay.date}日 - ${endDay.month}月 ${endDay.date}日`
|
|
310
|
+
: this.month
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
methods: {
|
|
314
|
+
isSameDay(day1, day2) {
|
|
315
|
+
return (
|
|
316
|
+
day1 &&
|
|
317
|
+
day2 &&
|
|
318
|
+
day1.year === day2.year &&
|
|
319
|
+
day1.month === day2.month &&
|
|
320
|
+
day1.date === day2.date
|
|
321
|
+
)
|
|
322
|
+
},
|
|
323
|
+
isDisabled(day) {
|
|
324
|
+
const isDisabled =
|
|
325
|
+
(this.getMinDate && day.timestamp < this.getMinDate.timestamp) ||
|
|
326
|
+
(this.getMaxDate && day.timestamp > this.getMaxDate.timestamp)
|
|
327
|
+
return isDisabled
|
|
328
|
+
},
|
|
329
|
+
handleChange(value) {
|
|
330
|
+
this.$emit('change', value)
|
|
331
|
+
},
|
|
332
|
+
handleSelectDate(date) {
|
|
333
|
+
if (date.disabled) return
|
|
334
|
+
if (this.type === 'date') {
|
|
335
|
+
// 单选方式
|
|
336
|
+
this.handleChange(date)
|
|
337
|
+
return
|
|
338
|
+
}
|
|
339
|
+
// 处理范围选择方式
|
|
340
|
+
if (this.calendarValue.length === 2) {
|
|
341
|
+
// 如果选了两项,则重新开始选择范围
|
|
342
|
+
this.handleChange([date])
|
|
343
|
+
} else {
|
|
344
|
+
// 和第一项判断大小,小的放前面
|
|
345
|
+
if (date.timestamp > this.calendarValue[0].timestamp) {
|
|
346
|
+
this.handleChange([this.calendarValue[0], date])
|
|
347
|
+
} else {
|
|
348
|
+
this.handleChange([date, this.calendarValue[0]])
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
</script>
|
|
355
|
+
|
|
356
|
+
<style lang="scss" scoped>
|
|
357
|
+
.date-item {
|
|
358
|
+
position: relative;
|
|
359
|
+
z-index: 2;
|
|
360
|
+
width: calc(100% / 7);
|
|
361
|
+
overflow: hidden;
|
|
362
|
+
.date-item-inner {
|
|
363
|
+
padding: 8rpx;
|
|
364
|
+
}
|
|
365
|
+
&.range {
|
|
366
|
+
.date-item-inner {
|
|
367
|
+
padding: 6rpx 0rpx;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
</style>
|