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
@@ -0,0 +1,601 @@
1
+ <template>
2
+ <pi-popup-select
3
+ :value="val"
4
+ :custom-style="getPopupSelect.customStyle"
5
+ :custom-class="getPopupSelect.customClass"
6
+ :height="getPopupSelect.height"
7
+ :show-title="getPopupSelect.showTitle"
8
+ :title="getPopupSelect.title"
9
+ :title-padding="getPopupSelect.titlePadding"
10
+ :toolbar-position="getPopupSelect.toolbarPosition"
11
+ :on-confirm-close="getPopupSelect.onConfirmClose"
12
+ :on-cancel-close="getPopupSelect.onCancelClose"
13
+ :confirm-btn="getConfirmBtn"
14
+ :cancel-btn="getCancelBtn"
15
+ :popup="getPopup"
16
+ @close="handlePopupClose"
17
+ @cancel="handleCancel"
18
+ @confirm="handleConfirm"
19
+ @showed="handlePopupShow"
20
+ >
21
+ <view
22
+ class="pi-cascader pi-h-100P pi-flex-column"
23
+ :style="[customStyle]"
24
+ :class="[customClass]"
25
+ >
26
+ <slot name="header" />
27
+ <view class="cascader-wrap pi-flex-sub pi-flex-column">
28
+ <!-- 顶部面包屑 -->
29
+ <scroll-view class="node-breadcrumb pi-solid-bottom-1" scroll-x>
30
+ <view
31
+ v-for="(item, index) in pathItems"
32
+ :key="index"
33
+ class="breadcrumb-item"
34
+ @click="handleClickItem(item)"
35
+ >
36
+ <pi-icon v-if="item[keyField] !== ROOT_NODE" name="right" custom-class="pi-mg-lr-6" />
37
+ <view
38
+ class="breadcrumb-item-title"
39
+ :class="{
40
+ active: currentItem && currentItem[keyField] === item[keyField]
41
+ }"
42
+ >
43
+ {{ item[displayField] }}
44
+ </view>
45
+ </view>
46
+ </scroll-view>
47
+ <!-- 选择区域 -->
48
+ <scroll-view class="scroll-view" :scroll-left="scrollLeft" scroll-x scroll-with-animation>
49
+ <scroll-view
50
+ v-for="(col, index) of columns"
51
+ :key="index"
52
+ scroll-y
53
+ class="column"
54
+ :style="[{ width: isOnlyColumn ? '100%' : '50%' }]"
55
+ >
56
+ <view
57
+ v-for="item in col"
58
+ :key="item[keyField]"
59
+ class="column-item pi-align-center"
60
+ :class="{
61
+ active: activeIds.includes(item[keyField]),
62
+ selected: selectedIds.includes(item[keyField])
63
+ }"
64
+ >
65
+ <view class="pi-flex-sub column-item-inner">
66
+ <slot name="item" :item="item">
67
+ <view class="pi-align-center column-item-inner">
68
+ <pi-checkbox
69
+ v-if="parentCanSelect"
70
+ :value="selectedIds.includes(item[keyField])"
71
+ shape="round"
72
+ active-mode="fill-circle"
73
+ class="pi-mg-right-16"
74
+ @change="handleChangeParentSelect(item, $event)"
75
+ />
76
+ <view class="pi-align-center pi-lh-36 pi-flex-sub column-item-inner" @click="handleClickItem(item)">
77
+ {{ item[displayField] || '' }}
78
+ </view>
79
+ </view>
80
+ </slot>
81
+ </view>
82
+ <pi-icon
83
+ v-if="!parentCanSelect && selectedIds.includes(item[keyField])"
84
+ name="blod-check"
85
+ size="36"
86
+ />
87
+ <pi-icon
88
+ v-if="item[childrenField] && item[childrenField].length > 0"
89
+ name="right"
90
+ @click="handleClickItem(item)"
91
+ />
92
+ </view>
93
+ </scroll-view>
94
+ </scroll-view>
95
+ <!-- 已选区域 -->
96
+ <view v-if="!isSingle" class="cascader-area">
97
+ <text>{{ `已选(${selectedIds.length})` }}</text>
98
+ <scroll-view class="scroll-area" scroll-x>
99
+ <view
100
+ v-for="id in selectedIds"
101
+ :key="id"
102
+ class="cascader-item"
103
+ @tap="handleRemoveItem(id)"
104
+ >
105
+ <text class="pi-mg-right-12">
106
+ {{ itemsMap && itemsMap[id] && itemsMap[id][displayField] }}
107
+ </text>
108
+ <pi-icon name="close" />
109
+ </view>
110
+ </scroll-view>
111
+ </view>
112
+ <view v-else class="cascader-area">
113
+ <text>已选:</text>
114
+ <scroll-view
115
+ class="node-breadcrumb pi-solid-bottom-1"
116
+ scroll-x
117
+ style="flex: 1;padding-left: 0;overflow: hidden;"
118
+ >
119
+ <view
120
+ v-for="(item, index) in currentPathItems"
121
+ :key="index"
122
+ class="breadcrumb-item"
123
+ @click="handleClickItem(item)"
124
+ >
125
+ <pi-icon v-if="index > 0" name="right" custom-class="pi-mg-lr-6" />
126
+ <view
127
+ class="breadcrumb-item-title"
128
+ >
129
+ {{ item[displayField] }}
130
+ </view>
131
+ </view>
132
+ </scroll-view>
133
+ </view>
134
+ </view>
135
+ <slot name="footer" />
136
+ </view>
137
+ </pi-popup-select>
138
+ </template>
139
+
140
+ <script>
141
+ import ValueSync from '../../mixin/value-sync'
142
+ import { getConfig } from '../../config'
143
+
144
+ const TAG = 'PiCascader'
145
+ const ROOT_NODE = 'ROOT'
146
+ const { cascader } = getConfig()
147
+
148
+ export default {
149
+ name: 'PiCascader',
150
+ // 混入v-model
151
+ mixins: [ValueSync],
152
+ props: {
153
+ // 初始值
154
+ value: {
155
+ required: false
156
+ },
157
+ // 自定义样式
158
+ customStyle: {
159
+ type: Object,
160
+ // {}
161
+ default() {
162
+ return cascader.customStyle
163
+ }
164
+ },
165
+ // 自定义样式类
166
+ customClass: {
167
+ type: String,
168
+ // ''
169
+ default() {
170
+ return cascader.customClass
171
+ }
172
+ },
173
+ // 数据源
174
+ items: {
175
+ type: Array,
176
+ default() {
177
+ return []
178
+ }
179
+ },
180
+ defaultValue: {
181
+ type: [Array, String, Number],
182
+ default: () => []
183
+ },
184
+ // 列表选项的唯一标识
185
+ keyField: {
186
+ type: String,
187
+ // 'id'
188
+ default: cascader.keyField
189
+ },
190
+ // 选项显示字段
191
+ displayField: {
192
+ type: String,
193
+ // 'text'
194
+ default: cascader.displayField
195
+ },
196
+ // children字段,默认为desc
197
+ childrenField: {
198
+ type: String,
199
+ // 'children'
200
+ default: cascader.childrenField
201
+ },
202
+ // 父节点是否可选(默认:'false')
203
+ parentCanSelect: {
204
+ type: Boolean,
205
+ // false
206
+ default: cascader.parentCanSelect
207
+ },
208
+ // 是否单选(默认:'false')
209
+ isSingle: {
210
+ type: Boolean,
211
+ // false
212
+ default: cascader.isSingle
213
+ },
214
+ // 弹窗选择参数设置
215
+ popupSelect: {
216
+ type: Object,
217
+ default() {
218
+ // 参照popupSelect
219
+ return cascader.popupSelect
220
+ }
221
+ },
222
+ // 确认按钮配置
223
+ confirmBtn: {
224
+ type: Object,
225
+ default() {
226
+ return cascader.confirmBtn
227
+ }
228
+ },
229
+ // 取消按钮配置
230
+ cancelBtn: {
231
+ type: Object,
232
+ default() {
233
+ return cascader.cancelBtn
234
+ }
235
+ },
236
+ // 弹窗参数设置
237
+ popup: {
238
+ type: Object,
239
+ default() {
240
+ // 参照popup
241
+ return cascader.popup
242
+ }
243
+ }
244
+ },
245
+ data() {
246
+ const rootItem = {
247
+ [this.displayField]: '全部',
248
+ [this.keyField]: ROOT_NODE
249
+ }
250
+ return {
251
+ rootItem,
252
+ currentItem: this.$pi.lang.cloneDeep(rootItem),
253
+ innerItems: [],
254
+ itemsMap: {}, // 已选数据id索引
255
+ selectedIds: [], // 已选数据
256
+ cascaderWidth: this.$pi.system.systemInfo.screenWidth, // 容器宽度
257
+ scrollLeft: 0 // 视图左侧滚动区域,自动对齐到选择的栏目
258
+ }
259
+ },
260
+ computed: {
261
+ ROOT_NODE() {
262
+ return ROOT_NODE
263
+ },
264
+ getPopupSelect() {
265
+ const popupSelect = this.$pi.lang.mergeDeep(cascader.popupSelect, this.popupSelect)
266
+ if (!this.singleCancel && this.singleConfirm) {
267
+ popupSelect.toolbarPosition = 'none'
268
+ }
269
+ return popupSelect
270
+ },
271
+ getConfirmBtn() {
272
+ const cascaderConfirmBtn = this.$pi.lang.mergeDeep(
273
+ cascader.confirmBtn,
274
+ this.popupSelect.confirmBtn
275
+ )
276
+ return this.$pi.lang.mergeDeep(cascaderConfirmBtn, this.confirmBtn)
277
+ },
278
+ getCancelBtn() {
279
+ const cascaderCancelBtn = this.$pi.lang.mergeDeep(
280
+ cascader.cancelBtn,
281
+ this.popupSelect.cancelBtn
282
+ )
283
+ return this.$pi.lang.mergeDeep(cascaderCancelBtn, this.cancelBtn)
284
+ },
285
+ getPopup() {
286
+ const cascaderPopup = this.$pi.lang.mergeDeep(cascader.popup, this.popupSelect.popup)
287
+ return this.$pi.lang.mergeDeep(cascaderPopup, this.popup)
288
+ },
289
+ getItemStyle() {
290
+ return {
291
+ height: this.$pi.common.addUnit(this.itemHeight)
292
+ }
293
+ },
294
+ columns() {
295
+ let columns = []
296
+ if (this.currentItem) {
297
+ // 如果有当前显示的节点,往上找父节点下的所有children放到数组的前面
298
+ let p = this.currentItem
299
+ while (p) {
300
+ const children = p[this.childrenField] || []
301
+ if (children.length > 0) {
302
+ columns.unshift(children)
303
+ }
304
+ p = p.pid ? this.itemsMap[p.pid] : undefined
305
+ }
306
+ columns.unshift(this.innerItems)
307
+ } else {
308
+ columns = [this.innerItems]
309
+ }
310
+ return columns
311
+ },
312
+ isOnlyColumn() {
313
+ return this.columns.length === 1
314
+ },
315
+ activeIds() {
316
+ return this.pathItems.map(i => i[this.keyField])
317
+ },
318
+ pathItems() {
319
+ const pathItems = []
320
+ if (this.currentItem[this.keyField] !== ROOT_NODE) {
321
+ // 往上找构建完整路径
322
+ let p = this.currentItem
323
+ while (p) {
324
+ pathItems.unshift(p)
325
+ p = this.itemsMap[p.pid]
326
+ }
327
+ }
328
+ return [
329
+ {
330
+ [this.displayField]: '全部',
331
+ [this.keyField]: 'ROOT'
332
+ }
333
+ ].concat(pathItems)
334
+ },
335
+ currentPathItems() {
336
+ const pathItems = []
337
+ if (this.isSingle) {
338
+ // 往上找构建完整路径
339
+ let p = this.itemsMap[this.selectedIds[0]]
340
+ while (p) {
341
+ pathItems.unshift(p)
342
+ p = this.itemsMap[p.pid]
343
+ }
344
+ }
345
+ return pathItems
346
+ }
347
+ },
348
+ watch: {
349
+ items: {
350
+ immediate: true,
351
+ deep: true,
352
+ handler() {
353
+ this.rebuildItems()
354
+ }
355
+ },
356
+ defaultValue: {
357
+ immediate: true,
358
+ handler(vals) {
359
+ this.selectedIds = this.isSingle ? [vals] : vals
360
+ }
361
+ }
362
+ },
363
+
364
+ methods: {
365
+ rebuildItems() {
366
+ console.log('重建innerItems')
367
+ /**
368
+ * 以非递归的方式 深度拷贝items 且建立父子节点关系
369
+ * 目的为了不影响外部传入的prop: items
370
+ * 写成非递归的目的 是为了防止树的层次太深,
371
+ * 递归调用太多次,导致栈溢出
372
+ */
373
+ this.currentItem = this.$pi.lang.cloneDeep(this.rootItem)
374
+ const innerItems = []
375
+ // 初始化堆栈 为items的根节点
376
+ const stack = [...this.items]
377
+ const itemsMap = {}
378
+ while (stack.length > 0) {
379
+ // 将栈顶元素出栈进行处理
380
+ let item = stack.shift()
381
+ if (!item.pid) {
382
+ item = {
383
+ ...item,
384
+ level: 0
385
+ }
386
+ innerItems.push(item)
387
+ }
388
+ const children = item[this.childrenField] || []
389
+ const newChilds = []
390
+ for (let i = children.length - 1; i >= 0; i--) {
391
+ // 浅拷贝子孩子
392
+ const subItem = {
393
+ ...children[i],
394
+ level: item.level + 1
395
+ }
396
+ // 建立父子关系
397
+ subItem.pid = item[this.keyField]
398
+ // 放置到新数组中
399
+ newChilds.unshift(subItem)
400
+ // 入栈 模拟递归效果 等待之后的while循环出栈进行处理
401
+ stack.unshift(subItem)
402
+ }
403
+ // 更新children 为新的数组
404
+ item[this.childrenField] = newChilds
405
+ itemsMap[item[this.keyField]] = item
406
+ }
407
+ // 此时的innerItems无论怎么修改 均不影响items
408
+ this.innerItems = innerItems
409
+ // 方便通过节点的id 为key快速定位到对应的节点dto
410
+ this.itemsMap = itemsMap
411
+ if (this.currentItem[this.keyField] === ROOT_NODE) {
412
+ if (this.isSingle && this.defaultValue) {
413
+ this.currentItem = this.getItemByKeyField(this.defaultValue)
414
+ }
415
+ if (!this.isSingle && this.defaultValue.length > 0) {
416
+ this.currentItem = this.getItemByKeyField(this.defaultValue[0])
417
+ }
418
+ }
419
+ },
420
+ handleRemoveItem(id) {
421
+ this.selectedIds = this.selectedIds.filter(i => i !== id)
422
+ },
423
+ handleClickItem(item) {
424
+ // 点击全部
425
+ if (item[this.keyField] === ROOT_NODE) {
426
+ this.currentItem = this.$pi.lang.cloneDeep(this.rootItem)
427
+ this.$nextTick(this.syncScrollLeft)
428
+ return
429
+ }
430
+ const isLeafNode = !item[this.childrenField] || item[this.childrenField]?.length === 0
431
+ // 点击非叶子节点
432
+ if (item && !isLeafNode && this.currentItem[this.keyField] !== item[this.keyField]) {
433
+ this.currentItem = item
434
+ this.$nextTick(this.syncScrollLeft)
435
+ return
436
+ }
437
+ // 点击的是叶子节点
438
+ if (isLeafNode) {
439
+ if (this.selectedIds.includes(item[this.keyField])) {
440
+ this.handleRemoveItem(item[this.keyField])
441
+ } else {
442
+ // 选中
443
+ if (this.isSingle) {
444
+ this.selectedIds = [item[this.keyField]]
445
+ } else {
446
+ this.selectedIds.push(item[this.keyField])
447
+ }
448
+ }
449
+ }
450
+ },
451
+ handleChangeParentSelect(item, selected) {
452
+ if (this.selectedIds.includes(item[this.keyField])) {
453
+ this.handleRemoveItem(item[this.keyField])
454
+ } else {
455
+ // 选中
456
+ this.selectedIds.push(item[this.keyField])
457
+ }
458
+ },
459
+ handlePopupShow() {
460
+ this.$emit('showd')
461
+ this.syncScrollLeft()
462
+ },
463
+ async syncScrollLeft() {
464
+ // 调用此方法的时候,必须使用$nextTick,因为column是动态变化的,需要等待界面更新渲染后,才能正确设置scrollLeft的位置
465
+ let scrollLeft = 0
466
+ if (this.cascaderWidth === 0) {
467
+ const srollWrapRect = await this.$pi.common.queryRect(this, '.cascader-wrap', false)
468
+ console.log(this, srollWrapRect)
469
+ if (srollWrapRect) {
470
+ this.cascaderWidth = srollWrapRect.width
471
+ }
472
+ }
473
+ if (this.columns.length > 2) {
474
+ scrollLeft = (this.columns.length - 2) * (this.cascaderWidth / 2)
475
+ }
476
+ this.scrollLeft = scrollLeft
477
+ },
478
+ handlePopupClose() {
479
+ this.val = false
480
+ // 关闭弹窗
481
+ this.$emit('close')
482
+ this.handleEmitChange()
483
+ },
484
+ /**
485
+ * @vuese
486
+ * 根据id获取item
487
+ */
488
+ getItemByKeyField(keyField) {
489
+ return this.itemsMap[keyField]
490
+ },
491
+ /**
492
+ * @vuese
493
+ * 取消选择
494
+ */
495
+ handleCancel() {
496
+ this.$emit('cancel')
497
+ this.selectedIds = this.isSingle ? [this.defaultValue] : [...this.defaultValue]
498
+ this.getPopupSelect.onCancelClose && this.handlePopupClose()
499
+ },
500
+ /**
501
+ * @vuese
502
+ * 确认选择
503
+ */
504
+ handleConfirm() {
505
+ this.$emit('confirm', this.isSingle ? this.selectedIds[0] || '' : this.selectedIds)
506
+ this.getPopupSelect.onConfirmClose && this.handlePopupClose()
507
+ }
508
+ }
509
+ }
510
+ </script>
511
+
512
+ <style lang="scss" scoped>
513
+ .cascader-wrap {
514
+ width: 100%;
515
+ height: 100%;
516
+ background: #f4f2f6;
517
+ }
518
+ .scroll-view {
519
+ width: 100%;
520
+ flex: 1;
521
+ white-space: nowrap;
522
+ overflow: auto hidden;
523
+ .column {
524
+ display: inline-block;
525
+ height: 100%;
526
+ width: 50%;
527
+ overflow: hidden auto;
528
+ &:last-child {
529
+ background: #ffffff;
530
+ }
531
+ .column-item {
532
+ position: relative;
533
+ min-height: 100rpx;
534
+ width: 100%;
535
+ white-space: initial;
536
+ padding: 16rpx 32rpx;
537
+ font-size: 28rpx;
538
+ color: #333333;
539
+ overflow: hidden;
540
+ .column-item-inner {
541
+ min-height: 100rpx;
542
+ }
543
+ &.active {
544
+ color: $pi-primary-color;
545
+ background: #ffffff;
546
+ ::v-deep .pi-icon-right {
547
+ color: #333333;
548
+ }
549
+ }
550
+ &.selected {
551
+ color: $pi-primary-color;
552
+ ::v-deep .pi-icon-right {
553
+ color: #333333;
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+
560
+ .node-breadcrumb {
561
+ width: 100%;
562
+ padding-left: 32rpx;
563
+ padding-right: 32rpx;
564
+ background: #ffffff;
565
+ white-space: nowrap;
566
+ .breadcrumb-item {
567
+ display: inline-flex;
568
+ align-items: center;
569
+ font-size: 14px;
570
+ padding: 32rpx 0;
571
+
572
+ .breadcrumb-item-title.active {
573
+ color: $pi-primary-color;
574
+ }
575
+ }
576
+ }
577
+
578
+ .cascader-area {
579
+ background: #ffffff;
580
+ padding: 22rpx 24rpx;
581
+ color: #333333;
582
+ display: flex;
583
+ align-items: center;
584
+ white-space: nowrap;
585
+
586
+ .scroll-area {
587
+ width: calc(100% - 128rpx);
588
+ flex: 1;
589
+ white-space: nowrap;
590
+ }
591
+ .cascader-item {
592
+ display: inline-flex;
593
+ padding: 14rpx 24rpx;
594
+ background: rgba($pi-primary-color, 0.1);
595
+ align-items: center;
596
+ margin-left: 16rpx;
597
+ border-radius: 8rpx;
598
+ color: $pi-primary-color;
599
+ }
600
+ }
601
+ </style>
@@ -2,7 +2,13 @@
2
2
  <view
3
3
  class="pi-check-wrap"
4
4
  :style="[customStyle]"
5
- :class="[getShape, getActiveMode, { disabled: getDisable }, { active: val }, customClass]"
5
+ :class="[
6
+ getShape,
7
+ getActiveMode,
8
+ { disabled: getDisable },
9
+ { active: val },
10
+ customClass
11
+ ]"
6
12
  >
7
13
  <view
8
14
  v-if="getShape !== 'text'"
@@ -289,14 +295,13 @@ $unactive-color: #cccccc;
289
295
  }
290
296
  .check-label {
291
297
  flex: 1;
292
- margin-left: 16rpx;
298
+ padding: 0 24rpx 0 16rpx;
293
299
  line-height: 1.5;
294
300
  word-wrap: break-word;
295
301
  transition: $pi-animation-duration $pi-animation-timing-function;
296
302
  transition-property: border, color, background-color;
297
303
  &.text {
298
304
  padding: 12rpx 24rpx;
299
- margin-left: 0;
300
305
  color: $unactive-color;
301
306
  border-color: transparent;
302
307
  border-style: solid;
@@ -322,7 +327,6 @@ $unactive-color: #cccccc;
322
327
  }
323
328
  }
324
329
  &.disabled {
325
- cursor: not-allowed;
326
330
  opacity: $pi-disabled-opacity;
327
331
  }
328
332
  &.active {
@@ -126,7 +126,9 @@ export default {
126
126
  // `''`
127
127
  default: checkboxGroup.activeMode,
128
128
  validator: function(value) {
129
- return ['', 'line', 'line-circle', 'fill', 'fill-circle'].includes(value)
129
+ return ['', 'line', 'line-circle', 'fill', 'fill-circle'].includes(
130
+ value
131
+ )
130
132
  }
131
133
  },
132
134
  // 是否点击图标才能选中,默认点击整行都能选中
@@ -143,6 +145,8 @@ export default {
143
145
  },
144
146
  watch: {
145
147
  val: {
148
+ deep: true,
149
+ immediate: true,
146
150
  handler(value) {
147
151
  this.handleValChange()
148
152
  }
@@ -151,10 +155,12 @@ export default {
151
155
  methods: {
152
156
  handleValChange() {
153
157
  // 同步checkbox子组件
154
- this._children.forEach(child => {
158
+ this._children?.forEach(child => {
155
159
  // 对设置了name属性的checkbox才做同步
156
160
  if (child.name) {
157
- child.val = this.val.includes(child.name)
161
+ setTimeout(() => {
162
+ child.val = this.val.includes(child.name)
163
+ }, 50)
158
164
  }
159
165
  })
160
166
  },
@@ -182,7 +188,9 @@ export default {
182
188
  emitChange() {
183
189
  const vals = []
184
190
  this._children.forEach(child => {
185
- if (child.val && child.name) vals.push(child.name)
191
+ console.log(child.val, child.name)
192
+ if (child.val && !this.$pi.lang.isEmpty(child.name))
193
+ vals.push(child.name)
186
194
  })
187
195
  this.val = vals
188
196
  this.handleEmitChange()
@@ -209,13 +217,6 @@ export default {
209
217
  &.horizontal {
210
218
  flex-direction: row;
211
219
  align-items: center;
212
- ::v-deep .pi-check-wrap:not(:last-child) {
213
- margin-right: 28rpx;
214
- }
215
- // 兼容小程序
216
- ::v-deep pi-checkbox:not(:last-child) {
217
- margin-right: 28rpx;
218
- }
219
220
  }
220
221
  }
221
222
  </style>