sadais-piui 1.2.7-beta13 → 1.2.7-beta131

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.
Files changed (71) hide show
  1. package/.prettierrc +8 -0
  2. package/components/pi-badge/index.vue +11 -1
  3. package/components/pi-bottom-bar/index.vue +1 -1
  4. package/components/pi-calendar/index.vue +207 -182
  5. package/components/pi-calendar-input/index.vue +61 -30
  6. package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
  7. package/components/pi-calendar-panel/index.vue +28 -12
  8. package/components/pi-canvas/index.vue +8 -1
  9. package/components/pi-cascader/index.vue +601 -0
  10. package/components/pi-checkbox/index.vue +8 -4
  11. package/components/pi-checkbox-group/index.vue +12 -11
  12. package/components/pi-circle-progress/index.vue +108 -21
  13. package/components/pi-code-input/index.vue +11 -3
  14. package/components/pi-collapse/index.vue +124 -0
  15. package/components/pi-collapse-item/index.vue +360 -0
  16. package/components/pi-date-picker/index.vue +512 -391
  17. package/components/pi-date-picker-input/index.vue +61 -30
  18. package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
  19. package/components/pi-dropdown/index.vue +34 -19
  20. package/components/pi-dropdown-item/index.vue +70 -58
  21. package/components/pi-form-item/index.vue +99 -21
  22. package/components/pi-grid/index.vue +1 -1
  23. package/components/pi-grid-item/index.vue +4 -4
  24. package/components/pi-img/index.vue +275 -267
  25. package/components/pi-img-cropper/index.vue +110 -110
  26. package/components/pi-input/index.vue +95 -34
  27. package/components/pi-list-item/index.vue +1 -1
  28. package/components/pi-mask/index.vue +3 -1
  29. package/components/pi-pagination/index.vue +13 -0
  30. package/components/pi-popup/index.vue +4 -1
  31. package/components/pi-popup-select/index.vue +8 -1
  32. package/components/pi-radio/index.vue +12 -11
  33. package/components/pi-radio-group/index.vue +25 -5
  34. package/components/pi-regions-select/index.vue +6 -1
  35. package/components/pi-regions-select-input/index.vue +69 -31
  36. package/components/pi-search/index.vue +37 -2
  37. package/components/pi-section/index.vue +1 -1
  38. package/components/pi-select/index.vue +237 -22
  39. package/components/pi-select-input/index.vue +106 -41
  40. package/components/pi-stepper/index.vue +135 -121
  41. package/components/pi-steps/index.vue +115 -36
  42. package/components/pi-swiper/index.vue +22 -7
  43. package/components/pi-switch/index.vue +5 -1
  44. package/components/pi-table/index.vue +351 -0
  45. package/components/pi-tabs/index.vue +46 -10
  46. package/components/pi-tag/index.vue +488 -0
  47. package/components/pi-upload-img/index.vue +541 -37
  48. package/components/pi-webview/index.vue +95 -82
  49. package/config/actionSheet.js +0 -1
  50. package/config/calendarInput.js +2 -1
  51. package/config/calendarPanel.js +2 -1
  52. package/config/cascader.js +22 -0
  53. package/config/circleProgress.js +17 -10
  54. package/config/codeInput.js +2 -1
  55. package/config/collapse.js +7 -0
  56. package/config/collapseItem.js +11 -0
  57. package/config/datePicker.js +29 -24
  58. package/config/datePickerInput.js +2 -1
  59. package/config/dropdown.js +3 -1
  60. package/config/input.js +5 -3
  61. package/config/regionsSelectInput.js +2 -1
  62. package/config/select.js +13 -1
  63. package/config/selectInput.js +2 -1
  64. package/config/steps.js +1 -1
  65. package/config/table.js +9 -0
  66. package/config/tag.js +21 -0
  67. package/config/uploadImg.js +30 -11
  68. package/package.json +5 -2
  69. package/scss/common.scss +11 -14
  70. package/scss/icon/icon.scss +2 -1
  71. package/scss/mixin.scss +5 -5
@@ -1,10 +1,10 @@
1
1
  <!--
2
2
  * @Author: zhangzhenfei
3
3
  * @Date: 2022-06-28 16:53:54
4
- * @LastEditTime: 2022-07-01 10:01:43
4
+ * @LastEditTime: 2023-05-12 16:02:29
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description: 日历日期数据
7
- * @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-calendar-panel/components/calendar-days/index.vue
7
+ * @FilePath: /piui-awesome/src/piui/components/pi-calendar-panel/components/calendar-days/index.vue
8
8
  -->
