@deot/vc-components 1.0.11 → 1.0.12
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 +293 -329
- package/dist/index.d.ts +12 -12
- package/dist/index.iife.js +305 -341
- package/dist/index.js +293 -329
- package/dist/index.umd.cjs +305 -341
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7986,6 +7986,7 @@ const Track = /* @__PURE__ */ defineComponent({
|
|
|
7986
7986
|
isVisible.value = cursorDown.value;
|
|
7987
7987
|
};
|
|
7988
7988
|
const refreshThumb = () => raf(() => {
|
|
7989
|
+
if (!thumb.value) return;
|
|
7989
7990
|
thumb.value.style[$.prefixStyle('transform').camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
|
|
7990
7991
|
});
|
|
7991
7992
|
const refreshThrottleThumb = throttle(refreshThumb, 10);
|
|
@@ -13146,6 +13147,7 @@ const RecycleList = /* @__PURE__ */ defineComponent({
|
|
|
13146
13147
|
|
|
13147
13148
|
// 设置data首个元素的在originalData索引值
|
|
13148
13149
|
const setFirstItemIndex = () => {
|
|
13150
|
+
if (!wrapper.value) return;
|
|
13149
13151
|
const position = wrapper.value[K.scrollAxis];
|
|
13150
13152
|
let item;
|
|
13151
13153
|
for (let i = 0; i < rebuildData.value.length; i++) {
|
|
@@ -13326,6 +13328,7 @@ const RecycleList = /* @__PURE__ */ defineComponent({
|
|
|
13326
13328
|
|
|
13327
13329
|
// 图片撑开时,会影响布局, 节流结束后调用
|
|
13328
13330
|
const handleResize = throttle$1(async () => {
|
|
13331
|
+
if (!wrapper.value) return;
|
|
13329
13332
|
const isNeedRefreshLayout = rebuildData.value.some(i => !i.isPlaceholder);
|
|
13330
13333
|
if (isNeedRefreshLayout) {
|
|
13331
13334
|
const oldFirstItemIndex = firstItemIndex.value;
|
|
@@ -13763,88 +13766,65 @@ const MSwitch = /* @__PURE__ */ defineComponent({
|
|
|
13763
13766
|
}
|
|
13764
13767
|
});
|
|
13765
13768
|
|
|
13766
|
-
const parseHeight = (
|
|
13767
|
-
if (typeof
|
|
13768
|
-
return
|
|
13769
|
+
const parseHeight = (v) => {
|
|
13770
|
+
if (typeof v === "number") {
|
|
13771
|
+
return v;
|
|
13769
13772
|
}
|
|
13770
|
-
if (
|
|
13771
|
-
if (/^\d+(?:px)?/.test(
|
|
13772
|
-
return parseInt(
|
|
13773
|
+
if (v && typeof v === "string") {
|
|
13774
|
+
if (/^\d+(?:px)?/.test(v)) {
|
|
13775
|
+
return parseInt(v, 10);
|
|
13773
13776
|
}
|
|
13774
13777
|
throw new VcError("table", "Invalid Height");
|
|
13775
13778
|
}
|
|
13776
13779
|
return null;
|
|
13777
13780
|
};
|
|
13778
|
-
const parseWidth = (
|
|
13779
|
-
if (
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13781
|
+
const parseWidth = (v) => {
|
|
13782
|
+
if (typeof v === "number") {
|
|
13783
|
+
return v;
|
|
13784
|
+
}
|
|
13785
|
+
let v1;
|
|
13786
|
+
if (typeof v !== "undefined") {
|
|
13787
|
+
v1 = parseInt(v, 10);
|
|
13788
|
+
if (isNaN(v1)) {
|
|
13789
|
+
v1 = null;
|
|
13783
13790
|
}
|
|
13784
13791
|
}
|
|
13785
|
-
return
|
|
13792
|
+
return v1;
|
|
13786
13793
|
};
|
|
13787
|
-
const parseMinWidth = (
|
|
13788
|
-
if (typeof
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13794
|
+
const parseMinWidth = (v) => {
|
|
13795
|
+
if (typeof v === "number") {
|
|
13796
|
+
return v;
|
|
13797
|
+
}
|
|
13798
|
+
let v1;
|
|
13799
|
+
if (typeof v !== "undefined") {
|
|
13800
|
+
v1 = parseWidth(v);
|
|
13801
|
+
if (isNaN(v1)) {
|
|
13802
|
+
v = 80;
|
|
13792
13803
|
}
|
|
13793
13804
|
}
|
|
13794
|
-
return
|
|
13805
|
+
return v1;
|
|
13795
13806
|
};
|
|
13796
|
-
const
|
|
13807
|
+
const getRowValue = (row, primaryKey) => {
|
|
13797
13808
|
if (row.__KEY__) return row.__KEY__;
|
|
13798
13809
|
if (!row) throw new VcError("table", "row is required when get row identity");
|
|
13799
|
-
if (typeof
|
|
13800
|
-
if (!
|
|
13801
|
-
return row[
|
|
13810
|
+
if (typeof primaryKey === "string") {
|
|
13811
|
+
if (!primaryKey.includes(".")) {
|
|
13812
|
+
return row[primaryKey];
|
|
13802
13813
|
}
|
|
13803
|
-
const key =
|
|
13814
|
+
const key = primaryKey.split(".");
|
|
13804
13815
|
let current = row;
|
|
13805
13816
|
for (let i = 0; i < key.length; i++) {
|
|
13806
13817
|
current = current[key[i]];
|
|
13807
13818
|
}
|
|
13808
13819
|
return current;
|
|
13809
|
-
} else if (typeof
|
|
13810
|
-
return
|
|
13820
|
+
} else if (typeof primaryKey === "function") {
|
|
13821
|
+
return primaryKey.call(null, row);
|
|
13811
13822
|
}
|
|
13812
13823
|
};
|
|
13813
|
-
const
|
|
13814
|
-
const {
|
|
13815
|
-
childrenKey = "children",
|
|
13816
|
-
lazyKey = "hasChildren",
|
|
13817
|
-
level: baseLevel = 0
|
|
13818
|
-
} = opts;
|
|
13819
|
-
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
13820
|
-
function _walker(parent, children, level) {
|
|
13821
|
-
cb(parent, children, level);
|
|
13822
|
-
children.forEach((item) => {
|
|
13823
|
-
if (item[lazyKey]) {
|
|
13824
|
-
cb(item, null, level + 1);
|
|
13825
|
-
return;
|
|
13826
|
-
}
|
|
13827
|
-
const $children = item[childrenKey];
|
|
13828
|
-
if (!isNil($children)) {
|
|
13829
|
-
_walker(item, $children, level + 1);
|
|
13830
|
-
}
|
|
13831
|
-
});
|
|
13832
|
-
}
|
|
13833
|
-
root.forEach((item) => {
|
|
13834
|
-
if (item[lazyKey]) {
|
|
13835
|
-
cb(item, null, baseLevel);
|
|
13836
|
-
return;
|
|
13837
|
-
}
|
|
13838
|
-
const children = item[childrenKey];
|
|
13839
|
-
if (!isNil(children)) {
|
|
13840
|
-
_walker(item, children, baseLevel);
|
|
13841
|
-
}
|
|
13842
|
-
});
|
|
13843
|
-
};
|
|
13844
|
-
const getKeysMap = (array = [], rowKey) => {
|
|
13824
|
+
const getValuesMap = (array = [], primaryKey) => {
|
|
13845
13825
|
const arrayMap = {};
|
|
13846
13826
|
array.forEach((row, index) => {
|
|
13847
|
-
arrayMap[
|
|
13827
|
+
arrayMap[getRowValue(row, primaryKey)] = { row, index };
|
|
13848
13828
|
});
|
|
13849
13829
|
return arrayMap;
|
|
13850
13830
|
};
|
|
@@ -13857,23 +13837,75 @@ const getColumnById = (columns, columnId) => {
|
|
|
13857
13837
|
});
|
|
13858
13838
|
return column;
|
|
13859
13839
|
};
|
|
13860
|
-
const getColumnByCell = (
|
|
13840
|
+
const getColumnByCell = (columns, cell) => {
|
|
13861
13841
|
const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
|
|
13862
13842
|
if (matches) {
|
|
13863
|
-
return getColumnById(
|
|
13843
|
+
return getColumnById(columns, matches[0]);
|
|
13864
13844
|
}
|
|
13865
13845
|
return null;
|
|
13866
13846
|
};
|
|
13867
|
-
const getCell = (
|
|
13868
|
-
let cell =
|
|
13847
|
+
const getCell = (e) => {
|
|
13848
|
+
let cell = e.target;
|
|
13869
13849
|
while (cell && cell.tagName.toUpperCase() !== "HTML") {
|
|
13870
|
-
if (cell.
|
|
13850
|
+
if (cell.classList.contains("vc-table__td")) {
|
|
13871
13851
|
return cell;
|
|
13872
13852
|
}
|
|
13873
13853
|
cell = cell.parentNode;
|
|
13874
13854
|
}
|
|
13875
13855
|
return null;
|
|
13876
13856
|
};
|
|
13857
|
+
|
|
13858
|
+
const getAllColumns = (columns) => {
|
|
13859
|
+
const result = [];
|
|
13860
|
+
columns.forEach((column) => {
|
|
13861
|
+
if (column.children) {
|
|
13862
|
+
result.push(column);
|
|
13863
|
+
result.push(...getAllColumns(column.children));
|
|
13864
|
+
} else {
|
|
13865
|
+
result.push(column);
|
|
13866
|
+
}
|
|
13867
|
+
});
|
|
13868
|
+
return result;
|
|
13869
|
+
};
|
|
13870
|
+
const columnsToRowsEffect = (v) => {
|
|
13871
|
+
let maxLevel = 1;
|
|
13872
|
+
const traverse = (column, parent) => {
|
|
13873
|
+
if (parent) {
|
|
13874
|
+
column.level = parent.level + 1;
|
|
13875
|
+
if (maxLevel < column.level) {
|
|
13876
|
+
maxLevel = column.level;
|
|
13877
|
+
}
|
|
13878
|
+
}
|
|
13879
|
+
if (column.children) {
|
|
13880
|
+
let colSpan = 0;
|
|
13881
|
+
column.children.forEach((subColumn) => {
|
|
13882
|
+
traverse(subColumn, column);
|
|
13883
|
+
colSpan += subColumn.colSpan;
|
|
13884
|
+
});
|
|
13885
|
+
column.colSpan = colSpan;
|
|
13886
|
+
} else {
|
|
13887
|
+
column.colSpan = 1;
|
|
13888
|
+
}
|
|
13889
|
+
};
|
|
13890
|
+
v.forEach((column) => {
|
|
13891
|
+
column.level = 1;
|
|
13892
|
+
traverse(column);
|
|
13893
|
+
});
|
|
13894
|
+
const rows = [];
|
|
13895
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
13896
|
+
rows.push([]);
|
|
13897
|
+
}
|
|
13898
|
+
const allColumns = getAllColumns(v);
|
|
13899
|
+
allColumns.forEach((column) => {
|
|
13900
|
+
if (!column.children) {
|
|
13901
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
13902
|
+
} else {
|
|
13903
|
+
column.rowSpan = 1;
|
|
13904
|
+
}
|
|
13905
|
+
rows[column.level - 1].push(column);
|
|
13906
|
+
});
|
|
13907
|
+
return rows;
|
|
13908
|
+
};
|
|
13877
13909
|
const flattenData = (data, opts = {}) => {
|
|
13878
13910
|
const result = [];
|
|
13879
13911
|
data.forEach((item) => {
|
|
@@ -13886,6 +13918,37 @@ const flattenData = (data, opts = {}) => {
|
|
|
13886
13918
|
});
|
|
13887
13919
|
return result;
|
|
13888
13920
|
};
|
|
13921
|
+
const walkTreeNode = (root, cb, opts = {}) => {
|
|
13922
|
+
const {
|
|
13923
|
+
childrenKey = "children",
|
|
13924
|
+
lazyKey = "hasChildren",
|
|
13925
|
+
level: baseLevel = 0
|
|
13926
|
+
} = opts;
|
|
13927
|
+
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
13928
|
+
function _walker(parent, children, level) {
|
|
13929
|
+
cb(parent, children, level);
|
|
13930
|
+
children.forEach((item) => {
|
|
13931
|
+
if (item[lazyKey]) {
|
|
13932
|
+
cb(item, null, level + 1);
|
|
13933
|
+
return;
|
|
13934
|
+
}
|
|
13935
|
+
const $children = item[childrenKey];
|
|
13936
|
+
if (!isNil($children)) {
|
|
13937
|
+
_walker(item, $children, level + 1);
|
|
13938
|
+
}
|
|
13939
|
+
});
|
|
13940
|
+
}
|
|
13941
|
+
root.forEach((item) => {
|
|
13942
|
+
if (item[lazyKey]) {
|
|
13943
|
+
cb(item, null, baseLevel);
|
|
13944
|
+
return;
|
|
13945
|
+
}
|
|
13946
|
+
const children = item[childrenKey];
|
|
13947
|
+
if (!isNil(children)) {
|
|
13948
|
+
_walker(item, children, baseLevel);
|
|
13949
|
+
}
|
|
13950
|
+
});
|
|
13951
|
+
};
|
|
13889
13952
|
|
|
13890
13953
|
class BaseWatcher {
|
|
13891
13954
|
states = reactive({
|
|
@@ -13893,23 +13956,14 @@ class BaseWatcher {
|
|
|
13893
13956
|
_data: [],
|
|
13894
13957
|
data: [],
|
|
13895
13958
|
list: [],
|
|
13896
|
-
//
|
|
13897
|
-
|
|
13898
|
-
// 列
|
|
13959
|
+
// 表头数据
|
|
13960
|
+
headerRows: [],
|
|
13961
|
+
// 列 动态收集vc-table-column中的columnConfig
|
|
13899
13962
|
_columns: [],
|
|
13900
|
-
// 动态收集vc-table-column中的columnConfig
|
|
13901
13963
|
originColumns: [],
|
|
13902
|
-
|
|
13903
|
-
columns: [],
|
|
13904
|
-
// 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
|
|
13964
|
+
notFixedColumns: [],
|
|
13905
13965
|
leftFixedColumns: [],
|
|
13906
13966
|
rightFixedColumns: [],
|
|
13907
|
-
leafColumns: [],
|
|
13908
|
-
leftFixedLeafColumns: [],
|
|
13909
|
-
rightFixedLeafColumns: [],
|
|
13910
|
-
leafColumnsLength: 0,
|
|
13911
|
-
leftFixedLeafColumnsLength: 0,
|
|
13912
|
-
rightFixedLeafColumnsLength: 0,
|
|
13913
13967
|
// 选择
|
|
13914
13968
|
isAllSelected: false,
|
|
13915
13969
|
selection: [],
|
|
@@ -13931,7 +13985,17 @@ class BaseWatcher {
|
|
|
13931
13985
|
treeLazyData: [],
|
|
13932
13986
|
// 源数据展开
|
|
13933
13987
|
treeLazyColumnIdentifier: "hasChildren",
|
|
13934
|
-
treeChildrenColumnName: "children"
|
|
13988
|
+
treeChildrenColumnName: "children",
|
|
13989
|
+
// compputeds
|
|
13990
|
+
isComplex: computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
|
|
13991
|
+
isGroup: computed(() => this.states.columns.length > this.states.originColumns.length),
|
|
13992
|
+
columns: computed(() => concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
|
|
13993
|
+
leafColumns: computed(() => flattenData(this.states.notFixedColumns)),
|
|
13994
|
+
leftFixedLeafColumns: computed(() => flattenData(this.states.leftFixedColumns)),
|
|
13995
|
+
rightFixedLeafColumns: computed(() => flattenData(this.states.rightFixedColumns)),
|
|
13996
|
+
leafColumnsLength: computed(() => this.states.leafColumns.length),
|
|
13997
|
+
leftFixedLeafColumnsLength: computed(() => this.states.leftFixedLeafColumns.length),
|
|
13998
|
+
rightFixedLeafColumnsLength: computed(() => this.states.rightFixedLeafColumns.length)
|
|
13935
13999
|
});
|
|
13936
14000
|
}
|
|
13937
14001
|
|
|
@@ -13942,14 +14006,14 @@ class Expand {
|
|
|
13942
14006
|
}
|
|
13943
14007
|
update() {
|
|
13944
14008
|
const store = this.store;
|
|
13945
|
-
const {
|
|
14009
|
+
const { primaryKey, defaultExpandAll } = this.store.table.props;
|
|
13946
14010
|
const { data = [], expandRows } = store.states;
|
|
13947
14011
|
if (defaultExpandAll) {
|
|
13948
14012
|
store.states.expandRows = data.slice();
|
|
13949
|
-
} else if (
|
|
13950
|
-
const expandRowsMap =
|
|
14013
|
+
} else if (primaryKey) {
|
|
14014
|
+
const expandRowsMap = getValuesMap(expandRows, primaryKey);
|
|
13951
14015
|
store.states.expandRows = data.reduce((prev, row) => {
|
|
13952
|
-
const rowId =
|
|
14016
|
+
const rowId = getRowValue(row, primaryKey);
|
|
13953
14017
|
const rowInfo = expandRowsMap[rowId];
|
|
13954
14018
|
if (rowInfo) {
|
|
13955
14019
|
prev.push(row);
|
|
@@ -13971,10 +14035,10 @@ class Expand {
|
|
|
13971
14035
|
}
|
|
13972
14036
|
reset(ids) {
|
|
13973
14037
|
const store = this.store;
|
|
13974
|
-
store.
|
|
13975
|
-
const {
|
|
14038
|
+
store.checkPrimaryKey();
|
|
14039
|
+
const { primaryKey } = store.table.props;
|
|
13976
14040
|
const { data } = store.states;
|
|
13977
|
-
const keysMap =
|
|
14041
|
+
const keysMap = getValuesMap(data, primaryKey);
|
|
13978
14042
|
store.states.expandRows = ids.reduce((prev, cur) => {
|
|
13979
14043
|
const info = keysMap[cur];
|
|
13980
14044
|
if (info) {
|
|
@@ -13984,11 +14048,11 @@ class Expand {
|
|
|
13984
14048
|
}, []);
|
|
13985
14049
|
}
|
|
13986
14050
|
isExpanded(row) {
|
|
13987
|
-
const {
|
|
14051
|
+
const { primaryKey } = this.store.table.props;
|
|
13988
14052
|
const { expandRows = [] } = this.store.states;
|
|
13989
|
-
if (
|
|
13990
|
-
const expandMap =
|
|
13991
|
-
return !!expandMap[
|
|
14053
|
+
if (primaryKey) {
|
|
14054
|
+
const expandMap = getValuesMap(expandRows, primaryKey);
|
|
14055
|
+
return !!expandMap[getRowValue(row, primaryKey)];
|
|
13992
14056
|
}
|
|
13993
14057
|
return expandRows.indexOf(row) !== -1;
|
|
13994
14058
|
}
|
|
@@ -14001,22 +14065,22 @@ class Current {
|
|
|
14001
14065
|
}
|
|
14002
14066
|
reset(id) {
|
|
14003
14067
|
const store = this.store;
|
|
14004
|
-
const {
|
|
14005
|
-
store.
|
|
14068
|
+
const { primaryKey } = store.table.props;
|
|
14069
|
+
store.checkPrimaryKey();
|
|
14006
14070
|
const { data = [] } = store.states;
|
|
14007
|
-
const currentRow = data.find((item) =>
|
|
14071
|
+
const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
|
|
14008
14072
|
store.states.currentRow = currentRow || null;
|
|
14009
14073
|
}
|
|
14010
14074
|
update() {
|
|
14011
14075
|
const store = this.store;
|
|
14012
|
-
const {
|
|
14076
|
+
const { primaryKey } = store.table.props;
|
|
14013
14077
|
const { data = [], currentRow } = store.states;
|
|
14014
14078
|
const oldCurrentRow = currentRow;
|
|
14015
14079
|
if (oldCurrentRow && !data.includes(oldCurrentRow)) {
|
|
14016
14080
|
let newCurrentRow = null;
|
|
14017
|
-
if (
|
|
14081
|
+
if (primaryKey) {
|
|
14018
14082
|
newCurrentRow = data.find((item) => {
|
|
14019
|
-
return
|
|
14083
|
+
return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
|
|
14020
14084
|
});
|
|
14021
14085
|
}
|
|
14022
14086
|
store.states.currentRow = newCurrentRow;
|
|
@@ -14035,8 +14099,8 @@ let Tree$1 = class Tree {
|
|
|
14035
14099
|
* { id: { level, children } }
|
|
14036
14100
|
*/
|
|
14037
14101
|
normalizedData = computed(() => {
|
|
14038
|
-
const {
|
|
14039
|
-
if (!
|
|
14102
|
+
const { primaryKey } = this.store.table.props;
|
|
14103
|
+
if (!primaryKey) return {};
|
|
14040
14104
|
return this.normalize(this.store.states.data || []);
|
|
14041
14105
|
});
|
|
14042
14106
|
/**
|
|
@@ -14044,7 +14108,7 @@ let Tree$1 = class Tree {
|
|
|
14044
14108
|
* { id: { children } }
|
|
14045
14109
|
*/
|
|
14046
14110
|
normalizedLazyNode = computed(() => {
|
|
14047
|
-
const {
|
|
14111
|
+
const { primaryKey } = this.store.table.props;
|
|
14048
14112
|
const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
|
|
14049
14113
|
const keys = Object.keys(treelazyNodeMap);
|
|
14050
14114
|
const res = {};
|
|
@@ -14053,7 +14117,7 @@ let Tree$1 = class Tree {
|
|
|
14053
14117
|
if (treelazyNodeMap[key].length) {
|
|
14054
14118
|
const item = { children: [] };
|
|
14055
14119
|
treelazyNodeMap[key].forEach((row) => {
|
|
14056
|
-
const id =
|
|
14120
|
+
const id = getRowValue(row, primaryKey);
|
|
14057
14121
|
item.children.push(id);
|
|
14058
14122
|
const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
|
|
14059
14123
|
if (hasChildren && !res[id]) {
|
|
@@ -14073,16 +14137,16 @@ let Tree$1 = class Tree {
|
|
|
14073
14137
|
);
|
|
14074
14138
|
}
|
|
14075
14139
|
normalize(data) {
|
|
14076
|
-
const {
|
|
14140
|
+
const { primaryKey } = this.store.table.props;
|
|
14077
14141
|
const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
|
|
14078
14142
|
const res = {};
|
|
14079
14143
|
walkTreeNode(
|
|
14080
14144
|
data,
|
|
14081
14145
|
(parent, children, level) => {
|
|
14082
|
-
const parentId =
|
|
14146
|
+
const parentId = getRowValue(parent, primaryKey);
|
|
14083
14147
|
if (Array.isArray(children)) {
|
|
14084
14148
|
res[parentId] = {
|
|
14085
|
-
children: children.map((row) =>
|
|
14149
|
+
children: children.map((row) => getRowValue(row, primaryKey)),
|
|
14086
14150
|
level
|
|
14087
14151
|
};
|
|
14088
14152
|
} else if (treeLazy) {
|
|
@@ -14102,7 +14166,7 @@ let Tree$1 = class Tree {
|
|
|
14102
14166
|
}
|
|
14103
14167
|
// 获取当前展开最大的level
|
|
14104
14168
|
getMaxLevel() {
|
|
14105
|
-
const {
|
|
14169
|
+
const { primaryKey } = this.store.table.props;
|
|
14106
14170
|
const { data, treeData } = this.store.states;
|
|
14107
14171
|
const levels = data.map((item) => {
|
|
14108
14172
|
const traverse = (source) => {
|
|
@@ -14113,7 +14177,7 @@ let Tree$1 = class Tree {
|
|
|
14113
14177
|
return source.level;
|
|
14114
14178
|
}
|
|
14115
14179
|
};
|
|
14116
|
-
const id =
|
|
14180
|
+
const id = getRowValue(item, primaryKey);
|
|
14117
14181
|
return traverse(treeData[id]);
|
|
14118
14182
|
});
|
|
14119
14183
|
return max(levels) || 0;
|
|
@@ -14175,10 +14239,10 @@ let Tree$1 = class Tree {
|
|
|
14175
14239
|
this.update();
|
|
14176
14240
|
}
|
|
14177
14241
|
toggle(row, expanded) {
|
|
14178
|
-
this.store.
|
|
14179
|
-
const {
|
|
14242
|
+
this.store.checkPrimaryKey();
|
|
14243
|
+
const { primaryKey } = this.store.table.props;
|
|
14180
14244
|
const { treeData } = this.store.states;
|
|
14181
|
-
const id =
|
|
14245
|
+
const id = getRowValue(row, primaryKey);
|
|
14182
14246
|
const data = id && treeData[id];
|
|
14183
14247
|
if (id && data && "expanded" in data) {
|
|
14184
14248
|
const oldExpanded = data.expanded;
|
|
@@ -14191,10 +14255,10 @@ let Tree$1 = class Tree {
|
|
|
14191
14255
|
}
|
|
14192
14256
|
}
|
|
14193
14257
|
loadOrToggle(row) {
|
|
14194
|
-
this.store.
|
|
14195
|
-
const {
|
|
14258
|
+
this.store.checkPrimaryKey();
|
|
14259
|
+
const { primaryKey } = this.store.table.props;
|
|
14196
14260
|
const { treeLazy, treeData } = this.store.states;
|
|
14197
|
-
const id =
|
|
14261
|
+
const id = getRowValue(row, primaryKey);
|
|
14198
14262
|
const data = treeData[id];
|
|
14199
14263
|
if (treeLazy && data && "loaded" in data && !data.loaded) {
|
|
14200
14264
|
this.loadData(row, id, data);
|
|
@@ -14203,9 +14267,9 @@ let Tree$1 = class Tree {
|
|
|
14203
14267
|
}
|
|
14204
14268
|
}
|
|
14205
14269
|
loadData(row, key, treeNode) {
|
|
14206
|
-
this.store.
|
|
14270
|
+
this.store.checkPrimaryKey();
|
|
14207
14271
|
const { table } = this.store;
|
|
14208
|
-
const {
|
|
14272
|
+
const { primaryKey } = table.props;
|
|
14209
14273
|
const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
|
|
14210
14274
|
if (table.props.loadExpand && !treeData[key].loaded) {
|
|
14211
14275
|
this.store.states.treeData[key].loading = true;
|
|
@@ -14220,7 +14284,7 @@ let Tree$1 = class Tree {
|
|
|
14220
14284
|
walkTreeNode(
|
|
14221
14285
|
data,
|
|
14222
14286
|
(parent, _, level) => {
|
|
14223
|
-
const id =
|
|
14287
|
+
const id = getRowValue(parent, primaryKey);
|
|
14224
14288
|
Object.defineProperty(parent, "__KEY__", {
|
|
14225
14289
|
value: `${level}__${id}`,
|
|
14226
14290
|
writable: false
|
|
@@ -14290,27 +14354,13 @@ class Layout {
|
|
|
14290
14354
|
if (!this.store) {
|
|
14291
14355
|
throw new VcError("table", "Table Layout 必须包含store实例");
|
|
14292
14356
|
}
|
|
14293
|
-
this.updateScroller = this.updateScroller.bind(this);
|
|
14294
|
-
this.updateColumns = this.updateColumns.bind(this);
|
|
14295
|
-
onMounted(() => {
|
|
14296
|
-
this.updateColumns();
|
|
14297
|
-
this.updateScroller();
|
|
14298
|
-
});
|
|
14299
|
-
let __updated__;
|
|
14300
|
-
onUpdated(() => {
|
|
14301
|
-
if (__updated__) return;
|
|
14302
|
-
this.updateColumns();
|
|
14303
|
-
this.updateScroller();
|
|
14304
|
-
__updated__ = true;
|
|
14305
|
-
});
|
|
14306
14357
|
}
|
|
14307
14358
|
updateScrollY() {
|
|
14308
14359
|
const { height, bodyHeight } = this.states;
|
|
14309
14360
|
if (height === null || bodyHeight === null) return;
|
|
14310
|
-
const
|
|
14311
|
-
if (this.table.vnode.el &&
|
|
14312
|
-
|
|
14313
|
-
this.states.scrollY = body.offsetHeight > bodyHeight;
|
|
14361
|
+
const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
|
|
14362
|
+
if (this.table.vnode.el && bodyYWrapper) {
|
|
14363
|
+
this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
|
|
14314
14364
|
}
|
|
14315
14365
|
}
|
|
14316
14366
|
setHeight(value, prop = "height") {
|
|
@@ -14327,18 +14377,6 @@ class Layout {
|
|
|
14327
14377
|
setMaxHeight(value) {
|
|
14328
14378
|
this.setHeight(value, "max-height");
|
|
14329
14379
|
}
|
|
14330
|
-
getFlattenColumns() {
|
|
14331
|
-
const flattenColumns = [];
|
|
14332
|
-
const columns = this.store.states.columns;
|
|
14333
|
-
columns.forEach((column) => {
|
|
14334
|
-
if (column.isColumnGroup) {
|
|
14335
|
-
flattenColumns.push(...column.columns);
|
|
14336
|
-
} else {
|
|
14337
|
-
flattenColumns.push(column);
|
|
14338
|
-
}
|
|
14339
|
-
});
|
|
14340
|
-
return flattenColumns;
|
|
14341
|
-
}
|
|
14342
14380
|
updateElsHeight() {
|
|
14343
14381
|
if (!this.table.exposed.isReady.value) return nextTick(() => this.updateElsHeight());
|
|
14344
14382
|
const table = this.table.exposed;
|
|
@@ -14361,13 +14399,12 @@ class Layout {
|
|
|
14361
14399
|
this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
|
14362
14400
|
}
|
|
14363
14401
|
this.updateScrollY();
|
|
14364
|
-
this.updateScroller();
|
|
14365
14402
|
}
|
|
14366
14403
|
updateColumnsWidth() {
|
|
14367
14404
|
if (IS_SERVER$1) return;
|
|
14368
14405
|
const bodyWidth = this.table.vnode.el.clientWidth;
|
|
14369
14406
|
let bodyMinWidth = 0;
|
|
14370
|
-
const flattenColumns = this.
|
|
14407
|
+
const flattenColumns = this.store.states.columns;
|
|
14371
14408
|
const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
|
|
14372
14409
|
const { fit } = this.table.props;
|
|
14373
14410
|
if (flexColumns.length > 0 && fit) {
|
|
@@ -14393,7 +14430,7 @@ class Layout {
|
|
|
14393
14430
|
}
|
|
14394
14431
|
} else {
|
|
14395
14432
|
this.states.scrollX = true;
|
|
14396
|
-
flexColumns.forEach(
|
|
14433
|
+
flexColumns.forEach((column) => {
|
|
14397
14434
|
column.realWidth = column.width || column.minWidth;
|
|
14398
14435
|
});
|
|
14399
14436
|
}
|
|
@@ -14427,12 +14464,6 @@ class Layout {
|
|
|
14427
14464
|
});
|
|
14428
14465
|
this.states.rightFixedWidth = rightFixedWidth;
|
|
14429
14466
|
}
|
|
14430
|
-
this.updateColumns();
|
|
14431
|
-
}
|
|
14432
|
-
// v2.x中的 notifyObservers
|
|
14433
|
-
updateColumns() {
|
|
14434
|
-
}
|
|
14435
|
-
updateScroller() {
|
|
14436
14467
|
}
|
|
14437
14468
|
}
|
|
14438
14469
|
|
|
@@ -14442,7 +14473,7 @@ class Store extends BaseWatcher {
|
|
|
14442
14473
|
expand;
|
|
14443
14474
|
tree;
|
|
14444
14475
|
layout;
|
|
14445
|
-
|
|
14476
|
+
flatData = computed(() => {
|
|
14446
14477
|
if (this.table.props.expandSelectable) {
|
|
14447
14478
|
return concat(
|
|
14448
14479
|
flattenData(this.states.data, { parent: true, cascader: true }),
|
|
@@ -14500,7 +14531,7 @@ class Store extends BaseWatcher {
|
|
|
14500
14531
|
this.cleanSelection();
|
|
14501
14532
|
}
|
|
14502
14533
|
} else {
|
|
14503
|
-
this.
|
|
14534
|
+
this.checkPrimaryKey();
|
|
14504
14535
|
this.updateSelectionByRowKey();
|
|
14505
14536
|
}
|
|
14506
14537
|
this.updateAllSelected();
|
|
@@ -14522,10 +14553,10 @@ class Store extends BaseWatcher {
|
|
|
14522
14553
|
}
|
|
14523
14554
|
}
|
|
14524
14555
|
/**
|
|
14525
|
-
* 检查
|
|
14556
|
+
* 检查 primaryKey 是否存在
|
|
14526
14557
|
*/
|
|
14527
|
-
|
|
14528
|
-
const {
|
|
14558
|
+
checkPrimaryKey() {
|
|
14559
|
+
const { primaryKey } = this.table.props;
|
|
14529
14560
|
}
|
|
14530
14561
|
/**
|
|
14531
14562
|
* states
|
|
@@ -14586,22 +14617,20 @@ class Store extends BaseWatcher {
|
|
|
14586
14617
|
updateColumns() {
|
|
14587
14618
|
const { states } = this;
|
|
14588
14619
|
const _columns = states._columns || [];
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
if (
|
|
14620
|
+
const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
14621
|
+
const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
|
|
14622
|
+
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
14592
14623
|
_columns[0].fixed = true;
|
|
14593
|
-
|
|
14624
|
+
leftFixedColumns.unshift(_columns[0]);
|
|
14594
14625
|
}
|
|
14595
14626
|
const notFixedColumns = _columns.filter((column) => !column.fixed);
|
|
14596
|
-
|
|
14597
|
-
const
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
states.
|
|
14601
|
-
states.
|
|
14602
|
-
states.
|
|
14603
|
-
states.columns = concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
|
|
14604
|
-
states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
|
14627
|
+
const originColumns = concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
14628
|
+
const headerRows = columnsToRowsEffect(originColumns);
|
|
14629
|
+
states.leftFixedColumns = leftFixedColumns;
|
|
14630
|
+
states.notFixedColumns = notFixedColumns;
|
|
14631
|
+
states.rightFixedColumns = rightFixedColumns;
|
|
14632
|
+
states.originColumns = originColumns;
|
|
14633
|
+
states.headerRows = headerRows;
|
|
14605
14634
|
}
|
|
14606
14635
|
// 选择
|
|
14607
14636
|
isSelected(row) {
|
|
@@ -14625,13 +14654,13 @@ class Store extends BaseWatcher {
|
|
|
14625
14654
|
* 清理选择
|
|
14626
14655
|
*/
|
|
14627
14656
|
cleanSelection() {
|
|
14628
|
-
const {
|
|
14657
|
+
const { primaryKey } = this.table.props;
|
|
14629
14658
|
const { selection = [] } = this.states;
|
|
14630
14659
|
let deleted;
|
|
14631
|
-
if (
|
|
14660
|
+
if (primaryKey) {
|
|
14632
14661
|
deleted = [];
|
|
14633
|
-
const selectedMap =
|
|
14634
|
-
const dataMap =
|
|
14662
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14663
|
+
const dataMap = getValuesMap(selection, primaryKey);
|
|
14635
14664
|
for (const key in selectedMap) {
|
|
14636
14665
|
if (hasOwn(selectedMap, key) && !dataMap[key]) {
|
|
14637
14666
|
deleted.push(selectedMap[key].row);
|
|
@@ -14639,7 +14668,7 @@ class Store extends BaseWatcher {
|
|
|
14639
14668
|
}
|
|
14640
14669
|
} else {
|
|
14641
14670
|
deleted = selection.filter((item) => {
|
|
14642
|
-
return !this.
|
|
14671
|
+
return !this.flatData.value.includes(item);
|
|
14643
14672
|
});
|
|
14644
14673
|
}
|
|
14645
14674
|
deleted.forEach((deletedItem) => {
|
|
@@ -14700,7 +14729,7 @@ class Store extends BaseWatcher {
|
|
|
14700
14729
|
const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
|
|
14701
14730
|
this.states.isAllSelected = value;
|
|
14702
14731
|
let selectionChanged = false;
|
|
14703
|
-
this.
|
|
14732
|
+
this.flatData.value.forEach((row, index) => {
|
|
14704
14733
|
if (selectable) {
|
|
14705
14734
|
if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
|
|
14706
14735
|
selectionChanged = true;
|
|
@@ -14731,11 +14760,11 @@ class Store extends BaseWatcher {
|
|
|
14731
14760
|
this.tree.expand(val);
|
|
14732
14761
|
}
|
|
14733
14762
|
updateSelectionByRowKey() {
|
|
14734
|
-
const {
|
|
14763
|
+
const { primaryKey } = this.table.props;
|
|
14735
14764
|
const { selection } = this.states;
|
|
14736
|
-
const selectedMap =
|
|
14737
|
-
this.states.selection = this.
|
|
14738
|
-
const rowId =
|
|
14765
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14766
|
+
this.states.selection = this.flatData.value.reduce((prev, row) => {
|
|
14767
|
+
const rowId = getRowValue(row, primaryKey);
|
|
14739
14768
|
const rowInfo = selectedMap[rowId];
|
|
14740
14769
|
if (rowInfo) {
|
|
14741
14770
|
prev.push(row);
|
|
@@ -14751,7 +14780,7 @@ class Store extends BaseWatcher {
|
|
|
14751
14780
|
}
|
|
14752
14781
|
let isAllSelected = true;
|
|
14753
14782
|
let selectedCount = 0;
|
|
14754
|
-
const temp = this.
|
|
14783
|
+
const temp = this.flatData.value;
|
|
14755
14784
|
for (let i = 0, j = temp.length; i < j; i++) {
|
|
14756
14785
|
const row = temp[i];
|
|
14757
14786
|
const isRowSelectable = selectable && selectable.call(null, row, i);
|
|
@@ -14866,6 +14895,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14866
14895
|
type
|
|
14867
14896
|
}) => type === 'default')
|
|
14868
14897
|
});
|
|
14898
|
+
const wrapper = ref();
|
|
14869
14899
|
watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
|
|
14870
14900
|
if (!props.store.states.isComplex || IS_SERVER$1) return;
|
|
14871
14901
|
raf(() => {
|
|
@@ -14876,12 +14906,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14876
14906
|
newRow && addClass(newRow, 'hover-row');
|
|
14877
14907
|
});
|
|
14878
14908
|
});
|
|
14879
|
-
const
|
|
14909
|
+
const getValueOfRow = (row, index) => {
|
|
14880
14910
|
const {
|
|
14881
|
-
|
|
14911
|
+
primaryKey
|
|
14882
14912
|
} = table.props;
|
|
14883
|
-
if (
|
|
14884
|
-
return
|
|
14913
|
+
if (primaryKey) {
|
|
14914
|
+
return getRowValue(row, primaryKey);
|
|
14885
14915
|
}
|
|
14886
14916
|
return index;
|
|
14887
14917
|
};
|
|
@@ -14946,7 +14976,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14946
14976
|
return cellStyle;
|
|
14947
14977
|
};
|
|
14948
14978
|
const getCellClass = (rowIndex, columnIndex, row, column) => {
|
|
14949
|
-
const classes = [column.
|
|
14979
|
+
const classes = [column.realAlign, column.className];
|
|
14950
14980
|
if (isColumnHidden(columnIndex)) {
|
|
14951
14981
|
classes.push('is-hidden');
|
|
14952
14982
|
}
|
|
@@ -15006,7 +15036,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15006
15036
|
const cell = getCell(e);
|
|
15007
15037
|
if (!cell) return;
|
|
15008
15038
|
const oldHoverState = table.exposed.hoverState.value || {};
|
|
15009
|
-
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell,
|
|
15039
|
+
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
|
|
15010
15040
|
};
|
|
15011
15041
|
const handleMouseEnter = debounce(index => {
|
|
15012
15042
|
props.store.setHoverRow(index);
|
|
@@ -15042,7 +15072,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15042
15072
|
const {
|
|
15043
15073
|
columns
|
|
15044
15074
|
} = states;
|
|
15045
|
-
const key =
|
|
15075
|
+
const key = getValueOfRow(row, rowIndex);
|
|
15046
15076
|
return createVNode("div", {
|
|
15047
15077
|
"key": key,
|
|
15048
15078
|
"class": [getRowClass(row, rowIndex), 'vc-table__tr'],
|
|
@@ -15106,13 +15136,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15106
15136
|
}
|
|
15107
15137
|
});
|
|
15108
15138
|
};
|
|
15109
|
-
const wrapper = ref();
|
|
15110
15139
|
expose({
|
|
15111
15140
|
wrapper,
|
|
15112
15141
|
getRootElement: () => instance.vnode.el
|
|
15113
15142
|
});
|
|
15143
|
+
const layout = table.exposed.layout;
|
|
15114
15144
|
return () => {
|
|
15115
|
-
const layout = table.exposed.layout;
|
|
15116
15145
|
return createVNode("div", {
|
|
15117
15146
|
"class": "vc-table__body"
|
|
15118
15147
|
}, [table.props.height ? createVNode(RecycleList, {
|
|
@@ -15157,57 +15186,6 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15157
15186
|
|
|
15158
15187
|
const TableSort = 'div';
|
|
15159
15188
|
const TableFilter = 'div';
|
|
15160
|
-
const getAllColumns = columns => {
|
|
15161
|
-
const result = [];
|
|
15162
|
-
columns.forEach(column => {
|
|
15163
|
-
if (column.children) {
|
|
15164
|
-
result.push(column);
|
|
15165
|
-
result.push(...getAllColumns(column.children));
|
|
15166
|
-
} else {
|
|
15167
|
-
result.push(column);
|
|
15168
|
-
}
|
|
15169
|
-
});
|
|
15170
|
-
return result;
|
|
15171
|
-
};
|
|
15172
|
-
const convertToRows = originColumns => {
|
|
15173
|
-
let maxLevel = 1;
|
|
15174
|
-
const traverse = (column, parent) => {
|
|
15175
|
-
if (parent) {
|
|
15176
|
-
column.level = parent.level + 1;
|
|
15177
|
-
if (maxLevel < column.level) {
|
|
15178
|
-
maxLevel = column.level;
|
|
15179
|
-
}
|
|
15180
|
-
}
|
|
15181
|
-
if (column.children) {
|
|
15182
|
-
let colSpan = 0;
|
|
15183
|
-
column.children.forEach(subColumn => {
|
|
15184
|
-
traverse(subColumn, column);
|
|
15185
|
-
colSpan += subColumn.colSpan;
|
|
15186
|
-
});
|
|
15187
|
-
column.colSpan = colSpan;
|
|
15188
|
-
} else {
|
|
15189
|
-
column.colSpan = 1;
|
|
15190
|
-
}
|
|
15191
|
-
};
|
|
15192
|
-
originColumns.forEach(column => {
|
|
15193
|
-
column.level = 1;
|
|
15194
|
-
traverse(column);
|
|
15195
|
-
});
|
|
15196
|
-
const rows = [];
|
|
15197
|
-
for (let i = 0; i < maxLevel; i++) {
|
|
15198
|
-
rows.push([]);
|
|
15199
|
-
}
|
|
15200
|
-
const allColumns = getAllColumns(originColumns);
|
|
15201
|
-
allColumns.forEach(column => {
|
|
15202
|
-
if (!column.children) {
|
|
15203
|
-
column.rowSpan = maxLevel - column.level + 1;
|
|
15204
|
-
} else {
|
|
15205
|
-
column.rowSpan = 1;
|
|
15206
|
-
}
|
|
15207
|
-
rows[column.level - 1].push(column);
|
|
15208
|
-
});
|
|
15209
|
-
return rows;
|
|
15210
|
-
};
|
|
15211
15189
|
const TableHeader = /* @__PURE__ */ defineComponent({
|
|
15212
15190
|
name: 'vc-table-header',
|
|
15213
15191
|
props: {
|
|
@@ -15234,16 +15212,18 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15234
15212
|
isAllSelected: 'isAllSelected',
|
|
15235
15213
|
leftFixedLeafCount: 'leftFixedLeafColumnsLength',
|
|
15236
15214
|
rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
|
15215
|
+
isGroup: 'isGroup',
|
|
15216
|
+
headerRows: 'headerRows',
|
|
15237
15217
|
columnsCount: $states => $states.columns.length,
|
|
15238
15218
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15239
15219
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15240
15220
|
});
|
|
15241
|
-
const
|
|
15221
|
+
const isColumnHidden = index => {
|
|
15242
15222
|
let start = 0;
|
|
15243
15223
|
for (let i = 0; i < index; i++) {
|
|
15244
|
-
start += columns[i].colSpan;
|
|
15224
|
+
start += states.columns[i].colSpan;
|
|
15245
15225
|
}
|
|
15246
|
-
const after = start + columns[index].colSpan - 1;
|
|
15226
|
+
const after = start + states.columns[index].colSpan - 1;
|
|
15247
15227
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15248
15228
|
return after >= states.leftFixedLeafCount;
|
|
15249
15229
|
} else if (props.fixed === 'right') {
|
|
@@ -15252,6 +15232,9 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15252
15232
|
return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
|
|
15253
15233
|
}
|
|
15254
15234
|
};
|
|
15235
|
+
const columnsHidden = computed(() => {
|
|
15236
|
+
return states.columns.map((_, index) => isColumnHidden(index));
|
|
15237
|
+
});
|
|
15255
15238
|
const getHeaderRowStyle = rowIndex => {
|
|
15256
15239
|
const {
|
|
15257
15240
|
headerRowStyle
|
|
@@ -15292,8 +15275,8 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15292
15275
|
return headerCellStyle;
|
|
15293
15276
|
};
|
|
15294
15277
|
const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
|
|
15295
|
-
const classes = [column.id, column.order, column.
|
|
15296
|
-
if (rowIndex === 0 &&
|
|
15278
|
+
const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
|
|
15279
|
+
if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
|
|
15297
15280
|
classes.push('is-hidden');
|
|
15298
15281
|
}
|
|
15299
15282
|
if (!column.children) {
|
|
@@ -15433,37 +15416,27 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15433
15416
|
});
|
|
15434
15417
|
};
|
|
15435
15418
|
return () => {
|
|
15436
|
-
const {
|
|
15437
|
-
originColumns
|
|
15438
|
-
} = props.store.states;
|
|
15439
|
-
const columnRows = convertToRows(originColumns);
|
|
15440
|
-
|
|
15441
|
-
// 是否拥有多级表头
|
|
15442
|
-
const isGroup = columnRows.length > 1;
|
|
15443
|
-
if (isGroup) table.exposed.isGroup.value = true;
|
|
15444
15419
|
return createVNode("div", {
|
|
15445
15420
|
"class": "vc-table__header"
|
|
15446
15421
|
}, [createVNode("div", {
|
|
15447
15422
|
"class": [{
|
|
15448
|
-
'is-group': isGroup
|
|
15423
|
+
'is-group': states.isGroup
|
|
15449
15424
|
}, 'vc-table__thead']
|
|
15450
15425
|
}, [
|
|
15451
15426
|
// renderList
|
|
15452
|
-
|
|
15427
|
+
states.headerRows.map((columns, rowIndex) => createVNode("div", {
|
|
15453
15428
|
"style": getHeaderRowStyle(rowIndex),
|
|
15454
15429
|
"class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
|
|
15455
|
-
}, [columns.map((column,
|
|
15456
|
-
"
|
|
15457
|
-
"rowspan": column.rowSpan,
|
|
15458
|
-
"onMousemove": $event => handleMouseMove($event, column),
|
|
15430
|
+
}, [columns.map((column, columnIndex) => createVNode("div", {
|
|
15431
|
+
"onMousemove": e => handleMouseMove(e, column),
|
|
15459
15432
|
"onMouseout": handleMouseOut,
|
|
15460
|
-
"onMousedown":
|
|
15461
|
-
"onClick":
|
|
15462
|
-
"onContextmenu":
|
|
15463
|
-
"style": [getHeaderCellStyle(rowIndex,
|
|
15433
|
+
"onMousedown": e => handleMouseDown(e, column),
|
|
15434
|
+
"onClick": e => handleHeaderClick(e, column),
|
|
15435
|
+
"onContextmenu": e => handleHeaderContextMenu(e, column),
|
|
15436
|
+
"style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
|
|
15464
15437
|
width: `${column.realWidth}px`
|
|
15465
15438
|
}],
|
|
15466
|
-
"class": [getHeaderCellClass(rowIndex,
|
|
15439
|
+
"class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
|
|
15467
15440
|
"key": column.id
|
|
15468
15441
|
}, [createVNode("div", {
|
|
15469
15442
|
"class": ['vc-table__cell',
|
|
@@ -15473,10 +15446,8 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15473
15446
|
column.labelClass]
|
|
15474
15447
|
}, [column.renderHeader ? column.renderHeader({
|
|
15475
15448
|
column,
|
|
15476
|
-
|
|
15477
|
-
|
|
15478
|
-
store: props.store,
|
|
15479
|
-
_self: instance
|
|
15449
|
+
columnIndex,
|
|
15450
|
+
store: props.store
|
|
15480
15451
|
}) : column.label, column.tooltip ? createVNode(Icon, {
|
|
15481
15452
|
"type": "o-info",
|
|
15482
15453
|
"onMouseenter": e => handleCellMouseEnter(e, column)
|
|
@@ -15518,28 +15489,28 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15518
15489
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15519
15490
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15520
15491
|
});
|
|
15521
|
-
const
|
|
15492
|
+
const isColumnHidden = (column, index) => {
|
|
15522
15493
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15523
15494
|
return index >= states.leftFixedLeafCount;
|
|
15524
15495
|
} else if (props.fixed === 'right') {
|
|
15525
15496
|
let before = 0;
|
|
15526
15497
|
for (let i = 0; i < index; i++) {
|
|
15527
|
-
before += columns[i].colSpan;
|
|
15498
|
+
before += states.columns[i].colSpan;
|
|
15528
15499
|
}
|
|
15529
15500
|
return before < states.columnsCount - states.rightFixedLeafCount;
|
|
15530
15501
|
} else if (!props.fixed && column.fixed) {
|
|
15531
|
-
// hide cell when footer instance is not fixed and column is fixed
|
|
15532
15502
|
return true;
|
|
15533
15503
|
} else {
|
|
15534
15504
|
return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
|
|
15535
15505
|
}
|
|
15536
15506
|
};
|
|
15537
|
-
const
|
|
15538
|
-
|
|
15507
|
+
const columnsHidden = computed(() => states.columns.map(isColumnHidden));
|
|
15508
|
+
const getRowClasses = (column, columnIndex) => {
|
|
15509
|
+
const classes = [column.realAlign, column.labelClass];
|
|
15539
15510
|
if (column.className) {
|
|
15540
15511
|
classes.push(column.className);
|
|
15541
15512
|
}
|
|
15542
|
-
if (
|
|
15513
|
+
if (columnsHidden.value[columnIndex]) {
|
|
15543
15514
|
classes.push('is-hidden');
|
|
15544
15515
|
}
|
|
15545
15516
|
if (!column.children) {
|
|
@@ -15547,17 +15518,17 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15547
15518
|
}
|
|
15548
15519
|
return classes;
|
|
15549
15520
|
};
|
|
15550
|
-
|
|
15551
|
-
let
|
|
15521
|
+
const sums = computed(() => {
|
|
15522
|
+
let v = [];
|
|
15552
15523
|
if (props.getSummary) {
|
|
15553
|
-
|
|
15524
|
+
v = props.getSummary({
|
|
15554
15525
|
columns: states.columns,
|
|
15555
15526
|
data: states.data
|
|
15556
15527
|
});
|
|
15557
15528
|
} else {
|
|
15558
15529
|
states.columns.forEach((column, index) => {
|
|
15559
15530
|
if (index === 0) {
|
|
15560
|
-
|
|
15531
|
+
v[index] = props.sumText;
|
|
15561
15532
|
return;
|
|
15562
15533
|
}
|
|
15563
15534
|
const values = states.data.map(item => Number(item[column.prop]));
|
|
@@ -15572,7 +15543,7 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15572
15543
|
});
|
|
15573
15544
|
const precision = Math.max.apply(null, precisions);
|
|
15574
15545
|
if (!notNumber) {
|
|
15575
|
-
|
|
15546
|
+
v[index] = values.reduce((prev, curr) => {
|
|
15576
15547
|
const value = Number(curr);
|
|
15577
15548
|
if (!isNaN(value)) {
|
|
15578
15549
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -15581,10 +15552,13 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15581
15552
|
}
|
|
15582
15553
|
}, 0);
|
|
15583
15554
|
} else {
|
|
15584
|
-
|
|
15555
|
+
v[index] = '';
|
|
15585
15556
|
}
|
|
15586
15557
|
});
|
|
15587
15558
|
}
|
|
15559
|
+
return v;
|
|
15560
|
+
});
|
|
15561
|
+
return () => {
|
|
15588
15562
|
return createVNode("div", {
|
|
15589
15563
|
"class": "vc-table__footer",
|
|
15590
15564
|
"cellspacing": "0",
|
|
@@ -15594,17 +15568,15 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15594
15568
|
"class": "vc-table__tbody"
|
|
15595
15569
|
}, [createVNode("div", {
|
|
15596
15570
|
"class": "vc-table__tr"
|
|
15597
|
-
}, [states.columns.map((column,
|
|
15598
|
-
"key":
|
|
15599
|
-
"
|
|
15600
|
-
"rowspan": column.rowSpan,
|
|
15601
|
-
"class": [getRowClasses(column, cellIndex), 'vc-table__td'],
|
|
15571
|
+
}, [states.columns.map((column, columnIndex) => createVNode("div", {
|
|
15572
|
+
"key": columnIndex,
|
|
15573
|
+
"class": [getRowClasses(column, columnIndex), 'vc-table__td'],
|
|
15602
15574
|
"style": [{
|
|
15603
15575
|
width: `${column.realWidth}px`
|
|
15604
15576
|
}]
|
|
15605
15577
|
}, [createVNode("div", {
|
|
15606
15578
|
"class": ['vc-table__cell', column.labelClass]
|
|
15607
|
-
}, [sums[
|
|
15579
|
+
}, [sums.value[columnIndex]])]))])])]);
|
|
15608
15580
|
};
|
|
15609
15581
|
}
|
|
15610
15582
|
});
|
|
@@ -15632,7 +15604,7 @@ const props$c = {
|
|
|
15632
15604
|
type: Number,
|
|
15633
15605
|
default: 10
|
|
15634
15606
|
},
|
|
15635
|
-
|
|
15607
|
+
primaryKey: [String, Function],
|
|
15636
15608
|
// 是否显示表头
|
|
15637
15609
|
showHeader: {
|
|
15638
15610
|
type: Boolean,
|
|
@@ -15749,23 +15721,21 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
15749
15721
|
const rightFixedBody = ref(null);
|
|
15750
15722
|
const rightFixedFooterWrapper = ref(null);
|
|
15751
15723
|
const resizeProxy = ref(null);
|
|
15752
|
-
|
|
15753
|
-
// 是否拥有多级表头, 由table-header控制
|
|
15754
|
-
const isGroup = ref(false);
|
|
15755
15724
|
const scrollPosition = ref('left');
|
|
15756
15725
|
const hoverState = ref(null);
|
|
15757
15726
|
const isReady = ref(false);
|
|
15758
15727
|
const states = useStates({
|
|
15759
15728
|
columns: 'columns',
|
|
15760
15729
|
leftFixedColumns: 'leftFixedColumns',
|
|
15761
|
-
rightFixedColumns: 'rightFixedColumns'
|
|
15730
|
+
rightFixedColumns: 'rightFixedColumns',
|
|
15731
|
+
isGroup: 'isGroup'
|
|
15762
15732
|
}, store);
|
|
15763
15733
|
const classes = computed(() => {
|
|
15764
15734
|
return {
|
|
15765
15735
|
'vc-table--fit': props.fit,
|
|
15766
15736
|
'vc-table--striped': props.stripe,
|
|
15767
|
-
'vc-table--border': props.border || isGroup
|
|
15768
|
-
'vc-table--group': isGroup
|
|
15737
|
+
'vc-table--border': props.border || states.isGroup,
|
|
15738
|
+
'vc-table--group': states.isGroup,
|
|
15769
15739
|
'vc-table--fluid-height': props.maxHeight,
|
|
15770
15740
|
'vc-table--scrollable-x': layout.states.scrollX,
|
|
15771
15741
|
'vc-table--scrollable-y': layout.states.scrollY,
|
|
@@ -16026,7 +15996,7 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16026
15996
|
immediate: true
|
|
16027
15997
|
});
|
|
16028
15998
|
watch(() => props.currentRowValue, v => {
|
|
16029
|
-
if (!props.
|
|
15999
|
+
if (!props.primaryKey) return;
|
|
16030
16000
|
store.current.reset(v);
|
|
16031
16001
|
}, {
|
|
16032
16002
|
immediate: true
|
|
@@ -16055,6 +16025,7 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16055
16025
|
}, {
|
|
16056
16026
|
immediate: true
|
|
16057
16027
|
});
|
|
16028
|
+
const tableId = getUid('table');
|
|
16058
16029
|
onMounted(() => {
|
|
16059
16030
|
bindEvents();
|
|
16060
16031
|
store.updateColumns();
|
|
@@ -16065,12 +16036,13 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16065
16036
|
};
|
|
16066
16037
|
isReady.value = true;
|
|
16067
16038
|
});
|
|
16068
|
-
|
|
16039
|
+
onUnmounted(() => {
|
|
16069
16040
|
isUnMount = true;
|
|
16070
16041
|
unbindEvents();
|
|
16071
16042
|
});
|
|
16072
|
-
const tableId = getUid('table');
|
|
16073
16043
|
expose({
|
|
16044
|
+
bodyXWrapper,
|
|
16045
|
+
bodyYWrapper,
|
|
16074
16046
|
tableId,
|
|
16075
16047
|
store,
|
|
16076
16048
|
layout,
|
|
@@ -16240,22 +16212,19 @@ const cellStarts = {
|
|
|
16240
16212
|
order: ''
|
|
16241
16213
|
},
|
|
16242
16214
|
selection: {
|
|
16243
|
-
width:
|
|
16244
|
-
minWidth:
|
|
16245
|
-
realWidth: 48,
|
|
16215
|
+
width: 60,
|
|
16216
|
+
minWidth: 60,
|
|
16246
16217
|
order: '',
|
|
16247
16218
|
className: 'vc-table-column--selection'
|
|
16248
16219
|
},
|
|
16249
16220
|
expand: {
|
|
16250
|
-
width:
|
|
16251
|
-
minWidth:
|
|
16252
|
-
realWidth: 48,
|
|
16221
|
+
width: 60,
|
|
16222
|
+
minWidth: 60,
|
|
16253
16223
|
order: ''
|
|
16254
16224
|
},
|
|
16255
16225
|
index: {
|
|
16256
|
-
width:
|
|
16257
|
-
minWidth:
|
|
16258
|
-
realWidth: 48,
|
|
16226
|
+
width: 60,
|
|
16227
|
+
minWidth: 60,
|
|
16259
16228
|
order: ''
|
|
16260
16229
|
}
|
|
16261
16230
|
};
|
|
@@ -16422,8 +16391,8 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16422
16391
|
customClass: String,
|
|
16423
16392
|
labelClass: String,
|
|
16424
16393
|
prop: String,
|
|
16425
|
-
width:
|
|
16426
|
-
minWidth:
|
|
16394
|
+
width: Number,
|
|
16395
|
+
minWidth: Number,
|
|
16427
16396
|
renderHeader: Function,
|
|
16428
16397
|
resizable: {
|
|
16429
16398
|
type: Boolean,
|
|
@@ -16495,7 +16464,6 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16495
16464
|
}, {});
|
|
16496
16465
|
return result;
|
|
16497
16466
|
};
|
|
16498
|
-
|
|
16499
16467
|
/**
|
|
16500
16468
|
* compose 1
|
|
16501
16469
|
* 对于特定类型的 column,某些属性不允许设置
|
|
@@ -16604,26 +16572,16 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16604
16572
|
}
|
|
16605
16573
|
return column;
|
|
16606
16574
|
};
|
|
16607
|
-
const
|
|
16575
|
+
const registerColumn = () => {
|
|
16608
16576
|
const defaults = {
|
|
16609
16577
|
...cellStarts[props.type],
|
|
16610
|
-
type: props.type,
|
|
16611
16578
|
id: columnId.value,
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
prop: props.prop,
|
|
16615
|
-
showPopover: props.showPopover,
|
|
16616
|
-
// index 列
|
|
16617
|
-
index: props.index
|
|
16579
|
+
realAlign,
|
|
16580
|
+
realHeaderAlign
|
|
16618
16581
|
};
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
const filterProps = ['filters', 'filteredValue', 'filterMultiple', 'filter', 'filterIcon', 'filterPopupClass'];
|
|
16623
|
-
let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
|
|
16624
|
-
column = merge$1(defaults, column);
|
|
16625
|
-
|
|
16626
|
-
// 注意 compose 中函数执行的顺序是从右到左
|
|
16582
|
+
let column = merge$1(defaults, getPropsData(Object.keys(props)));
|
|
16583
|
+
|
|
16584
|
+
// minWidth/realWidth/renderHeader
|
|
16627
16585
|
column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
|
|
16628
16586
|
for (const key in column) {
|
|
16629
16587
|
if (hasOwn(column, key)) {
|
|
@@ -16631,11 +16589,17 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16631
16589
|
}
|
|
16632
16590
|
}
|
|
16633
16591
|
};
|
|
16634
|
-
const
|
|
16592
|
+
const registerWatchers = () => {
|
|
16593
|
+
// 赋值
|
|
16594
|
+
Object.keys(props).forEach(k => watch(() => props[k], v => columnConfig[k] = v));
|
|
16595
|
+
|
|
16596
|
+
// 影响布局
|
|
16635
16597
|
watch(() => props.fixed, () => {
|
|
16636
16598
|
table.exposed.store.scheduleLayout(true);
|
|
16637
16599
|
});
|
|
16638
|
-
watch(() => realWidth.value,
|
|
16600
|
+
watch(() => realWidth.value, v => {
|
|
16601
|
+
columnConfig['width'] = v;
|
|
16602
|
+
columnConfig['realWidth'] = v;
|
|
16639
16603
|
table.exposed.store.scheduleLayout(false);
|
|
16640
16604
|
});
|
|
16641
16605
|
watch(() => realMinWidth.value, () => {
|
|
@@ -16643,10 +16607,9 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16643
16607
|
});
|
|
16644
16608
|
};
|
|
16645
16609
|
onBeforeMount(() => {
|
|
16646
|
-
|
|
16647
|
-
|
|
16610
|
+
registerColumn();
|
|
16611
|
+
registerWatchers();
|
|
16648
16612
|
});
|
|
16649
|
-
onUpdated(refreshColumnBasicConfig);
|
|
16650
16613
|
onMounted(() => {
|
|
16651
16614
|
const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
|
|
16652
16615
|
|
|
@@ -16674,7 +16637,8 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16674
16637
|
const renderDefault = slots?.default?.({
|
|
16675
16638
|
row: {},
|
|
16676
16639
|
column: {},
|
|
16677
|
-
|
|
16640
|
+
columnIndex: -1,
|
|
16641
|
+
rowIndex: -1
|
|
16678
16642
|
});
|
|
16679
16643
|
if (renderDefault instanceof Array) {
|
|
16680
16644
|
for (const childNode of renderDefault) {
|