sadais-piui 1.2.7-beta87 → 1.2.7-beta89

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.
@@ -28,7 +28,7 @@
28
28
  <!-- 顶部面包屑 -->
29
29
  <scroll-view class="node-breadcrumb pi-solid-bottom-1" scroll-x>
30
30
  <view
31
- v-for="(item, index) in allPathItems"
31
+ v-for="(item, index) in pathItems"
32
32
  :key="index"
33
33
  class="breadcrumb-item"
34
34
  @click="handleClickItem(item)"
@@ -117,18 +117,13 @@
117
117
  style="flex: 1;padding-left: 0;overflow: hidden;"
118
118
  >
119
119
  <view
120
- v-for="(item, index) in pathItems"
120
+ v-for="(item, index) in currentPathItems"
121
121
  :key="index"
122
122
  class="breadcrumb-item"
123
123
  @click="handleClickItem(item)"
124
124
  >
125
125
  <pi-icon v-if="index > 0" name="right" custom-class="pi-mg-lr-6" />
126
- <view
127
- class="breadcrumb-item-title"
128
- :class="{
129
- active: currentItem && currentItem[keyField] === item[keyField]
130
- }"
131
- >
126
+ <view class="breadcrumb-item-title">
132
127
  {{ item[displayField] }}
133
128
  </view>
134
129
  </view>
@@ -328,20 +323,30 @@ export default {
328
323
  p = this.itemsMap[p.pid]
329
324
  }
330
325
  }
331
- return pathItems
332
- },
333
- allPathItems() {
334
326
  return [
335
327
  {
336
328
  [this.displayField]: '全部',
337
329
  [this.keyField]: 'ROOT'
338
330
  }
339
- ].concat(this.pathItems)
331
+ ].concat(pathItems)
332
+ },
333
+ currentPathItems() {
334
+ const pathItems = []
335
+ if (this.isSingle) {
336
+ // 往上找构建完整路径
337
+ let p = this.itemsMap[this.selectedIds[0]]
338
+ while (p) {
339
+ pathItems.unshift(p)
340
+ p = this.itemsMap[p.pid]
341
+ }
342
+ }
343
+ return pathItems
340
344
  }
341
345
  },
342
346
  watch: {
343
347
  items: {
344
348
  immediate: true,
349
+ deep: true,
345
350
  handler() {
346
351
  this.rebuildItems()
347
352
  }
@@ -356,12 +361,14 @@ export default {
356
361
 
357
362
  methods: {
358
363
  rebuildItems() {
364
+ console.log('重建innerItems')
359
365
  /**
360
366
  * 以非递归的方式 深度拷贝items 且建立父子节点关系
361
367
  * 目的为了不影响外部传入的prop: items
362
368
  * 写成非递归的目的 是为了防止树的层次太深,
363
369
  * 递归调用太多次,导致栈溢出
364
370
  */
371
+ this.currentItem = this.$pi.lang.cloneDeep(this.rootItem)
365
372
  const innerItems = []
366
373
  // 初始化堆栈 为items的根节点
367
374
  const stack = [...this.items]
@@ -521,10 +528,10 @@ export default {
521
528
  }
522
529
  .column-item {
523
530
  position: relative;
524
- height: 100rpx;
531
+ min-height: 100rpx;
525
532
  width: 100%;
526
533
  white-space: initial;
527
- padding: 0 16rpx 0 32rpx;
534
+ padding: 16rpx 32rpx;
528
535
  font-size: 28rpx;
529
536
  color: #333333;
530
537
  overflow: hidden;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta87",
3
+ "version": "1.2.7-beta89",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {