@deot/vc-components 1.0.11 → 1.0.13
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/dist/index.cjs +353 -368
- package/dist/index.d.ts +12 -12
- package/dist/index.iife.js +365 -380
- package/dist/index.js +353 -368
- package/dist/index.style.css +1 -1
- package/dist/index.umd.cjs +365 -380
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -756,7 +756,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
756
756
|
|
|
757
757
|
// [color, borderColor, backgroundColor], -> CSS
|
|
758
758
|
const THEME_MAP = {
|
|
759
|
-
info: ['#
|
|
759
|
+
info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
|
|
760
760
|
success: ['#52c41a', '#b7eb8f', '#f6ffed'],
|
|
761
761
|
error: ['#ed4014', '#ffb08f', '#fbe9e9'],
|
|
762
762
|
warning: ['#ffbf00', '#ffe58f', '#fffbe6']
|
|
@@ -13315,6 +13315,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
13315
13315
|
isVisible.value = cursorDown.value;
|
|
13316
13316
|
};
|
|
13317
13317
|
const refreshThumb = () => raf(() => {
|
|
13318
|
+
if (!thumb.value) return;
|
|
13318
13319
|
thumb.value.style[prefixStyle('transform').camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
|
|
13319
13320
|
});
|
|
13320
13321
|
const refreshThrottleThumb = throttle$2(refreshThumb, 10);
|
|
@@ -18892,7 +18893,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
18892
18893
|
color: {
|
|
18893
18894
|
type: [Object, String],
|
|
18894
18895
|
default: () => ({
|
|
18895
|
-
normal: "#
|
|
18896
|
+
normal: "#2B72FD",
|
|
18896
18897
|
success: "#52c41a",
|
|
18897
18898
|
error: "#f5222d"
|
|
18898
18899
|
})
|
|
@@ -20031,6 +20032,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
20031
20032
|
|
|
20032
20033
|
// 设置data首个元素的在originalData索引值
|
|
20033
20034
|
const setFirstItemIndex = () => {
|
|
20035
|
+
if (!wrapper.value) return;
|
|
20034
20036
|
const position = wrapper.value[K.scrollAxis];
|
|
20035
20037
|
let item;
|
|
20036
20038
|
for (let i = 0; i < rebuildData.value.length; i++) {
|
|
@@ -20211,6 +20213,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
20211
20213
|
|
|
20212
20214
|
// 图片撑开时,会影响布局, 节流结束后调用
|
|
20213
20215
|
const handleResize = throttle$1(async () => {
|
|
20216
|
+
if (!wrapper.value) return;
|
|
20214
20217
|
const isNeedRefreshLayout = rebuildData.value.some(i => !i.isPlaceholder);
|
|
20215
20218
|
if (isNeedRefreshLayout) {
|
|
20216
20219
|
const oldFirstItemIndex = firstItemIndex.value;
|
|
@@ -20244,6 +20247,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
20244
20247
|
});
|
|
20245
20248
|
if (!originalData.length) {
|
|
20246
20249
|
rebuildData.value = [];
|
|
20250
|
+
} else {
|
|
20251
|
+
rebuildData.value = originalData.slice();
|
|
20247
20252
|
}
|
|
20248
20253
|
offsetPageSize.value = 0;
|
|
20249
20254
|
await refreshLayout(0, originalData.length);
|
|
@@ -20648,88 +20653,65 @@ var VcComponents = (function (exports, vue) {
|
|
|
20648
20653
|
}
|
|
20649
20654
|
});
|
|
20650
20655
|
|
|
20651
|
-
const parseHeight = (
|
|
20652
|
-
if (typeof
|
|
20653
|
-
return
|
|
20656
|
+
const parseHeight = (v) => {
|
|
20657
|
+
if (typeof v === "number") {
|
|
20658
|
+
return v;
|
|
20654
20659
|
}
|
|
20655
|
-
if (
|
|
20656
|
-
if (/^\d+(?:px)?/.test(
|
|
20657
|
-
return parseInt(
|
|
20660
|
+
if (v && typeof v === "string") {
|
|
20661
|
+
if (/^\d+(?:px)?/.test(v)) {
|
|
20662
|
+
return parseInt(v, 10);
|
|
20658
20663
|
}
|
|
20659
20664
|
throw new VcError("table", "Invalid Height");
|
|
20660
20665
|
}
|
|
20661
20666
|
return null;
|
|
20662
20667
|
};
|
|
20663
|
-
const parseWidth = (
|
|
20664
|
-
if (
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
20668
|
+
const parseWidth = (v) => {
|
|
20669
|
+
if (typeof v === "number") {
|
|
20670
|
+
return v;
|
|
20671
|
+
}
|
|
20672
|
+
let v1;
|
|
20673
|
+
if (typeof v !== "undefined") {
|
|
20674
|
+
v1 = parseInt(v, 10);
|
|
20675
|
+
if (isNaN(v1)) {
|
|
20676
|
+
v1 = null;
|
|
20668
20677
|
}
|
|
20669
20678
|
}
|
|
20670
|
-
return
|
|
20679
|
+
return v1;
|
|
20671
20680
|
};
|
|
20672
|
-
const parseMinWidth = (
|
|
20673
|
-
if (typeof
|
|
20674
|
-
|
|
20675
|
-
|
|
20676
|
-
|
|
20681
|
+
const parseMinWidth = (v) => {
|
|
20682
|
+
if (typeof v === "number") {
|
|
20683
|
+
return v;
|
|
20684
|
+
}
|
|
20685
|
+
let v1;
|
|
20686
|
+
if (typeof v !== "undefined") {
|
|
20687
|
+
v1 = parseWidth(v);
|
|
20688
|
+
if (isNaN(v1)) {
|
|
20689
|
+
v = 80;
|
|
20677
20690
|
}
|
|
20678
20691
|
}
|
|
20679
|
-
return
|
|
20692
|
+
return v1;
|
|
20680
20693
|
};
|
|
20681
|
-
const
|
|
20694
|
+
const getRowValue = (row, primaryKey) => {
|
|
20682
20695
|
if (row.__KEY__) return row.__KEY__;
|
|
20683
20696
|
if (!row) throw new VcError("table", "row is required when get row identity");
|
|
20684
|
-
if (typeof
|
|
20685
|
-
if (!
|
|
20686
|
-
return row[
|
|
20697
|
+
if (typeof primaryKey === "string") {
|
|
20698
|
+
if (!primaryKey.includes(".")) {
|
|
20699
|
+
return row[primaryKey];
|
|
20687
20700
|
}
|
|
20688
|
-
const key =
|
|
20701
|
+
const key = primaryKey.split(".");
|
|
20689
20702
|
let current = row;
|
|
20690
20703
|
for (let i = 0; i < key.length; i++) {
|
|
20691
20704
|
current = current[key[i]];
|
|
20692
20705
|
}
|
|
20693
20706
|
return current;
|
|
20694
|
-
} else if (typeof
|
|
20695
|
-
return
|
|
20707
|
+
} else if (typeof primaryKey === "function") {
|
|
20708
|
+
return primaryKey.call(null, row);
|
|
20696
20709
|
}
|
|
20697
20710
|
};
|
|
20698
|
-
const
|
|
20699
|
-
const {
|
|
20700
|
-
childrenKey = "children",
|
|
20701
|
-
lazyKey = "hasChildren",
|
|
20702
|
-
level: baseLevel = 0
|
|
20703
|
-
} = opts;
|
|
20704
|
-
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
20705
|
-
function _walker(parent, children, level) {
|
|
20706
|
-
cb(parent, children, level);
|
|
20707
|
-
children.forEach((item) => {
|
|
20708
|
-
if (item[lazyKey]) {
|
|
20709
|
-
cb(item, null, level + 1);
|
|
20710
|
-
return;
|
|
20711
|
-
}
|
|
20712
|
-
const $children = item[childrenKey];
|
|
20713
|
-
if (!isNil($children)) {
|
|
20714
|
-
_walker(item, $children, level + 1);
|
|
20715
|
-
}
|
|
20716
|
-
});
|
|
20717
|
-
}
|
|
20718
|
-
root.forEach((item) => {
|
|
20719
|
-
if (item[lazyKey]) {
|
|
20720
|
-
cb(item, null, baseLevel);
|
|
20721
|
-
return;
|
|
20722
|
-
}
|
|
20723
|
-
const children = item[childrenKey];
|
|
20724
|
-
if (!isNil(children)) {
|
|
20725
|
-
_walker(item, children, baseLevel);
|
|
20726
|
-
}
|
|
20727
|
-
});
|
|
20728
|
-
};
|
|
20729
|
-
const getKeysMap = (array = [], rowKey) => {
|
|
20711
|
+
const getValuesMap = (array = [], primaryKey) => {
|
|
20730
20712
|
const arrayMap = {};
|
|
20731
20713
|
array.forEach((row, index) => {
|
|
20732
|
-
arrayMap[
|
|
20714
|
+
arrayMap[getRowValue(row, primaryKey)] = { row, index };
|
|
20733
20715
|
});
|
|
20734
20716
|
return arrayMap;
|
|
20735
20717
|
};
|
|
@@ -20742,35 +20724,23 @@ var VcComponents = (function (exports, vue) {
|
|
|
20742
20724
|
});
|
|
20743
20725
|
return column;
|
|
20744
20726
|
};
|
|
20745
|
-
const getColumnByCell = (
|
|
20727
|
+
const getColumnByCell = (columns, cell) => {
|
|
20746
20728
|
const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
|
|
20747
20729
|
if (matches) {
|
|
20748
|
-
return getColumnById(
|
|
20730
|
+
return getColumnById(columns, matches[0]);
|
|
20749
20731
|
}
|
|
20750
20732
|
return null;
|
|
20751
20733
|
};
|
|
20752
|
-
const getCell = (
|
|
20753
|
-
let cell =
|
|
20734
|
+
const getCell = (e) => {
|
|
20735
|
+
let cell = e.target;
|
|
20754
20736
|
while (cell && cell.tagName.toUpperCase() !== "HTML") {
|
|
20755
|
-
if (cell.
|
|
20737
|
+
if (cell.classList.contains("vc-table__td")) {
|
|
20756
20738
|
return cell;
|
|
20757
20739
|
}
|
|
20758
20740
|
cell = cell.parentNode;
|
|
20759
20741
|
}
|
|
20760
20742
|
return null;
|
|
20761
20743
|
};
|
|
20762
|
-
const flattenData = (data, opts = {}) => {
|
|
20763
|
-
const result = [];
|
|
20764
|
-
data.forEach((item) => {
|
|
20765
|
-
if (item.children) {
|
|
20766
|
-
const { children, ...rest } = item;
|
|
20767
|
-
opts.parent ? result.push(...[opts.cascader ? item : rest, ...flattenData(children, opts)]) : result.push(...flattenData(children));
|
|
20768
|
-
} else {
|
|
20769
|
-
result.push(item);
|
|
20770
|
-
}
|
|
20771
|
-
});
|
|
20772
|
-
return result;
|
|
20773
|
-
};
|
|
20774
20744
|
|
|
20775
20745
|
var lodash$1 = {exports: {}};
|
|
20776
20746
|
|
|
@@ -37983,29 +37953,115 @@ var VcComponents = (function (exports, vue) {
|
|
|
37983
37953
|
|
|
37984
37954
|
var lodashExports = requireLodash();
|
|
37985
37955
|
|
|
37956
|
+
const getAllColumns = (columns) => {
|
|
37957
|
+
const result = [];
|
|
37958
|
+
columns.forEach((column) => {
|
|
37959
|
+
if (column.children) {
|
|
37960
|
+
result.push(column);
|
|
37961
|
+
result.push(...getAllColumns(column.children));
|
|
37962
|
+
} else {
|
|
37963
|
+
result.push(column);
|
|
37964
|
+
}
|
|
37965
|
+
});
|
|
37966
|
+
return result;
|
|
37967
|
+
};
|
|
37968
|
+
const columnsToRowsEffect = (v) => {
|
|
37969
|
+
let maxLevel = 1;
|
|
37970
|
+
const traverse = (column, parent) => {
|
|
37971
|
+
if (parent) {
|
|
37972
|
+
column.level = parent.level + 1;
|
|
37973
|
+
if (maxLevel < column.level) {
|
|
37974
|
+
maxLevel = column.level;
|
|
37975
|
+
}
|
|
37976
|
+
}
|
|
37977
|
+
if (column.children) {
|
|
37978
|
+
let colSpan = 0;
|
|
37979
|
+
column.children.forEach((subColumn) => {
|
|
37980
|
+
traverse(subColumn, column);
|
|
37981
|
+
colSpan += subColumn.colSpan;
|
|
37982
|
+
});
|
|
37983
|
+
column.colSpan = colSpan;
|
|
37984
|
+
} else {
|
|
37985
|
+
column.colSpan = 1;
|
|
37986
|
+
}
|
|
37987
|
+
};
|
|
37988
|
+
v.forEach((column) => {
|
|
37989
|
+
column.level = 1;
|
|
37990
|
+
traverse(column);
|
|
37991
|
+
});
|
|
37992
|
+
const rows = [];
|
|
37993
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
37994
|
+
rows.push([]);
|
|
37995
|
+
}
|
|
37996
|
+
const allColumns = getAllColumns(v);
|
|
37997
|
+
allColumns.forEach((column) => {
|
|
37998
|
+
if (!column.children) {
|
|
37999
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
38000
|
+
} else {
|
|
38001
|
+
column.rowSpan = 1;
|
|
38002
|
+
}
|
|
38003
|
+
rows[column.level - 1].push(column);
|
|
38004
|
+
});
|
|
38005
|
+
return rows;
|
|
38006
|
+
};
|
|
38007
|
+
const flattenData = (data, opts = {}) => {
|
|
38008
|
+
const result = [];
|
|
38009
|
+
data.forEach((item) => {
|
|
38010
|
+
if (item.children) {
|
|
38011
|
+
const { children, ...rest } = item;
|
|
38012
|
+
opts.parent ? result.push(...[opts.cascader ? item : rest, ...flattenData(children, opts)]) : result.push(...flattenData(children));
|
|
38013
|
+
} else {
|
|
38014
|
+
result.push(item);
|
|
38015
|
+
}
|
|
38016
|
+
});
|
|
38017
|
+
return result;
|
|
38018
|
+
};
|
|
38019
|
+
const walkTreeNode = (root, cb, opts = {}) => {
|
|
38020
|
+
const {
|
|
38021
|
+
childrenKey = "children",
|
|
38022
|
+
lazyKey = "hasChildren",
|
|
38023
|
+
level: baseLevel = 0
|
|
38024
|
+
} = opts;
|
|
38025
|
+
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
38026
|
+
function _walker(parent, children, level) {
|
|
38027
|
+
cb(parent, children, level);
|
|
38028
|
+
children.forEach((item) => {
|
|
38029
|
+
if (item[lazyKey]) {
|
|
38030
|
+
cb(item, null, level + 1);
|
|
38031
|
+
return;
|
|
38032
|
+
}
|
|
38033
|
+
const $children = item[childrenKey];
|
|
38034
|
+
if (!isNil($children)) {
|
|
38035
|
+
_walker(item, $children, level + 1);
|
|
38036
|
+
}
|
|
38037
|
+
});
|
|
38038
|
+
}
|
|
38039
|
+
root.forEach((item) => {
|
|
38040
|
+
if (item[lazyKey]) {
|
|
38041
|
+
cb(item, null, baseLevel);
|
|
38042
|
+
return;
|
|
38043
|
+
}
|
|
38044
|
+
const children = item[childrenKey];
|
|
38045
|
+
if (!isNil(children)) {
|
|
38046
|
+
_walker(item, children, baseLevel);
|
|
38047
|
+
}
|
|
38048
|
+
});
|
|
38049
|
+
};
|
|
38050
|
+
|
|
37986
38051
|
class BaseWatcher {
|
|
37987
38052
|
states = vue.reactive({
|
|
37988
38053
|
// 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
|
|
37989
38054
|
_data: [],
|
|
37990
38055
|
data: [],
|
|
37991
38056
|
list: [],
|
|
37992
|
-
//
|
|
37993
|
-
|
|
37994
|
-
// 列
|
|
38057
|
+
// 表头数据
|
|
38058
|
+
headerRows: [],
|
|
38059
|
+
// 列 动态收集vc-table-column中的columnConfig
|
|
37995
38060
|
_columns: [],
|
|
37996
|
-
// 动态收集vc-table-column中的columnConfig
|
|
37997
38061
|
originColumns: [],
|
|
37998
|
-
|
|
37999
|
-
columns: [],
|
|
38000
|
-
// 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
|
|
38062
|
+
notFixedColumns: [],
|
|
38001
38063
|
leftFixedColumns: [],
|
|
38002
38064
|
rightFixedColumns: [],
|
|
38003
|
-
leafColumns: [],
|
|
38004
|
-
leftFixedLeafColumns: [],
|
|
38005
|
-
rightFixedLeafColumns: [],
|
|
38006
|
-
leafColumnsLength: 0,
|
|
38007
|
-
leftFixedLeafColumnsLength: 0,
|
|
38008
|
-
rightFixedLeafColumnsLength: 0,
|
|
38009
38065
|
// 选择
|
|
38010
38066
|
isAllSelected: false,
|
|
38011
38067
|
selection: [],
|
|
@@ -38027,7 +38083,17 @@ var VcComponents = (function (exports, vue) {
|
|
|
38027
38083
|
treeLazyData: [],
|
|
38028
38084
|
// 源数据展开
|
|
38029
38085
|
treeLazyColumnIdentifier: "hasChildren",
|
|
38030
|
-
treeChildrenColumnName: "children"
|
|
38086
|
+
treeChildrenColumnName: "children",
|
|
38087
|
+
// compputeds
|
|
38088
|
+
isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
|
|
38089
|
+
isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
|
|
38090
|
+
columns: vue.computed(() => lodashExports.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
|
|
38091
|
+
leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
|
|
38092
|
+
leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
|
|
38093
|
+
rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
|
|
38094
|
+
leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
|
|
38095
|
+
leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
|
|
38096
|
+
rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
|
|
38031
38097
|
});
|
|
38032
38098
|
}
|
|
38033
38099
|
|
|
@@ -38038,14 +38104,14 @@ var VcComponents = (function (exports, vue) {
|
|
|
38038
38104
|
}
|
|
38039
38105
|
update() {
|
|
38040
38106
|
const store = this.store;
|
|
38041
|
-
const {
|
|
38107
|
+
const { primaryKey, defaultExpandAll } = this.store.table.props;
|
|
38042
38108
|
const { data = [], expandRows } = store.states;
|
|
38043
38109
|
if (defaultExpandAll) {
|
|
38044
38110
|
store.states.expandRows = data.slice();
|
|
38045
|
-
} else if (
|
|
38046
|
-
const expandRowsMap =
|
|
38111
|
+
} else if (primaryKey) {
|
|
38112
|
+
const expandRowsMap = getValuesMap(expandRows, primaryKey);
|
|
38047
38113
|
store.states.expandRows = data.reduce((prev, row) => {
|
|
38048
|
-
const rowId =
|
|
38114
|
+
const rowId = getRowValue(row, primaryKey);
|
|
38049
38115
|
const rowInfo = expandRowsMap[rowId];
|
|
38050
38116
|
if (rowInfo) {
|
|
38051
38117
|
prev.push(row);
|
|
@@ -38067,10 +38133,10 @@ var VcComponents = (function (exports, vue) {
|
|
|
38067
38133
|
}
|
|
38068
38134
|
reset(ids) {
|
|
38069
38135
|
const store = this.store;
|
|
38070
|
-
store.
|
|
38071
|
-
const {
|
|
38136
|
+
store.checkPrimaryKey();
|
|
38137
|
+
const { primaryKey } = store.table.props;
|
|
38072
38138
|
const { data } = store.states;
|
|
38073
|
-
const keysMap =
|
|
38139
|
+
const keysMap = getValuesMap(data, primaryKey);
|
|
38074
38140
|
store.states.expandRows = ids.reduce((prev, cur) => {
|
|
38075
38141
|
const info = keysMap[cur];
|
|
38076
38142
|
if (info) {
|
|
@@ -38080,11 +38146,11 @@ var VcComponents = (function (exports, vue) {
|
|
|
38080
38146
|
}, []);
|
|
38081
38147
|
}
|
|
38082
38148
|
isExpanded(row) {
|
|
38083
|
-
const {
|
|
38149
|
+
const { primaryKey } = this.store.table.props;
|
|
38084
38150
|
const { expandRows = [] } = this.store.states;
|
|
38085
|
-
if (
|
|
38086
|
-
const expandMap =
|
|
38087
|
-
return !!expandMap[
|
|
38151
|
+
if (primaryKey) {
|
|
38152
|
+
const expandMap = getValuesMap(expandRows, primaryKey);
|
|
38153
|
+
return !!expandMap[getRowValue(row, primaryKey)];
|
|
38088
38154
|
}
|
|
38089
38155
|
return expandRows.indexOf(row) !== -1;
|
|
38090
38156
|
}
|
|
@@ -38097,22 +38163,22 @@ var VcComponents = (function (exports, vue) {
|
|
|
38097
38163
|
}
|
|
38098
38164
|
reset(id) {
|
|
38099
38165
|
const store = this.store;
|
|
38100
|
-
const {
|
|
38101
|
-
store.
|
|
38166
|
+
const { primaryKey } = store.table.props;
|
|
38167
|
+
store.checkPrimaryKey();
|
|
38102
38168
|
const { data = [] } = store.states;
|
|
38103
|
-
const currentRow = data.find((item) =>
|
|
38169
|
+
const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
|
|
38104
38170
|
store.states.currentRow = currentRow || null;
|
|
38105
38171
|
}
|
|
38106
38172
|
update() {
|
|
38107
38173
|
const store = this.store;
|
|
38108
|
-
const {
|
|
38174
|
+
const { primaryKey } = store.table.props;
|
|
38109
38175
|
const { data = [], currentRow } = store.states;
|
|
38110
38176
|
const oldCurrentRow = currentRow;
|
|
38111
38177
|
if (oldCurrentRow && !data.includes(oldCurrentRow)) {
|
|
38112
38178
|
let newCurrentRow = null;
|
|
38113
|
-
if (
|
|
38179
|
+
if (primaryKey) {
|
|
38114
38180
|
newCurrentRow = data.find((item) => {
|
|
38115
|
-
return
|
|
38181
|
+
return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
|
|
38116
38182
|
});
|
|
38117
38183
|
}
|
|
38118
38184
|
store.states.currentRow = newCurrentRow;
|
|
@@ -38131,8 +38197,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
38131
38197
|
* { id: { level, children } }
|
|
38132
38198
|
*/
|
|
38133
38199
|
normalizedData = vue.computed(() => {
|
|
38134
|
-
const {
|
|
38135
|
-
if (!
|
|
38200
|
+
const { primaryKey } = this.store.table.props;
|
|
38201
|
+
if (!primaryKey) return {};
|
|
38136
38202
|
return this.normalize(this.store.states.data || []);
|
|
38137
38203
|
});
|
|
38138
38204
|
/**
|
|
@@ -38140,7 +38206,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38140
38206
|
* { id: { children } }
|
|
38141
38207
|
*/
|
|
38142
38208
|
normalizedLazyNode = vue.computed(() => {
|
|
38143
|
-
const {
|
|
38209
|
+
const { primaryKey } = this.store.table.props;
|
|
38144
38210
|
const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
|
|
38145
38211
|
const keys = Object.keys(treelazyNodeMap);
|
|
38146
38212
|
const res = {};
|
|
@@ -38149,7 +38215,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38149
38215
|
if (treelazyNodeMap[key].length) {
|
|
38150
38216
|
const item = { children: [] };
|
|
38151
38217
|
treelazyNodeMap[key].forEach((row) => {
|
|
38152
|
-
const id =
|
|
38218
|
+
const id = getRowValue(row, primaryKey);
|
|
38153
38219
|
item.children.push(id);
|
|
38154
38220
|
const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
|
|
38155
38221
|
if (hasChildren && !res[id]) {
|
|
@@ -38169,16 +38235,16 @@ var VcComponents = (function (exports, vue) {
|
|
|
38169
38235
|
);
|
|
38170
38236
|
}
|
|
38171
38237
|
normalize(data) {
|
|
38172
|
-
const {
|
|
38238
|
+
const { primaryKey } = this.store.table.props;
|
|
38173
38239
|
const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
|
|
38174
38240
|
const res = {};
|
|
38175
38241
|
walkTreeNode(
|
|
38176
38242
|
data,
|
|
38177
38243
|
(parent, children, level) => {
|
|
38178
|
-
const parentId =
|
|
38244
|
+
const parentId = getRowValue(parent, primaryKey);
|
|
38179
38245
|
if (Array.isArray(children)) {
|
|
38180
38246
|
res[parentId] = {
|
|
38181
|
-
children: children.map((row) =>
|
|
38247
|
+
children: children.map((row) => getRowValue(row, primaryKey)),
|
|
38182
38248
|
level
|
|
38183
38249
|
};
|
|
38184
38250
|
} else if (treeLazy) {
|
|
@@ -38198,7 +38264,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38198
38264
|
}
|
|
38199
38265
|
// 获取当前展开最大的level
|
|
38200
38266
|
getMaxLevel() {
|
|
38201
|
-
const {
|
|
38267
|
+
const { primaryKey } = this.store.table.props;
|
|
38202
38268
|
const { data, treeData } = this.store.states;
|
|
38203
38269
|
const levels = data.map((item) => {
|
|
38204
38270
|
const traverse = (source) => {
|
|
@@ -38209,7 +38275,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38209
38275
|
return source.level;
|
|
38210
38276
|
}
|
|
38211
38277
|
};
|
|
38212
|
-
const id =
|
|
38278
|
+
const id = getRowValue(item, primaryKey);
|
|
38213
38279
|
return traverse(treeData[id]);
|
|
38214
38280
|
});
|
|
38215
38281
|
return max$2(levels) || 0;
|
|
@@ -38271,10 +38337,10 @@ var VcComponents = (function (exports, vue) {
|
|
|
38271
38337
|
this.update();
|
|
38272
38338
|
}
|
|
38273
38339
|
toggle(row, expanded) {
|
|
38274
|
-
this.store.
|
|
38275
|
-
const {
|
|
38340
|
+
this.store.checkPrimaryKey();
|
|
38341
|
+
const { primaryKey } = this.store.table.props;
|
|
38276
38342
|
const { treeData } = this.store.states;
|
|
38277
|
-
const id =
|
|
38343
|
+
const id = getRowValue(row, primaryKey);
|
|
38278
38344
|
const data = id && treeData[id];
|
|
38279
38345
|
if (id && data && "expanded" in data) {
|
|
38280
38346
|
const oldExpanded = data.expanded;
|
|
@@ -38287,10 +38353,10 @@ var VcComponents = (function (exports, vue) {
|
|
|
38287
38353
|
}
|
|
38288
38354
|
}
|
|
38289
38355
|
loadOrToggle(row) {
|
|
38290
|
-
this.store.
|
|
38291
|
-
const {
|
|
38356
|
+
this.store.checkPrimaryKey();
|
|
38357
|
+
const { primaryKey } = this.store.table.props;
|
|
38292
38358
|
const { treeLazy, treeData } = this.store.states;
|
|
38293
|
-
const id =
|
|
38359
|
+
const id = getRowValue(row, primaryKey);
|
|
38294
38360
|
const data = treeData[id];
|
|
38295
38361
|
if (treeLazy && data && "loaded" in data && !data.loaded) {
|
|
38296
38362
|
this.loadData(row, id, data);
|
|
@@ -38299,9 +38365,9 @@ var VcComponents = (function (exports, vue) {
|
|
|
38299
38365
|
}
|
|
38300
38366
|
}
|
|
38301
38367
|
loadData(row, key, treeNode) {
|
|
38302
|
-
this.store.
|
|
38368
|
+
this.store.checkPrimaryKey();
|
|
38303
38369
|
const { table } = this.store;
|
|
38304
|
-
const {
|
|
38370
|
+
const { primaryKey } = table.props;
|
|
38305
38371
|
const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
|
|
38306
38372
|
if (table.props.loadExpand && !treeData[key].loaded) {
|
|
38307
38373
|
this.store.states.treeData[key].loading = true;
|
|
@@ -38316,7 +38382,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38316
38382
|
walkTreeNode(
|
|
38317
38383
|
data,
|
|
38318
38384
|
(parent, _, level) => {
|
|
38319
|
-
const id =
|
|
38385
|
+
const id = getRowValue(parent, primaryKey);
|
|
38320
38386
|
Object.defineProperty(parent, "__KEY__", {
|
|
38321
38387
|
value: `${level}__${id}`,
|
|
38322
38388
|
writable: false
|
|
@@ -38386,27 +38452,13 @@ var VcComponents = (function (exports, vue) {
|
|
|
38386
38452
|
if (!this.store) {
|
|
38387
38453
|
throw new VcError("table", "Table Layout 必须包含store实例");
|
|
38388
38454
|
}
|
|
38389
|
-
this.updateScroller = this.updateScroller.bind(this);
|
|
38390
|
-
this.updateColumns = this.updateColumns.bind(this);
|
|
38391
|
-
vue.onMounted(() => {
|
|
38392
|
-
this.updateColumns();
|
|
38393
|
-
this.updateScroller();
|
|
38394
|
-
});
|
|
38395
|
-
let __updated__;
|
|
38396
|
-
vue.onUpdated(() => {
|
|
38397
|
-
if (__updated__) return;
|
|
38398
|
-
this.updateColumns();
|
|
38399
|
-
this.updateScroller();
|
|
38400
|
-
__updated__ = true;
|
|
38401
|
-
});
|
|
38402
38455
|
}
|
|
38403
38456
|
updateScrollY() {
|
|
38404
38457
|
const { height, bodyHeight } = this.states;
|
|
38405
38458
|
if (height === null || bodyHeight === null) return;
|
|
38406
|
-
const
|
|
38407
|
-
if (this.table.vnode.el &&
|
|
38408
|
-
|
|
38409
|
-
this.states.scrollY = body.offsetHeight > bodyHeight;
|
|
38459
|
+
const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
|
|
38460
|
+
if (this.table.vnode.el && bodyYWrapper) {
|
|
38461
|
+
this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
|
|
38410
38462
|
}
|
|
38411
38463
|
}
|
|
38412
38464
|
setHeight(value, prop = "height") {
|
|
@@ -38423,18 +38475,6 @@ var VcComponents = (function (exports, vue) {
|
|
|
38423
38475
|
setMaxHeight(value) {
|
|
38424
38476
|
this.setHeight(value, "max-height");
|
|
38425
38477
|
}
|
|
38426
|
-
getFlattenColumns() {
|
|
38427
|
-
const flattenColumns = [];
|
|
38428
|
-
const columns = this.store.states.columns;
|
|
38429
|
-
columns.forEach((column) => {
|
|
38430
|
-
if (column.isColumnGroup) {
|
|
38431
|
-
flattenColumns.push(...column.columns);
|
|
38432
|
-
} else {
|
|
38433
|
-
flattenColumns.push(column);
|
|
38434
|
-
}
|
|
38435
|
-
});
|
|
38436
|
-
return flattenColumns;
|
|
38437
|
-
}
|
|
38438
38478
|
updateElsHeight() {
|
|
38439
38479
|
if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
|
|
38440
38480
|
const table = this.table.exposed;
|
|
@@ -38457,13 +38497,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
38457
38497
|
this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
|
38458
38498
|
}
|
|
38459
38499
|
this.updateScrollY();
|
|
38460
|
-
this.updateScroller();
|
|
38461
38500
|
}
|
|
38462
38501
|
updateColumnsWidth() {
|
|
38463
38502
|
if (IS_SERVER$2) return;
|
|
38464
38503
|
const bodyWidth = this.table.vnode.el.clientWidth;
|
|
38465
38504
|
let bodyMinWidth = 0;
|
|
38466
|
-
const flattenColumns = this.
|
|
38505
|
+
const flattenColumns = this.store.states.columns;
|
|
38467
38506
|
const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
|
|
38468
38507
|
const { fit } = this.table.props;
|
|
38469
38508
|
if (flexColumns.length > 0 && fit) {
|
|
@@ -38489,7 +38528,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38489
38528
|
}
|
|
38490
38529
|
} else {
|
|
38491
38530
|
this.states.scrollX = true;
|
|
38492
|
-
flexColumns.forEach(
|
|
38531
|
+
flexColumns.forEach((column) => {
|
|
38493
38532
|
column.realWidth = column.width || column.minWidth;
|
|
38494
38533
|
});
|
|
38495
38534
|
}
|
|
@@ -38523,12 +38562,6 @@ var VcComponents = (function (exports, vue) {
|
|
|
38523
38562
|
});
|
|
38524
38563
|
this.states.rightFixedWidth = rightFixedWidth;
|
|
38525
38564
|
}
|
|
38526
|
-
this.updateColumns();
|
|
38527
|
-
}
|
|
38528
|
-
// v2.x中的 notifyObservers
|
|
38529
|
-
updateColumns() {
|
|
38530
|
-
}
|
|
38531
|
-
updateScroller() {
|
|
38532
38565
|
}
|
|
38533
38566
|
}
|
|
38534
38567
|
|
|
@@ -38538,7 +38571,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38538
38571
|
expand;
|
|
38539
38572
|
tree;
|
|
38540
38573
|
layout;
|
|
38541
|
-
|
|
38574
|
+
flatData = vue.computed(() => {
|
|
38542
38575
|
if (this.table.props.expandSelectable) {
|
|
38543
38576
|
return lodashExports.concat(
|
|
38544
38577
|
flattenData(this.states.data, { parent: true, cascader: true }),
|
|
@@ -38569,17 +38602,24 @@ var VcComponents = (function (exports, vue) {
|
|
|
38569
38602
|
const dataInstanceChanged = this.states._data !== data;
|
|
38570
38603
|
this.states._data = data;
|
|
38571
38604
|
this.states.data = data;
|
|
38605
|
+
const caches = /* @__PURE__ */ new Map();
|
|
38606
|
+
this.states.list.forEach((item) => {
|
|
38607
|
+
item.rows.forEach((row) => {
|
|
38608
|
+
caches.set(row.data, row);
|
|
38609
|
+
});
|
|
38610
|
+
});
|
|
38572
38611
|
this.states.list = data.reduce((pre, row, index) => {
|
|
38612
|
+
const cache = caches.get(row) || { heightMap: {} };
|
|
38573
38613
|
pre.push({
|
|
38574
38614
|
rows: [
|
|
38575
38615
|
{
|
|
38576
38616
|
index,
|
|
38577
38617
|
data: row,
|
|
38578
|
-
height: "",
|
|
38618
|
+
height: cache.height || "",
|
|
38579
38619
|
heightMap: {
|
|
38580
|
-
left: "",
|
|
38581
|
-
main: "",
|
|
38582
|
-
right: ""
|
|
38620
|
+
left: cache.heightMap.left || "",
|
|
38621
|
+
main: cache.heightMap.main || "",
|
|
38622
|
+
right: cache.heightMap.right || ""
|
|
38583
38623
|
}
|
|
38584
38624
|
}
|
|
38585
38625
|
],
|
|
@@ -38587,6 +38627,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38587
38627
|
});
|
|
38588
38628
|
return pre;
|
|
38589
38629
|
}, []);
|
|
38630
|
+
caches.clear();
|
|
38590
38631
|
this.current.update();
|
|
38591
38632
|
this.expand.update();
|
|
38592
38633
|
if (!this.states.reserveSelection) {
|
|
@@ -38596,7 +38637,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38596
38637
|
this.cleanSelection();
|
|
38597
38638
|
}
|
|
38598
38639
|
} else {
|
|
38599
|
-
this.
|
|
38640
|
+
this.checkPrimaryKey();
|
|
38600
38641
|
this.updateSelectionByRowKey();
|
|
38601
38642
|
}
|
|
38602
38643
|
this.updateAllSelected();
|
|
@@ -38618,10 +38659,10 @@ var VcComponents = (function (exports, vue) {
|
|
|
38618
38659
|
}
|
|
38619
38660
|
}
|
|
38620
38661
|
/**
|
|
38621
|
-
* 检查
|
|
38662
|
+
* 检查 primaryKey 是否存在
|
|
38622
38663
|
*/
|
|
38623
|
-
|
|
38624
|
-
const {
|
|
38664
|
+
checkPrimaryKey() {
|
|
38665
|
+
const { primaryKey } = this.table.props;
|
|
38625
38666
|
}
|
|
38626
38667
|
/**
|
|
38627
38668
|
* states
|
|
@@ -38682,22 +38723,20 @@ var VcComponents = (function (exports, vue) {
|
|
|
38682
38723
|
updateColumns() {
|
|
38683
38724
|
const { states } = this;
|
|
38684
38725
|
const _columns = states._columns || [];
|
|
38685
|
-
|
|
38686
|
-
|
|
38687
|
-
if (
|
|
38726
|
+
const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
38727
|
+
const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
|
|
38728
|
+
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
38688
38729
|
_columns[0].fixed = true;
|
|
38689
|
-
|
|
38730
|
+
leftFixedColumns.unshift(_columns[0]);
|
|
38690
38731
|
}
|
|
38691
38732
|
const notFixedColumns = _columns.filter((column) => !column.fixed);
|
|
38692
|
-
|
|
38693
|
-
const
|
|
38694
|
-
|
|
38695
|
-
|
|
38696
|
-
states.
|
|
38697
|
-
states.
|
|
38698
|
-
states.
|
|
38699
|
-
states.columns = lodashExports.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
|
|
38700
|
-
states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
|
38733
|
+
const originColumns = lodashExports.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
38734
|
+
const headerRows = columnsToRowsEffect(originColumns);
|
|
38735
|
+
states.leftFixedColumns = leftFixedColumns;
|
|
38736
|
+
states.notFixedColumns = notFixedColumns;
|
|
38737
|
+
states.rightFixedColumns = rightFixedColumns;
|
|
38738
|
+
states.originColumns = originColumns;
|
|
38739
|
+
states.headerRows = headerRows;
|
|
38701
38740
|
}
|
|
38702
38741
|
// 选择
|
|
38703
38742
|
isSelected(row) {
|
|
@@ -38721,13 +38760,13 @@ var VcComponents = (function (exports, vue) {
|
|
|
38721
38760
|
* 清理选择
|
|
38722
38761
|
*/
|
|
38723
38762
|
cleanSelection() {
|
|
38724
|
-
const {
|
|
38725
|
-
const { selection = [] } = this.states;
|
|
38763
|
+
const { primaryKey } = this.table.props;
|
|
38764
|
+
const { selection = [], data } = this.states;
|
|
38726
38765
|
let deleted;
|
|
38727
|
-
if (
|
|
38766
|
+
if (primaryKey) {
|
|
38728
38767
|
deleted = [];
|
|
38729
|
-
const selectedMap =
|
|
38730
|
-
const dataMap =
|
|
38768
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
38769
|
+
const dataMap = getValuesMap(data, primaryKey);
|
|
38731
38770
|
for (const key in selectedMap) {
|
|
38732
38771
|
if (hasOwn$1(selectedMap, key) && !dataMap[key]) {
|
|
38733
38772
|
deleted.push(selectedMap[key].row);
|
|
@@ -38735,7 +38774,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38735
38774
|
}
|
|
38736
38775
|
} else {
|
|
38737
38776
|
deleted = selection.filter((item) => {
|
|
38738
|
-
return !this.
|
|
38777
|
+
return !this.flatData.value.includes(item);
|
|
38739
38778
|
});
|
|
38740
38779
|
}
|
|
38741
38780
|
deleted.forEach((deletedItem) => {
|
|
@@ -38796,7 +38835,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38796
38835
|
const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
|
|
38797
38836
|
this.states.isAllSelected = value;
|
|
38798
38837
|
let selectionChanged = false;
|
|
38799
|
-
this.
|
|
38838
|
+
this.flatData.value.forEach((row, index) => {
|
|
38800
38839
|
if (selectable) {
|
|
38801
38840
|
if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
|
|
38802
38841
|
selectionChanged = true;
|
|
@@ -38827,11 +38866,11 @@ var VcComponents = (function (exports, vue) {
|
|
|
38827
38866
|
this.tree.expand(val);
|
|
38828
38867
|
}
|
|
38829
38868
|
updateSelectionByRowKey() {
|
|
38830
|
-
const {
|
|
38869
|
+
const { primaryKey } = this.table.props;
|
|
38831
38870
|
const { selection } = this.states;
|
|
38832
|
-
const selectedMap =
|
|
38833
|
-
this.states.selection = this.
|
|
38834
|
-
const rowId =
|
|
38871
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
38872
|
+
this.states.selection = this.flatData.value.reduce((prev, row) => {
|
|
38873
|
+
const rowId = getRowValue(row, primaryKey);
|
|
38835
38874
|
const rowInfo = selectedMap[rowId];
|
|
38836
38875
|
if (rowInfo) {
|
|
38837
38876
|
prev.push(row);
|
|
@@ -38847,7 +38886,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38847
38886
|
}
|
|
38848
38887
|
let isAllSelected = true;
|
|
38849
38888
|
let selectedCount = 0;
|
|
38850
|
-
const temp = this.
|
|
38889
|
+
const temp = this.flatData.value;
|
|
38851
38890
|
for (let i = 0, j = temp.length; i < j; i++) {
|
|
38852
38891
|
const row = temp[i];
|
|
38853
38892
|
const isRowSelectable = selectable && selectable.call(null, row, i);
|
|
@@ -38902,8 +38941,10 @@ var VcComponents = (function (exports, vue) {
|
|
|
38902
38941
|
const NormalList = /* @__PURE__ */ vue.defineComponent({
|
|
38903
38942
|
name: COMPONENT_NAME$h,
|
|
38904
38943
|
props: {
|
|
38905
|
-
data:
|
|
38906
|
-
|
|
38944
|
+
data: {
|
|
38945
|
+
type: Array,
|
|
38946
|
+
default: () => []
|
|
38947
|
+
}
|
|
38907
38948
|
},
|
|
38908
38949
|
emits: ['row-resize'],
|
|
38909
38950
|
setup(props, {
|
|
@@ -38945,7 +38986,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38945
38986
|
expose
|
|
38946
38987
|
}) {
|
|
38947
38988
|
const instance = vue.getCurrentInstance();
|
|
38948
|
-
const table =
|
|
38989
|
+
const table = vue.inject('vc-table');
|
|
38949
38990
|
const states = useStates({
|
|
38950
38991
|
data: 'data',
|
|
38951
38992
|
list: 'list',
|
|
@@ -38962,6 +39003,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
38962
39003
|
type
|
|
38963
39004
|
}) => type === 'default')
|
|
38964
39005
|
});
|
|
39006
|
+
const wrapper = vue.ref();
|
|
38965
39007
|
vue.watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
|
|
38966
39008
|
if (!props.store.states.isComplex || IS_SERVER$2) return;
|
|
38967
39009
|
raf(() => {
|
|
@@ -38972,12 +39014,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
38972
39014
|
newRow && addClass(newRow, 'hover-row');
|
|
38973
39015
|
});
|
|
38974
39016
|
});
|
|
38975
|
-
const
|
|
39017
|
+
const getValueOfRow = (row, index) => {
|
|
38976
39018
|
const {
|
|
38977
|
-
|
|
39019
|
+
primaryKey
|
|
38978
39020
|
} = table.props;
|
|
38979
|
-
if (
|
|
38980
|
-
return
|
|
39021
|
+
if (primaryKey) {
|
|
39022
|
+
return getRowValue(row, primaryKey);
|
|
38981
39023
|
}
|
|
38982
39024
|
return index;
|
|
38983
39025
|
};
|
|
@@ -39042,7 +39084,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39042
39084
|
return cellStyle;
|
|
39043
39085
|
};
|
|
39044
39086
|
const getCellClass = (rowIndex, columnIndex, row, column) => {
|
|
39045
|
-
const classes = [column.
|
|
39087
|
+
const classes = [column.realAlign, column.className];
|
|
39046
39088
|
if (isColumnHidden(columnIndex)) {
|
|
39047
39089
|
classes.push('is-hidden');
|
|
39048
39090
|
}
|
|
@@ -39068,7 +39110,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39068
39110
|
column,
|
|
39069
39111
|
row
|
|
39070
39112
|
};
|
|
39071
|
-
table.
|
|
39113
|
+
table.hoverState.value = hoverState;
|
|
39072
39114
|
table.emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, e);
|
|
39073
39115
|
}
|
|
39074
39116
|
|
|
@@ -39101,8 +39143,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39101
39143
|
const handleCellMouseLeave = e => {
|
|
39102
39144
|
const cell = getCell(e);
|
|
39103
39145
|
if (!cell) return;
|
|
39104
|
-
const oldHoverState = table.
|
|
39105
|
-
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell,
|
|
39146
|
+
const oldHoverState = table.hoverState.value || {};
|
|
39147
|
+
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
|
|
39106
39148
|
};
|
|
39107
39149
|
const handleMouseEnter = debounce$1(index => {
|
|
39108
39150
|
props.store.setHoverRow(index);
|
|
@@ -39138,7 +39180,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39138
39180
|
const {
|
|
39139
39181
|
columns
|
|
39140
39182
|
} = states;
|
|
39141
|
-
const key =
|
|
39183
|
+
const key = getValueOfRow(row, rowIndex);
|
|
39184
|
+
const selected = props.store.isSelected(row);
|
|
39142
39185
|
return vue.createVNode("div", {
|
|
39143
39186
|
"key": key,
|
|
39144
39187
|
"class": [getRowClass(row, rowIndex), 'vc-table__tr'],
|
|
@@ -39159,10 +39202,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
39159
39202
|
};
|
|
39160
39203
|
if (columnsHidden.value[columnIndex]) {
|
|
39161
39204
|
return vue.createVNode("div", {
|
|
39205
|
+
"key": column.id,
|
|
39162
39206
|
"style": [sizeStyle]
|
|
39163
39207
|
}, null);
|
|
39164
39208
|
}
|
|
39165
39209
|
return vue.createVNode("div", {
|
|
39210
|
+
"key": column.id,
|
|
39166
39211
|
"style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
|
|
39167
39212
|
"class": [getCellClass(rowIndex, columnIndex, row, column), 'vc-table__td'],
|
|
39168
39213
|
"onMouseenter": e => handleCellMouseEnter(e, row),
|
|
@@ -39172,7 +39217,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39172
39217
|
column,
|
|
39173
39218
|
rowIndex,
|
|
39174
39219
|
columnIndex,
|
|
39175
|
-
store: props.store
|
|
39220
|
+
store: props.store,
|
|
39221
|
+
selected
|
|
39176
39222
|
})]);
|
|
39177
39223
|
})]);
|
|
39178
39224
|
};
|
|
@@ -39202,13 +39248,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
39202
39248
|
}
|
|
39203
39249
|
});
|
|
39204
39250
|
};
|
|
39205
|
-
const wrapper = vue.ref();
|
|
39206
39251
|
expose({
|
|
39207
39252
|
wrapper,
|
|
39208
39253
|
getRootElement: () => instance.vnode.el
|
|
39209
39254
|
});
|
|
39255
|
+
const layout = table.layout;
|
|
39210
39256
|
return () => {
|
|
39211
|
-
const layout = table.exposed.layout;
|
|
39212
39257
|
return vue.createVNode("div", {
|
|
39213
39258
|
"class": "vc-table__body"
|
|
39214
39259
|
}, [table.props.height ? vue.createVNode(RecycleList, {
|
|
@@ -39217,7 +39262,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39217
39262
|
"disabled": true,
|
|
39218
39263
|
"class": "vc-table__tbody",
|
|
39219
39264
|
"scrollerOptions": {
|
|
39220
|
-
barTo: `.${table.
|
|
39265
|
+
barTo: `.${table.tableId}`,
|
|
39221
39266
|
native: false,
|
|
39222
39267
|
always: false,
|
|
39223
39268
|
showBar: !props.fixed,
|
|
@@ -39253,57 +39298,6 @@ var VcComponents = (function (exports, vue) {
|
|
|
39253
39298
|
|
|
39254
39299
|
const TableSort = 'div';
|
|
39255
39300
|
const TableFilter = 'div';
|
|
39256
|
-
const getAllColumns = columns => {
|
|
39257
|
-
const result = [];
|
|
39258
|
-
columns.forEach(column => {
|
|
39259
|
-
if (column.children) {
|
|
39260
|
-
result.push(column);
|
|
39261
|
-
result.push(...getAllColumns(column.children));
|
|
39262
|
-
} else {
|
|
39263
|
-
result.push(column);
|
|
39264
|
-
}
|
|
39265
|
-
});
|
|
39266
|
-
return result;
|
|
39267
|
-
};
|
|
39268
|
-
const convertToRows = originColumns => {
|
|
39269
|
-
let maxLevel = 1;
|
|
39270
|
-
const traverse = (column, parent) => {
|
|
39271
|
-
if (parent) {
|
|
39272
|
-
column.level = parent.level + 1;
|
|
39273
|
-
if (maxLevel < column.level) {
|
|
39274
|
-
maxLevel = column.level;
|
|
39275
|
-
}
|
|
39276
|
-
}
|
|
39277
|
-
if (column.children) {
|
|
39278
|
-
let colSpan = 0;
|
|
39279
|
-
column.children.forEach(subColumn => {
|
|
39280
|
-
traverse(subColumn, column);
|
|
39281
|
-
colSpan += subColumn.colSpan;
|
|
39282
|
-
});
|
|
39283
|
-
column.colSpan = colSpan;
|
|
39284
|
-
} else {
|
|
39285
|
-
column.colSpan = 1;
|
|
39286
|
-
}
|
|
39287
|
-
};
|
|
39288
|
-
originColumns.forEach(column => {
|
|
39289
|
-
column.level = 1;
|
|
39290
|
-
traverse(column);
|
|
39291
|
-
});
|
|
39292
|
-
const rows = [];
|
|
39293
|
-
for (let i = 0; i < maxLevel; i++) {
|
|
39294
|
-
rows.push([]);
|
|
39295
|
-
}
|
|
39296
|
-
const allColumns = getAllColumns(originColumns);
|
|
39297
|
-
allColumns.forEach(column => {
|
|
39298
|
-
if (!column.children) {
|
|
39299
|
-
column.rowSpan = maxLevel - column.level + 1;
|
|
39300
|
-
} else {
|
|
39301
|
-
column.rowSpan = 1;
|
|
39302
|
-
}
|
|
39303
|
-
rows[column.level - 1].push(column);
|
|
39304
|
-
});
|
|
39305
|
-
return rows;
|
|
39306
|
-
};
|
|
39307
39301
|
const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
39308
39302
|
name: 'vc-table-header',
|
|
39309
39303
|
props: {
|
|
@@ -39320,7 +39314,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39320
39314
|
}
|
|
39321
39315
|
},
|
|
39322
39316
|
setup(props) {
|
|
39323
|
-
const table =
|
|
39317
|
+
const table = vue.inject('vc-table');
|
|
39324
39318
|
const instance = vue.getCurrentInstance();
|
|
39325
39319
|
const draggingColumn = vue.ref(null);
|
|
39326
39320
|
const dragging = vue.ref(false);
|
|
@@ -39330,16 +39324,18 @@ var VcComponents = (function (exports, vue) {
|
|
|
39330
39324
|
isAllSelected: 'isAllSelected',
|
|
39331
39325
|
leftFixedLeafCount: 'leftFixedLeafColumnsLength',
|
|
39332
39326
|
rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
|
39327
|
+
isGroup: 'isGroup',
|
|
39328
|
+
headerRows: 'headerRows',
|
|
39333
39329
|
columnsCount: $states => $states.columns.length,
|
|
39334
39330
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
39335
39331
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
39336
39332
|
});
|
|
39337
|
-
const
|
|
39333
|
+
const isColumnHidden = index => {
|
|
39338
39334
|
let start = 0;
|
|
39339
39335
|
for (let i = 0; i < index; i++) {
|
|
39340
|
-
start += columns[i].colSpan;
|
|
39336
|
+
start += states.columns[i].colSpan;
|
|
39341
39337
|
}
|
|
39342
|
-
const after = start + columns[index].colSpan - 1;
|
|
39338
|
+
const after = start + states.columns[index].colSpan - 1;
|
|
39343
39339
|
if (props.fixed === true || props.fixed === 'left') {
|
|
39344
39340
|
return after >= states.leftFixedLeafCount;
|
|
39345
39341
|
} else if (props.fixed === 'right') {
|
|
@@ -39348,6 +39344,9 @@ var VcComponents = (function (exports, vue) {
|
|
|
39348
39344
|
return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
|
|
39349
39345
|
}
|
|
39350
39346
|
};
|
|
39347
|
+
const columnsHidden = vue.computed(() => {
|
|
39348
|
+
return states.columns.map((_, index) => isColumnHidden(index));
|
|
39349
|
+
});
|
|
39351
39350
|
const getHeaderRowStyle = rowIndex => {
|
|
39352
39351
|
const {
|
|
39353
39352
|
headerRowStyle
|
|
@@ -39388,8 +39387,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39388
39387
|
return headerCellStyle;
|
|
39389
39388
|
};
|
|
39390
39389
|
const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
|
|
39391
|
-
const classes = [column.id, column.order, column.
|
|
39392
|
-
if (rowIndex === 0 &&
|
|
39390
|
+
const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
|
|
39391
|
+
if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
|
|
39393
39392
|
classes.push('is-hidden');
|
|
39394
39393
|
}
|
|
39395
39394
|
if (!column.children) {
|
|
@@ -39422,7 +39421,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39422
39421
|
/* istanbul ignore if */
|
|
39423
39422
|
if (draggingColumn.value && props.border) {
|
|
39424
39423
|
dragging.value = true;
|
|
39425
|
-
table.
|
|
39424
|
+
table.resizeProxyVisible.value = true;
|
|
39426
39425
|
const tableEl = table.vnode.el;
|
|
39427
39426
|
const tableLeft = tableEl.getBoundingClientRect().left;
|
|
39428
39427
|
const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
|
|
@@ -39435,7 +39434,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39435
39434
|
startColumnLeft: columnRect.left - tableLeft,
|
|
39436
39435
|
tableLeft
|
|
39437
39436
|
};
|
|
39438
|
-
const resizeProxy = table.
|
|
39437
|
+
const resizeProxy = table.resizeProxy.value;
|
|
39439
39438
|
resizeProxy.style.left = dragState.value.startLeft + 'px';
|
|
39440
39439
|
document.onselectstart = () => false;
|
|
39441
39440
|
document.ondragstart = () => false;
|
|
@@ -39529,37 +39528,27 @@ var VcComponents = (function (exports, vue) {
|
|
|
39529
39528
|
});
|
|
39530
39529
|
};
|
|
39531
39530
|
return () => {
|
|
39532
|
-
const {
|
|
39533
|
-
originColumns
|
|
39534
|
-
} = props.store.states;
|
|
39535
|
-
const columnRows = convertToRows(originColumns);
|
|
39536
|
-
|
|
39537
|
-
// 是否拥有多级表头
|
|
39538
|
-
const isGroup = columnRows.length > 1;
|
|
39539
|
-
if (isGroup) table.exposed.isGroup.value = true;
|
|
39540
39531
|
return vue.createVNode("div", {
|
|
39541
39532
|
"class": "vc-table__header"
|
|
39542
39533
|
}, [vue.createVNode("div", {
|
|
39543
39534
|
"class": [{
|
|
39544
|
-
'is-group': isGroup
|
|
39535
|
+
'is-group': states.isGroup
|
|
39545
39536
|
}, 'vc-table__thead']
|
|
39546
39537
|
}, [
|
|
39547
39538
|
// renderList
|
|
39548
|
-
|
|
39539
|
+
states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
|
|
39549
39540
|
"style": getHeaderRowStyle(rowIndex),
|
|
39550
39541
|
"class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
|
|
39551
|
-
}, [columns.map((column,
|
|
39552
|
-
"
|
|
39553
|
-
"rowspan": column.rowSpan,
|
|
39554
|
-
"onMousemove": $event => handleMouseMove($event, column),
|
|
39542
|
+
}, [columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
39543
|
+
"onMousemove": e => handleMouseMove(e, column),
|
|
39555
39544
|
"onMouseout": handleMouseOut,
|
|
39556
|
-
"onMousedown":
|
|
39557
|
-
"onClick":
|
|
39558
|
-
"onContextmenu":
|
|
39559
|
-
"style": [getHeaderCellStyle(rowIndex,
|
|
39545
|
+
"onMousedown": e => handleMouseDown(e, column),
|
|
39546
|
+
"onClick": e => handleHeaderClick(e, column),
|
|
39547
|
+
"onContextmenu": e => handleHeaderContextMenu(e, column),
|
|
39548
|
+
"style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
|
|
39560
39549
|
width: `${column.realWidth}px`
|
|
39561
39550
|
}],
|
|
39562
|
-
"class": [getHeaderCellClass(rowIndex,
|
|
39551
|
+
"class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
|
|
39563
39552
|
"key": column.id
|
|
39564
39553
|
}, [vue.createVNode("div", {
|
|
39565
39554
|
"class": ['vc-table__cell',
|
|
@@ -39569,10 +39558,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39569
39558
|
column.labelClass]
|
|
39570
39559
|
}, [column.renderHeader ? column.renderHeader({
|
|
39571
39560
|
column,
|
|
39572
|
-
|
|
39573
|
-
|
|
39574
|
-
store: props.store,
|
|
39575
|
-
_self: instance
|
|
39561
|
+
columnIndex,
|
|
39562
|
+
store: props.store
|
|
39576
39563
|
}) : column.label, column.tooltip ? vue.createVNode(Icon, {
|
|
39577
39564
|
"type": "o-info",
|
|
39578
39565
|
"onMouseenter": e => handleCellMouseEnter(e, column)
|
|
@@ -39614,28 +39601,28 @@ var VcComponents = (function (exports, vue) {
|
|
|
39614
39601
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
39615
39602
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
39616
39603
|
});
|
|
39617
|
-
const
|
|
39604
|
+
const isColumnHidden = (column, index) => {
|
|
39618
39605
|
if (props.fixed === true || props.fixed === 'left') {
|
|
39619
39606
|
return index >= states.leftFixedLeafCount;
|
|
39620
39607
|
} else if (props.fixed === 'right') {
|
|
39621
39608
|
let before = 0;
|
|
39622
39609
|
for (let i = 0; i < index; i++) {
|
|
39623
|
-
before += columns[i].colSpan;
|
|
39610
|
+
before += states.columns[i].colSpan;
|
|
39624
39611
|
}
|
|
39625
39612
|
return before < states.columnsCount - states.rightFixedLeafCount;
|
|
39626
39613
|
} else if (!props.fixed && column.fixed) {
|
|
39627
|
-
// hide cell when footer instance is not fixed and column is fixed
|
|
39628
39614
|
return true;
|
|
39629
39615
|
} else {
|
|
39630
39616
|
return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
|
|
39631
39617
|
}
|
|
39632
39618
|
};
|
|
39633
|
-
const
|
|
39634
|
-
|
|
39619
|
+
const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
|
|
39620
|
+
const getRowClasses = (column, columnIndex) => {
|
|
39621
|
+
const classes = [column.realAlign, column.labelClass];
|
|
39635
39622
|
if (column.className) {
|
|
39636
39623
|
classes.push(column.className);
|
|
39637
39624
|
}
|
|
39638
|
-
if (
|
|
39625
|
+
if (columnsHidden.value[columnIndex]) {
|
|
39639
39626
|
classes.push('is-hidden');
|
|
39640
39627
|
}
|
|
39641
39628
|
if (!column.children) {
|
|
@@ -39643,17 +39630,17 @@ var VcComponents = (function (exports, vue) {
|
|
|
39643
39630
|
}
|
|
39644
39631
|
return classes;
|
|
39645
39632
|
};
|
|
39646
|
-
|
|
39647
|
-
let
|
|
39633
|
+
const sums = vue.computed(() => {
|
|
39634
|
+
let v = [];
|
|
39648
39635
|
if (props.getSummary) {
|
|
39649
|
-
|
|
39636
|
+
v = props.getSummary({
|
|
39650
39637
|
columns: states.columns,
|
|
39651
39638
|
data: states.data
|
|
39652
39639
|
});
|
|
39653
39640
|
} else {
|
|
39654
39641
|
states.columns.forEach((column, index) => {
|
|
39655
39642
|
if (index === 0) {
|
|
39656
|
-
|
|
39643
|
+
v[index] = props.sumText;
|
|
39657
39644
|
return;
|
|
39658
39645
|
}
|
|
39659
39646
|
const values = states.data.map(item => Number(item[column.prop]));
|
|
@@ -39668,7 +39655,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39668
39655
|
});
|
|
39669
39656
|
const precision = Math.max.apply(null, precisions);
|
|
39670
39657
|
if (!notNumber) {
|
|
39671
|
-
|
|
39658
|
+
v[index] = values.reduce((prev, curr) => {
|
|
39672
39659
|
const value = Number(curr);
|
|
39673
39660
|
if (!isNaN(value)) {
|
|
39674
39661
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -39677,10 +39664,13 @@ var VcComponents = (function (exports, vue) {
|
|
|
39677
39664
|
}
|
|
39678
39665
|
}, 0);
|
|
39679
39666
|
} else {
|
|
39680
|
-
|
|
39667
|
+
v[index] = '';
|
|
39681
39668
|
}
|
|
39682
39669
|
});
|
|
39683
39670
|
}
|
|
39671
|
+
return v;
|
|
39672
|
+
});
|
|
39673
|
+
return () => {
|
|
39684
39674
|
return vue.createVNode("div", {
|
|
39685
39675
|
"class": "vc-table__footer",
|
|
39686
39676
|
"cellspacing": "0",
|
|
@@ -39690,17 +39680,15 @@ var VcComponents = (function (exports, vue) {
|
|
|
39690
39680
|
"class": "vc-table__tbody"
|
|
39691
39681
|
}, [vue.createVNode("div", {
|
|
39692
39682
|
"class": "vc-table__tr"
|
|
39693
|
-
}, [states.columns.map((column,
|
|
39694
|
-
"key":
|
|
39695
|
-
"
|
|
39696
|
-
"rowspan": column.rowSpan,
|
|
39697
|
-
"class": [getRowClasses(column, cellIndex), 'vc-table__td'],
|
|
39683
|
+
}, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
39684
|
+
"key": columnIndex,
|
|
39685
|
+
"class": [getRowClasses(column, columnIndex), 'vc-table__td'],
|
|
39698
39686
|
"style": [{
|
|
39699
39687
|
width: `${column.realWidth}px`
|
|
39700
39688
|
}]
|
|
39701
39689
|
}, [vue.createVNode("div", {
|
|
39702
39690
|
"class": ['vc-table__cell', column.labelClass]
|
|
39703
|
-
}, [sums[
|
|
39691
|
+
}, [sums.value[columnIndex]])]))])])]);
|
|
39704
39692
|
};
|
|
39705
39693
|
}
|
|
39706
39694
|
});
|
|
@@ -39728,7 +39716,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
39728
39716
|
type: Number,
|
|
39729
39717
|
default: 10
|
|
39730
39718
|
},
|
|
39731
|
-
|
|
39719
|
+
primaryKey: [String, Function],
|
|
39732
39720
|
// 是否显示表头
|
|
39733
39721
|
showHeader: {
|
|
39734
39722
|
type: Boolean,
|
|
@@ -39805,7 +39793,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
39805
39793
|
emits: ['select', 'select-all', 'selection-change', 'cell-mouse-enter', 'cell-mouse-leave', 'cell-click', 'cell-dblclick', 'row-click', 'row-contextmenu', 'row-dblclick', 'header-click', 'header-contextmenu', 'current-change', 'header-dragend ', 'expand-change', 'sort-change'],
|
|
39806
39794
|
setup(props, {
|
|
39807
39795
|
slots,
|
|
39808
|
-
expose
|
|
39796
|
+
expose,
|
|
39797
|
+
emit
|
|
39809
39798
|
}) {
|
|
39810
39799
|
const instance = vue.getCurrentInstance();
|
|
39811
39800
|
const store = new Store({
|
|
@@ -39845,23 +39834,21 @@ var VcComponents = (function (exports, vue) {
|
|
|
39845
39834
|
const rightFixedBody = vue.ref(null);
|
|
39846
39835
|
const rightFixedFooterWrapper = vue.ref(null);
|
|
39847
39836
|
const resizeProxy = vue.ref(null);
|
|
39848
|
-
|
|
39849
|
-
// 是否拥有多级表头, 由table-header控制
|
|
39850
|
-
const isGroup = vue.ref(false);
|
|
39851
39837
|
const scrollPosition = vue.ref('left');
|
|
39852
39838
|
const hoverState = vue.ref(null);
|
|
39853
39839
|
const isReady = vue.ref(false);
|
|
39854
39840
|
const states = useStates({
|
|
39855
39841
|
columns: 'columns',
|
|
39856
39842
|
leftFixedColumns: 'leftFixedColumns',
|
|
39857
|
-
rightFixedColumns: 'rightFixedColumns'
|
|
39843
|
+
rightFixedColumns: 'rightFixedColumns',
|
|
39844
|
+
isGroup: 'isGroup'
|
|
39858
39845
|
}, store);
|
|
39859
39846
|
const classes = vue.computed(() => {
|
|
39860
39847
|
return {
|
|
39861
39848
|
'vc-table--fit': props.fit,
|
|
39862
39849
|
'vc-table--striped': props.stripe,
|
|
39863
|
-
'vc-table--border': props.border || isGroup
|
|
39864
|
-
'vc-table--group': isGroup
|
|
39850
|
+
'vc-table--border': props.border || states.isGroup,
|
|
39851
|
+
'vc-table--group': states.isGroup,
|
|
39865
39852
|
'vc-table--fluid-height': props.maxHeight,
|
|
39866
39853
|
'vc-table--scrollable-x': layout.states.scrollX,
|
|
39867
39854
|
'vc-table--scrollable-y': layout.states.scrollY,
|
|
@@ -40122,13 +40109,13 @@ var VcComponents = (function (exports, vue) {
|
|
|
40122
40109
|
immediate: true
|
|
40123
40110
|
});
|
|
40124
40111
|
vue.watch(() => props.currentRowValue, v => {
|
|
40125
|
-
if (!props.
|
|
40112
|
+
if (!props.primaryKey) return;
|
|
40126
40113
|
store.current.reset(v);
|
|
40127
40114
|
}, {
|
|
40128
40115
|
immediate: true
|
|
40129
40116
|
});
|
|
40130
|
-
vue.watch(() => props.data,
|
|
40131
|
-
store.setData(
|
|
40117
|
+
vue.watch(() => [props.data, props.data.length], () => {
|
|
40118
|
+
store.setData(props.data);
|
|
40132
40119
|
isReady.value && vue.nextTick(refreshLayout);
|
|
40133
40120
|
}, {
|
|
40134
40121
|
immediate: true
|
|
@@ -40151,6 +40138,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
40151
40138
|
}, {
|
|
40152
40139
|
immediate: true
|
|
40153
40140
|
});
|
|
40141
|
+
const tableId = getUid('table');
|
|
40154
40142
|
vue.onMounted(() => {
|
|
40155
40143
|
bindEvents();
|
|
40156
40144
|
store.updateColumns();
|
|
@@ -40161,12 +40149,13 @@ var VcComponents = (function (exports, vue) {
|
|
|
40161
40149
|
};
|
|
40162
40150
|
isReady.value = true;
|
|
40163
40151
|
});
|
|
40164
|
-
vue.
|
|
40152
|
+
vue.onUnmounted(() => {
|
|
40165
40153
|
isUnMount = true;
|
|
40166
40154
|
unbindEvents();
|
|
40167
40155
|
});
|
|
40168
|
-
const
|
|
40169
|
-
|
|
40156
|
+
const exposed = {
|
|
40157
|
+
bodyXWrapper,
|
|
40158
|
+
bodyYWrapper,
|
|
40170
40159
|
tableId,
|
|
40171
40160
|
store,
|
|
40172
40161
|
layout,
|
|
@@ -40186,8 +40175,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
40186
40175
|
isReady,
|
|
40187
40176
|
hoverState,
|
|
40188
40177
|
renderExpanded,
|
|
40189
|
-
hiddenColumns
|
|
40190
|
-
|
|
40178
|
+
hiddenColumns,
|
|
40179
|
+
props,
|
|
40180
|
+
emit
|
|
40181
|
+
};
|
|
40182
|
+
expose(exposed);
|
|
40183
|
+
vue.provide('vc-table', exposed);
|
|
40191
40184
|
return () => {
|
|
40192
40185
|
return vue.createVNode("div", {
|
|
40193
40186
|
"class": [classes.value, tableId, 'vc-table'],
|
|
@@ -40336,22 +40329,19 @@ var VcComponents = (function (exports, vue) {
|
|
|
40336
40329
|
order: ''
|
|
40337
40330
|
},
|
|
40338
40331
|
selection: {
|
|
40339
|
-
width:
|
|
40340
|
-
minWidth:
|
|
40341
|
-
realWidth: 48,
|
|
40332
|
+
width: 60,
|
|
40333
|
+
minWidth: 60,
|
|
40342
40334
|
order: '',
|
|
40343
40335
|
className: 'vc-table-column--selection'
|
|
40344
40336
|
},
|
|
40345
40337
|
expand: {
|
|
40346
|
-
width:
|
|
40347
|
-
minWidth:
|
|
40348
|
-
realWidth: 48,
|
|
40338
|
+
width: 60,
|
|
40339
|
+
minWidth: 60,
|
|
40349
40340
|
order: ''
|
|
40350
40341
|
},
|
|
40351
40342
|
index: {
|
|
40352
|
-
width:
|
|
40353
|
-
minWidth:
|
|
40354
|
-
realWidth: 48,
|
|
40343
|
+
width: 60,
|
|
40344
|
+
minWidth: 60,
|
|
40355
40345
|
order: ''
|
|
40356
40346
|
}
|
|
40357
40347
|
};
|
|
@@ -40377,10 +40367,11 @@ var VcComponents = (function (exports, vue) {
|
|
|
40377
40367
|
column,
|
|
40378
40368
|
store,
|
|
40379
40369
|
rowIndex,
|
|
40380
|
-
level
|
|
40370
|
+
level,
|
|
40371
|
+
selected
|
|
40381
40372
|
}) {
|
|
40382
40373
|
return vue.withDirectives(vue.createVNode(Checkbox, {
|
|
40383
|
-
"modelValue":
|
|
40374
|
+
"modelValue": selected,
|
|
40384
40375
|
"disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
|
|
40385
40376
|
"onChange": () => store.rowSelectedChanged(row),
|
|
40386
40377
|
"onClick": e => e.stopPropagation()
|
|
@@ -40518,8 +40509,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
40518
40509
|
customClass: String,
|
|
40519
40510
|
labelClass: String,
|
|
40520
40511
|
prop: String,
|
|
40521
|
-
width:
|
|
40522
|
-
minWidth:
|
|
40512
|
+
width: Number,
|
|
40513
|
+
minWidth: Number,
|
|
40523
40514
|
renderHeader: Function,
|
|
40524
40515
|
resizable: {
|
|
40525
40516
|
type: Boolean,
|
|
@@ -40553,15 +40544,14 @@ var VcComponents = (function (exports, vue) {
|
|
|
40553
40544
|
tooltip: [String, Function]
|
|
40554
40545
|
},
|
|
40555
40546
|
setup(props, {
|
|
40556
|
-
slots
|
|
40557
|
-
expose
|
|
40547
|
+
slots
|
|
40558
40548
|
}) {
|
|
40559
40549
|
const instance = vue.getCurrentInstance();
|
|
40560
|
-
const table =
|
|
40561
|
-
const parent =
|
|
40550
|
+
const table = vue.inject('vc-table');
|
|
40551
|
+
const parent = vue.inject('vc-table-column', table);
|
|
40562
40552
|
const isSubColumn = table !== parent; // 用于多久表头
|
|
40563
40553
|
|
|
40564
|
-
const columnId = vue.ref((parent.
|
|
40554
|
+
const columnId = vue.ref((parent.tableId || parent.columnId) + getUid('column'));
|
|
40565
40555
|
const realWidth = vue.computed(() => {
|
|
40566
40556
|
return parseWidth(props.width);
|
|
40567
40557
|
});
|
|
@@ -40591,7 +40581,6 @@ var VcComponents = (function (exports, vue) {
|
|
|
40591
40581
|
}, {});
|
|
40592
40582
|
return result;
|
|
40593
40583
|
};
|
|
40594
|
-
|
|
40595
40584
|
/**
|
|
40596
40585
|
* compose 1
|
|
40597
40586
|
* 对于特定类型的 column,某些属性不允许设置
|
|
@@ -40661,7 +40650,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
40661
40650
|
column.renderCell = data => vue.createVNode("div", {
|
|
40662
40651
|
"class": "vc-table__cell"
|
|
40663
40652
|
}, [originRenderCell(data)]);
|
|
40664
|
-
table.
|
|
40653
|
+
table.renderExpanded.value = data => {
|
|
40665
40654
|
return slots.default ? slots.default(data) : slots.default;
|
|
40666
40655
|
};
|
|
40667
40656
|
} else {
|
|
@@ -40680,7 +40669,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
40680
40669
|
style: {}
|
|
40681
40670
|
};
|
|
40682
40671
|
// 存在树形数组,且当前行无箭头图标且处于当前展开列,表格对齐
|
|
40683
|
-
if (!isEmpty$1(table.
|
|
40672
|
+
if (!isEmpty$1(table.store.states.treeData) && !prefix && data.isExpandColumn) {
|
|
40684
40673
|
prefix = vue.createVNode("span", {
|
|
40685
40674
|
"class": "vc-table-un-expand__indent"
|
|
40686
40675
|
}, null);
|
|
@@ -40700,26 +40689,16 @@ var VcComponents = (function (exports, vue) {
|
|
|
40700
40689
|
}
|
|
40701
40690
|
return column;
|
|
40702
40691
|
};
|
|
40703
|
-
const
|
|
40692
|
+
const registerColumn = () => {
|
|
40704
40693
|
const defaults = {
|
|
40705
40694
|
...cellStarts[props.type],
|
|
40706
|
-
type: props.type,
|
|
40707
40695
|
id: columnId.value,
|
|
40708
|
-
|
|
40709
|
-
|
|
40710
|
-
prop: props.prop,
|
|
40711
|
-
showPopover: props.showPopover,
|
|
40712
|
-
// index 列
|
|
40713
|
-
index: props.index
|
|
40696
|
+
realAlign,
|
|
40697
|
+
realHeaderAlign
|
|
40714
40698
|
};
|
|
40715
|
-
|
|
40716
|
-
|
|
40717
|
-
|
|
40718
|
-
const filterProps = ['filters', 'filteredValue', 'filterMultiple', 'filter', 'filterIcon', 'filterPopupClass'];
|
|
40719
|
-
let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
|
|
40720
|
-
column = merge$1(defaults, column);
|
|
40721
|
-
|
|
40722
|
-
// 注意 compose 中函数执行的顺序是从右到左
|
|
40699
|
+
let column = merge$1(defaults, getPropsData(Object.keys(props)));
|
|
40700
|
+
|
|
40701
|
+
// minWidth/realWidth/renderHeader
|
|
40723
40702
|
column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
|
|
40724
40703
|
for (const key in column) {
|
|
40725
40704
|
if (hasOwn$1(column, key)) {
|
|
@@ -40727,34 +40706,39 @@ var VcComponents = (function (exports, vue) {
|
|
|
40727
40706
|
}
|
|
40728
40707
|
}
|
|
40729
40708
|
};
|
|
40730
|
-
const
|
|
40709
|
+
const registerWatchers = () => {
|
|
40710
|
+
// 赋值
|
|
40711
|
+
Object.keys(props).forEach(k => vue.watch(() => props[k], v => columnConfig[k] = v));
|
|
40712
|
+
|
|
40713
|
+
// 影响布局
|
|
40731
40714
|
vue.watch(() => props.fixed, () => {
|
|
40732
|
-
table.
|
|
40715
|
+
table.store.scheduleLayout(true);
|
|
40733
40716
|
});
|
|
40734
|
-
vue.watch(() => realWidth.value,
|
|
40735
|
-
|
|
40717
|
+
vue.watch(() => realWidth.value, v => {
|
|
40718
|
+
columnConfig['width'] = v;
|
|
40719
|
+
columnConfig['realWidth'] = v;
|
|
40720
|
+
table.store.scheduleLayout(false);
|
|
40736
40721
|
});
|
|
40737
40722
|
vue.watch(() => realMinWidth.value, () => {
|
|
40738
|
-
table.
|
|
40723
|
+
table.store.scheduleLayout(false);
|
|
40739
40724
|
});
|
|
40740
40725
|
};
|
|
40741
40726
|
vue.onBeforeMount(() => {
|
|
40742
|
-
|
|
40743
|
-
|
|
40727
|
+
registerColumn();
|
|
40728
|
+
registerWatchers();
|
|
40744
40729
|
});
|
|
40745
|
-
vue.onUpdated(refreshColumnBasicConfig);
|
|
40746
40730
|
vue.onMounted(() => {
|
|
40747
|
-
const children = isSubColumn ? parent.vnode.el.children : parent.
|
|
40731
|
+
const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
|
|
40748
40732
|
|
|
40749
40733
|
// DOM上
|
|
40750
40734
|
const columnIndex = [...children].indexOf(instance.vnode.el);
|
|
40751
|
-
table.
|
|
40735
|
+
table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
|
|
40752
40736
|
});
|
|
40753
40737
|
vue.onUnmounted(() => {
|
|
40754
40738
|
if (!instance.parent) return;
|
|
40755
|
-
table.
|
|
40739
|
+
table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
|
|
40756
40740
|
});
|
|
40757
|
-
|
|
40741
|
+
vue.provide('vc-table-column', {
|
|
40758
40742
|
columnId,
|
|
40759
40743
|
columnConfig
|
|
40760
40744
|
});
|
|
@@ -40770,7 +40754,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
40770
40754
|
const renderDefault = slots?.default?.({
|
|
40771
40755
|
row: {},
|
|
40772
40756
|
column: {},
|
|
40773
|
-
|
|
40757
|
+
columnIndex: -1,
|
|
40758
|
+
rowIndex: -1
|
|
40774
40759
|
});
|
|
40775
40760
|
if (renderDefault instanceof Array) {
|
|
40776
40761
|
for (const childNode of renderDefault) {
|