@sy-common/organize-select-help 1.0.0-beta.50 → 1.0.0-beta.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sy-common/organize-select-help",
3
- "version": "1.0.0-beta.50",
3
+ "version": "1.0.0-beta.52",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
package/src/index.vue CHANGED
@@ -126,15 +126,17 @@
126
126
  <div class="staff-left-panel">
127
127
  <div class="panel-title">组织选择</div>
128
128
  <div class="tree staff-org-tree">
129
- <organizeTree
130
- @handleChange="getStaffList"
131
- ref="staffTree"
132
- :treeList="staffTree"
133
- :showCheckbox="true"
134
- :checkStrictly="true"
135
- :autoExpandParent="true"
136
- :isSingleSelect="true"
137
- ></organizeTree>
129
+ <div class="tree-scroll-force">
130
+ <organizeTree
131
+ @handleChange="getStaffList"
132
+ ref="staffTree"
133
+ :treeList="staffTree"
134
+ :showCheckbox="true"
135
+ :checkStrictly="true"
136
+ :autoExpandParent="true"
137
+ :isSingleSelect="true"
138
+ ></organizeTree>
139
+ </div>
138
140
  </div>
139
141
  </div>
140
142
 
@@ -1573,6 +1575,7 @@ export default {
1573
1575
  }
1574
1576
  }
1575
1577
  }
1578
+
1576
1579
  .staff-left-right-layout {
1577
1580
  display: flex;
1578
1581
  height: 600px;
@@ -1590,49 +1593,51 @@ export default {
1590
1593
  box-sizing: border-box;
1591
1594
  flex-shrink: 0;
1592
1595
 
1593
- .panel-title {
1594
- font-weight: 600;
1595
- font-size: 15px;
1596
- color: #1f2937;
1597
- margin-bottom: 10px;
1598
- height: 28px;
1599
- display: flex;
1600
- align-items: center;
1601
- position: relative;
1602
- padding-left: 18px; // 内边距同步加宽2px,保持视觉平衡
1603
- // 调整竖线宽度为6px,更醒目且仍符合整体简约风格
1604
- &::before {
1605
- content: '';
1606
- position: absolute;
1607
- left: 0;
1608
- top: 50%;
1609
- transform: translateY(-50%);
1610
- width: 6px; // 从3px调整为6px,加宽竖线
1611
- height: 18px; // 高度同步微调至18px,比例更协调
1612
- background-color: var(--primary-color);
1613
- border-radius: 3px; // 圆角保持3px,视觉更柔和
1614
- }
1615
- }
1596
+ .panel-title { /* 原有样式保留 */ }
1616
1597
 
1617
1598
  .staff-org-tree {
1618
- height: calc(100% - 38px) !important; // 对应title高度+margin-bottom调整
1619
- overflow: auto;
1599
+ height: calc(100% - 38px) !important;
1620
1600
  border: 1px solid #EAECF0;
1621
1601
  border-radius: 4px;
1622
1602
  padding: 8px;
1623
1603
  box-sizing: border-box;
1624
- // 保持原有树节点样式
1625
- /deep/ .ivu-tree-node-content {
1626
- white-space: normal !important;
1627
- line-height: 1.4;
1628
- padding: 4px 0;
1629
- }
1630
- /deep/ .ivu-tree-node {
1631
- padding-left: 4px !important;
1604
+ /* 原样式保留,新增:禁止自身滚动,交给内部容器 */
1605
+ overflow: hidden !important;
1606
+ position: relative;
1607
+ }
1608
+
1609
+ /* 新增强制滚动容器样式(关键) */
1610
+ .tree-scroll-force {
1611
+ width: 100%;
1612
+ height: 100%;
1613
+ overflow: auto !important; /* 强制开启滚动 */
1614
+ overflow-x: scroll !important; /* 强制显示横向滚动条 */
1615
+ overflow-y: auto !important;
1616
+ /* 强制最小宽度,确保内容溢出时触发滚动 */
1617
+ min-width: 100%;
1618
+ max-width: none !important;
1619
+ /* 滚动条样式强制显示 */
1620
+ &::-webkit-scrollbar {
1621
+ width: 8px !important;
1622
+ height: 8px !important;
1623
+ display: block !important;
1624
+ background: #f9f9f9 !important;
1632
1625
  }
1633
- /deep/ .ivu-tree-child-tree {
1634
- padding-left: 16px !important;
1626
+ &::-webkit-scrollbar-thumb {
1627
+ background: #ccc !important;
1628
+ border-radius: 4px !important;
1635
1629
  }
1630
+ /* 兼容Firefox */
1631
+ scrollbar-width: thin !important;
1632
+ scrollbar-color: #ccc #f9f9f9 !important;
1633
+ }
1634
+
1635
+ /* 强制组织树组件宽度自适应内容 */
1636
+ .tree-scroll-force /deep/ .ivu-tree {
1637
+ width: fit-content !important; /* 宽度跟随内容 */
1638
+ min-width: 100% !important; /* 最小占满容器 */
1639
+ white-space: nowrap !important;
1640
+ display: inline-block !important;
1636
1641
  }
1637
1642
  }
1638
1643
 
@@ -1,16 +1,18 @@
1
1
  <template>
2
2
  <div class="content">
3
3
  <Spin fix v-if="loading"></Spin>
4
- <Tree
5
- :data="data"
6
- ref="tree"
7
- :load-data="loadData"
8
- :render="renderContent"
9
- multiple
10
- :check-strictly="true"
11
- :cascade-check="false"
12
- @on-select-change="handleChange"
13
- ></Tree>
4
+ <div class="tree-inner">
5
+ <Tree
6
+ :data="data"
7
+ ref="tree"
8
+ :load-data="loadData"
9
+ :render="renderContent"
10
+ multiple
11
+ :check-strictly="true"
12
+ :cascade-check="false"
13
+ @on-select-change="handleChange"
14
+ ></Tree>
15
+ </div>
14
16
  </div>
15
17
  </template>
16
18
 
@@ -50,7 +52,14 @@ export default {
50
52
  this.data = data;
51
53
  },
52
54
 
55
+ // 树组件内的 handleChange 方法修改(仅保留核心逻辑,移除冗余触发)
53
56
  handleChange(data) {
57
+ // 仅处理复选框触发的选中数据,过滤空数据
58
+ if (!data || (Array.isArray(data) && data.length === 0)) {
59
+ this.$emit('handleChange', []);
60
+ return;
61
+ }
62
+
54
63
  let checkedData = Array.isArray(data)
55
64
  ? data.filter(item => item.checked)
56
65
  : (data.checked ? [data] : []);
@@ -63,6 +72,7 @@ export default {
63
72
  }
64
73
 
65
74
  this.syncAllNodeCheckedState(checkedData);
75
+ // 仅当有有效选中节点时才触发父组件事件
66
76
  this.$emit('handleChange', checkedData);
67
77
  },
68
78
  clearOtherCheckedNodes(keepIds) {
@@ -292,7 +302,18 @@ export default {
292
302
  overflow: 'hidden',
293
303
  display: 'flex',
294
304
  alignItems: 'center',
295
- cursor: 'pointer'
305
+ cursor: 'default' // 文本区域鼠标指针改为默认
306
+ },
307
+ // 阻断整个节点容器的点击事件(仅复选框除外)
308
+ on: {
309
+ click: (e) => {
310
+ // 仅当点击复选框时放行,其他区域阻断
311
+ const isCheckbox = e.target.closest('.ivu-checkbox') || e.target.closest('.ivu-checkbox-icon');
312
+ if (!isCheckbox) {
313
+ e.stopPropagation();
314
+ e.preventDefault();
315
+ }
316
+ }
296
317
  }
297
318
  }, [
298
319
  h('Checkbox', {
@@ -302,7 +323,8 @@ export default {
302
323
  indeterminate: false
303
324
  },
304
325
  style: {
305
- marginRight: '8px'
326
+ marginRight: '8px',
327
+ cursor: 'pointer' // 复选框保留点击指针
306
328
  },
307
329
  on: {
308
330
  'on-change': (checked) => {
@@ -324,10 +346,21 @@ export default {
324
346
  }),
325
347
  h('img', {
326
348
  attrs: { src: require('./assets/icon.png') },
327
- style: { marginRight: '8px', width: '14px', height: '14px' }
349
+ style: {
350
+ marginRight: '8px',
351
+ width: '14px',
352
+ height: '14px',
353
+ pointerEvents: 'none' // 图标禁用点击
354
+ }
328
355
  }),
329
356
  h('span', {
330
- style: { overflow: 'hidden', textOverflow: 'ellipsis', flex: 1 }
357
+ style: {
358
+ // overflow: 'hidden',
359
+ // textOverflow: 'ellipsis',
360
+ flex: 1,
361
+ pointerEvents: 'none', // 文本完全禁用点击
362
+ userSelect: 'none' // 禁止文本选中
363
+ }
331
364
  }, data.title)
332
365
  ]);
333
366
  },
@@ -378,9 +411,44 @@ export default {
378
411
 
379
412
  <style lang="less" scoped>
380
413
  .content {
381
- width: 100%;
382
- height: 100%;
383
- overflow: auto;
414
+ width: 100% !important;
415
+ height: 100% !important;
416
+ overflow: visible !important; /* 完全放开溢出限制 */
417
+ box-sizing: border-box;
418
+ }
419
+
420
+ /* 子组件内层容器强制宽度自适应 */
421
+ .tree-inner {
422
+ width: fit-content !important;
423
+ min-width: 100% !important;
424
+ height: 100% !important;
425
+ white-space: nowrap !important;
426
+ }
427
+
428
+ /deep/ .ivu-tree-node {
429
+ white-space: nowrap !important;
430
+ width: auto !important;
431
+ min-width: 100% !important;
432
+ box-sizing: border-box;
433
+ }
434
+
435
+ /deep/ .ivu-tree-node-content {
436
+ cursor: default !important;
437
+ pointer-events: none !important;
438
+ padding-left: 0 !important;
439
+
440
+ .ivu-checkbox, .ivu-tree-switcher {
441
+ pointer-events: auto !important;
442
+ cursor: pointer !important;
443
+ }
444
+ }
445
+
446
+ /deep/ .ivu-tree {
447
+ white-space: nowrap !important;
448
+ display: inline-block !important;
449
+ width: auto !important; /* 宽度自适应内容 */
450
+ min-width: 100% !important; /* 最小宽度占满容器 */
451
+ box-sizing: border-box;
384
452
  }
385
453
 
386
454
  /deep/ .ivu-tree-node,
@@ -410,8 +478,13 @@ export default {
410
478
  padding-left: 0 !important;
411
479
  }
412
480
 
481
+ /deep/ .ivu-tree::-webkit-scrollbar {
482
+ display: block !important;
483
+ }
484
+
413
485
  /deep/ .ivu-tree-indent {
414
486
  margin-right: 4px;
487
+ display: inline-block !important;
415
488
  }
416
489
 
417
490
  /deep/ .ivu-tree-node::before,