sadais-piui 1.2.7-beta49 → 1.2.7-beta50
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-cascader/index.vue +41 -27
- package/package.json +1 -1
|
@@ -60,19 +60,22 @@
|
|
|
60
60
|
active: activeIds.includes(item[keyField]),
|
|
61
61
|
selected: selectedIds.includes(item[keyField])
|
|
62
62
|
}"
|
|
63
|
-
@click="handleClickItem(item)"
|
|
64
63
|
>
|
|
65
|
-
<view class="pi-flex-sub
|
|
64
|
+
<view class="pi-flex-sub">
|
|
66
65
|
<slot name="item" :item="item">
|
|
67
|
-
<pi-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
<view class="pi-align-center">
|
|
67
|
+
<pi-checkbox
|
|
68
|
+
v-if="parentCanSelect"
|
|
69
|
+
:value="selectedIds.includes(item[keyField])"
|
|
70
|
+
shape="round"
|
|
71
|
+
active-mode="fill-circle"
|
|
72
|
+
class="pi-mg-right-16"
|
|
73
|
+
@change="handleChangeParentSelect(item, $event)"
|
|
74
|
+
/>
|
|
75
|
+
<text class="pi-lh-36 pi-flex-sub" @click="handleClickItem(item)">
|
|
76
|
+
{{ item[displayField] || '' }}
|
|
77
|
+
</text>
|
|
78
|
+
</view>
|
|
76
79
|
</slot>
|
|
77
80
|
</view>
|
|
78
81
|
<pi-icon
|
|
@@ -80,7 +83,11 @@
|
|
|
80
83
|
name="blod-check"
|
|
81
84
|
size="36"
|
|
82
85
|
/>
|
|
83
|
-
<pi-icon
|
|
86
|
+
<pi-icon
|
|
87
|
+
v-if="item[childrenField] && item[childrenField].length > 0"
|
|
88
|
+
name="right"
|
|
89
|
+
@click="handleClickItem(item)"
|
|
90
|
+
/>
|
|
84
91
|
</view>
|
|
85
92
|
</scroll-view>
|
|
86
93
|
</scroll-view>
|
|
@@ -358,22 +365,22 @@ export default {
|
|
|
358
365
|
this.selectedIds = this.selectedIds.filter(i => i !== id)
|
|
359
366
|
},
|
|
360
367
|
handleClickItem(item) {
|
|
368
|
+
console.log(item)
|
|
369
|
+
// 点击全部
|
|
361
370
|
if (item[this.keyField] === ROOT_NODE) {
|
|
362
371
|
this.currentItem = cloneDeep(this.rootItem)
|
|
363
372
|
this.$nextTick(this.syncScrollLeft)
|
|
364
373
|
return
|
|
365
374
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
this.currentItem[this.keyField] !== item[this.keyField]
|
|
370
|
-
) {
|
|
375
|
+
const isLeafNode = !item[this.childrenField] || item[this.childrenField]?.length === 0
|
|
376
|
+
// 点击非叶子节点
|
|
377
|
+
if (item && !isLeafNode && this.currentItem[this.keyField] !== item[this.keyField]) {
|
|
371
378
|
this.currentItem = item
|
|
372
379
|
this.$nextTick(this.syncScrollLeft)
|
|
373
380
|
return
|
|
374
381
|
}
|
|
375
|
-
|
|
376
|
-
|
|
382
|
+
// 点击的是叶子节点
|
|
383
|
+
if (isLeafNode) {
|
|
377
384
|
if (this.selectedIds.includes(item[this.keyField])) {
|
|
378
385
|
this.handleRemoveItem(item[this.keyField])
|
|
379
386
|
} else {
|
|
@@ -382,6 +389,15 @@ export default {
|
|
|
382
389
|
}
|
|
383
390
|
}
|
|
384
391
|
},
|
|
392
|
+
handleChangeParentSelect(item, selected) {
|
|
393
|
+
if (this.selectedIds.includes(item[this.keyField])) {
|
|
394
|
+
this.handleRemoveItem(item[this.keyField])
|
|
395
|
+
} else {
|
|
396
|
+
// 选中
|
|
397
|
+
this.selectedIds.push(item[this.keyField])
|
|
398
|
+
console.log(this.selectedIds)
|
|
399
|
+
}
|
|
400
|
+
},
|
|
385
401
|
async syncScrollLeft() {
|
|
386
402
|
// 调用此方法的时候,必须使用$nextTick,因为column是动态变化的,需要等待界面更新渲染后,才能正确设置scrollLeft的位置
|
|
387
403
|
let scrollLeft = 0
|
|
@@ -402,14 +418,6 @@ export default {
|
|
|
402
418
|
this.$emit('close')
|
|
403
419
|
this.handleEmitChange()
|
|
404
420
|
},
|
|
405
|
-
handleChangeParentSelect(item, selected) {
|
|
406
|
-
if (this.selectedIds.includes(item[this.keyField])) {
|
|
407
|
-
this.handleRemoveItem(item[this.keyField])
|
|
408
|
-
} else {
|
|
409
|
-
// 选中
|
|
410
|
-
this.selectedIds.push(item[this.keyField])
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
421
|
/**
|
|
414
422
|
* @vuese
|
|
415
423
|
* 根据id获取item
|
|
@@ -468,9 +476,15 @@ export default {
|
|
|
468
476
|
&.active {
|
|
469
477
|
color: $pi-primary-color;
|
|
470
478
|
background: #ffffff;
|
|
479
|
+
::v-deep .pi-icon-right {
|
|
480
|
+
color: #333333;
|
|
481
|
+
}
|
|
471
482
|
}
|
|
472
483
|
&.selected {
|
|
473
484
|
color: $pi-primary-color;
|
|
485
|
+
::v-deep .pi-icon-right {
|
|
486
|
+
color: #333333;
|
|
487
|
+
}
|
|
474
488
|
}
|
|
475
489
|
}
|
|
476
490
|
}
|