sadais-piui 1.2.7-beta15 → 1.2.7-beta151

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 (75) hide show
  1. package/.prettierrc +8 -0
  2. package/components/pi-action-sheet/index.vue +260 -247
  3. package/components/pi-badge/index.vue +11 -1
  4. package/components/pi-bottom-bar/index.vue +1 -1
  5. package/components/pi-calendar/index.vue +207 -182
  6. package/components/pi-calendar-input/index.vue +61 -30
  7. package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
  8. package/components/pi-calendar-panel/index.vue +28 -12
  9. package/components/pi-canvas/index.vue +8 -1
  10. package/components/pi-cascader/index.vue +601 -0
  11. package/components/pi-checkbox/index.vue +8 -4
  12. package/components/pi-checkbox-group/index.vue +12 -11
  13. package/components/pi-circle-progress/index.vue +53 -16
  14. package/components/pi-code-input/index.vue +11 -3
  15. package/components/pi-collapse/index.vue +16 -6
  16. package/components/pi-collapse-item/index.vue +35 -22
  17. package/components/pi-date-picker/index.vue +512 -391
  18. package/components/pi-date-picker-input/index.vue +61 -30
  19. package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
  20. package/components/pi-dropdown/index.vue +34 -19
  21. package/components/pi-dropdown-item/index.vue +70 -58
  22. package/components/pi-form-item/index.vue +98 -20
  23. package/components/pi-grid/index.vue +1 -1
  24. package/components/pi-grid-item/index.vue +4 -4
  25. package/components/pi-img/index.vue +275 -267
  26. package/components/pi-img-cropper/index.vue +6 -3
  27. package/components/pi-input/index.vue +97 -36
  28. package/components/pi-list-item/index.vue +1 -1
  29. package/components/pi-marquee/index.vue +322 -310
  30. package/components/pi-marquee-pure-css/index.vue +267 -0
  31. package/components/pi-mask/index.vue +3 -1
  32. package/components/pi-modal/index.vue +311 -303
  33. package/components/pi-pagination/index.vue +13 -0
  34. package/components/pi-picker/index.vue +332 -317
  35. package/components/pi-popup/index.vue +4 -1
  36. package/components/pi-popup-select/index.vue +13 -4
  37. package/components/pi-radio/index.vue +12 -11
  38. package/components/pi-radio-group/index.vue +25 -5
  39. package/components/pi-regions-select/index.vue +6 -1
  40. package/components/pi-regions-select-input/index.vue +69 -31
  41. package/components/pi-search/index.vue +37 -2
  42. package/components/pi-section/index.vue +1 -1
  43. package/components/pi-select/index.vue +237 -22
  44. package/components/pi-select-input/index.vue +106 -41
  45. package/components/pi-stepper/index.vue +135 -121
  46. package/components/pi-steps/index.vue +115 -36
  47. package/components/pi-swiper/index.vue +22 -7
  48. package/components/pi-switch/index.vue +5 -1
  49. package/components/pi-table/index.vue +351 -0
  50. package/components/pi-tabs/index.vue +46 -10
  51. package/components/pi-upload-img/index.vue +895 -44
  52. package/components/pi-webview/index.vue +95 -82
  53. package/config/actionSheet.js +0 -1
  54. package/config/calendarInput.js +2 -1
  55. package/config/calendarPanel.js +2 -1
  56. package/config/cascader.js +22 -0
  57. package/config/circleProgress.js +12 -4
  58. package/config/codeInput.js +2 -1
  59. package/config/datePicker.js +29 -24
  60. package/config/datePickerInput.js +2 -1
  61. package/config/dropdown.js +3 -1
  62. package/config/input.js +5 -3
  63. package/config/marqueePureCss.js +18 -0
  64. package/config/regionsSelectInput.js +2 -1
  65. package/config/select.js +13 -1
  66. package/config/selectInput.js +2 -1
  67. package/config/steps.js +1 -1
  68. package/config/table.js +9 -0
  69. package/config/uploadImg.js +33 -11
  70. package/mixin/emitter.js +8 -1
  71. package/mixin/value-sync.js +5 -0
  72. package/package.json +5 -2
  73. package/scss/common.scss +11 -14
  74. package/scss/icon/icon.scss +2 -1
  75. package/scss/mixin.scss +5 -5
@@ -12,7 +12,12 @@
12
12
  :style="[computedLabelStyle, getLabelStyle]"
13
13
  :class="[{ border: getWrap && getLabelWrapBorder }]"
14
14
  >
15
- <view v-if="required" style="color: #ed2235;" class="pi-mg-right-12" :style="[requiredStyle]">
15
+ <view
16
+ v-if="required"
17
+ style="color: #ed2235;"
18
+ class="pi-mg-right-12"
19
+ :style="[requiredStyle]"
20
+ >
16
21
  *
17
22
  </view>
18
23
  <!-- 表单项label -->
@@ -28,7 +33,11 @@
28
33
  :class="[
29
34
  { 'pi-flex-sub': !getWrap },
30
35
  getInputAlign,
31
- { 'wrap': getWrap, 'nowrap': !getWrap, 'wrap-bottom': getWrap && getWrapBottomGap }
36
+ {
37
+ 'wrap': getWrap,
38
+ 'nowrap': !getWrap,
39
+ 'wrap-bottom': getWrap && getWrapBottomGap
40
+ }
32
41
  ]"
33
42
  :style="[contentWrapStyle]"
34
43
  >
@@ -41,7 +50,11 @@
41
50
  <slot />
42
51
  </view>
43
52
  <view
44
- v-if="getErrorType === 'message' && validateState === 'error' && validateMessage"
53
+ v-if="
54
+ getErrorType === 'message' &&
55
+ validateState === 'error' &&
56
+ validateMessage
57
+ "
45
58
  class="form-valid"
46
59
  >
47
60
  <view class="form-valid-item">{{ validateMessage }}</view>
@@ -262,17 +275,24 @@ export default {
262
275
  },
263
276
  data() {
264
277
  return {
278
+ componentDestroy: false,
265
279
  initialValue: '', // 初始值
266
- validateState: '', // 是否校验成功
280
+ validateState: 'success', // 是否校验成功
267
281
  validateMessage: '' // 校验失败的提示语
268
282
  }
269
283
  },
