stk-table-vue 0.2.0 → 0.2.2
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/README.md +57 -18
- package/lib/src/StkTable/StkTable.vue.d.ts +27 -10
- package/lib/src/StkTable/types/index.d.ts +8 -3
- package/lib/src/StkTable/useAutoResize.d.ts +2 -3
- package/lib/src/StkTable/useThDrag.d.ts +4 -1
- package/lib/src/StkTable/utils.d.ts +4 -2
- package/lib/stk-table-vue.js +439 -488
- package/lib/style.css +7 -3
- package/package.json +2 -2
- package/src/StkTable/StkTable.vue +29 -12
- package/src/StkTable/style.less +7 -5
- package/src/StkTable/types/index.ts +9 -3
- package/src/StkTable/useAutoResize.ts +2 -3
- package/src/StkTable/useColResize.ts +3 -3
- package/src/StkTable/useFixedCol.ts +1 -1
- package/src/StkTable/useFixedStyle.ts +4 -3
- package/src/StkTable/useHighlight.ts +2 -0
- package/src/StkTable/useThDrag.ts +37 -8
- package/src/StkTable/useVirtualScroll.ts +6 -12
- package/src/StkTable/utils.ts +55 -20
package/lib/stk-table-vue.js
CHANGED
|
@@ -20,7 +20,7 @@ try {
|
|
|
20
20
|
console.error("Cannot get Chrome version", e);
|
|
21
21
|
}
|
|
22
22
|
const Is_Legacy_Mode = _chromeVersion < 56;
|
|
23
|
-
function useAutoResize({ tableContainer, initVirtualScroll,
|
|
23
|
+
function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs }) {
|
|
24
24
|
let resizeObserver = null;
|
|
25
25
|
onMounted(() => {
|
|
26
26
|
initResizeObserver();
|
|
@@ -70,6 +70,125 @@ function useAutoResize({ tableContainer, initVirtualScroll, scrollTo, props, deb
|
|
|
70
70
|
}, debounceMs);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
function insertToOrderedArray(sortState, newItem, targetArray) {
|
|
74
|
+
const { dataIndex, order } = sortState;
|
|
75
|
+
let { sortType } = sortState;
|
|
76
|
+
if (!sortType)
|
|
77
|
+
sortType = typeof newItem[dataIndex];
|
|
78
|
+
const data = [...targetArray];
|
|
79
|
+
if (!order) {
|
|
80
|
+
data.unshift(newItem);
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
let sIndex = 0;
|
|
84
|
+
let eIndex = data.length - 1;
|
|
85
|
+
const targetVal = newItem[dataIndex];
|
|
86
|
+
while (sIndex <= eIndex) {
|
|
87
|
+
const midIndex = Math.floor((sIndex + eIndex) / 2);
|
|
88
|
+
const midVal = data[midIndex][dataIndex];
|
|
89
|
+
const compareRes = strCompare(midVal, targetVal, sortType);
|
|
90
|
+
if (compareRes === 0) {
|
|
91
|
+
sIndex = midIndex;
|
|
92
|
+
break;
|
|
93
|
+
} else if (compareRes === -1) {
|
|
94
|
+
if (order === "asc")
|
|
95
|
+
sIndex = midIndex + 1;
|
|
96
|
+
else
|
|
97
|
+
eIndex = midIndex - 1;
|
|
98
|
+
} else {
|
|
99
|
+
if (order === "asc")
|
|
100
|
+
eIndex = midIndex - 1;
|
|
101
|
+
else
|
|
102
|
+
sIndex = midIndex + 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
data.splice(sIndex, 0, newItem);
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
function strCompare(a, b, type) {
|
|
109
|
+
if (type === "number") {
|
|
110
|
+
if (+a > +b)
|
|
111
|
+
return 1;
|
|
112
|
+
else if (+a === +b)
|
|
113
|
+
return 0;
|
|
114
|
+
else
|
|
115
|
+
return -1;
|
|
116
|
+
} else {
|
|
117
|
+
return String(a).localeCompare(b);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function separatedData(sortOption, targetDataSource, isNumber) {
|
|
121
|
+
const emptyArr = [];
|
|
122
|
+
const valueArr = [];
|
|
123
|
+
for (let i = 0; i < targetDataSource.length; i++) {
|
|
124
|
+
const row = targetDataSource[i];
|
|
125
|
+
const sortField = sortOption.sortField || sortOption.dataIndex;
|
|
126
|
+
let isEmpty = row[sortField] === null || row[sortField] === "";
|
|
127
|
+
if (isNumber) {
|
|
128
|
+
isEmpty || (isEmpty = typeof row[sortField] === "boolean" || Number.isNaN(+row[sortField]));
|
|
129
|
+
}
|
|
130
|
+
if (isEmpty) {
|
|
131
|
+
emptyArr.push(row);
|
|
132
|
+
} else {
|
|
133
|
+
valueArr.push(row);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return [valueArr, emptyArr];
|
|
137
|
+
}
|
|
138
|
+
function tableSort(sortOption, order, dataSource, sortConfig = {}) {
|
|
139
|
+
if (!(dataSource == null ? void 0 : dataSource.length))
|
|
140
|
+
return dataSource || [];
|
|
141
|
+
sortConfig = Object.assign({ emptyToBottom: false }, sortConfig);
|
|
142
|
+
let targetDataSource = [...dataSource];
|
|
143
|
+
if (typeof sortOption.sorter === "function") {
|
|
144
|
+
const customSorterData = sortOption.sorter(targetDataSource, { order, column: sortOption });
|
|
145
|
+
if (customSorterData)
|
|
146
|
+
targetDataSource = customSorterData;
|
|
147
|
+
} else if (order) {
|
|
148
|
+
const sortField = sortOption.sortField || sortOption.dataIndex;
|
|
149
|
+
let { sortType } = sortOption;
|
|
150
|
+
if (!sortType)
|
|
151
|
+
sortType = typeof dataSource[0][sortField];
|
|
152
|
+
const [valueArr, emptyArr] = separatedData(sortOption, targetDataSource, sortType === "number");
|
|
153
|
+
if (sortType === "number") {
|
|
154
|
+
if (order === "asc") {
|
|
155
|
+
valueArr.sort((a, b) => +a[sortField] - +b[sortField]);
|
|
156
|
+
targetDataSource = [...emptyArr, ...valueArr];
|
|
157
|
+
} else {
|
|
158
|
+
valueArr.sort((a, b) => +b[sortField] - +a[sortField]);
|
|
159
|
+
targetDataSource = [...valueArr, ...emptyArr];
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
if (order === "asc") {
|
|
163
|
+
valueArr.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]));
|
|
164
|
+
targetDataSource = [...emptyArr, ...valueArr];
|
|
165
|
+
} else {
|
|
166
|
+
valueArr.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]) * -1);
|
|
167
|
+
targetDataSource = [...valueArr, ...emptyArr];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (sortConfig.emptyToBottom) {
|
|
171
|
+
targetDataSource = [...valueArr, ...emptyArr];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return targetDataSource;
|
|
175
|
+
}
|
|
176
|
+
function howDeepTheHeader(arr, level = 1) {
|
|
177
|
+
const levels = [level];
|
|
178
|
+
arr.forEach((item) => {
|
|
179
|
+
var _a;
|
|
180
|
+
if ((_a = item.children) == null ? void 0 : _a.length) {
|
|
181
|
+
levels.push(howDeepTheHeader(item.children, level + 1));
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return Math.max(...levels);
|
|
185
|
+
}
|
|
186
|
+
function getColWidth(col) {
|
|
187
|
+
if (typeof (col == null ? void 0 : col.width) === "number") {
|
|
188
|
+
return Math.floor(col.width ?? Default_Col_Width);
|
|
189
|
+
}
|
|
190
|
+
return parseInt((col == null ? void 0 : col.width) ?? Default_Col_Width);
|
|
191
|
+
}
|
|
73
192
|
function useColResize({
|
|
74
193
|
tableContainer,
|
|
75
194
|
tableHeaderLast,
|
|
@@ -137,7 +256,7 @@ function useColResize({
|
|
|
137
256
|
const { lastCol, startX, startOffsetTableX } = colResizeState;
|
|
138
257
|
const { clientX } = e;
|
|
139
258
|
let moveX = clientX - startX;
|
|
140
|
-
const currentColWidth =
|
|
259
|
+
const currentColWidth = getColWidth(lastCol);
|
|
141
260
|
if (currentColWidth + moveX < props.colMinWidth) {
|
|
142
261
|
moveX = -currentColWidth;
|
|
143
262
|
}
|
|
@@ -152,7 +271,7 @@ function useColResize({
|
|
|
152
271
|
const { startX, lastCol } = colResizeState;
|
|
153
272
|
const { clientX } = e;
|
|
154
273
|
const moveX = clientX - startX;
|
|
155
|
-
let width =
|
|
274
|
+
let width = getColWidth(lastCol) + moveX;
|
|
156
275
|
if (width < props.colMinWidth)
|
|
157
276
|
width = props.colMinWidth;
|
|
158
277
|
const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
|
|
@@ -201,7 +320,7 @@ function useFixedCol({ props, tableHeaderLast, tableContainer }) {
|
|
|
201
320
|
return;
|
|
202
321
|
fixedShadowCols = [];
|
|
203
322
|
let lastLeftCol = null;
|
|
204
|
-
for (let i = tableHeaderLast.value.length - 1; i
|
|
323
|
+
for (let i = tableHeaderLast.value.length - 1; i >= 0; i--) {
|
|
205
324
|
const col = tableHeaderLast.value[i];
|
|
206
325
|
if (col.fixed === "left") {
|
|
207
326
|
lastLeftCol = col;
|
|
@@ -258,7 +377,7 @@ function useFixedStyle({ props, tableHeaderLast, virtualScroll, virtualScrollX,
|
|
|
258
377
|
const item = cols[i];
|
|
259
378
|
if (item.fixed === "left") {
|
|
260
379
|
store[item.dataIndex] = left;
|
|
261
|
-
left +=
|
|
380
|
+
left += getColWidth(item);
|
|
262
381
|
}
|
|
263
382
|
if (!rightStartIndex && item.fixed === "right") {
|
|
264
383
|
rightStartIndex = i;
|
|
@@ -269,7 +388,7 @@ function useFixedStyle({ props, tableHeaderLast, virtualScroll, virtualScrollX,
|
|
|
269
388
|
const item = cols[i];
|
|
270
389
|
if (item.fixed === "right") {
|
|
271
390
|
store[item.dataIndex] = right;
|
|
272
|
-
right +=
|
|
391
|
+
right += getColWidth(item);
|
|
273
392
|
}
|
|
274
393
|
}
|
|
275
394
|
return store;
|
|
@@ -471,36 +590,57 @@ function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll,
|
|
|
471
590
|
isMouseOver = true;
|
|
472
591
|
}
|
|
473
592
|
}
|
|
474
|
-
function useThDrag({ emits }) {
|
|
593
|
+
function useThDrag({ props, emits }) {
|
|
475
594
|
let dragStartKey = void 0;
|
|
595
|
+
function findParentTH(el) {
|
|
596
|
+
let n = el;
|
|
597
|
+
while (n) {
|
|
598
|
+
if (n.tagName === "TH")
|
|
599
|
+
return n;
|
|
600
|
+
n = n.parentElement;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
476
603
|
function onThDragStart(e) {
|
|
477
|
-
|
|
604
|
+
const th = findParentTH(e.target);
|
|
605
|
+
if (!th)
|
|
606
|
+
return;
|
|
607
|
+
dragStartKey = th.dataset.colKey;
|
|
478
608
|
emits("th-drag-start", dragStartKey);
|
|
479
609
|
}
|
|
480
610
|
function onThDragOver(e) {
|
|
611
|
+
const th = findParentTH(e.target);
|
|
612
|
+
if (!th)
|
|
613
|
+
return;
|
|
614
|
+
const isHeaderDraggable2 = th.getAttribute("draggable") === "true";
|
|
615
|
+
if (!isHeaderDraggable2) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
481
618
|
e.preventDefault();
|
|
482
619
|
}
|
|
483
620
|
function onThDrop(e) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
break;
|
|
488
|
-
th = th.parentNode;
|
|
489
|
-
}
|
|
621
|
+
const th = findParentTH(e.target);
|
|
622
|
+
if (!th)
|
|
623
|
+
return;
|
|
490
624
|
if (dragStartKey !== th.dataset.colKey) {
|
|
491
625
|
emits("col-order-change", dragStartKey, th.dataset.colKey);
|
|
492
626
|
}
|
|
493
627
|
emits("th-drop", th.dataset.colKey);
|
|
494
628
|
}
|
|
629
|
+
const isHeaderDragFun = typeof props.headerDrag === "function";
|
|
630
|
+
function isHeaderDraggable(col) {
|
|
631
|
+
if (isHeaderDragFun) {
|
|
632
|
+
return props.headerDrag(col);
|
|
633
|
+
} else {
|
|
634
|
+
return props.headerDrag;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
495
637
|
return {
|
|
496
638
|
onThDragStart,
|
|
497
639
|
onThDragOver,
|
|
498
|
-
onThDrop
|
|
640
|
+
onThDrop,
|
|
641
|
+
isHeaderDraggable
|
|
499
642
|
};
|
|
500
643
|
}
|
|
501
|
-
function getCalcWidth(col) {
|
|
502
|
-
return parseInt(col.minWidth || col.width || Default_Col_Width);
|
|
503
|
-
}
|
|
504
644
|
const VUE2_SCROLL_TIMEOUT_MS = 200;
|
|
505
645
|
function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLast }) {
|
|
506
646
|
const virtualScroll = ref({
|
|
@@ -535,7 +675,7 @@ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLa
|
|
|
535
675
|
return (dataSourceCopy.value.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
|
|
536
676
|
});
|
|
537
677
|
const virtualX_on = computed(() => {
|
|
538
|
-
return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum +=
|
|
678
|
+
return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getColWidth(col), 0) > virtualScrollX.value.containerWidth + 100;
|
|
539
679
|
});
|
|
540
680
|
const virtualX_columnPart = computed(() => {
|
|
541
681
|
if (virtualX_on.value) {
|
|
@@ -564,7 +704,7 @@ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLa
|
|
|
564
704
|
for (let i = virtualScrollX.value.endIndex; i < tableHeaderLast.value.length; i++) {
|
|
565
705
|
const col = tableHeaderLast.value[i];
|
|
566
706
|
if (col.fixed !== "right") {
|
|
567
|
-
width +=
|
|
707
|
+
width += getColWidth(col);
|
|
568
708
|
}
|
|
569
709
|
}
|
|
570
710
|
return width;
|
|
@@ -639,7 +779,7 @@ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLa
|
|
|
639
779
|
const col = tableHeaderLast.value[colIndex];
|
|
640
780
|
if (col.fixed === "left")
|
|
641
781
|
continue;
|
|
642
|
-
const colWidth =
|
|
782
|
+
const colWidth = getColWidth(col);
|
|
643
783
|
colWidthSum += colWidth;
|
|
644
784
|
if (colWidthSum >= sLeft) {
|
|
645
785
|
offsetLeft = colWidthSum - colWidth;
|
|
@@ -651,7 +791,7 @@ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLa
|
|
|
651
791
|
let endIndex = headerLength;
|
|
652
792
|
for (let colIndex = startIndex + 1; colIndex < headerLength; colIndex++) {
|
|
653
793
|
const col = tableHeaderLast.value[colIndex];
|
|
654
|
-
colWidthSum +=
|
|
794
|
+
colWidthSum += getColWidth(col);
|
|
655
795
|
if (colWidthSum >= virtualScrollX.value.containerWidth) {
|
|
656
796
|
endIndex = colIndex + 1;
|
|
657
797
|
break;
|
|
@@ -688,114 +828,10 @@ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLa
|
|
|
688
828
|
updateVirtualScrollX
|
|
689
829
|
};
|
|
690
830
|
}
|
|
691
|
-
|
|
692
|
-
const { dataIndex, order } = sortState;
|
|
693
|
-
let { sortType } = sortState;
|
|
694
|
-
if (!sortType)
|
|
695
|
-
sortType = typeof newItem[dataIndex];
|
|
696
|
-
const data = [...targetArray];
|
|
697
|
-
if (!order) {
|
|
698
|
-
data.unshift(newItem);
|
|
699
|
-
return data;
|
|
700
|
-
}
|
|
701
|
-
let sIndex = 0;
|
|
702
|
-
let eIndex = data.length - 1;
|
|
703
|
-
const targetVal = newItem[dataIndex];
|
|
704
|
-
while (sIndex <= eIndex) {
|
|
705
|
-
const midIndex = Math.floor((sIndex + eIndex) / 2);
|
|
706
|
-
const midVal = data[midIndex][dataIndex];
|
|
707
|
-
const compareRes = strCompare(midVal, targetVal, sortType);
|
|
708
|
-
if (compareRes === 0) {
|
|
709
|
-
sIndex = midIndex;
|
|
710
|
-
break;
|
|
711
|
-
} else if (compareRes === -1) {
|
|
712
|
-
if (order === "asc")
|
|
713
|
-
sIndex = midIndex + 1;
|
|
714
|
-
else
|
|
715
|
-
eIndex = midIndex - 1;
|
|
716
|
-
} else {
|
|
717
|
-
if (order === "asc")
|
|
718
|
-
eIndex = midIndex - 1;
|
|
719
|
-
else
|
|
720
|
-
sIndex = midIndex + 1;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
data.splice(sIndex, 0, newItem);
|
|
724
|
-
return data;
|
|
725
|
-
}
|
|
726
|
-
function strCompare(a, b, type) {
|
|
727
|
-
if (type === "number") {
|
|
728
|
-
if (+a > +b)
|
|
729
|
-
return 1;
|
|
730
|
-
else if (+a === +b)
|
|
731
|
-
return 0;
|
|
732
|
-
else
|
|
733
|
-
return -1;
|
|
734
|
-
} else {
|
|
735
|
-
return String(a).localeCompare(b);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
function tableSort(sortOption, order, dataSource) {
|
|
739
|
-
if (!(dataSource == null ? void 0 : dataSource.length))
|
|
740
|
-
return dataSource || [];
|
|
741
|
-
let targetDataSource = [...dataSource];
|
|
742
|
-
if (typeof sortOption.sorter === "function") {
|
|
743
|
-
const customSorterData = sortOption.sorter(targetDataSource, { order, column: sortOption });
|
|
744
|
-
if (customSorterData)
|
|
745
|
-
targetDataSource = customSorterData;
|
|
746
|
-
} else if (order) {
|
|
747
|
-
const sortField = sortOption.sortField || sortOption.dataIndex;
|
|
748
|
-
let { sortType } = sortOption;
|
|
749
|
-
if (!sortType)
|
|
750
|
-
sortType = typeof dataSource[0][sortField];
|
|
751
|
-
if (sortType === "number") {
|
|
752
|
-
const nanArr = [];
|
|
753
|
-
const numArr = [];
|
|
754
|
-
for (let i = 0; i < targetDataSource.length; i++) {
|
|
755
|
-
const row = targetDataSource[i];
|
|
756
|
-
if (row[sortField] === null || row[sortField] === "" || typeof row[sortField] === "boolean" || Number.isNaN(+row[sortField])) {
|
|
757
|
-
nanArr.push(row);
|
|
758
|
-
} else {
|
|
759
|
-
numArr.push(row);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
if (order === "asc") {
|
|
763
|
-
numArr.sort((a, b) => +a[sortField] - +b[sortField]);
|
|
764
|
-
targetDataSource = [...nanArr, ...numArr];
|
|
765
|
-
} else {
|
|
766
|
-
numArr.sort((a, b) => +b[sortField] - +a[sortField]);
|
|
767
|
-
targetDataSource = [...numArr, ...nanArr];
|
|
768
|
-
}
|
|
769
|
-
} else {
|
|
770
|
-
if (order === "asc") {
|
|
771
|
-
targetDataSource.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]));
|
|
772
|
-
} else {
|
|
773
|
-
targetDataSource.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]) * -1);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
return targetDataSource;
|
|
778
|
-
}
|
|
779
|
-
function howDeepTheHeader(arr, level = 1) {
|
|
780
|
-
const levels = [level];
|
|
781
|
-
arr.forEach((item) => {
|
|
782
|
-
var _a;
|
|
783
|
-
if ((_a = item.children) == null ? void 0 : _a.length) {
|
|
784
|
-
levels.push(howDeepTheHeader(item.children, level + 1));
|
|
785
|
-
}
|
|
786
|
-
});
|
|
787
|
-
return Math.max(...levels);
|
|
788
|
-
}
|
|
789
|
-
const _hoisted_1 = {
|
|
790
|
-
key: 0
|
|
791
|
-
};
|
|
831
|
+
const _hoisted_1 = { key: 0 };
|
|
792
832
|
const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
793
|
-
const _hoisted_3 = {
|
|
794
|
-
|
|
795
|
-
};
|
|
796
|
-
const _hoisted_4 = {
|
|
797
|
-
class: "table-header-title"
|
|
798
|
-
};
|
|
833
|
+
const _hoisted_3 = { class: "table-header-cell-wrapper" };
|
|
834
|
+
const _hoisted_4 = { class: "table-header-title" };
|
|
799
835
|
const _hoisted_5 = {
|
|
800
836
|
key: 2,
|
|
801
837
|
class: "table-header-sorter"
|
|
@@ -805,154 +841,75 @@ const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
805
841
|
width: "16px",
|
|
806
842
|
height: "16px",
|
|
807
843
|
viewBox: "0 0 16 16"
|
|
808
|
-
}, [
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
844
|
+
}, [
|
|
845
|
+
/* @__PURE__ */ createElementVNode("polygon", {
|
|
846
|
+
class: "arrow-up",
|
|
847
|
+
fill: "#757699",
|
|
848
|
+
points: "8 2 4.8 6 11.2 6"
|
|
849
|
+
}),
|
|
850
|
+
/* @__PURE__ */ createElementVNode("polygon", {
|
|
851
|
+
class: "arrow-down",
|
|
852
|
+
transform: "translate(8, 12) rotate(-180) translate(-8, -12) ",
|
|
853
|
+
points: "8 10 4.8 14 11.2 14"
|
|
854
|
+
})
|
|
855
|
+
], -1);
|
|
856
|
+
const _hoisted_7 = [
|
|
857
|
+
_hoisted_6
|
|
858
|
+
];
|
|
818
859
|
const _hoisted_8 = ["onMousedown"];
|
|
819
860
|
const _hoisted_9 = ["onMousedown"];
|
|
820
861
|
const _hoisted_10 = {
|
|
821
862
|
key: 0,
|
|
822
863
|
class: "virtual-x-left",
|
|
823
|
-
style: {
|
|
824
|
-
"padding": "0"
|
|
825
|
-
}
|
|
864
|
+
style: { "padding": "0" }
|
|
826
865
|
};
|
|
827
866
|
const _hoisted_11 = ["data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
|
|
828
867
|
const _hoisted_12 = {
|
|
829
868
|
key: 0,
|
|
830
869
|
class: "virtual-x-left",
|
|
831
|
-
style: {
|
|
832
|
-
"padding": "0"
|
|
833
|
-
}
|
|
870
|
+
style: { "padding": "0" }
|
|
834
871
|
};
|
|
835
872
|
const _hoisted_13 = ["data-index", "onClick"];
|
|
836
873
|
const _hoisted_14 = ["title"];
|
|
837
874
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
838
875
|
__name: "StkTable",
|
|
839
876
|
props: {
|
|
840
|
-
width: {
|
|
841
|
-
|
|
842
|
-
},
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
},
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
},
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
},
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
},
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
},
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
},
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
},
|
|
874
|
-
virtualX: {
|
|
875
|
-
type: Boolean,
|
|
876
|
-
default: false
|
|
877
|
-
},
|
|
878
|
-
columns: {
|
|
879
|
-
default: () => []
|
|
880
|
-
},
|
|
881
|
-
dataSource: {
|
|
882
|
-
default: () => []
|
|
883
|
-
},
|
|
884
|
-
rowKey: {
|
|
885
|
-
type: [String, Function],
|
|
886
|
-
default: ""
|
|
887
|
-
},
|
|
888
|
-
colKey: {
|
|
889
|
-
type: [String, Function],
|
|
890
|
-
default: "dataIndex"
|
|
891
|
-
},
|
|
892
|
-
emptyCellText: {
|
|
893
|
-
default: "--"
|
|
894
|
-
},
|
|
895
|
-
noDataFull: {
|
|
896
|
-
type: Boolean,
|
|
897
|
-
default: false
|
|
898
|
-
},
|
|
899
|
-
showNoData: {
|
|
900
|
-
type: Boolean,
|
|
901
|
-
default: true
|
|
902
|
-
},
|
|
903
|
-
sortRemote: {
|
|
904
|
-
type: Boolean,
|
|
905
|
-
default: false
|
|
906
|
-
},
|
|
907
|
-
showHeaderOverflow: {
|
|
908
|
-
type: Boolean,
|
|
909
|
-
default: false
|
|
910
|
-
},
|
|
911
|
-
showOverflow: {
|
|
912
|
-
type: Boolean,
|
|
913
|
-
default: false
|
|
914
|
-
},
|
|
915
|
-
showTrHoverClass: {
|
|
916
|
-
type: Boolean,
|
|
917
|
-
default: false
|
|
918
|
-
},
|
|
919
|
-
headerDrag: {
|
|
920
|
-
type: Boolean,
|
|
921
|
-
default: false
|
|
922
|
-
},
|
|
923
|
-
rowClassName: {
|
|
924
|
-
type: Function,
|
|
925
|
-
default: () => ""
|
|
926
|
-
},
|
|
927
|
-
colResizable: {
|
|
928
|
-
type: Boolean,
|
|
929
|
-
default: false
|
|
930
|
-
},
|
|
931
|
-
colMinWidth: {
|
|
932
|
-
default: 10
|
|
933
|
-
},
|
|
934
|
-
bordered: {
|
|
935
|
-
type: [Boolean, String],
|
|
936
|
-
default: true
|
|
937
|
-
},
|
|
938
|
-
autoResize: {
|
|
939
|
-
type: [Boolean, Function],
|
|
940
|
-
default: true
|
|
941
|
-
},
|
|
942
|
-
fixedColShadow: {
|
|
943
|
-
type: Boolean,
|
|
944
|
-
default: false
|
|
945
|
-
},
|
|
946
|
-
optimizeVue2Scroll: {
|
|
947
|
-
type: Boolean,
|
|
948
|
-
default: false
|
|
949
|
-
}
|
|
877
|
+
width: { default: "" },
|
|
878
|
+
minWidth: { default: "" },
|
|
879
|
+
maxWidth: { default: "" },
|
|
880
|
+
stripe: { type: Boolean, default: false },
|
|
881
|
+
fixedMode: { type: Boolean, default: false },
|
|
882
|
+
headless: { type: Boolean, default: false },
|
|
883
|
+
theme: { default: "light" },
|
|
884
|
+
rowHeight: { default: Default_Row_Height },
|
|
885
|
+
headerRowHeight: { default: null },
|
|
886
|
+
virtual: { type: Boolean, default: false },
|
|
887
|
+
virtualX: { type: Boolean, default: false },
|
|
888
|
+
columns: { default: () => [] },
|
|
889
|
+
dataSource: { default: () => [] },
|
|
890
|
+
rowKey: { type: [String, Function], default: "" },
|
|
891
|
+
colKey: { type: [String, Function], default: "dataIndex" },
|
|
892
|
+
emptyCellText: { default: "--" },
|
|
893
|
+
noDataFull: { type: Boolean, default: false },
|
|
894
|
+
showNoData: { type: Boolean, default: true },
|
|
895
|
+
sortRemote: { type: Boolean, default: false },
|
|
896
|
+
showHeaderOverflow: { type: Boolean, default: false },
|
|
897
|
+
showOverflow: { type: Boolean, default: false },
|
|
898
|
+
showTrHoverClass: { type: Boolean, default: false },
|
|
899
|
+
headerDrag: { type: [Boolean, Function], default: false },
|
|
900
|
+
rowClassName: { type: Function, default: () => "" },
|
|
901
|
+
colResizable: { type: Boolean, default: false },
|
|
902
|
+
colMinWidth: { default: 10 },
|
|
903
|
+
bordered: { type: [Boolean, String], default: true },
|
|
904
|
+
autoResize: { type: [Boolean, Function], default: true },
|
|
905
|
+
fixedColShadow: { type: Boolean, default: false },
|
|
906
|
+
optimizeVue2Scroll: { type: Boolean, default: false },
|
|
907
|
+
sortConfig: { default: () => ({
|
|
908
|
+
emptyToBottom: false
|
|
909
|
+
}) }
|
|
950
910
|
},
|
|
951
911
|
emits: ["sort-change", "row-click", "current-change", "row-dblclick", "header-row-menu", "row-menu", "cell-click", "header-cell-click", "scroll", "scroll-x", "col-order-change", "th-drag-start", "th-drop", "update:columns"],
|
|
952
|
-
setup(__props, {
|
|
953
|
-
expose: __expose,
|
|
954
|
-
emit: __emit
|
|
955
|
-
}) {
|
|
912
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
956
913
|
const props = __props;
|
|
957
914
|
const emits = __emit;
|
|
958
915
|
const tableContainer = ref();
|
|
@@ -967,10 +924,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
967
924
|
const tableHeaderLast = ref([]);
|
|
968
925
|
const dataSourceCopy = shallowRef([...props.dataSource]);
|
|
969
926
|
const rowKeyGenStore = /* @__PURE__ */ new WeakMap();
|
|
970
|
-
const {
|
|
971
|
-
isColResizing,
|
|
972
|
-
onThResizeMouseDown
|
|
973
|
-
} = useColResize({
|
|
927
|
+
const { isColResizing, onThResizeMouseDown } = useColResize({
|
|
974
928
|
props,
|
|
975
929
|
emits,
|
|
976
930
|
colKeyGen,
|
|
@@ -978,13 +932,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
978
932
|
tableContainer,
|
|
979
933
|
tableHeaderLast
|
|
980
934
|
});
|
|
981
|
-
const {
|
|
982
|
-
onThDragStart,
|
|
983
|
-
onThDragOver,
|
|
984
|
-
onThDrop
|
|
985
|
-
} = useThDrag({
|
|
986
|
-
emits
|
|
987
|
-
});
|
|
935
|
+
const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
|
|
988
936
|
const {
|
|
989
937
|
virtualScroll,
|
|
990
938
|
virtualScrollX,
|
|
@@ -999,15 +947,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
999
947
|
initVirtualScrollX,
|
|
1000
948
|
updateVirtualScrollY,
|
|
1001
949
|
updateVirtualScrollX
|
|
1002
|
-
} = useVirtualScroll({
|
|
1003
|
-
|
|
1004
|
-
props,
|
|
1005
|
-
dataSourceCopy,
|
|
1006
|
-
tableHeaderLast
|
|
1007
|
-
});
|
|
1008
|
-
const {
|
|
1009
|
-
getFixedStyle
|
|
1010
|
-
} = useFixedStyle({
|
|
950
|
+
} = useVirtualScroll({ tableContainer, props, dataSourceCopy, tableHeaderLast });
|
|
951
|
+
const { getFixedStyle } = useFixedStyle({
|
|
1011
952
|
props,
|
|
1012
953
|
tableHeaderLast,
|
|
1013
954
|
virtualScroll,
|
|
@@ -1015,22 +956,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1015
956
|
virtualX_on,
|
|
1016
957
|
virtualX_offsetRight
|
|
1017
958
|
});
|
|
1018
|
-
const {
|
|
1019
|
-
setHighlightDimCell,
|
|
1020
|
-
setHighlightDimRow
|
|
1021
|
-
} = useHighlight({
|
|
1022
|
-
props,
|
|
1023
|
-
tableContainer,
|
|
1024
|
-
rowKeyGen
|
|
1025
|
-
});
|
|
959
|
+
const { setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, tableContainer, rowKeyGen });
|
|
1026
960
|
if (props.autoResize) {
|
|
1027
|
-
useAutoResize({
|
|
1028
|
-
tableContainer,
|
|
1029
|
-
initVirtualScroll,
|
|
1030
|
-
scrollTo,
|
|
1031
|
-
props,
|
|
1032
|
-
debounceMs: 500
|
|
1033
|
-
});
|
|
961
|
+
useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs: 200 });
|
|
1034
962
|
}
|
|
1035
963
|
useKeyboardArrowScroll(tableContainer, {
|
|
1036
964
|
props,
|
|
@@ -1039,40 +967,43 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1039
967
|
virtualScrollX,
|
|
1040
968
|
tableHeaders
|
|
1041
969
|
});
|
|
1042
|
-
const {
|
|
1043
|
-
getFixedColClass,
|
|
1044
|
-
dealFixedColShadow,
|
|
1045
|
-
updateFixedShadow
|
|
1046
|
-
} = useFixedCol({
|
|
970
|
+
const { getFixedColClass, dealFixedColShadow, updateFixedShadow } = useFixedCol({
|
|
1047
971
|
props,
|
|
1048
972
|
tableContainer,
|
|
1049
973
|
tableHeaderLast
|
|
1050
974
|
});
|
|
1051
|
-
watch(
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
watch(() => props.dataSource, (val) => {
|
|
1057
|
-
if (!val) {
|
|
1058
|
-
console.warn("invalid dataSource");
|
|
1059
|
-
return;
|
|
975
|
+
watch(
|
|
976
|
+
() => props.columns,
|
|
977
|
+
() => {
|
|
978
|
+
dealColumns();
|
|
979
|
+
initVirtualScrollX();
|
|
1060
980
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
981
|
+
);
|
|
982
|
+
dealColumns();
|
|
983
|
+
watch(
|
|
984
|
+
() => props.dataSource,
|
|
985
|
+
(val) => {
|
|
986
|
+
if (!val) {
|
|
987
|
+
console.warn("invalid dataSource");
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
let needInitVirtualScrollY = false;
|
|
991
|
+
if (dataSourceCopy.value.length !== val.length) {
|
|
992
|
+
needInitVirtualScrollY = true;
|
|
993
|
+
}
|
|
994
|
+
dataSourceCopy.value = [...val];
|
|
995
|
+
if (needInitVirtualScrollY)
|
|
996
|
+
initVirtualScrollY();
|
|
997
|
+
if (sortCol.value) {
|
|
998
|
+
const column = tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
|
|
999
|
+
onColumnSort(column, false);
|
|
1000
|
+
}
|
|
1001
|
+
updateFixedShadow();
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
deep: false
|
|
1071
1005
|
}
|
|
1072
|
-
|
|
1073
|
-
}, {
|
|
1074
|
-
deep: false
|
|
1075
|
-
});
|
|
1006
|
+
);
|
|
1076
1007
|
watch(() => props.fixedColShadow, dealFixedColShadow);
|
|
1077
1008
|
onMounted(() => {
|
|
1078
1009
|
initVirtualScroll();
|
|
@@ -1165,11 +1096,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1165
1096
|
function onColumnSort(col, click = true, options = {}) {
|
|
1166
1097
|
if (!(col == null ? void 0 : col.sorter))
|
|
1167
1098
|
return;
|
|
1168
|
-
options = {
|
|
1169
|
-
force: false,
|
|
1170
|
-
emit: false,
|
|
1171
|
-
...options
|
|
1172
|
-
};
|
|
1099
|
+
options = { force: false, emit: false, ...options };
|
|
1173
1100
|
if (sortCol.value !== col.dataIndex) {
|
|
1174
1101
|
sortCol.value = col.dataIndex;
|
|
1175
1102
|
sortOrderIndex.value = 0;
|
|
@@ -1178,11 +1105,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1178
1105
|
sortOrderIndex.value++;
|
|
1179
1106
|
sortOrderIndex.value = sortOrderIndex.value % 3;
|
|
1180
1107
|
const order = sortSwitchOrder[sortOrderIndex.value];
|
|
1108
|
+
const sortConfig = props.sortConfig;
|
|
1181
1109
|
if (!props.sortRemote || options.force) {
|
|
1182
|
-
dataSourceCopy.value = tableSort(col, order, props.dataSource);
|
|
1110
|
+
dataSourceCopy.value = tableSort(col, order, props.dataSource, sortConfig);
|
|
1183
1111
|
}
|
|
1184
1112
|
if (click || options.emit) {
|
|
1185
|
-
emits("sort-change", col, order, toRaw(dataSourceCopy.value));
|
|
1113
|
+
emits("sort-change", col, order, toRaw(dataSourceCopy.value), sortConfig);
|
|
1186
1114
|
}
|
|
1187
1115
|
}
|
|
1188
1116
|
function onRowClick(e, row) {
|
|
@@ -1218,16 +1146,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1218
1146
|
function onTableScroll(e) {
|
|
1219
1147
|
if (!(e == null ? void 0 : e.target))
|
|
1220
1148
|
return;
|
|
1221
|
-
const {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
} = e.target;
|
|
1225
|
-
const {
|
|
1226
|
-
scrollTop: vScrollTop
|
|
1227
|
-
} = virtualScroll.value;
|
|
1228
|
-
const {
|
|
1229
|
-
scrollLeft: vScrollLeft
|
|
1230
|
-
} = virtualScrollX.value;
|
|
1149
|
+
const { scrollTop, scrollLeft } = e.target;
|
|
1150
|
+
const { scrollTop: vScrollTop } = virtualScroll.value;
|
|
1151
|
+
const { scrollLeft: vScrollLeft } = virtualScrollX.value;
|
|
1231
1152
|
const isYScroll = scrollTop !== vScrollTop;
|
|
1232
1153
|
const isXScroll = scrollLeft !== vScrollLeft;
|
|
1233
1154
|
if (isYScroll && virtual_on.value) {
|
|
@@ -1237,16 +1158,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1237
1158
|
updateFixedShadow();
|
|
1238
1159
|
if (virtualX_on.value) {
|
|
1239
1160
|
updateVirtualScrollX(scrollLeft);
|
|
1161
|
+
} else {
|
|
1162
|
+
virtualScrollX.value.scrollLeft = scrollLeft;
|
|
1240
1163
|
}
|
|
1241
1164
|
}
|
|
1242
|
-
const {
|
|
1243
|
-
|
|
1244
|
-
endIndex
|
|
1245
|
-
} = virtualScroll.value;
|
|
1246
|
-
const data = {
|
|
1247
|
-
startIndex,
|
|
1248
|
-
endIndex
|
|
1249
|
-
};
|
|
1165
|
+
const { startIndex, endIndex } = virtualScroll.value;
|
|
1166
|
+
const data = { startIndex, endIndex };
|
|
1250
1167
|
if (isYScroll) {
|
|
1251
1168
|
emits("scroll", e, data);
|
|
1252
1169
|
}
|
|
@@ -1259,9 +1176,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1259
1176
|
currentHover.value = rowKeyGen(row);
|
|
1260
1177
|
}
|
|
1261
1178
|
}
|
|
1262
|
-
function setCurrentRow(rowKey, option = {
|
|
1263
|
-
silent: false
|
|
1264
|
-
}) {
|
|
1179
|
+
function setCurrentRow(rowKey, option = { silent: false }) {
|
|
1265
1180
|
if (!dataSourceCopy.value.length)
|
|
1266
1181
|
return;
|
|
1267
1182
|
currentItem.value = dataSourceCopy.value.find((it) => rowKeyGen(it) === rowKey);
|
|
@@ -1272,21 +1187,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1272
1187
|
}
|
|
1273
1188
|
function setSorter(dataIndex, order, option = {}) {
|
|
1274
1189
|
var _a;
|
|
1275
|
-
const newOption = {
|
|
1276
|
-
silent: true,
|
|
1277
|
-
sortOption: null,
|
|
1278
|
-
sort: true,
|
|
1279
|
-
...option
|
|
1280
|
-
};
|
|
1190
|
+
const newOption = { silent: true, sortOption: null, sort: true, ...option };
|
|
1281
1191
|
sortCol.value = dataIndex;
|
|
1282
1192
|
sortOrderIndex.value = sortSwitchOrder.findIndex((it) => it === order);
|
|
1283
1193
|
if (newOption.sort && ((_a = dataSourceCopy.value) == null ? void 0 : _a.length)) {
|
|
1284
1194
|
const column = newOption.sortOption || tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
|
|
1285
1195
|
if (column)
|
|
1286
|
-
onColumnSort(column, false, {
|
|
1287
|
-
force: true,
|
|
1288
|
-
emit: !newOption.silent
|
|
1289
|
-
});
|
|
1196
|
+
onColumnSort(column, false, { force: true, emit: !newOption.silent });
|
|
1290
1197
|
else
|
|
1291
1198
|
console.warn("Can not find column by dataIndex:", sortCol.value);
|
|
1292
1199
|
}
|
|
@@ -1308,6 +1215,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1308
1215
|
function getTableData() {
|
|
1309
1216
|
return toRaw(dataSourceCopy.value);
|
|
1310
1217
|
}
|
|
1218
|
+
function getSortColumns() {
|
|
1219
|
+
const sortOrder = sortSwitchOrder[sortOrderIndex.value];
|
|
1220
|
+
if (!sortOrder)
|
|
1221
|
+
return [];
|
|
1222
|
+
return [{ dataIndex: sortCol.value, order: sortOrder }];
|
|
1223
|
+
}
|
|
1311
1224
|
__expose({
|
|
1312
1225
|
/** 初始化横向纵向虚拟滚动 */
|
|
1313
1226
|
initVirtualScroll,
|
|
@@ -1323,6 +1236,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1323
1236
|
setHighlightDimRow,
|
|
1324
1237
|
/** 表格排序列dataIndex */
|
|
1325
1238
|
sortCol,
|
|
1239
|
+
/** 获取当前排序状态 */
|
|
1240
|
+
getSortColumns,
|
|
1326
1241
|
/** 设置排序 */
|
|
1327
1242
|
setSorter,
|
|
1328
1243
|
/** 重置排序 */
|
|
@@ -1349,137 +1264,173 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1349
1264
|
"border-body-v": props.bordered === "body-v",
|
|
1350
1265
|
stripe: props.stripe
|
|
1351
1266
|
}]),
|
|
1352
|
-
style: normalizeStyle(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1267
|
+
style: normalizeStyle(
|
|
1268
|
+
_ctx.virtual && {
|
|
1269
|
+
"--row-height": unref(virtualScroll).rowHeight + "px",
|
|
1270
|
+
"--header-row-height": (props.headerRowHeight || props.rowHeight) + "px"
|
|
1271
|
+
}
|
|
1272
|
+
),
|
|
1356
1273
|
onScroll: onTableScroll,
|
|
1357
1274
|
onWheel: onTableWheel
|
|
1358
|
-
}, [
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1275
|
+
}, [
|
|
1276
|
+
withDirectives(createElementVNode("div", {
|
|
1277
|
+
ref_key: "colResizeIndicator",
|
|
1278
|
+
ref: colResizeIndicator,
|
|
1279
|
+
class: "column-resize-indicator"
|
|
1280
|
+
}, null, 512), [
|
|
1281
|
+
[vShow, _ctx.colResizable]
|
|
1282
|
+
]),
|
|
1283
|
+
createElementVNode("table", {
|
|
1284
|
+
class: normalizeClass(["stk-table-main", {
|
|
1285
|
+
"fixed-mode": props.fixedMode
|
|
1286
|
+
}]),
|
|
1287
|
+
style: normalizeStyle({ width: _ctx.width, minWidth: _ctx.minWidth, maxWidth: _ctx.maxWidth })
|
|
1288
|
+
}, [
|
|
1289
|
+
!_ctx.headless ? (openBlock(), createElementBlock("thead", _hoisted_1, [
|
|
1290
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
|
|
1291
|
+
return openBlock(), createElementBlock("tr", {
|
|
1292
|
+
key: rowIndex,
|
|
1293
|
+
onContextmenu: _cache[3] || (_cache[3] = (e) => onHeaderMenu(e))
|
|
1294
|
+
}, [
|
|
1295
|
+
unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
|
|
1296
|
+
key: 0,
|
|
1297
|
+
class: "virtual-x-left",
|
|
1298
|
+
style: normalizeStyle({
|
|
1299
|
+
minWidth: unref(virtualScrollX).offsetLeft + "px",
|
|
1300
|
+
width: unref(virtualScrollX).offsetLeft + "px"
|
|
1301
|
+
})
|
|
1302
|
+
}, null, 4)) : createCommentVNode("", true),
|
|
1303
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
|
|
1304
|
+
return openBlock(), createElementBlock("th", {
|
|
1305
|
+
key: col.dataIndex,
|
|
1306
|
+
"data-col-key": colKeyGen(col),
|
|
1307
|
+
draggable: unref(isHeaderDraggable)(col) ? "true" : "false",
|
|
1308
|
+
rowspan: unref(virtualX_on) ? 1 : col.rowSpan,
|
|
1309
|
+
colspan: col.colSpan,
|
|
1310
|
+
style: normalizeStyle(getCellStyle(1, col, rowIndex)),
|
|
1311
|
+
title: col.title,
|
|
1312
|
+
class: normalizeClass([
|
|
1313
|
+
col.sorter ? "sortable" : "",
|
|
1314
|
+
col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
|
|
1315
|
+
_ctx.showHeaderOverflow ? "text-overflow" : "",
|
|
1316
|
+
col.headerClassName,
|
|
1317
|
+
unref(getFixedColClass)(col)
|
|
1318
|
+
]),
|
|
1319
|
+
onClick: (e) => {
|
|
1320
|
+
onColumnSort(col);
|
|
1321
|
+
onHeaderCellClick(e, col);
|
|
1322
|
+
},
|
|
1323
|
+
onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
|
|
1324
|
+
(...args) => unref(onThDragStart) && unref(onThDragStart)(...args)),
|
|
1325
|
+
onDrop: _cache[1] || (_cache[1] = //@ts-ignore
|
|
1326
|
+
(...args) => unref(onThDrop) && unref(onThDrop)(...args)),
|
|
1327
|
+
onDragover: _cache[2] || (_cache[2] = //@ts-ignore
|
|
1328
|
+
(...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
|
|
1329
|
+
}, [
|
|
1330
|
+
createElementVNode("div", _hoisted_3, [
|
|
1331
|
+
col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
|
|
1332
|
+
key: 0,
|
|
1333
|
+
col
|
|
1334
|
+
}, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1335
|
+
key: 1,
|
|
1336
|
+
col
|
|
1337
|
+
}, () => [
|
|
1338
|
+
createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
|
|
1339
|
+
]),
|
|
1340
|
+
col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true),
|
|
1341
|
+
_ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
1342
|
+
key: 3,
|
|
1343
|
+
class: "table-header-resizer left",
|
|
1344
|
+
onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
|
|
1345
|
+
}, null, 40, _hoisted_8)) : createCommentVNode("", true),
|
|
1346
|
+
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1347
|
+
key: 4,
|
|
1348
|
+
class: "table-header-resizer right",
|
|
1349
|
+
onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
|
|
1350
|
+
}, null, 40, _hoisted_9)) : createCommentVNode("", true)
|
|
1351
|
+
])
|
|
1352
|
+
], 46, _hoisted_2);
|
|
1353
|
+
}), 128)),
|
|
1354
|
+
unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
|
|
1355
|
+
key: 1,
|
|
1356
|
+
class: "virtual-x-right",
|
|
1357
|
+
style: normalizeStyle({
|
|
1358
|
+
minWidth: unref(virtualX_offsetRight) + "px",
|
|
1359
|
+
width: unref(virtualX_offsetRight) + "px"
|
|
1360
|
+
})
|
|
1361
|
+
}, null, 4)) : createCommentVNode("", true)
|
|
1362
|
+
], 32);
|
|
1363
|
+
}), 128))
|
|
1364
|
+
])) : createCommentVNode("", true),
|
|
1365
|
+
createElementVNode("tbody", null, [
|
|
1366
|
+
unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1367
|
+
key: 0,
|
|
1368
|
+
style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
|
|
1369
|
+
class: "padding-top-tr"
|
|
1370
|
+
}, [
|
|
1371
|
+
unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
|
|
1372
|
+
_ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
|
|
1373
|
+
return openBlock(), createElementBlock("td", {
|
|
1374
|
+
key: col.dataIndex,
|
|
1375
|
+
style: normalizeStyle(getCellStyle(2, col))
|
|
1376
|
+
}, null, 4);
|
|
1377
|
+
}), 128)) : createCommentVNode("", true)
|
|
1378
|
+
], 4)) : createCommentVNode("", true),
|
|
1379
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, i) => {
|
|
1380
|
+
return openBlock(), createElementBlock("tr", {
|
|
1381
|
+
key: _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1382
|
+
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1383
|
+
class: normalizeClass({
|
|
1384
|
+
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
|
|
1385
|
+
hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
|
|
1386
|
+
[_ctx.rowClassName(row, i)]: true
|
|
1387
|
+
}),
|
|
1388
|
+
style: normalizeStyle({
|
|
1389
|
+
backgroundColor: row._bgc
|
|
1390
|
+
}),
|
|
1391
|
+
onClick: (e) => onRowClick(e, row),
|
|
1392
|
+
onDblclick: (e) => onRowDblclick(e, row),
|
|
1393
|
+
onContextmenu: (e) => onRowMenu(e, row),
|
|
1394
|
+
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1395
|
+
}, [
|
|
1396
|
+
unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true),
|
|
1397
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
|
|
1398
|
+
return openBlock(), createElementBlock("td", {
|
|
1399
|
+
key: col.dataIndex,
|
|
1400
|
+
"data-index": col.dataIndex,
|
|
1401
|
+
class: normalizeClass([col.className, _ctx.showOverflow ? "text-overflow" : "", unref(getFixedColClass)(col)]),
|
|
1402
|
+
style: normalizeStyle(getCellStyle(2, col)),
|
|
1403
|
+
onClick: (e) => onCellClick(e, row, col)
|
|
1404
|
+
}, [
|
|
1405
|
+
col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
|
|
1406
|
+
key: 0,
|
|
1407
|
+
col,
|
|
1408
|
+
row,
|
|
1409
|
+
"cell-value": row[col.dataIndex]
|
|
1410
|
+
}, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1411
|
+
key: 1,
|
|
1412
|
+
class: "table-cell-wrapper",
|
|
1413
|
+
title: row[col.dataIndex]
|
|
1414
|
+
}, toDisplayString(row[col.dataIndex] ?? _ctx.emptyCellText), 9, _hoisted_14))
|
|
1415
|
+
], 14, _hoisted_13);
|
|
1416
|
+
}), 128))
|
|
1417
|
+
], 46, _hoisted_11);
|
|
1418
|
+
}), 128)),
|
|
1419
|
+
unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1420
|
+
key: 1,
|
|
1421
|
+
style: normalizeStyle({ height: `${unref(virtual_offsetBottom)}px` })
|
|
1422
|
+
}, null, 4)) : createCommentVNode("", true)
|
|
1423
|
+
])
|
|
1424
|
+
], 6),
|
|
1425
|
+
(!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
|
|
1376
1426
|
key: 0,
|
|
1377
|
-
class: "
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
key: col.dataIndex,
|
|
1385
|
-
"data-col-key": colKeyGen(col),
|
|
1386
|
-
draggable: _ctx.headerDrag ? "true" : "false",
|
|
1387
|
-
rowspan: unref(virtualX_on) ? 1 : col.rowSpan,
|
|
1388
|
-
colspan: col.colSpan,
|
|
1389
|
-
style: normalizeStyle(getCellStyle(1, col, rowIndex)),
|
|
1390
|
-
title: col.title,
|
|
1391
|
-
class: normalizeClass([col.sorter ? "sortable" : "", col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)], _ctx.showHeaderOverflow ? "text-overflow" : "", col.headerClassName, unref(getFixedColClass)(col)]),
|
|
1392
|
-
onClick: (e) => {
|
|
1393
|
-
onColumnSort(col);
|
|
1394
|
-
onHeaderCellClick(e, col);
|
|
1395
|
-
},
|
|
1396
|
-
onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
|
|
1397
|
-
(...args) => unref(onThDragStart) && unref(onThDragStart)(...args)),
|
|
1398
|
-
onDrop: _cache[1] || (_cache[1] = //@ts-ignore
|
|
1399
|
-
(...args) => unref(onThDrop) && unref(onThDrop)(...args)),
|
|
1400
|
-
onDragover: _cache[2] || (_cache[2] = //@ts-ignore
|
|
1401
|
-
(...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
|
|
1402
|
-
}, [createElementVNode("div", _hoisted_3, [col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
|
|
1403
|
-
key: 0,
|
|
1404
|
-
col
|
|
1405
|
-
}, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1406
|
-
key: 1,
|
|
1407
|
-
col
|
|
1408
|
-
}, () => [createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)]), col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true), _ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
1409
|
-
key: 3,
|
|
1410
|
-
class: "table-header-resizer left",
|
|
1411
|
-
onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
|
|
1412
|
-
}, null, 40, _hoisted_8)) : createCommentVNode("", true), _ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1413
|
-
key: 4,
|
|
1414
|
-
class: "table-header-resizer right",
|
|
1415
|
-
onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
|
|
1416
|
-
}, null, 40, _hoisted_9)) : createCommentVNode("", true)])], 46, _hoisted_2);
|
|
1417
|
-
}), 128)), unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
|
|
1418
|
-
key: 1,
|
|
1419
|
-
class: "virtual-x-right",
|
|
1420
|
-
style: normalizeStyle({
|
|
1421
|
-
minWidth: unref(virtualX_offsetRight) + "px",
|
|
1422
|
-
width: unref(virtualX_offsetRight) + "px"
|
|
1423
|
-
})
|
|
1424
|
-
}, null, 4)) : createCommentVNode("", true)], 32);
|
|
1425
|
-
}), 128))])) : createCommentVNode("", true), createElementVNode("tbody", null, [unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1426
|
-
key: 0,
|
|
1427
|
-
style: normalizeStyle({
|
|
1428
|
-
height: `${unref(virtualScroll).offsetTop}px`
|
|
1429
|
-
}),
|
|
1430
|
-
class: "padding-top-tr"
|
|
1431
|
-
}, [unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true), _ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, {
|
|
1432
|
-
key: 1
|
|
1433
|
-
}, renderList(unref(virtualX_columnPart), (col) => {
|
|
1434
|
-
return openBlock(), createElementBlock("td", {
|
|
1435
|
-
key: col.dataIndex,
|
|
1436
|
-
style: normalizeStyle(getCellStyle(2, col))
|
|
1437
|
-
}, null, 4);
|
|
1438
|
-
}), 128)) : createCommentVNode("", true)], 4)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, i) => {
|
|
1439
|
-
return openBlock(), createElementBlock("tr", {
|
|
1440
|
-
key: _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1441
|
-
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1442
|
-
class: normalizeClass({
|
|
1443
|
-
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
|
|
1444
|
-
hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
|
|
1445
|
-
[_ctx.rowClassName(row, i)]: true
|
|
1446
|
-
}),
|
|
1447
|
-
style: normalizeStyle({
|
|
1448
|
-
backgroundColor: row._bgc
|
|
1449
|
-
}),
|
|
1450
|
-
onClick: (e) => onRowClick(e, row),
|
|
1451
|
-
onDblclick: (e) => onRowDblclick(e, row),
|
|
1452
|
-
onContextmenu: (e) => onRowMenu(e, row),
|
|
1453
|
-
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1454
|
-
}, [unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
|
|
1455
|
-
return openBlock(), createElementBlock("td", {
|
|
1456
|
-
key: col.dataIndex,
|
|
1457
|
-
"data-index": col.dataIndex,
|
|
1458
|
-
class: normalizeClass([col.className, _ctx.showOverflow ? "text-overflow" : "", unref(getFixedColClass)(col)]),
|
|
1459
|
-
style: normalizeStyle(getCellStyle(2, col)),
|
|
1460
|
-
onClick: (e) => onCellClick(e, row, col)
|
|
1461
|
-
}, [col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
|
|
1462
|
-
key: 0,
|
|
1463
|
-
col,
|
|
1464
|
-
row,
|
|
1465
|
-
"cell-value": row[col.dataIndex]
|
|
1466
|
-
}, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1467
|
-
key: 1,
|
|
1468
|
-
class: "table-cell-wrapper",
|
|
1469
|
-
title: row[col.dataIndex]
|
|
1470
|
-
}, toDisplayString(row[col.dataIndex] ?? _ctx.emptyCellText), 9, _hoisted_14))], 14, _hoisted_13);
|
|
1471
|
-
}), 128))], 46, _hoisted_11);
|
|
1472
|
-
}), 128)), unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1473
|
-
key: 1,
|
|
1474
|
-
style: normalizeStyle({
|
|
1475
|
-
height: `${unref(virtual_offsetBottom)}px`
|
|
1476
|
-
})
|
|
1477
|
-
}, null, 4)) : createCommentVNode("", true)])], 6), (!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
|
|
1478
|
-
key: 0,
|
|
1479
|
-
class: normalizeClass(["stk-table-no-data", {
|
|
1480
|
-
"no-data-full": _ctx.noDataFull
|
|
1481
|
-
}])
|
|
1482
|
-
}, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode("暂无数据")])], 2)) : createCommentVNode("", true)], 38);
|
|
1427
|
+
class: normalizeClass(["stk-table-no-data", { "no-data-full": _ctx.noDataFull }])
|
|
1428
|
+
}, [
|
|
1429
|
+
renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
1430
|
+
createTextVNode("暂无数据")
|
|
1431
|
+
])
|
|
1432
|
+
], 2)) : createCommentVNode("", true)
|
|
1433
|
+
], 38);
|
|
1483
1434
|
};
|
|
1484
1435
|
}
|
|
1485
1436
|
});
|