9
9
 
10
10
  <template>
@@ -14,14 +14,18 @@
14
14
  :key="day.key"
15
15
  class="date-item"
16
16
  style="cursor: pointer;"
17
- :class="[{ 'pi-disabled': day.disabled || day.type === 'disabled' }, { range: day.range }]"
17
+ :class="[
18
+ { 'pi-disabled': day.disabled || day.type === 'disabled' },
19
+ { range: day.range },
20
+ { marked: day.marked }
21
+ ]"
18
22
  @tap.stop="handleSelectDate(day)"
19
23
  >
20
24
  <view class="pi-square">
21
25
  <view class="pi-rela date-item-inner">
22
26
  <view
23
27
  class="pi-w-100P pi-h-100P pi-flex-column-center pi-lh-28"
24
- :style="[day.rangeStyle, day.nowStyle, day.activeStyle]"
28
+ :style="[day.nowStyle, day.activeStyle, day.rangeStyle]"
25
29
  >
26
30
  <text>{{ day.date }}</text>
27
31
  <text v-if="day.tip" class=" pi-text-nowrap pi-fz-18 pi-mg-top-6">
@@ -152,6 +156,12 @@ export default {
152
156
  type: Boolean,
153
157
  // '是否显示周视图'
154
158
  default: calendarPanel.defalutWeekView
159
+ },
160
+ // 日期标记,数组形式,默认([])
161
+ marks: {
162
+ type: Array,
163
+ // []
164
+ default: () => calendarPanel.marks
155
165
  }
156
166
  },
157
167
  data() {
@@ -174,7 +184,7 @@ export default {
174
184
  }
175
185
  return new Date(year, month, '0')
176
186
  },
177
- getNexMonthFirstDay() {
187
+ getNextMonthFirstDay() {
178
188
  let year = this.year
179
189
  let month = this.month + 1
180
190
  if (month === 13) {
@@ -188,7 +198,7 @@ export default {
188
198
  const firstDays = []
189
199
  const preMonthLastDay = this.getPreMonthLastDay
190
200
  const lastDay = preMonthLastDay.getDate()
191
- const firstDay = new Date(`${this.year}/${this.month}/01 00:00:00`).getDay()
201
+ const firstDay = new Date(this.year, this.month - 1, '1').getDay()
192
202
  for (let i = 0; i < firstDay; i++) {
193
203
  const day = preMonthLastDay.setDate(lastDay - firstDay + i + 1)
194
204
  firstDays.push(new Date(day))
@@ -201,16 +211,21 @@ export default {
201
211
  getMaxDate() {
202
212
  return this.maxDate ? this.$pi.date.parseDate(this.maxDate) : ''
203
213
  },
214
+ getMarks() {
215
+ return this.marks.map(item => {
216
+ return this.$pi.date.parseDate(item)
217
+ })
218
+ },
204
219
  // 总天数
205
220
  days() {
206
221
  const days = []
207
222
  const dayCount = 7 * 6 // 固定显示6周
208
223
  const monthDays = new Date(this.year, this.month, 0).getDate()
209
224
  const firstDayCount = this.firstDay.length
210
- const nextMonthFirstDay = this.getNexMonthFirstDay
225
+ const nextMonthFirstDay = this.getNextMonthFirstDay
211
226
  for (let i = 1; i <= dayCount; i++) {
212
227
  let day = {
213
- key: 'pi-calander-day-item-' + i,
228
+ key: this.$pi.guid(),
214
229
  index: i
215
230
  }
216
231
 
@@ -234,52 +249,62 @@ export default {
234
249
  // 当月数据
235
250
  day = {
236
251
  ...day,
237
- ...this.$pi.date.parseDate(`${this.year}/${this.month}/${i - firstDayCount}`)
252
+ ...this.$pi.date.parseDate(new Date(this.year, this.month - 1, i - firstDayCount))
238
253
  }
239
- const isDisabled = this.isDisabled(day)
240
- // 禁用
241
- if (isDisabled) {
242
- day.disabled = true
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
243
266
  }
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
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
252
283
  }
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
- }
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
283
308
  }
284
309
  }
285
310
  // 当天样式
@@ -337,7 +362,7 @@ export default {
337
362
  return
338
363
  }
339
364
  // 处理范围选择方式
340
- if (this.calendarValue.length === 2) {
365
+ if (this.calendarValue.length === 0 || this.calendarValue.length === 2) {
341
366
  // 如果选了两项,则重新开始选择范围
342
367
  this.handleChange([date])
343
368
  } else {
@@ -359,6 +384,20 @@ export default {
359
384
  z-index: 2;
360
385
  width: calc(100% / 7);
361
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
+ }
362
401
  .date-item-inner {
363
402
  padding: 8rpx;
364
403
  }
@@ -60,6 +60,7 @@
60
60
  :end-text="endText"
61
61
  :week-view="weekView"
62
62
  :show-back-today="showBackToday"
63
+ :marks="marks"
63
64
  @change="handleChange"
64
65
  />
65
66
  </swiper-item>
@@ -219,14 +220,20 @@ export default {
219
220
  type: Boolean,
220
221
  // true
221
222
  default: calendarPanel.defalutWeekView
223
+ },
224
+ // 日期标记,数组形式,默认([])
225
+ marks: {
226
+ type: Array,
227
+ // []
228
+ default: () => calendarPanel.marks
222
229
  }
223
230
  },
224
231
  data() {
225
232
  const now = this.$pi.date.parseDate()
226
233
  return {
227
234
  now: now, // 当前时间
228
- year: '', // 年份
229
- month: '', // 月份
235
+ year: now.year, // 年份
236
+ month: now.month, // 月份
230
237
  week: 1, // 当前周
231
238
  calendarValue: '',
232
239
  currentTabIndex: 1, // 当前选中的tab索引
@@ -271,24 +278,25 @@ export default {
271
278
  this.init()
272
279
  },
273
280
  methods: {
274
- valid() {
275
- if (this.type === 'date') return true
276
- if (this.type === 'range' && this.$pi.lang.isArray(this.value) && this.value.length === 2)
277
- return true
278
- return false
279
- },
280
281
  init() {
281
282
  console.log(TAG, '组件初始化', this.value)
282
- if (!this.valid()) return
283
283
  let initValue = this.value
284
284
  const nowDate = this.$pi.date.parseDate(this.type === 'date' ? this.value : this.value[0])
285
285
  if (this.type === 'range') {
286
- const endDate = this.$pi.date.parseDate(this.value[1])
287
- if (this.year !== endDate.year && this.month !== endDate.month) {
286
+ initValue = initValue || []
287
+ if (this.value[1]) {
288
+ const endDate = this.$pi.date.parseDate(this.value[1])
289
+
290
+ this.year = endDate.year
291
+ this.month = endDate.month
292
+
293
+ initValue = [nowDate, endDate]
294
+ } else if (initValue.length === 1) {
295
+ initValue = [nowDate]
296
+
288
297
  this.year = nowDate.year
289
298
  this.month = nowDate.month
290
299
  }
291
- initValue = [nowDate, endDate]
292
300
  } else {
293
301
  this.year = nowDate.year
294
302
  this.month = nowDate.month
@@ -340,6 +348,10 @@ export default {
340
348
  } else {
341
349
  this.month = month
342
350
  }
351
+ this.$emit('date-change', {
352
+ year: this.year,
353
+ month: this.month
354
+ })
343
355
  },
344
356
  handlePrevMonth() {
345
357
  if (this.currentTabIndex === 0) {
@@ -361,6 +373,10 @@ export default {
361
373
  if (change > 0 && this.isMaxYear) return
362
374
  if (change < 0 && this.isMinYear) return
363
375
  this.year = this.year + change
376
+ this.$emit('date-change', {
377
+ year: this.year,
378
+ month: this.month
379
+ })
364
380
  },
365
381
  handleBackToday() {
366
382
  this.year = this.now.year
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view ref="root" :class="[customClass, 'wrapper']" :style="[customStyle]">
2
+ <view ref="root" :class="['wrapper',customClass, {disabled}]" :style="[customStyle]">
3
3
  <canvas
4
4
  ref="canvas"
5
5
  :style="[canvasStyle]"
@@ -72,6 +72,10 @@ export default {
72
72
  type: Number,
73
73
  // `1`
74
74
  default: 1
75
+ },
76
+ disabled: {
77
+ type: Boolean,
78
+ default: false
75
79
  }
76
80
  },
77
81
  data() {
@@ -385,6 +389,9 @@ export default {
385
389
  width: 100%;
386
390
  height: 100%;
387
391
  border: 1px solid #aaaaaa;
392
+ &.disabled {
393
+ pointer-events: none;
394
+ }
388
395
  }
389
396
 
390
397
  .content {