address-book-shell 0.0.40 → 0.0.42
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/CHANGELOG.md +13 -0
- package/README.md +25 -29
- package/lib/address-book-shell.common.js +429 -393
- package/lib/address-book-shell.umd.js +429 -393
- package/lib/address-book-shell.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/address-book/src/components/address-aside.vue +68 -54
- package/packages/address-book/src/components/address-content.vue +127 -92
- package/packages/address-book/src/index.vue +2 -2
package/package.json
CHANGED
|
@@ -125,6 +125,8 @@ export default {
|
|
|
125
125
|
this.treeData = Object.freeze(res.nodes.children)
|
|
126
126
|
// console.log(this.treeData, 'treeData')
|
|
127
127
|
if (cb) {
|
|
128
|
+
console.log('this.currentNode', this.currentNode)
|
|
129
|
+
|
|
128
130
|
this.$nextTick(() => {
|
|
129
131
|
cb({ depId: this.currentNode })
|
|
130
132
|
})
|
|
@@ -161,79 +163,91 @@ export default {
|
|
|
161
163
|
},
|
|
162
164
|
// 部门选择
|
|
163
165
|
handleSelectDep(item) {
|
|
166
|
+
// 统一 depId 字段
|
|
164
167
|
item.depId = item.depId || item.depid
|
|
165
|
-
//在这次选中节点之前被选中的节点
|
|
166
|
-
let lastNode = null
|
|
167
|
-
let currentNode = null
|
|
168
|
-
if (this.$refs.videoTree && this.$refs.videoTree.getCurrentNode()) {
|
|
169
|
-
lastNode = this.$refs.videoTree.getNode(this.$refs.videoTree.getCurrentNode())
|
|
170
|
-
//这次选中的节点
|
|
171
|
-
currentNode = this.$refs.videoTree.getNode(item.depId)
|
|
172
|
-
}
|
|
173
|
-
// console.log(lastNode, 'lastNode')
|
|
174
168
|
|
|
169
|
+
// 获取树组件实例
|
|
170
|
+
const tree = this.$refs.videoTree
|
|
171
|
+
if (!tree) return
|
|
172
|
+
|
|
173
|
+
// 获取当前节点
|
|
174
|
+
const currentNode = tree.getNode(item.depId)
|
|
175
175
|
if (!currentNode) return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
176
|
+
|
|
177
|
+
// 收起之前展开的节点
|
|
178
|
+
const lastNode = tree.getCurrentNode() && tree.getNode(tree.getCurrentNode())
|
|
179
|
+
if (lastNode && lastNode.level) {
|
|
180
|
+
let node = lastNode
|
|
181
|
+
do {
|
|
182
|
+
node.expanded = false
|
|
183
|
+
node = node.parent
|
|
184
|
+
} while (node && node.level)
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
|
|
189
|
-
let
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
let childNodes = currentNode.childNodes
|
|
187
|
+
// 计算节点位置
|
|
188
|
+
let nodeIndex = 0
|
|
189
|
+
let node = currentNode
|
|
190
|
+
let currentNodeId = node.data.itemTypeId
|
|
191
|
+
|
|
192
|
+
while (node.parent && node.parent.level) {
|
|
193
|
+
const parentNode = node.parent
|
|
194
|
+
const childNodes = parentNode.childNodes
|
|
195
|
+
|
|
198
196
|
for (let i = 0; i < childNodes.length; i++) {
|
|
199
|
-
if (childNodes[i].data.itemTypeId
|
|
200
|
-
// 计算当前选中的部门在其父部分的第几个
|
|
197
|
+
if (childNodes[i].data.itemTypeId === currentNodeId) {
|
|
201
198
|
nodeIndex += i + 1
|
|
199
|
+
break
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
|
|
203
|
+
node = parentNode
|
|
204
|
+
currentNodeId = node.data.itemTypeId
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 展开并选中当前节点
|
|
208
208
|
this.expandedKeys = [item.depId]
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
209
|
+
tree.setCurrentKey(item.depId)
|
|
210
|
+
|
|
211
|
+
// 计算滚动位置并执行滚动
|
|
212
|
+
const addressAsideScroll = this.$refs['address-aside-scroll']
|
|
213
|
+
if (!addressAsideScroll || !addressAsideScroll.$el) return
|
|
214
|
+
const scrollContainer = addressAsideScroll.$el
|
|
215
|
+
if (scrollContainer) {
|
|
216
|
+
const scrollHeight = scrollContainer.offsetHeight
|
|
217
|
+
const nodeHeight = 35 // 节点高度
|
|
218
|
+
const scrollTop = nodeIndex * nodeHeight - scrollHeight / 2
|
|
219
|
+
|
|
220
|
+
if (nodeIndex > 8) {
|
|
221
|
+
this.setScrollheight(scrollTop, 500)
|
|
222
|
+
} else {
|
|
223
|
+
this.setScrollheight(0, 500)
|
|
224
|
+
}
|
|
223
225
|
}
|
|
226
|
+
|
|
227
|
+
// 触发数据更新
|
|
224
228
|
this.$emit('asideChange', item)
|
|
225
229
|
},
|
|
226
230
|
|
|
227
231
|
// 部门搜索清除
|
|
228
232
|
clearSearchHandler() {
|
|
233
|
+
// 重置搜索状态
|
|
229
234
|
this.depname = ''
|
|
230
235
|
this.currentNode = ''
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
|
|
237
|
+
// 重置树状态
|
|
238
|
+
const tree = this.$refs.videoTree
|
|
239
|
+
if (tree) {
|
|
240
|
+
tree.setCurrentKey(this.currentNode)
|
|
241
|
+
|
|
242
|
+
// 收起所有节点
|
|
243
|
+
if (tree.store && tree.store.nodesMap) {
|
|
244
|
+
Object.values(tree.store.nodesMap).forEach((node) => {
|
|
245
|
+
node.expanded = false
|
|
246
|
+
})
|
|
247
|
+
}
|
|
235
248
|
}
|
|
236
|
-
|
|
249
|
+
|
|
250
|
+
// 清空自动完成列表并通知父组件
|
|
237
251
|
this.autocompleteCB([])
|
|
238
252
|
this.$emit('asideChange', null)
|
|
239
253
|
},
|
|
@@ -192,6 +192,7 @@ export default {
|
|
|
192
192
|
|
|
193
193
|
myFriengInput: '',
|
|
194
194
|
loadingTimer: null,
|
|
195
|
+
isAllSelected: false, // 是否全选
|
|
195
196
|
}
|
|
196
197
|
},
|
|
197
198
|
|
|
@@ -329,6 +330,9 @@ export default {
|
|
|
329
330
|
item.hrId = item.hrId || ''
|
|
330
331
|
item.avatar = item.userImage || ''
|
|
331
332
|
})
|
|
333
|
+
if (this.isAllSelected) {
|
|
334
|
+
this.$emit('addSelectionList', data.detail)
|
|
335
|
+
}
|
|
332
336
|
}
|
|
333
337
|
table.loading = false
|
|
334
338
|
if (initScrollTop) {
|
|
@@ -349,31 +353,31 @@ export default {
|
|
|
349
353
|
},
|
|
350
354
|
setDisableSelect() {
|
|
351
355
|
const hasDisableData = this.selectDisabledlist.length
|
|
352
|
-
|
|
356
|
+
|
|
353
357
|
// 如果没有需要设置的条件,直接返回
|
|
354
358
|
if (!this.disableLeaderSelection && !hasDisableData) {
|
|
355
359
|
return
|
|
356
360
|
}
|
|
357
|
-
|
|
361
|
+
|
|
358
362
|
// 创建禁用列表的 Map 以提高查找效率
|
|
359
|
-
const disabledMap = hasDisableData
|
|
360
|
-
? new Map(this.selectDisabledlist.map(item => [item.hrId, true]))
|
|
363
|
+
const disabledMap = hasDisableData
|
|
364
|
+
? new Map(this.selectDisabledlist.map((item) => [item.hrId, true]))
|
|
361
365
|
: new Map()
|
|
362
|
-
|
|
366
|
+
|
|
363
367
|
// 遍历数据并设置禁用状态
|
|
364
|
-
this.table.tableDataList.forEach(item => {
|
|
368
|
+
this.table.tableDataList.forEach((item) => {
|
|
365
369
|
let shouldDisable = false
|
|
366
|
-
|
|
370
|
+
|
|
367
371
|
// 检查是否禁用领导
|
|
368
372
|
if (this.disableLeaderSelection && (item.depid === 'D1' || item.depId === 'D1')) {
|
|
369
373
|
shouldDisable = true
|
|
370
374
|
}
|
|
371
|
-
|
|
375
|
+
|
|
372
376
|
// 检查是否在禁用列表中
|
|
373
377
|
if (!shouldDisable && hasDisableData && disabledMap.has(item.hrId)) {
|
|
374
378
|
shouldDisable = true
|
|
375
379
|
}
|
|
376
|
-
|
|
380
|
+
|
|
377
381
|
// 只有状态发生变化时才更新,避免不必要的变更
|
|
378
382
|
if (shouldDisable !== item.disable) {
|
|
379
383
|
item.disable = shouldDisable
|
|
@@ -384,56 +388,40 @@ export default {
|
|
|
384
388
|
recoverySelect(falg = false, item = null) {
|
|
385
389
|
let data = this.table.tableDataList
|
|
386
390
|
if (!item) {
|
|
387
|
-
// 如果不传item,比较费性能,不推荐
|
|
388
391
|
this.emptySelect()
|
|
389
392
|
this.$nextTick(() => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (hasArr.length) {
|
|
399
|
-
hasArr.forEach((i) => {
|
|
400
|
-
this.toggleRowSelection(i, true)
|
|
401
|
-
})
|
|
402
|
-
}
|
|
403
|
-
})
|
|
404
|
-
}
|
|
393
|
+
if (!this.selected.length) return
|
|
394
|
+
const dataMap = new Map(data.map((row) => [row.hrId, row]))
|
|
395
|
+
this.selected.forEach((selectedItem) => {
|
|
396
|
+
const matchedRow = dataMap.get(selectedItem.hrId)
|
|
397
|
+
if (matchedRow) {
|
|
398
|
+
this.toggleRowSelection(matchedRow, true)
|
|
399
|
+
}
|
|
400
|
+
})
|
|
405
401
|
})
|
|
406
402
|
} else {
|
|
407
403
|
// 有item 不用对比数据,直接恢复勾选,推荐
|
|
408
404
|
// 传item必须传flag,true 勾选; false 取消勾选
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
// }
|
|
430
|
-
// })
|
|
431
|
-
// if (hasArr.length) {
|
|
432
|
-
// hasArr.forEach((i) => {
|
|
433
|
-
// this.toggleRowSelection(i, falg, true)
|
|
434
|
-
// })
|
|
435
|
-
// }
|
|
436
|
-
// }
|
|
405
|
+
if (Array.isArray(item)) {
|
|
406
|
+
// item为数组,表示恢复多个状态
|
|
407
|
+
const dataMap = new Map(data.map((row) => [row.badge, row]))
|
|
408
|
+
item.forEach((it) => {
|
|
409
|
+
const badge = it.badge || it.fdBadge
|
|
410
|
+
const matchedRow = dataMap.get(badge)
|
|
411
|
+
if (matchedRow) {
|
|
412
|
+
this.toggleRowSelection(matchedRow, falg)
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
} else if (item && typeof item === 'object') {
|
|
416
|
+
// item为对象,表示恢复单个状态
|
|
417
|
+
const badge = item.badge || item.fdBadge
|
|
418
|
+
const matchedRow = data.find(
|
|
419
|
+
(row) => row.tagProfileCustomBadge === badge || row.badge === badge
|
|
420
|
+
)
|
|
421
|
+
if (matchedRow) {
|
|
422
|
+
this.toggleRowSelection(matchedRow, falg)
|
|
423
|
+
}
|
|
424
|
+
}
|
|
437
425
|
}
|
|
438
426
|
},
|
|
439
427
|
// 清空勾选状态
|
|
@@ -441,35 +429,66 @@ export default {
|
|
|
441
429
|
this.$refs.addressTable.clearSelection()
|
|
442
430
|
},
|
|
443
431
|
tableScroll() {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
432
|
+
const table = this.table
|
|
433
|
+
|
|
434
|
+
// 边界检查
|
|
435
|
+
if (!table.tableDom || table.loading || table.flag) {
|
|
436
|
+
return
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const scrollTop = table.tableDom.scrollTop // 滚动距离
|
|
440
|
+
const scrollHeight = table.tableDom.scrollHeight // 滚动条高度
|
|
441
|
+
const clientHeight = table.tableDom.clientHeight // table 高度
|
|
442
|
+
const isBottom = scrollHeight - scrollTop - clientHeight < 100 // 距离底部50px时触发
|
|
443
|
+
|
|
449
444
|
if (isBottom) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
445
|
+
const tableDataLength = table.tableDataList.length
|
|
446
|
+
const targetLength = table.pageSize * table.currentPage
|
|
447
|
+
|
|
448
|
+
// 检查是否需要加载更多数据
|
|
449
|
+
if (tableDataLength >= targetLength) {
|
|
450
|
+
// 表示当前页数据已满,需要加载下一页
|
|
455
451
|
table.flag = true
|
|
456
452
|
table.currentPage++
|
|
457
|
-
this.recoverySelect()
|
|
458
453
|
this.queryData()
|
|
459
454
|
}
|
|
460
455
|
}
|
|
461
456
|
},
|
|
457
|
+
// 节流函数
|
|
458
|
+
throttle(func, delay) {
|
|
459
|
+
let timer = null
|
|
460
|
+
return function () {
|
|
461
|
+
if (!timer) {
|
|
462
|
+
timer = setTimeout(() => {
|
|
463
|
+
func.apply(this, arguments)
|
|
464
|
+
timer = null
|
|
465
|
+
}, delay)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
|
|
462
470
|
listenTableScroll() {
|
|
463
|
-
|
|
471
|
+
const tableDom = this.$refs.addressTable
|
|
472
|
+
if (tableDom) {
|
|
464
473
|
let table = this.table
|
|
465
|
-
|
|
466
|
-
|
|
474
|
+
// 兼容不同版本的 Element UI DOM 结构
|
|
475
|
+
const bodyWrapper = tableDom.bodyWrapperScrollbar || tableDom.bodyWrapper
|
|
476
|
+
|
|
477
|
+
if (bodyWrapper) {
|
|
478
|
+
table.tableDom = bodyWrapper
|
|
479
|
+
// 使用节流处理滚动事件
|
|
480
|
+
this.tableScroll = this.throttle(this.tableScroll, 200)
|
|
481
|
+
table.tableDom.addEventListener('scroll', this.tableScroll)
|
|
482
|
+
} else {
|
|
483
|
+
console.warn('Could not find table scroll container')
|
|
484
|
+
}
|
|
467
485
|
}
|
|
468
486
|
},
|
|
469
487
|
initScrollTop() {
|
|
470
488
|
this.$nextTick(() => {
|
|
471
|
-
|
|
472
|
-
|
|
489
|
+
const tableDom = this.$refs.addressTable
|
|
490
|
+
if (!this.table.tableDom && tableDom) {
|
|
491
|
+
this.table.tableDom = tableDom.bodyWrapperScrollbar || tableDom.bodyWrapper
|
|
473
492
|
}
|
|
474
493
|
this.table.tableDom.scrollTop = 0
|
|
475
494
|
})
|
|
@@ -485,35 +504,32 @@ export default {
|
|
|
485
504
|
},
|
|
486
505
|
// 动勾选数据行的 Checkbox 时触发
|
|
487
506
|
select(selection, item) {
|
|
488
|
-
if(item.disable) return
|
|
489
|
-
|
|
507
|
+
if (item.disable) return
|
|
508
|
+
|
|
490
509
|
if (this.radio) {
|
|
491
|
-
//
|
|
492
|
-
if (selection.length
|
|
510
|
+
// 单选模式
|
|
511
|
+
if (selection.length >= 2) {
|
|
493
512
|
this.$refs.addressTable.clearSelection()
|
|
494
|
-
|
|
513
|
+
if (selection.length === 2) {
|
|
514
|
+
this.$refs.addressTable.toggleRowSelection(selection[1])
|
|
515
|
+
}
|
|
495
516
|
} else if (selection.length === 1) {
|
|
496
|
-
this.selection = [selection[
|
|
497
|
-
} else if (selection.length > 2) {
|
|
498
|
-
this.$refs.addressTable.clearSelection()
|
|
517
|
+
this.selection = [selection[0]]
|
|
499
518
|
}
|
|
500
519
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
console.log('勾选数据', item)
|
|
506
|
-
} else {
|
|
507
|
-
// 删除操作
|
|
508
|
-
this.$emit('deleteSelectionItem', item)
|
|
509
|
-
}
|
|
520
|
+
|
|
521
|
+
// 判断是添加还是删除操作
|
|
522
|
+
const isAdd = selection.some(it => it.hrId === item.hrId)
|
|
523
|
+
this.$emit(isAdd ? 'addSelectionItem' : 'deleteSelectionItem', item)
|
|
510
524
|
},
|
|
511
525
|
selectAll(selection) {
|
|
512
526
|
if (selection.length) {
|
|
513
527
|
// 全选
|
|
528
|
+
this.isAllSelected = true
|
|
514
529
|
this.$emit('addSelectionList', selection)
|
|
515
530
|
} else {
|
|
516
531
|
// 全取消
|
|
532
|
+
this.resetAllSelected()
|
|
517
533
|
let dataList = this.table.tableDataList
|
|
518
534
|
this.$emit('deleteSelectionList', dataList)
|
|
519
535
|
}
|
|
@@ -521,12 +537,9 @@ export default {
|
|
|
521
537
|
// 手动修改选中状态
|
|
522
538
|
toggleRowSelection(data, flag = true) {
|
|
523
539
|
this.$nextTick(() => {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (i > -1) {
|
|
528
|
-
// 如果删除的是当前显示的列表数据,直接在列表中取消勾选
|
|
529
|
-
this.$refs.addressTable.toggleRowSelection(this.table.tableDataList[i], flag)
|
|
540
|
+
const matchedRow = this.table.tableDataList.find(item => item.hrId === data.hrId)
|
|
541
|
+
if (matchedRow) {
|
|
542
|
+
this.$refs.addressTable.toggleRowSelection(matchedRow, flag)
|
|
530
543
|
}
|
|
531
544
|
})
|
|
532
545
|
},
|
|
@@ -668,6 +681,9 @@ export default {
|
|
|
668
681
|
this.searchInput.searchToTable = false
|
|
669
682
|
this.queryData()
|
|
670
683
|
},
|
|
684
|
+
resetAllSelected() {
|
|
685
|
+
this.isAllSelected = false
|
|
686
|
+
},
|
|
671
687
|
},
|
|
672
688
|
computed: {
|
|
673
689
|
currentTypeList() {
|
|
@@ -704,6 +720,22 @@ export default {
|
|
|
704
720
|
this.loadingTimer = null
|
|
705
721
|
}
|
|
706
722
|
},
|
|
723
|
+
'table.currentPage': {
|
|
724
|
+
handler(newVal) {
|
|
725
|
+
if (newVal === 1) {
|
|
726
|
+
console.log('当前页码', newVal)
|
|
727
|
+
this.resetAllSelected()
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
'table.depId': {
|
|
732
|
+
handler(newVal, oldVal) {
|
|
733
|
+
if (newVal !== oldVal) {
|
|
734
|
+
console.log('部门id', newVal)
|
|
735
|
+
this.resetAllSelected()
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
},
|
|
707
739
|
},
|
|
708
740
|
destroyed() {
|
|
709
741
|
this.table.tableDom.removeEventListener('scroll', this.tableScroll)
|
|
@@ -721,6 +753,9 @@ export default {
|
|
|
721
753
|
&::before {
|
|
722
754
|
height: 0;
|
|
723
755
|
}
|
|
756
|
+
::v-deep .el-scrollbar__wrap {
|
|
757
|
+
height: 100% !important;
|
|
758
|
+
}
|
|
724
759
|
}
|
|
725
760
|
height: 100%;
|
|
726
761
|
width: 100%;
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
</div>
|
|
300
300
|
|
|
301
301
|
<div class="selected">
|
|
302
|
-
<
|
|
302
|
+
<template v-if="!showOnlyNewPersonnels">
|
|
303
303
|
<AddreddGroup
|
|
304
304
|
class="selected-list"
|
|
305
305
|
:class="nameImport ? 'has-name-import' : ''"
|
|
@@ -315,7 +315,7 @@
|
|
|
315
315
|
>
|
|
316
316
|
</AddreddGroup>
|
|
317
317
|
<span v-show="!selectedList.length" class="no-selected-data">还未进行选择</span>
|
|
318
|
-
</
|
|
318
|
+
</template>
|
|
319
319
|
<template v-else>
|
|
320
320
|
<AddreddGroup
|
|
321
321
|
class="selected-list"
|