ai.touchui-vue 1.35.2 → 1.37.0
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/lib/ai.touchui-vue.common.js +217 -82
- package/lib/calendar.js +11 -5
- package/lib/checkbox.js +2 -3
- package/lib/date-picker.js +20 -6
- package/lib/index.js +1 -1
- package/lib/input.js +3 -3
- package/lib/select.js +18 -3
- package/lib/slide.js +42 -14
- package/lib/table.js +82 -9
- package/lib/upload.js +3 -3
- package/package.json +4 -3
- package/packages/calendar/src/calendar.vue +10 -4
- package/packages/checkbox/src/checkbox.vue +0 -1
- package/packages/date-picker/src/date-picker.vue +27 -13
- package/packages/dialog/.DS_Store +0 -0
- package/packages/form/.DS_Store +0 -0
- package/packages/input/src/input.vue +1 -1
- package/packages/select/src/select.vue +7 -4
- package/packages/slide/src/slide.vue +27 -2
- package/packages/table/src/table.vue +53 -7
- package/packages/theme/src/img/.DS_Store +0 -0
- package/packages/upload/src/upload.vue +1 -1
- package/src/index.js +1 -1
|
@@ -35,7 +35,8 @@ export default {
|
|
|
35
35
|
animate: true,
|
|
36
36
|
playTimer: null,
|
|
37
37
|
startPosition: false,
|
|
38
|
-
width: 0
|
|
38
|
+
width: 0,
|
|
39
|
+
observer: null
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
computed: {
|
|
@@ -62,8 +63,28 @@ export default {
|
|
|
62
63
|
window.addEventListener('resize', () => {
|
|
63
64
|
this.width = this.$el.offsetWidth
|
|
64
65
|
})
|
|
66
|
+
|
|
67
|
+
// 初始化 MutationObserver
|
|
68
|
+
const observer = new MutationObserver((mutations) => {
|
|
69
|
+
this.setLength(); // 每次子节点变化时更新长度
|
|
70
|
+
});
|
|
71
|
+
observer.observe(this.$refs.ul, {
|
|
72
|
+
childList: true, // 监听子节点变化
|
|
73
|
+
subtree: true // 监听所有后代节点
|
|
74
|
+
});
|
|
75
|
+
this.observer = observer;
|
|
76
|
+
|
|
65
77
|
}, 100)
|
|
66
78
|
},
|
|
79
|
+
beforeDestroy() {
|
|
80
|
+
if (this.observer) {
|
|
81
|
+
this.observer.disconnect(); // 断开监听
|
|
82
|
+
}
|
|
83
|
+
clearInterval(this.playTimer); // 清理定时器
|
|
84
|
+
window.removeEventListener('resize', () => {
|
|
85
|
+
this.width = this.$el.offsetWidth;
|
|
86
|
+
});
|
|
87
|
+
},
|
|
67
88
|
methods: {
|
|
68
89
|
play() {
|
|
69
90
|
if (!this.autoplay || this.length < 2) {
|
|
@@ -77,7 +98,11 @@ export default {
|
|
|
77
98
|
clearInterval(this.playTimer)
|
|
78
99
|
},
|
|
79
100
|
setLength() {
|
|
80
|
-
this
|
|
101
|
+
this.$nextTick(() => {
|
|
102
|
+
if (this.$refs.ul) {
|
|
103
|
+
this.length = this.$refs.ul.children.length - 2;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
81
106
|
},
|
|
82
107
|
next() {
|
|
83
108
|
if (this.animate) {
|
|
@@ -344,6 +344,11 @@ export default {
|
|
|
344
344
|
default: function _default() {
|
|
345
345
|
return this.height && !this.fixTop ? '0r' : '1r'
|
|
346
346
|
}
|
|
347
|
+
},
|
|
348
|
+
// selectionChange 事件时是否需要将扁平数据转换为层级树形结构输出
|
|
349
|
+
selectionValueType: {
|
|
350
|
+
type: String,
|
|
351
|
+
default: 'flat' // flat | tree
|
|
347
352
|
}
|
|
348
353
|
},
|
|
349
354
|
data() {
|
|
@@ -456,9 +461,7 @@ export default {
|
|
|
456
461
|
this.iData.map(item => {
|
|
457
462
|
if (item._checked) {
|
|
458
463
|
const obj = JSON.parse(JSON.stringify(item))
|
|
459
|
-
delete obj._index
|
|
460
464
|
delete obj._checked
|
|
461
|
-
delete obj._level
|
|
462
465
|
delete obj._show
|
|
463
466
|
delete obj._hover
|
|
464
467
|
delete obj._active
|
|
@@ -867,7 +870,7 @@ export default {
|
|
|
867
870
|
if (leftThs.length > 0) {
|
|
868
871
|
for (let j = 0; j < leftThs.length; j++) {
|
|
869
872
|
const th = ths[j]
|
|
870
|
-
const leftTh = leftThs[
|
|
873
|
+
const leftTh = leftThs[j]
|
|
871
874
|
leftTh.style.width = th.getBoundingClientRect().width + 'px'
|
|
872
875
|
leftTh.style.height = th.getBoundingClientRect().height + 'px'
|
|
873
876
|
}
|
|
@@ -999,8 +1002,8 @@ export default {
|
|
|
999
1002
|
}
|
|
1000
1003
|
})
|
|
1001
1004
|
this.$emit('change', this.checked, checked)
|
|
1002
|
-
this.$emit('selectionChange', this.checked)
|
|
1003
|
-
this.$emit('selection-change', this.checked)
|
|
1005
|
+
this.$emit('selectionChange', this.selectionValueType === 'tree' ? this.buildHierarchyTree(this.checked) : this.checked)
|
|
1006
|
+
this.$emit('selection-change', this.selectionValueType === 'tree' ? this.buildHierarchyTree(this.checked) : this.checked)
|
|
1004
1007
|
},
|
|
1005
1008
|
// 根据 checkbox 计算是否全选
|
|
1006
1009
|
setSelectAll() {
|
|
@@ -1020,8 +1023,8 @@ export default {
|
|
|
1020
1023
|
}
|
|
1021
1024
|
this.setSelectAll()
|
|
1022
1025
|
this.$emit('change', this.checked, checked, current)
|
|
1023
|
-
this.$emit('selectionChange', this.checked, current)
|
|
1024
|
-
this.$emit('selection-change', this.checked, current)
|
|
1026
|
+
this.$emit('selectionChange', this.selectionValueType === 'tree' ? this.buildHierarchyTree(this.checked) : this.checked, current)
|
|
1027
|
+
this.$emit('selection-change', this.selectionValueType === 'tree' ? this.buildHierarchyTree(this.checked) : this.checked, current)
|
|
1025
1028
|
},
|
|
1026
1029
|
// 从记录中移除
|
|
1027
1030
|
removeFromCache(rowData) {
|
|
@@ -1488,6 +1491,49 @@ export default {
|
|
|
1488
1491
|
this.collapseAll()
|
|
1489
1492
|
}
|
|
1490
1493
|
this.expandFlag = !this.expandFlag
|
|
1494
|
+
},
|
|
1495
|
+
// 将扁平数据转换为层级树形结构
|
|
1496
|
+
buildHierarchyTree(flatData) {
|
|
1497
|
+
const result = [];
|
|
1498
|
+
const levelStack = [];
|
|
1499
|
+
|
|
1500
|
+
for (const item of flatData) {
|
|
1501
|
+
const currentNode = Object.assign({}, item);
|
|
1502
|
+
currentNode.children = [];
|
|
1503
|
+
|
|
1504
|
+
const level = currentNode._level;
|
|
1505
|
+
|
|
1506
|
+
// 清除高于当前level的节点
|
|
1507
|
+
while (levelStack.length && levelStack[levelStack.length - 1]._level >= level) {
|
|
1508
|
+
levelStack.pop();
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
if (levelStack.length === 0) {
|
|
1512
|
+
// 当前是顶级节点
|
|
1513
|
+
result.push(currentNode);
|
|
1514
|
+
} else {
|
|
1515
|
+
// 插入到上一层级的 children 中
|
|
1516
|
+
const parent = levelStack[levelStack.length - 1];
|
|
1517
|
+
parent.children.push(currentNode);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// 当前节点入栈
|
|
1521
|
+
levelStack.push(currentNode);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// 清理空 children
|
|
1525
|
+
const cleanEmptyChildren = (nodeList) => {
|
|
1526
|
+
for (const node of nodeList) {
|
|
1527
|
+
if (node.children.length === 0) {
|
|
1528
|
+
delete node.children;
|
|
1529
|
+
} else {
|
|
1530
|
+
cleanEmptyChildren(node.children);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
|
|
1535
|
+
cleanEmptyChildren(result);
|
|
1536
|
+
return result;
|
|
1491
1537
|
}
|
|
1492
1538
|
}
|
|
1493
1539
|
}
|
|
Binary file
|