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