270
284
  computed: {
271
285
  getShowRightIcon() {
272
- return this.$pi.expand.getPropValue(this.inheritProps.showRightIcon, this.showRightIcon)
286
+ return this.$pi.expand.getPropValue(
287
+ this.inheritProps.showRightIcon,
288
+ this.showRightIcon
289
+ )
273
290
  },
274
291
  getRightIcon() {
275
- const rightIcon = this.$pi.lang.mergeDeep(this.inheritProps.rightIcon, this.rightIcon)
292
+ const rightIcon = this.$pi.lang.mergeDeep(
293
+ this.inheritProps.rightIcon,
294
+ this.rightIcon
295
+ )
276
296
  return this.$pi.lang.mergeDeep(formItem.rightIcon, rightIcon)
277
297
  },
278
298
  getBorder() {
@@ -282,7 +302,10 @@ export default {
282
302
  return this.$pi.expand.getPropValue(this.inheritProps.wrap, this.wrap)
283
303
  },
284
304
  getWrapBottomGap() {
285
- return this.$pi.expand.getPropValue(this.inheritProps.wrapBottomGap, this.wrapBottomGap)
305
+ return this.$pi.expand.getPropValue(
306
+ this.inheritProps.wrapBottomGap,
307
+ this.wrapBottomGap
308
+ )
286
309
  },
287
310
  getLabelWrapBorder() {
288
311
  return this.inheritProps.labelWrapBorder !== null
@@ -293,23 +316,38 @@ export default {
293
316
  return this.$pi.expand.getPropValue(this.inheritProps.colon, this.colon)
294
317
  },
295
318
  getDisabled() {
296
- return this.$pi.expand.getPropValue(this.inheritProps.disabled, this.disabled)
319
+ return this.$pi.expand.getPropValue(
320
+ this.inheritProps.disabled,
321
+ this.disabled
322
+ )
297
323
  },
298
324
  getLabelAlign() {
299
- return this.$pi.expand.getPropValue(this.inheritProps.labelAlign, this.labelAlign)
325
+ return this.$pi.expand.getPropValue(
326
+ this.inheritProps.labelAlign,
327
+ this.labelAlign
328
+ )
300
329
  },
301
330
  getInputAlign() {
302
- return this.$pi.expand.getPropValue(this.inheritProps.inputAlign, this.inputAlign)
331
+ return this.$pi.expand.getPropValue(
332
+ this.inheritProps.inputAlign,
333
+ this.inputAlign
334
+ )
303
335
  },
304
336
  getErrorType() {
305
337
  return this.inheritProps.errorType
306
338
  },
307
339
  getPadding() {
308
- const padding = this.$pi.expand.getPropValue(this.inheritProps.padding, this.padding)
340
+ const padding = this.$pi.expand.getPropValue(
341
+ this.inheritProps.padding,
342
+ this.padding
343
+ )
309
344
  return this.$pi.common.addUnit(padding)
310
345
  },
311
346
  getHeight() {
312
- const height = this.$pi.expand.getPropValue(this.inheritProps.height, this.height)
347
+ const height = this.$pi.expand.getPropValue(
348
+ this.inheritProps.height,
349
+ this.height
350
+ )
313
351
  return this.$pi.common.addUnit(height)
314
352
  },
315
353
  itemStyle() {
@@ -320,7 +358,10 @@ export default {
320
358
  return style
321
359
  },
322
360
  getLabelStyle() {
323
- return this.$pi.expand.getPropValue(this.inheritProps.labelStyle, this.labelStyle)
361
+ return this.$pi.expand.getPropValue(
362
+ this.inheritProps.labelStyle,
363
+ this.labelStyle
364
+ )
324
365
  },
325
366
  getItemVerticalAlign() {
326
367
  return this.$pi.expand.getPropValue(
@@ -374,6 +415,12 @@ export default {
374
415
  mounted() {
375
416
  this.initRulesValidation()
376
417
  },
418
+ created() {
419
+ this.componentDestroy = false
420
+ },
421
+ beforeDestroy() {
422
+ this.componentDestroy = true
423
+ },
377
424
  methods: {
378
425
  handleItemClick(e) {
379
426
  this.$emit('click', e)
@@ -400,7 +447,7 @@ export default {
400
447
  // 从pi-form的rules属性中,取出当前pi-form-item的校验规则
401
448
  getRules() {
402
449
  // 父组件的所有规则
403
- const parentRules = this._parent && (this._parent.validRules || this._parent.rules)
450
+ const parentRules = this._parent && this._parent.validRules
404
451
  const rules = parentRules ? parentRules[this.prop] : []
405
452
  return [].concat(rules || [])
406
453
  },
@@ -409,7 +456,22 @@ export default {
409
456
  let rules = this.getRules()
410
457
  // 整体验证表单时,triggerType为空字符串
411
458
  if (!triggerType) return rules
412
- return rules.filter(res => res.trigger && res.trigger.indexOf(triggerType) !== -1)
459
+ return rules.filter(
460
+ res => res.trigger && res.trigger.indexOf(triggerType) !== -1
461
+ )
462
+ },
463
+ getFieldValue(obj, keypath) {
464
+ if (obj) {
465
+ return keypath.split('-').reduce((prev, key) => {
466
+ let tmpKey = key
467
+ if (/^\[\d+\]$/.test(key)) {
468
+ tmpKey = tmpKey.slice(1, -1)
469
+ }
470
+ prev = prev && prev[tmpKey]
471
+ return prev
472
+ }, obj)
473
+ }
474
+ return undefined
413
475
  },
414
476
  // 校验数据
415
477
  validation(trigger) {
@@ -422,10 +484,20 @@ export default {
422
484
  }
423
485
  return new Promise((resolve, reject) => {
424
486
  const rules = this.getFilteredRule(trigger)
425
- if (!this.prop || !rules || rules.length === 0) {
487
+ if (
488
+ this.componentDestroy ||
489
+ !this.prop ||
490
+ !rules ||
491
+ rules.length === 0
492
+ ) {
493
+ this.validateState = 'success'
494
+ this.validateMessage = ''
495
+ console.log(TAG, '字段无需校验', this.prop)
426
496
  return resolve(_getResolve())
427
497
  }
428
- const fieldValue = this._parent ? this._parent.model[this.prop] : undefined
498
+ const fieldValue = this._parent
499
+ ? this.getFieldValue(this._parent.model, this.prop)
500
+ : undefined
429
501
  // 设置当前的装填,标识为校验中
430
502
  this.validateState = 'validating'
431
503
  // 调用async-validator的方法
@@ -449,7 +521,11 @@ export default {
449
521
  resolve(_getResolve())
450
522
  })
451
523
  .catch(({ errors, fields }) => {
452
- console.log(TAG, '表单校验失败', `字段名:${this.prop},字段值:${fieldValue}`)
524
+ console.log(
525
+ TAG,
526
+ '表单校验失败',
527
+ `字段名:${this.prop},字段值:${fieldValue}`
528
+ )
453
529
  console.log(TAG, '字段值:', fieldValue)
454
530
  console.log(TAG, '错误信息', errors)
455
531
  console.log(TAG, '校验规则', fields)
@@ -490,7 +566,7 @@ export default {
490
566
  }
491
567
  &.border {
492
568
  @include pi-border;
493
- &::after {
569
+ &::before {
494
570
  border: 0 solid $pi-form-border-color;
495
571
  border-bottom-width: $pi-form-border-width;
496
572
  }
@@ -498,15 +574,17 @@ export default {
498
574
  .form-label {
499
575
  font-weight: $pi-form-label-weight;
500
576
  color: $pi-form-label-color;
577
+ white-space: nowrap;
501
578
  &.border {
502
579
  @include pi-border;
503
- &::after {
580
+ &::before {
504
581
  border: 0 solid $pi-form-border-color;
505
582
  border-bottom-width: $pi-form-border-width;
506
583
  }
507
584
  }
508
585
  }
509
586
  .content-wrap {
587
+ overflow: hidden;
510
588
  &.nowrap {
511
589
  margin-left: 24rpx;
512
590
  }
@@ -82,7 +82,7 @@ export default {
82
82
  }
83
83
  &.border {
84
84
  @include pi-border;
85
- &::after {
85
+ &::before {
86
86
  border: 0 solid $pi-grid-border-color;
87
87
  border-top-width: $pi-grid-border-width;
88
88
  border-left-width: $pi-grid-border-width;
@@ -192,21 +192,21 @@ export default {
192
192
  vertical-align: middle;
193
193
  &.border {
194
194
  @include pi-border;
195
- &::after {
195
+ &::before {
196
196
  border: 0 solid $pi-grid-border-color;
197
197
  // 只生成右下边框
198
198
  border-right-width: $pi-grid-border-width;
199
199
  border-bottom-width: $pi-grid-border-width;
200
200
  }
201
- &.gap::after {
201
+ &.gap::before {
202
202
  // 如果有间隔的情况下(边框全部生成)
203
203
  border-width: $pi-grid-border-width;
204
204
  }
205
- &.first-row::after {
205
+ &.first-row::before {
206
206
  // 首行生成上边框
207
207
  border-top-width: $pi-grid-border-width;
208
208
  }
209
- &.first-col::after {
209
+ &.first-col::before {
210
210
  // 首列生成左边框
211
211
  border-left-width: $pi-grid-border-width;
212
212
  }