@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.js
CHANGED
|
@@ -772,7 +772,7 @@ const COMPONENT_NAME$1T = 'vc-alert';
|
|
|
772
772
|
|
|
773
773
|
// [color, borderColor, backgroundColor], -> CSS
|
|
774
774
|
const THEME_MAP = {
|
|
775
|
-
info: ['#
|
|
775
|
+
info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
|
|
776
776
|
success: ['#52c41a', '#b7eb8f', '#f6ffed'],
|
|
777
777
|
error: ['#ed4014', '#ffb08f', '#fbe9e9'],
|
|
778
778
|
warning: ['#ffbf00', '#ffe58f', '#fffbe6']
|
|
@@ -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);
|
|
@@ -12121,7 +12122,7 @@ const props$m = {
|
|
|
12121
12122
|
color: {
|
|
12122
12123
|
type: [Object, String],
|
|
12123
12124
|
default: () => ({
|
|
12124
|
-
normal: "#
|
|
12125
|
+
normal: "#2B72FD",
|
|
12125
12126
|
success: "#52c41a",
|
|
12126
12127
|
error: "#f5222d"
|
|
12127
12128
|
})
|
|
@@ -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;
|
|
@@ -13359,6 +13362,8 @@ const RecycleList = /* @__PURE__ */ defineComponent({
|
|
|
13359
13362
|
});
|
|
13360
13363
|
if (!originalData.length) {
|
|
13361
13364
|
rebuildData.value = [];
|
|
13365
|
+
} else {
|
|
13366
|
+
rebuildData.value = originalData.slice();
|
|
13362
13367
|
}
|
|
13363
13368
|
offsetPageSize.value = 0;
|
|
13364
13369
|
await refreshLayout(0, originalData.length);
|
|
@@ -13763,88 +13768,65 @@ const MSwitch = /* @__PURE__ */ defineComponent({
|
|
|
13763
13768
|
}
|
|
13764
13769
|
});
|
|
13765
13770
|
|
|
13766
|
-
const parseHeight = (
|
|
13767
|
-
if (typeof
|
|
13768
|
-
return
|
|
13771
|
+
const parseHeight = (v) => {
|
|
13772
|
+
if (typeof v === "number") {
|
|
13773
|
+
return v;
|
|
13769
13774
|
}
|
|
13770
|
-
if (
|
|
13771
|
-
if (/^\d+(?:px)?/.test(
|
|
13772
|
-
return parseInt(
|
|
13775
|
+
if (v && typeof v === "string") {
|
|
13776
|
+
if (/^\d+(?:px)?/.test(v)) {
|
|
13777
|
+
return parseInt(v, 10);
|
|
13773
13778
|
}
|
|
13774
13779
|
throw new VcError("table", "Invalid Height");
|
|
13775
13780
|
}
|
|
13776
13781
|
return null;
|
|
13777
13782
|
};
|
|
13778
|
-
const parseWidth = (
|
|
13779
|
-
if (
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
+
const parseWidth = (v) => {
|
|
13784
|
+
if (typeof v === "number") {
|
|
13785
|
+
return v;
|
|
13786
|
+
}
|
|
13787
|
+
let v1;
|
|
13788
|
+
if (typeof v !== "undefined") {
|
|
13789
|
+
v1 = parseInt(v, 10);
|
|
13790
|
+
if (isNaN(v1)) {
|
|
13791
|
+
v1 = null;
|
|
13783
13792
|
}
|
|
13784
13793
|
}
|
|
13785
|
-
return
|
|
13794
|
+
return v1;
|
|
13786
13795
|
};
|
|
13787
|
-
const parseMinWidth = (
|
|
13788
|
-
if (typeof
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13796
|
+
const parseMinWidth = (v) => {
|
|
13797
|
+
if (typeof v === "number") {
|
|
13798
|
+
return v;
|
|
13799
|
+
}
|
|
13800
|
+
let v1;
|
|
13801
|
+
if (typeof v !== "undefined") {
|
|
13802
|
+
v1 = parseWidth(v);
|
|
13803
|
+
if (isNaN(v1)) {
|
|
13804
|
+
v = 80;
|
|
13792
13805
|
}
|
|
13793
13806
|
}
|
|
13794
|
-
return
|
|
13807
|
+
return v1;
|
|
13795
13808
|
};
|
|
13796
|
-
const
|
|
13809
|
+
const getRowValue = (row, primaryKey) => {
|
|
13797
13810
|
if (row.__KEY__) return row.__KEY__;
|
|
13798
13811
|
if (!row) throw new VcError("table", "row is required when get row identity");
|
|
13799
|
-
if (typeof
|
|
13800
|
-
if (!
|
|
13801
|
-
return row[
|
|
13812
|
+
if (typeof primaryKey === "string") {
|
|
13813
|
+
if (!primaryKey.includes(".")) {
|
|
13814
|
+
return row[primaryKey];
|
|
13802
13815
|
}
|
|
13803
|
-
const key =
|
|
13816
|
+
const key = primaryKey.split(".");
|
|
13804
13817
|
let current = row;
|
|
13805
13818
|
for (let i = 0; i < key.length; i++) {
|
|
13806
13819
|
current = current[key[i]];
|
|
13807
13820
|
}
|
|
13808
13821
|
return current;
|
|
13809
|
-
} else if (typeof
|
|
13810
|
-
return
|
|
13811
|
-
}
|
|
13812
|
-
};
|
|
13813
|
-
const walkTreeNode = (root, cb, opts = {}) => {
|
|
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
|
-
});
|
|
13822
|
+
} else if (typeof primaryKey === "function") {
|
|
13823
|
+
return primaryKey.call(null, row);
|
|
13832
13824
|
}
|
|
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
13825
|
};
|
|
13844
|
-
const
|
|
13826
|
+
const getValuesMap = (array = [], primaryKey) => {
|
|
13845
13827
|
const arrayMap = {};
|
|
13846
13828
|
array.forEach((row, index) => {
|
|
13847
|
-
arrayMap[
|
|
13829
|
+
arrayMap[getRowValue(row, primaryKey)] = { row, index };
|
|
13848
13830
|
});
|
|
13849
13831
|
return arrayMap;
|
|
13850
13832
|
};
|
|
@@ -13857,23 +13839,75 @@ const getColumnById = (columns, columnId) => {
|
|
|
13857
13839
|
});
|
|
13858
13840
|
return column;
|
|
13859
13841
|
};
|
|
13860
|
-
const getColumnByCell = (
|
|
13842
|
+
const getColumnByCell = (columns, cell) => {
|
|
13861
13843
|
const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
|
|
13862
13844
|
if (matches) {
|
|
13863
|
-
return getColumnById(
|
|
13845
|
+
return getColumnById(columns, matches[0]);
|
|
13864
13846
|
}
|
|
13865
13847
|
return null;
|
|
13866
13848
|
};
|
|
13867
|
-
const getCell = (
|
|
13868
|
-
let cell =
|
|
13849
|
+
const getCell = (e) => {
|
|
13850
|
+
let cell = e.target;
|
|
13869
13851
|
while (cell && cell.tagName.toUpperCase() !== "HTML") {
|
|
13870
|
-
if (cell.
|
|
13852
|
+
if (cell.classList.contains("vc-table__td")) {
|
|
13871
13853
|
return cell;
|
|
13872
13854
|
}
|
|
13873
13855
|
cell = cell.parentNode;
|
|
13874
13856
|
}
|
|
13875
13857
|
return null;
|
|
13876
13858
|
};
|
|
13859
|
+
|
|
13860
|
+
const getAllColumns = (columns) => {
|
|
13861
|
+
const result = [];
|
|
13862
|
+
columns.forEach((column) => {
|
|
13863
|
+
if (column.children) {
|
|
13864
|
+
result.push(column);
|
|
13865
|
+
result.push(...getAllColumns(column.children));
|
|
13866
|
+
} else {
|
|
13867
|
+
result.push(column);
|
|
13868
|
+
}
|
|
13869
|
+
});
|
|
13870
|
+
return result;
|
|
13871
|
+
};
|
|
13872
|
+
const columnsToRowsEffect = (v) => {
|
|
13873
|
+
let maxLevel = 1;
|
|
13874
|
+
const traverse = (column, parent) => {
|
|
13875
|
+
if (parent) {
|
|
13876
|
+
column.level = parent.level + 1;
|
|
13877
|
+
if (maxLevel < column.level) {
|
|
13878
|
+
maxLevel = column.level;
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
if (column.children) {
|
|
13882
|
+
let colSpan = 0;
|
|
13883
|
+
column.children.forEach((subColumn) => {
|
|
13884
|
+
traverse(subColumn, column);
|
|
13885
|
+
colSpan += subColumn.colSpan;
|
|
13886
|
+
});
|
|
13887
|
+
column.colSpan = colSpan;
|
|
13888
|
+
} else {
|
|
13889
|
+
column.colSpan = 1;
|
|
13890
|
+
}
|
|
13891
|
+
};
|
|
13892
|
+
v.forEach((column) => {
|
|
13893
|
+
column.level = 1;
|
|
13894
|
+
traverse(column);
|
|
13895
|
+
});
|
|
13896
|
+
const rows = [];
|
|
13897
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
13898
|
+
rows.push([]);
|
|
13899
|
+
}
|
|
13900
|
+
const allColumns = getAllColumns(v);
|
|
13901
|
+
allColumns.forEach((column) => {
|
|
13902
|
+
if (!column.children) {
|
|
13903
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
13904
|
+
} else {
|
|
13905
|
+
column.rowSpan = 1;
|
|
13906
|
+
}
|
|
13907
|
+
rows[column.level - 1].push(column);
|
|
13908
|
+
});
|
|
13909
|
+
return rows;
|
|
13910
|
+
};
|
|
13877
13911
|
const flattenData = (data, opts = {}) => {
|
|
13878
13912
|
const result = [];
|
|
13879
13913
|
data.forEach((item) => {
|
|
@@ -13886,6 +13920,37 @@ const flattenData = (data, opts = {}) => {
|
|
|
13886
13920
|
});
|
|
13887
13921
|
return result;
|
|
13888
13922
|
};
|
|
13923
|
+
const walkTreeNode = (root, cb, opts = {}) => {
|
|
13924
|
+
const {
|
|
13925
|
+
childrenKey = "children",
|
|
13926
|
+
lazyKey = "hasChildren",
|
|
13927
|
+
level: baseLevel = 0
|
|
13928
|
+
} = opts;
|
|
13929
|
+
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
13930
|
+
function _walker(parent, children, level) {
|
|
13931
|
+
cb(parent, children, level);
|
|
13932
|
+
children.forEach((item) => {
|
|
13933
|
+
if (item[lazyKey]) {
|
|
13934
|
+
cb(item, null, level + 1);
|
|
13935
|
+
return;
|
|
13936
|
+
}
|
|
13937
|
+
const $children = item[childrenKey];
|
|
13938
|
+
if (!isNil($children)) {
|
|
13939
|
+
_walker(item, $children, level + 1);
|
|
13940
|
+
}
|
|
13941
|
+
});
|
|
13942
|
+
}
|
|
13943
|
+
root.forEach((item) => {
|
|
13944
|
+
if (item[lazyKey]) {
|
|
13945
|
+
cb(item, null, baseLevel);
|
|
13946
|
+
return;
|
|
13947
|
+
}
|
|
13948
|
+
const children = item[childrenKey];
|
|
13949
|
+
if (!isNil(children)) {
|
|
13950
|
+
_walker(item, children, baseLevel);
|
|
13951
|
+
}
|
|
13952
|
+
});
|
|
13953
|
+
};
|
|
13889
13954
|
|
|
13890
13955
|
class BaseWatcher {
|
|
13891
13956
|
states = reactive({
|
|
@@ -13893,23 +13958,14 @@ class BaseWatcher {
|
|
|
13893
13958
|
_data: [],
|
|
13894
13959
|
data: [],
|
|
13895
13960
|
list: [],
|
|
13896
|
-
//
|
|
13897
|
-
|
|
13898
|
-
// 列
|
|
13961
|
+
// 表头数据
|
|
13962
|
+
headerRows: [],
|
|
13963
|
+
// 列 动态收集vc-table-column中的columnConfig
|
|
13899
13964
|
_columns: [],
|
|
13900
|
-
// 动态收集vc-table-column中的columnConfig
|
|
13901
13965
|
originColumns: [],
|
|
13902
|
-
|
|
13903
|
-
columns: [],
|
|
13904
|
-
// 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
|
|
13966
|
+
notFixedColumns: [],
|
|
13905
13967
|
leftFixedColumns: [],
|
|
13906
13968
|
rightFixedColumns: [],
|
|
13907
|
-
leafColumns: [],
|
|
13908
|
-
leftFixedLeafColumns: [],
|
|
13909
|
-
rightFixedLeafColumns: [],
|
|
13910
|
-
leafColumnsLength: 0,
|
|
13911
|
-
leftFixedLeafColumnsLength: 0,
|
|
13912
|
-
rightFixedLeafColumnsLength: 0,
|
|
13913
13969
|
// 选择
|
|
13914
13970
|
isAllSelected: false,
|
|
13915
13971
|
selection: [],
|
|
@@ -13931,7 +13987,17 @@ class BaseWatcher {
|
|
|
13931
13987
|
treeLazyData: [],
|
|
13932
13988
|
// 源数据展开
|
|
13933
13989
|
treeLazyColumnIdentifier: "hasChildren",
|
|
13934
|
-
treeChildrenColumnName: "children"
|
|
13990
|
+
treeChildrenColumnName: "children",
|
|
13991
|
+
// compputeds
|
|
13992
|
+
isComplex: computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
|
|
13993
|
+
isGroup: computed(() => this.states.columns.length > this.states.originColumns.length),
|
|
13994
|
+
columns: computed(() => concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
|
|
13995
|
+
leafColumns: computed(() => flattenData(this.states.notFixedColumns)),
|
|
13996
|
+
leftFixedLeafColumns: computed(() => flattenData(this.states.leftFixedColumns)),
|
|
13997
|
+
rightFixedLeafColumns: computed(() => flattenData(this.states.rightFixedColumns)),
|
|
13998
|
+
leafColumnsLength: computed(() => this.states.leafColumns.length),
|
|
13999
|
+
leftFixedLeafColumnsLength: computed(() => this.states.leftFixedLeafColumns.length),
|
|
14000
|
+
rightFixedLeafColumnsLength: computed(() => this.states.rightFixedLeafColumns.length)
|
|
13935
14001
|
});
|
|
13936
14002
|
}
|
|
13937
14003
|
|
|
@@ -13942,14 +14008,14 @@ class Expand {
|
|
|
13942
14008
|
}
|
|
13943
14009
|
update() {
|
|
13944
14010
|
const store = this.store;
|
|
13945
|
-
const {
|
|
14011
|
+
const { primaryKey, defaultExpandAll } = this.store.table.props;
|
|
13946
14012
|
const { data = [], expandRows } = store.states;
|
|
13947
14013
|
if (defaultExpandAll) {
|
|
13948
14014
|
store.states.expandRows = data.slice();
|
|
13949
|
-
} else if (
|
|
13950
|
-
const expandRowsMap =
|
|
14015
|
+
} else if (primaryKey) {
|
|
14016
|
+
const expandRowsMap = getValuesMap(expandRows, primaryKey);
|
|
13951
14017
|
store.states.expandRows = data.reduce((prev, row) => {
|
|
13952
|
-
const rowId =
|
|
14018
|
+
const rowId = getRowValue(row, primaryKey);
|
|
13953
14019
|
const rowInfo = expandRowsMap[rowId];
|
|
13954
14020
|
if (rowInfo) {
|
|
13955
14021
|
prev.push(row);
|
|
@@ -13971,10 +14037,10 @@ class Expand {
|
|
|
13971
14037
|
}
|
|
13972
14038
|
reset(ids) {
|
|
13973
14039
|
const store = this.store;
|
|
13974
|
-
store.
|
|
13975
|
-
const {
|
|
14040
|
+
store.checkPrimaryKey();
|
|
14041
|
+
const { primaryKey } = store.table.props;
|
|
13976
14042
|
const { data } = store.states;
|
|
13977
|
-
const keysMap =
|
|
14043
|
+
const keysMap = getValuesMap(data, primaryKey);
|
|
13978
14044
|
store.states.expandRows = ids.reduce((prev, cur) => {
|
|
13979
14045
|
const info = keysMap[cur];
|
|
13980
14046
|
if (info) {
|
|
@@ -13984,11 +14050,11 @@ class Expand {
|
|
|
13984
14050
|
}, []);
|
|
13985
14051
|
}
|
|
13986
14052
|
isExpanded(row) {
|
|
13987
|
-
const {
|
|
14053
|
+
const { primaryKey } = this.store.table.props;
|
|
13988
14054
|
const { expandRows = [] } = this.store.states;
|
|
13989
|
-
if (
|
|
13990
|
-
const expandMap =
|
|
13991
|
-
return !!expandMap[
|
|
14055
|
+
if (primaryKey) {
|
|
14056
|
+
const expandMap = getValuesMap(expandRows, primaryKey);
|
|
14057
|
+
return !!expandMap[getRowValue(row, primaryKey)];
|
|
13992
14058
|
}
|
|
13993
14059
|
return expandRows.indexOf(row) !== -1;
|
|
13994
14060
|
}
|
|
@@ -14001,22 +14067,22 @@ class Current {
|
|
|
14001
14067
|
}
|
|
14002
14068
|
reset(id) {
|
|
14003
14069
|
const store = this.store;
|
|
14004
|
-
const {
|
|
14005
|
-
store.
|
|
14070
|
+
const { primaryKey } = store.table.props;
|
|
14071
|
+
store.checkPrimaryKey();
|
|
14006
14072
|
const { data = [] } = store.states;
|
|
14007
|
-
const currentRow = data.find((item) =>
|
|
14073
|
+
const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
|
|
14008
14074
|
store.states.currentRow = currentRow || null;
|
|
14009
14075
|
}
|
|
14010
14076
|
update() {
|
|
14011
14077
|
const store = this.store;
|
|
14012
|
-
const {
|
|
14078
|
+
const { primaryKey } = store.table.props;
|
|
14013
14079
|
const { data = [], currentRow } = store.states;
|
|
14014
14080
|
const oldCurrentRow = currentRow;
|
|
14015
14081
|
if (oldCurrentRow && !data.includes(oldCurrentRow)) {
|
|
14016
14082
|
let newCurrentRow = null;
|
|
14017
|
-
if (
|
|
14083
|
+
if (primaryKey) {
|
|
14018
14084
|
newCurrentRow = data.find((item) => {
|
|
14019
|
-
return
|
|
14085
|
+
return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
|
|
14020
14086
|
});
|
|
14021
14087
|
}
|
|
14022
14088
|
store.states.currentRow = newCurrentRow;
|
|
@@ -14035,8 +14101,8 @@ let Tree$1 = class Tree {
|
|
|
14035
14101
|
* { id: { level, children } }
|
|
14036
14102
|
*/
|
|
14037
14103
|
normalizedData = computed(() => {
|
|
14038
|
-
const {
|
|
14039
|
-
if (!
|
|
14104
|
+
const { primaryKey } = this.store.table.props;
|
|
14105
|
+
if (!primaryKey) return {};
|
|
14040
14106
|
return this.normalize(this.store.states.data || []);
|
|
14041
14107
|
});
|
|
14042
14108
|
/**
|
|
@@ -14044,7 +14110,7 @@ let Tree$1 = class Tree {
|
|
|
14044
14110
|
* { id: { children } }
|
|
14045
14111
|
*/
|
|
14046
14112
|
normalizedLazyNode = computed(() => {
|
|
14047
|
-
const {
|
|
14113
|
+
const { primaryKey } = this.store.table.props;
|
|
14048
14114
|
const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
|
|
14049
14115
|
const keys = Object.keys(treelazyNodeMap);
|
|
14050
14116
|
const res = {};
|
|
@@ -14053,7 +14119,7 @@ let Tree$1 = class Tree {
|
|
|
14053
14119
|
if (treelazyNodeMap[key].length) {
|
|
14054
14120
|
const item = { children: [] };
|
|
14055
14121
|
treelazyNodeMap[key].forEach((row) => {
|
|
14056
|
-
const id =
|
|
14122
|
+
const id = getRowValue(row, primaryKey);
|
|
14057
14123
|
item.children.push(id);
|
|
14058
14124
|
const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
|
|
14059
14125
|
if (hasChildren && !res[id]) {
|
|
@@ -14073,16 +14139,16 @@ let Tree$1 = class Tree {
|
|
|
14073
14139
|
);
|
|
14074
14140
|
}
|
|
14075
14141
|
normalize(data) {
|
|
14076
|
-
const {
|
|
14142
|
+
const { primaryKey } = this.store.table.props;
|
|
14077
14143
|
const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
|
|
14078
14144
|
const res = {};
|
|
14079
14145
|
walkTreeNode(
|
|
14080
14146
|
data,
|
|
14081
14147
|
(parent, children, level) => {
|
|
14082
|
-
const parentId =
|
|
14148
|
+
const parentId = getRowValue(parent, primaryKey);
|
|
14083
14149
|
if (Array.isArray(children)) {
|
|
14084
14150
|
res[parentId] = {
|
|
14085
|
-
children: children.map((row) =>
|
|
14151
|
+
children: children.map((row) => getRowValue(row, primaryKey)),
|
|
14086
14152
|
level
|
|
14087
14153
|
};
|
|
14088
14154
|
} else if (treeLazy) {
|
|
@@ -14102,7 +14168,7 @@ let Tree$1 = class Tree {
|
|
|
14102
14168
|
}
|
|
14103
14169
|
// 获取当前展开最大的level
|
|
14104
14170
|
getMaxLevel() {
|
|
14105
|
-
const {
|
|
14171
|
+
const { primaryKey } = this.store.table.props;
|
|
14106
14172
|
const { data, treeData } = this.store.states;
|
|
14107
14173
|
const levels = data.map((item) => {
|
|
14108
14174
|
const traverse = (source) => {
|
|
@@ -14113,7 +14179,7 @@ let Tree$1 = class Tree {
|
|
|
14113
14179
|
return source.level;
|
|
14114
14180
|
}
|
|
14115
14181
|
};
|
|
14116
|
-
const id =
|
|
14182
|
+
const id = getRowValue(item, primaryKey);
|
|
14117
14183
|
return traverse(treeData[id]);
|
|
14118
14184
|
});
|
|
14119
14185
|
return max(levels) || 0;
|
|
@@ -14175,10 +14241,10 @@ let Tree$1 = class Tree {
|
|
|
14175
14241
|
this.update();
|
|
14176
14242
|
}
|
|
14177
14243
|
toggle(row, expanded) {
|
|
14178
|
-
this.store.
|
|
14179
|
-
const {
|
|
14244
|
+
this.store.checkPrimaryKey();
|
|
14245
|
+
const { primaryKey } = this.store.table.props;
|
|
14180
14246
|
const { treeData } = this.store.states;
|
|
14181
|
-
const id =
|
|
14247
|
+
const id = getRowValue(row, primaryKey);
|
|
14182
14248
|
const data = id && treeData[id];
|
|
14183
14249
|
if (id && data && "expanded" in data) {
|
|
14184
14250
|
const oldExpanded = data.expanded;
|
|
@@ -14191,10 +14257,10 @@ let Tree$1 = class Tree {
|
|
|
14191
14257
|
}
|
|
14192
14258
|
}
|
|
14193
14259
|
loadOrToggle(row) {
|
|
14194
|
-
this.store.
|
|
14195
|
-
const {
|
|
14260
|
+
this.store.checkPrimaryKey();
|
|
14261
|
+
const { primaryKey } = this.store.table.props;
|
|
14196
14262
|
const { treeLazy, treeData } = this.store.states;
|
|
14197
|
-
const id =
|
|
14263
|
+
const id = getRowValue(row, primaryKey);
|
|
14198
14264
|
const data = treeData[id];
|
|
14199
14265
|
if (treeLazy && data && "loaded" in data && !data.loaded) {
|
|
14200
14266
|
this.loadData(row, id, data);
|
|
@@ -14203,9 +14269,9 @@ let Tree$1 = class Tree {
|
|
|
14203
14269
|
}
|
|
14204
14270
|
}
|
|
14205
14271
|
loadData(row, key, treeNode) {
|
|
14206
|
-
this.store.
|
|
14272
|
+
this.store.checkPrimaryKey();
|
|
14207
14273
|
const { table } = this.store;
|
|
14208
|
-
const {
|
|
14274
|
+
const { primaryKey } = table.props;
|
|
14209
14275
|
const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
|
|
14210
14276
|
if (table.props.loadExpand && !treeData[key].loaded) {
|
|
14211
14277
|
this.store.states.treeData[key].loading = true;
|
|
@@ -14220,7 +14286,7 @@ let Tree$1 = class Tree {
|
|
|
14220
14286
|
walkTreeNode(
|
|
14221
14287
|
data,
|
|
14222
14288
|
(parent, _, level) => {
|
|
14223
|
-
const id =
|
|
14289
|
+
const id = getRowValue(parent, primaryKey);
|
|
14224
14290
|
Object.defineProperty(parent, "__KEY__", {
|
|
14225
14291
|
value: `${level}__${id}`,
|
|
14226
14292
|
writable: false
|
|
@@ -14290,27 +14356,13 @@ class Layout {
|
|
|
14290
14356
|
if (!this.store) {
|
|
14291
14357
|
throw new VcError("table", "Table Layout 必须包含store实例");
|
|
14292
14358
|
}
|
|
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
14359
|
}
|
|
14307
14360
|
updateScrollY() {
|
|
14308
14361
|
const { height, bodyHeight } = this.states;
|
|
14309
14362
|
if (height === null || bodyHeight === null) return;
|
|
14310
|
-
const
|
|
14311
|
-
if (this.table.vnode.el &&
|
|
14312
|
-
|
|
14313
|
-
this.states.scrollY = body.offsetHeight > bodyHeight;
|
|
14363
|
+
const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
|
|
14364
|
+
if (this.table.vnode.el && bodyYWrapper) {
|
|
14365
|
+
this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
|
|
14314
14366
|
}
|
|
14315
14367
|
}
|
|
14316
14368
|
setHeight(value, prop = "height") {
|
|
@@ -14327,18 +14379,6 @@ class Layout {
|
|
|
14327
14379
|
setMaxHeight(value) {
|
|
14328
14380
|
this.setHeight(value, "max-height");
|
|
14329
14381
|
}
|
|
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
14382
|
updateElsHeight() {
|
|
14343
14383
|
if (!this.table.exposed.isReady.value) return nextTick(() => this.updateElsHeight());
|
|
14344
14384
|
const table = this.table.exposed;
|
|
@@ -14361,13 +14401,12 @@ class Layout {
|
|
|
14361
14401
|
this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
|
14362
14402
|
}
|
|
14363
14403
|
this.updateScrollY();
|
|
14364
|
-
this.updateScroller();
|
|
14365
14404
|
}
|
|
14366
14405
|
updateColumnsWidth() {
|
|
14367
14406
|
if (IS_SERVER$1) return;
|
|
14368
14407
|
const bodyWidth = this.table.vnode.el.clientWidth;
|
|
14369
14408
|
let bodyMinWidth = 0;
|
|
14370
|
-
const flattenColumns = this.
|
|
14409
|
+
const flattenColumns = this.store.states.columns;
|
|
14371
14410
|
const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
|
|
14372
14411
|
const { fit } = this.table.props;
|
|
14373
14412
|
if (flexColumns.length > 0 && fit) {
|
|
@@ -14393,7 +14432,7 @@ class Layout {
|
|
|
14393
14432
|
}
|
|
14394
14433
|
} else {
|
|
14395
14434
|
this.states.scrollX = true;
|
|
14396
|
-
flexColumns.forEach(
|
|
14435
|
+
flexColumns.forEach((column) => {
|
|
14397
14436
|
column.realWidth = column.width || column.minWidth;
|
|
14398
14437
|
});
|
|
14399
14438
|
}
|
|
@@ -14427,12 +14466,6 @@ class Layout {
|
|
|
14427
14466
|
});
|
|
14428
14467
|
this.states.rightFixedWidth = rightFixedWidth;
|
|
14429
14468
|
}
|
|
14430
|
-
this.updateColumns();
|
|
14431
|
-
}
|
|
14432
|
-
// v2.x中的 notifyObservers
|
|
14433
|
-
updateColumns() {
|
|
14434
|
-
}
|
|
14435
|
-
updateScroller() {
|
|
14436
14469
|
}
|
|
14437
14470
|
}
|
|
14438
14471
|
|
|
@@ -14442,7 +14475,7 @@ class Store extends BaseWatcher {
|
|
|
14442
14475
|
expand;
|
|
14443
14476
|
tree;
|
|
14444
14477
|
layout;
|
|
14445
|
-
|
|
14478
|
+
flatData = computed(() => {
|
|
14446
14479
|
if (this.table.props.expandSelectable) {
|
|
14447
14480
|
return concat(
|
|
14448
14481
|
flattenData(this.states.data, { parent: true, cascader: true }),
|
|
@@ -14473,17 +14506,24 @@ class Store extends BaseWatcher {
|
|
|
14473
14506
|
const dataInstanceChanged = this.states._data !== data;
|
|
14474
14507
|
this.states._data = data;
|
|
14475
14508
|
this.states.data = data;
|
|
14509
|
+
const caches = /* @__PURE__ */ new Map();
|
|
14510
|
+
this.states.list.forEach((item) => {
|
|
14511
|
+
item.rows.forEach((row) => {
|
|
14512
|
+
caches.set(row.data, row);
|
|
14513
|
+
});
|
|
14514
|
+
});
|
|
14476
14515
|
this.states.list = data.reduce((pre, row, index) => {
|
|
14516
|
+
const cache = caches.get(row) || { heightMap: {} };
|
|
14477
14517
|
pre.push({
|
|
14478
14518
|
rows: [
|
|
14479
14519
|
{
|
|
14480
14520
|
index,
|
|
14481
14521
|
data: row,
|
|
14482
|
-
height: "",
|
|
14522
|
+
height: cache.height || "",
|
|
14483
14523
|
heightMap: {
|
|
14484
|
-
left: "",
|
|
14485
|
-
main: "",
|
|
14486
|
-
right: ""
|
|
14524
|
+
left: cache.heightMap.left || "",
|
|
14525
|
+
main: cache.heightMap.main || "",
|
|
14526
|
+
right: cache.heightMap.right || ""
|
|
14487
14527
|
}
|
|
14488
14528
|
}
|
|
14489
14529
|
],
|
|
@@ -14491,6 +14531,7 @@ class Store extends BaseWatcher {
|
|
|
14491
14531
|
});
|
|
14492
14532
|
return pre;
|
|
14493
14533
|
}, []);
|
|
14534
|
+
caches.clear();
|
|
14494
14535
|
this.current.update();
|
|
14495
14536
|
this.expand.update();
|
|
14496
14537
|
if (!this.states.reserveSelection) {
|
|
@@ -14500,7 +14541,7 @@ class Store extends BaseWatcher {
|
|
|
14500
14541
|
this.cleanSelection();
|
|
14501
14542
|
}
|
|
14502
14543
|
} else {
|
|
14503
|
-
this.
|
|
14544
|
+
this.checkPrimaryKey();
|
|
14504
14545
|
this.updateSelectionByRowKey();
|
|
14505
14546
|
}
|
|
14506
14547
|
this.updateAllSelected();
|
|
@@ -14522,10 +14563,10 @@ class Store extends BaseWatcher {
|
|
|
14522
14563
|
}
|
|
14523
14564
|
}
|
|
14524
14565
|
/**
|
|
14525
|
-
* 检查
|
|
14566
|
+
* 检查 primaryKey 是否存在
|
|
14526
14567
|
*/
|
|
14527
|
-
|
|
14528
|
-
const {
|
|
14568
|
+
checkPrimaryKey() {
|
|
14569
|
+
const { primaryKey } = this.table.props;
|
|
14529
14570
|
}
|
|
14530
14571
|
/**
|
|
14531
14572
|
* states
|
|
@@ -14586,22 +14627,20 @@ class Store extends BaseWatcher {
|
|
|
14586
14627
|
updateColumns() {
|
|
14587
14628
|
const { states } = this;
|
|
14588
14629
|
const _columns = states._columns || [];
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
if (
|
|
14630
|
+
const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
14631
|
+
const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
|
|
14632
|
+
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
14592
14633
|
_columns[0].fixed = true;
|
|
14593
|
-
|
|
14634
|
+
leftFixedColumns.unshift(_columns[0]);
|
|
14594
14635
|
}
|
|
14595
14636
|
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;
|
|
14637
|
+
const originColumns = concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
14638
|
+
const headerRows = columnsToRowsEffect(originColumns);
|
|
14639
|
+
states.leftFixedColumns = leftFixedColumns;
|
|
14640
|
+
states.notFixedColumns = notFixedColumns;
|
|
14641
|
+
states.rightFixedColumns = rightFixedColumns;
|
|
14642
|
+
states.originColumns = originColumns;
|
|
14643
|
+
states.headerRows = headerRows;
|
|
14605
14644
|
}
|
|
14606
14645
|
// 选择
|
|
14607
14646
|
isSelected(row) {
|
|
@@ -14625,13 +14664,13 @@ class Store extends BaseWatcher {
|
|
|
14625
14664
|
* 清理选择
|
|
14626
14665
|
*/
|
|
14627
14666
|
cleanSelection() {
|
|
14628
|
-
const {
|
|
14629
|
-
const { selection = [] } = this.states;
|
|
14667
|
+
const { primaryKey } = this.table.props;
|
|
14668
|
+
const { selection = [], data } = this.states;
|
|
14630
14669
|
let deleted;
|
|
14631
|
-
if (
|
|
14670
|
+
if (primaryKey) {
|
|
14632
14671
|
deleted = [];
|
|
14633
|
-
const selectedMap =
|
|
14634
|
-
const dataMap =
|
|
14672
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14673
|
+
const dataMap = getValuesMap(data, primaryKey);
|
|
14635
14674
|
for (const key in selectedMap) {
|
|
14636
14675
|
if (hasOwn(selectedMap, key) && !dataMap[key]) {
|
|
14637
14676
|
deleted.push(selectedMap[key].row);
|
|
@@ -14639,7 +14678,7 @@ class Store extends BaseWatcher {
|
|
|
14639
14678
|
}
|
|
14640
14679
|
} else {
|
|
14641
14680
|
deleted = selection.filter((item) => {
|
|
14642
|
-
return !this.
|
|
14681
|
+
return !this.flatData.value.includes(item);
|
|
14643
14682
|
});
|
|
14644
14683
|
}
|
|
14645
14684
|
deleted.forEach((deletedItem) => {
|
|
@@ -14700,7 +14739,7 @@ class Store extends BaseWatcher {
|
|
|
14700
14739
|
const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
|
|
14701
14740
|
this.states.isAllSelected = value;
|
|
14702
14741
|
let selectionChanged = false;
|
|
14703
|
-
this.
|
|
14742
|
+
this.flatData.value.forEach((row, index) => {
|
|
14704
14743
|
if (selectable) {
|
|
14705
14744
|
if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
|
|
14706
14745
|
selectionChanged = true;
|
|
@@ -14731,11 +14770,11 @@ class Store extends BaseWatcher {
|
|
|
14731
14770
|
this.tree.expand(val);
|
|
14732
14771
|
}
|
|
14733
14772
|
updateSelectionByRowKey() {
|
|
14734
|
-
const {
|
|
14773
|
+
const { primaryKey } = this.table.props;
|
|
14735
14774
|
const { selection } = this.states;
|
|
14736
|
-
const selectedMap =
|
|
14737
|
-
this.states.selection = this.
|
|
14738
|
-
const rowId =
|
|
14775
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14776
|
+
this.states.selection = this.flatData.value.reduce((prev, row) => {
|
|
14777
|
+
const rowId = getRowValue(row, primaryKey);
|
|
14739
14778
|
const rowInfo = selectedMap[rowId];
|
|
14740
14779
|
if (rowInfo) {
|
|
14741
14780
|
prev.push(row);
|
|
@@ -14751,7 +14790,7 @@ class Store extends BaseWatcher {
|
|
|
14751
14790
|
}
|
|
14752
14791
|
let isAllSelected = true;
|
|
14753
14792
|
let selectedCount = 0;
|
|
14754
|
-
const temp = this.
|
|
14793
|
+
const temp = this.flatData.value;
|
|
14755
14794
|
for (let i = 0, j = temp.length; i < j; i++) {
|
|
14756
14795
|
const row = temp[i];
|
|
14757
14796
|
const isRowSelectable = selectable && selectable.call(null, row, i);
|
|
@@ -14806,8 +14845,10 @@ const COMPONENT_NAME$h = 'vc-table-normal-list';
|
|
|
14806
14845
|
const NormalList = /* @__PURE__ */ defineComponent({
|
|
14807
14846
|
name: COMPONENT_NAME$h,
|
|
14808
14847
|
props: {
|
|
14809
|
-
data:
|
|
14810
|
-
|
|
14848
|
+
data: {
|
|
14849
|
+
type: Array,
|
|
14850
|
+
default: () => []
|
|
14851
|
+
}
|
|
14811
14852
|
},
|
|
14812
14853
|
emits: ['row-resize'],
|
|
14813
14854
|
setup(props, {
|
|
@@ -14849,7 +14890,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14849
14890
|
expose
|
|
14850
14891
|
}) {
|
|
14851
14892
|
const instance = getCurrentInstance();
|
|
14852
|
-
const table =
|
|
14893
|
+
const table = inject('vc-table');
|
|
14853
14894
|
const states = useStates({
|
|
14854
14895
|
data: 'data',
|
|
14855
14896
|
list: 'list',
|
|
@@ -14866,6 +14907,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14866
14907
|
type
|
|
14867
14908
|
}) => type === 'default')
|
|
14868
14909
|
});
|
|
14910
|
+
const wrapper = ref();
|
|
14869
14911
|
watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
|
|
14870
14912
|
if (!props.store.states.isComplex || IS_SERVER$1) return;
|
|
14871
14913
|
raf(() => {
|
|
@@ -14876,12 +14918,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14876
14918
|
newRow && addClass(newRow, 'hover-row');
|
|
14877
14919
|
});
|
|
14878
14920
|
});
|
|
14879
|
-
const
|
|
14921
|
+
const getValueOfRow = (row, index) => {
|
|
14880
14922
|
const {
|
|
14881
|
-
|
|
14923
|
+
primaryKey
|
|
14882
14924
|
} = table.props;
|
|
14883
|
-
if (
|
|
14884
|
-
return
|
|
14925
|
+
if (primaryKey) {
|
|
14926
|
+
return getRowValue(row, primaryKey);
|
|
14885
14927
|
}
|
|
14886
14928
|
return index;
|
|
14887
14929
|
};
|
|
@@ -14946,7 +14988,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14946
14988
|
return cellStyle;
|
|
14947
14989
|
};
|
|
14948
14990
|
const getCellClass = (rowIndex, columnIndex, row, column) => {
|
|
14949
|
-
const classes = [column.
|
|
14991
|
+
const classes = [column.realAlign, column.className];
|
|
14950
14992
|
if (isColumnHidden(columnIndex)) {
|
|
14951
14993
|
classes.push('is-hidden');
|
|
14952
14994
|
}
|
|
@@ -14972,7 +15014,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
14972
15014
|
column,
|
|
14973
15015
|
row
|
|
14974
15016
|
};
|
|
14975
|
-
table.
|
|
15017
|
+
table.hoverState.value = hoverState;
|
|
14976
15018
|
table.emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, e);
|
|
14977
15019
|
}
|
|
14978
15020
|
|
|
@@ -15005,8 +15047,8 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15005
15047
|
const handleCellMouseLeave = e => {
|
|
15006
15048
|
const cell = getCell(e);
|
|
15007
15049
|
if (!cell) return;
|
|
15008
|
-
const oldHoverState = table.
|
|
15009
|
-
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell,
|
|
15050
|
+
const oldHoverState = table.hoverState.value || {};
|
|
15051
|
+
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
|
|
15010
15052
|
};
|
|
15011
15053
|
const handleMouseEnter = debounce(index => {
|
|
15012
15054
|
props.store.setHoverRow(index);
|
|
@@ -15042,7 +15084,8 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15042
15084
|
const {
|
|
15043
15085
|
columns
|
|
15044
15086
|
} = states;
|
|
15045
|
-
const key =
|
|
15087
|
+
const key = getValueOfRow(row, rowIndex);
|
|
15088
|
+
const selected = props.store.isSelected(row);
|
|
15046
15089
|
return createVNode("div", {
|
|
15047
15090
|
"key": key,
|
|
15048
15091
|
"class": [getRowClass(row, rowIndex), 'vc-table__tr'],
|
|
@@ -15063,10 +15106,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15063
15106
|
};
|
|
15064
15107
|
if (columnsHidden.value[columnIndex]) {
|
|
15065
15108
|
return createVNode("div", {
|
|
15109
|
+
"key": column.id,
|
|
15066
15110
|
"style": [sizeStyle]
|
|
15067
15111
|
}, null);
|
|
15068
15112
|
}
|
|
15069
15113
|
return createVNode("div", {
|
|
15114
|
+
"key": column.id,
|
|
15070
15115
|
"style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
|
|
15071
15116
|
"class": [getCellClass(rowIndex, columnIndex, row, column), 'vc-table__td'],
|
|
15072
15117
|
"onMouseenter": e => handleCellMouseEnter(e, row),
|
|
@@ -15076,7 +15121,8 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15076
15121
|
column,
|
|
15077
15122
|
rowIndex,
|
|
15078
15123
|
columnIndex,
|
|
15079
|
-
store: props.store
|
|
15124
|
+
store: props.store,
|
|
15125
|
+
selected
|
|
15080
15126
|
})]);
|
|
15081
15127
|
})]);
|
|
15082
15128
|
};
|
|
@@ -15106,13 +15152,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15106
15152
|
}
|
|
15107
15153
|
});
|
|
15108
15154
|
};
|
|
15109
|
-
const wrapper = ref();
|
|
15110
15155
|
expose({
|
|
15111
15156
|
wrapper,
|
|
15112
15157
|
getRootElement: () => instance.vnode.el
|
|
15113
15158
|
});
|
|
15159
|
+
const layout = table.layout;
|
|
15114
15160
|
return () => {
|
|
15115
|
-
const layout = table.exposed.layout;
|
|
15116
15161
|
return createVNode("div", {
|
|
15117
15162
|
"class": "vc-table__body"
|
|
15118
15163
|
}, [table.props.height ? createVNode(RecycleList, {
|
|
@@ -15121,7 +15166,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15121
15166
|
"disabled": true,
|
|
15122
15167
|
"class": "vc-table__tbody",
|
|
15123
15168
|
"scrollerOptions": {
|
|
15124
|
-
barTo: `.${table.
|
|
15169
|
+
barTo: `.${table.tableId}`,
|
|
15125
15170
|
native: false,
|
|
15126
15171
|
always: false,
|
|
15127
15172
|
showBar: !props.fixed,
|
|
@@ -15157,57 +15202,6 @@ const TableBody = /* @__PURE__ */ defineComponent({
|
|
|
15157
15202
|
|
|
15158
15203
|
const TableSort = 'div';
|
|
15159
15204
|
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
15205
|
const TableHeader = /* @__PURE__ */ defineComponent({
|
|
15212
15206
|
name: 'vc-table-header',
|
|
15213
15207
|
props: {
|
|
@@ -15224,7 +15218,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15224
15218
|
}
|
|
15225
15219
|
},
|
|
15226
15220
|
setup(props) {
|
|
15227
|
-
const table =
|
|
15221
|
+
const table = inject('vc-table');
|
|
15228
15222
|
const instance = getCurrentInstance();
|
|
15229
15223
|
const draggingColumn = ref(null);
|
|
15230
15224
|
const dragging = ref(false);
|
|
@@ -15234,16 +15228,18 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15234
15228
|
isAllSelected: 'isAllSelected',
|
|
15235
15229
|
leftFixedLeafCount: 'leftFixedLeafColumnsLength',
|
|
15236
15230
|
rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
|
15231
|
+
isGroup: 'isGroup',
|
|
15232
|
+
headerRows: 'headerRows',
|
|
15237
15233
|
columnsCount: $states => $states.columns.length,
|
|
15238
15234
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15239
15235
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15240
15236
|
});
|
|
15241
|
-
const
|
|
15237
|
+
const isColumnHidden = index => {
|
|
15242
15238
|
let start = 0;
|
|
15243
15239
|
for (let i = 0; i < index; i++) {
|
|
15244
|
-
start += columns[i].colSpan;
|
|
15240
|
+
start += states.columns[i].colSpan;
|
|
15245
15241
|
}
|
|
15246
|
-
const after = start + columns[index].colSpan - 1;
|
|
15242
|
+
const after = start + states.columns[index].colSpan - 1;
|
|
15247
15243
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15248
15244
|
return after >= states.leftFixedLeafCount;
|
|
15249
15245
|
} else if (props.fixed === 'right') {
|
|
@@ -15252,6 +15248,9 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15252
15248
|
return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
|
|
15253
15249
|
}
|
|
15254
15250
|
};
|
|
15251
|
+
const columnsHidden = computed(() => {
|
|
15252
|
+
return states.columns.map((_, index) => isColumnHidden(index));
|
|
15253
|
+
});
|
|
15255
15254
|
const getHeaderRowStyle = rowIndex => {
|
|
15256
15255
|
const {
|
|
15257
15256
|
headerRowStyle
|
|
@@ -15292,8 +15291,8 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15292
15291
|
return headerCellStyle;
|
|
15293
15292
|
};
|
|
15294
15293
|
const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
|
|
15295
|
-
const classes = [column.id, column.order, column.
|
|
15296
|
-
if (rowIndex === 0 &&
|
|
15294
|
+
const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
|
|
15295
|
+
if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
|
|
15297
15296
|
classes.push('is-hidden');
|
|
15298
15297
|
}
|
|
15299
15298
|
if (!column.children) {
|
|
@@ -15326,7 +15325,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15326
15325
|
/* istanbul ignore if */
|
|
15327
15326
|
if (draggingColumn.value && props.border) {
|
|
15328
15327
|
dragging.value = true;
|
|
15329
|
-
table.
|
|
15328
|
+
table.resizeProxyVisible.value = true;
|
|
15330
15329
|
const tableEl = table.vnode.el;
|
|
15331
15330
|
const tableLeft = tableEl.getBoundingClientRect().left;
|
|
15332
15331
|
const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
|
|
@@ -15339,7 +15338,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15339
15338
|
startColumnLeft: columnRect.left - tableLeft,
|
|
15340
15339
|
tableLeft
|
|
15341
15340
|
};
|
|
15342
|
-
const resizeProxy = table.
|
|
15341
|
+
const resizeProxy = table.resizeProxy.value;
|
|
15343
15342
|
resizeProxy.style.left = dragState.value.startLeft + 'px';
|
|
15344
15343
|
document.onselectstart = () => false;
|
|
15345
15344
|
document.ondragstart = () => false;
|
|
@@ -15433,37 +15432,27 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15433
15432
|
});
|
|
15434
15433
|
};
|
|
15435
15434
|
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
15435
|
return createVNode("div", {
|
|
15445
15436
|
"class": "vc-table__header"
|
|
15446
15437
|
}, [createVNode("div", {
|
|
15447
15438
|
"class": [{
|
|
15448
|
-
'is-group': isGroup
|
|
15439
|
+
'is-group': states.isGroup
|
|
15449
15440
|
}, 'vc-table__thead']
|
|
15450
15441
|
}, [
|
|
15451
15442
|
// renderList
|
|
15452
|
-
|
|
15443
|
+
states.headerRows.map((columns, rowIndex) => createVNode("div", {
|
|
15453
15444
|
"style": getHeaderRowStyle(rowIndex),
|
|
15454
15445
|
"class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
|
|
15455
|
-
}, [columns.map((column,
|
|
15456
|
-
"
|
|
15457
|
-
"rowspan": column.rowSpan,
|
|
15458
|
-
"onMousemove": $event => handleMouseMove($event, column),
|
|
15446
|
+
}, [columns.map((column, columnIndex) => createVNode("div", {
|
|
15447
|
+
"onMousemove": e => handleMouseMove(e, column),
|
|
15459
15448
|
"onMouseout": handleMouseOut,
|
|
15460
|
-
"onMousedown":
|
|
15461
|
-
"onClick":
|
|
15462
|
-
"onContextmenu":
|
|
15463
|
-
"style": [getHeaderCellStyle(rowIndex,
|
|
15449
|
+
"onMousedown": e => handleMouseDown(e, column),
|
|
15450
|
+
"onClick": e => handleHeaderClick(e, column),
|
|
15451
|
+
"onContextmenu": e => handleHeaderContextMenu(e, column),
|
|
15452
|
+
"style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
|
|
15464
15453
|
width: `${column.realWidth}px`
|
|
15465
15454
|
}],
|
|
15466
|
-
"class": [getHeaderCellClass(rowIndex,
|
|
15455
|
+
"class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
|
|
15467
15456
|
"key": column.id
|
|
15468
15457
|
}, [createVNode("div", {
|
|
15469
15458
|
"class": ['vc-table__cell',
|
|
@@ -15473,10 +15462,8 @@ const TableHeader = /* @__PURE__ */ defineComponent({
|
|
|
15473
15462
|
column.labelClass]
|
|
15474
15463
|
}, [column.renderHeader ? column.renderHeader({
|
|
15475
15464
|
column,
|
|
15476
|
-
|
|
15477
|
-
|
|
15478
|
-
store: props.store,
|
|
15479
|
-
_self: instance
|
|
15465
|
+
columnIndex,
|
|
15466
|
+
store: props.store
|
|
15480
15467
|
}) : column.label, column.tooltip ? createVNode(Icon, {
|
|
15481
15468
|
"type": "o-info",
|
|
15482
15469
|
"onMouseenter": e => handleCellMouseEnter(e, column)
|
|
@@ -15518,28 +15505,28 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15518
15505
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15519
15506
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15520
15507
|
});
|
|
15521
|
-
const
|
|
15508
|
+
const isColumnHidden = (column, index) => {
|
|
15522
15509
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15523
15510
|
return index >= states.leftFixedLeafCount;
|
|
15524
15511
|
} else if (props.fixed === 'right') {
|
|
15525
15512
|
let before = 0;
|
|
15526
15513
|
for (let i = 0; i < index; i++) {
|
|
15527
|
-
before += columns[i].colSpan;
|
|
15514
|
+
before += states.columns[i].colSpan;
|
|
15528
15515
|
}
|
|
15529
15516
|
return before < states.columnsCount - states.rightFixedLeafCount;
|
|
15530
15517
|
} else if (!props.fixed && column.fixed) {
|
|
15531
|
-
// hide cell when footer instance is not fixed and column is fixed
|
|
15532
15518
|
return true;
|
|
15533
15519
|
} else {
|
|
15534
15520
|
return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
|
|
15535
15521
|
}
|
|
15536
15522
|
};
|
|
15537
|
-
const
|
|
15538
|
-
|
|
15523
|
+
const columnsHidden = computed(() => states.columns.map(isColumnHidden));
|
|
15524
|
+
const getRowClasses = (column, columnIndex) => {
|
|
15525
|
+
const classes = [column.realAlign, column.labelClass];
|
|
15539
15526
|
if (column.className) {
|
|
15540
15527
|
classes.push(column.className);
|
|
15541
15528
|
}
|
|
15542
|
-
if (
|
|
15529
|
+
if (columnsHidden.value[columnIndex]) {
|
|
15543
15530
|
classes.push('is-hidden');
|
|
15544
15531
|
}
|
|
15545
15532
|
if (!column.children) {
|
|
@@ -15547,17 +15534,17 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15547
15534
|
}
|
|
15548
15535
|
return classes;
|
|
15549
15536
|
};
|
|
15550
|
-
|
|
15551
|
-
let
|
|
15537
|
+
const sums = computed(() => {
|
|
15538
|
+
let v = [];
|
|
15552
15539
|
if (props.getSummary) {
|
|
15553
|
-
|
|
15540
|
+
v = props.getSummary({
|
|
15554
15541
|
columns: states.columns,
|
|
15555
15542
|
data: states.data
|
|
15556
15543
|
});
|
|
15557
15544
|
} else {
|
|
15558
15545
|
states.columns.forEach((column, index) => {
|
|
15559
15546
|
if (index === 0) {
|
|
15560
|
-
|
|
15547
|
+
v[index] = props.sumText;
|
|
15561
15548
|
return;
|
|
15562
15549
|
}
|
|
15563
15550
|
const values = states.data.map(item => Number(item[column.prop]));
|
|
@@ -15572,7 +15559,7 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15572
15559
|
});
|
|
15573
15560
|
const precision = Math.max.apply(null, precisions);
|
|
15574
15561
|
if (!notNumber) {
|
|
15575
|
-
|
|
15562
|
+
v[index] = values.reduce((prev, curr) => {
|
|
15576
15563
|
const value = Number(curr);
|
|
15577
15564
|
if (!isNaN(value)) {
|
|
15578
15565
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -15581,10 +15568,13 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15581
15568
|
}
|
|
15582
15569
|
}, 0);
|
|
15583
15570
|
} else {
|
|
15584
|
-
|
|
15571
|
+
v[index] = '';
|
|
15585
15572
|
}
|
|
15586
15573
|
});
|
|
15587
15574
|
}
|
|
15575
|
+
return v;
|
|
15576
|
+
});
|
|
15577
|
+
return () => {
|
|
15588
15578
|
return createVNode("div", {
|
|
15589
15579
|
"class": "vc-table__footer",
|
|
15590
15580
|
"cellspacing": "0",
|
|
@@ -15594,17 +15584,15 @@ const TableFooter = /* @__PURE__ */ defineComponent({
|
|
|
15594
15584
|
"class": "vc-table__tbody"
|
|
15595
15585
|
}, [createVNode("div", {
|
|
15596
15586
|
"class": "vc-table__tr"
|
|
15597
|
-
}, [states.columns.map((column,
|
|
15598
|
-
"key":
|
|
15599
|
-
"
|
|
15600
|
-
"rowspan": column.rowSpan,
|
|
15601
|
-
"class": [getRowClasses(column, cellIndex), 'vc-table__td'],
|
|
15587
|
+
}, [states.columns.map((column, columnIndex) => createVNode("div", {
|
|
15588
|
+
"key": columnIndex,
|
|
15589
|
+
"class": [getRowClasses(column, columnIndex), 'vc-table__td'],
|
|
15602
15590
|
"style": [{
|
|
15603
15591
|
width: `${column.realWidth}px`
|
|
15604
15592
|
}]
|
|
15605
15593
|
}, [createVNode("div", {
|
|
15606
15594
|
"class": ['vc-table__cell', column.labelClass]
|
|
15607
|
-
}, [sums[
|
|
15595
|
+
}, [sums.value[columnIndex]])]))])])]);
|
|
15608
15596
|
};
|
|
15609
15597
|
}
|
|
15610
15598
|
});
|
|
@@ -15632,7 +15620,7 @@ const props$c = {
|
|
|
15632
15620
|
type: Number,
|
|
15633
15621
|
default: 10
|
|
15634
15622
|
},
|
|
15635
|
-
|
|
15623
|
+
primaryKey: [String, Function],
|
|
15636
15624
|
// 是否显示表头
|
|
15637
15625
|
showHeader: {
|
|
15638
15626
|
type: Boolean,
|
|
@@ -15709,7 +15697,8 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
15709
15697
|
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'],
|
|
15710
15698
|
setup(props, {
|
|
15711
15699
|
slots,
|
|
15712
|
-
expose
|
|
15700
|
+
expose,
|
|
15701
|
+
emit
|
|
15713
15702
|
}) {
|
|
15714
15703
|
const instance = getCurrentInstance();
|
|
15715
15704
|
const store = new Store({
|
|
@@ -15749,23 +15738,21 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
15749
15738
|
const rightFixedBody = ref(null);
|
|
15750
15739
|
const rightFixedFooterWrapper = ref(null);
|
|
15751
15740
|
const resizeProxy = ref(null);
|
|
15752
|
-
|
|
15753
|
-
// 是否拥有多级表头, 由table-header控制
|
|
15754
|
-
const isGroup = ref(false);
|
|
15755
15741
|
const scrollPosition = ref('left');
|
|
15756
15742
|
const hoverState = ref(null);
|
|
15757
15743
|
const isReady = ref(false);
|
|
15758
15744
|
const states = useStates({
|
|
15759
15745
|
columns: 'columns',
|
|
15760
15746
|
leftFixedColumns: 'leftFixedColumns',
|
|
15761
|
-
rightFixedColumns: 'rightFixedColumns'
|
|
15747
|
+
rightFixedColumns: 'rightFixedColumns',
|
|
15748
|
+
isGroup: 'isGroup'
|
|
15762
15749
|
}, store);
|
|
15763
15750
|
const classes = computed(() => {
|
|
15764
15751
|
return {
|
|
15765
15752
|
'vc-table--fit': props.fit,
|
|
15766
15753
|
'vc-table--striped': props.stripe,
|
|
15767
|
-
'vc-table--border': props.border || isGroup
|
|
15768
|
-
'vc-table--group': isGroup
|
|
15754
|
+
'vc-table--border': props.border || states.isGroup,
|
|
15755
|
+
'vc-table--group': states.isGroup,
|
|
15769
15756
|
'vc-table--fluid-height': props.maxHeight,
|
|
15770
15757
|
'vc-table--scrollable-x': layout.states.scrollX,
|
|
15771
15758
|
'vc-table--scrollable-y': layout.states.scrollY,
|
|
@@ -16026,13 +16013,13 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16026
16013
|
immediate: true
|
|
16027
16014
|
});
|
|
16028
16015
|
watch(() => props.currentRowValue, v => {
|
|
16029
|
-
if (!props.
|
|
16016
|
+
if (!props.primaryKey) return;
|
|
16030
16017
|
store.current.reset(v);
|
|
16031
16018
|
}, {
|
|
16032
16019
|
immediate: true
|
|
16033
16020
|
});
|
|
16034
|
-
watch(() => props.data,
|
|
16035
|
-
store.setData(
|
|
16021
|
+
watch(() => [props.data, props.data.length], () => {
|
|
16022
|
+
store.setData(props.data);
|
|
16036
16023
|
isReady.value && nextTick(refreshLayout);
|
|
16037
16024
|
}, {
|
|
16038
16025
|
immediate: true
|
|
@@ -16055,6 +16042,7 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16055
16042
|
}, {
|
|
16056
16043
|
immediate: true
|
|
16057
16044
|
});
|
|
16045
|
+
const tableId = getUid('table');
|
|
16058
16046
|
onMounted(() => {
|
|
16059
16047
|
bindEvents();
|
|
16060
16048
|
store.updateColumns();
|
|
@@ -16065,12 +16053,13 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16065
16053
|
};
|
|
16066
16054
|
isReady.value = true;
|
|
16067
16055
|
});
|
|
16068
|
-
|
|
16056
|
+
onUnmounted(() => {
|
|
16069
16057
|
isUnMount = true;
|
|
16070
16058
|
unbindEvents();
|
|
16071
16059
|
});
|
|
16072
|
-
const
|
|
16073
|
-
|
|
16060
|
+
const exposed = {
|
|
16061
|
+
bodyXWrapper,
|
|
16062
|
+
bodyYWrapper,
|
|
16074
16063
|
tableId,
|
|
16075
16064
|
store,
|
|
16076
16065
|
layout,
|
|
@@ -16090,8 +16079,12 @@ const Table = /* @__PURE__ */ defineComponent({
|
|
|
16090
16079
|
isReady,
|
|
16091
16080
|
hoverState,
|
|
16092
16081
|
renderExpanded,
|
|
16093
|
-
hiddenColumns
|
|
16094
|
-
|
|
16082
|
+
hiddenColumns,
|
|
16083
|
+
props,
|
|
16084
|
+
emit
|
|
16085
|
+
};
|
|
16086
|
+
expose(exposed);
|
|
16087
|
+
provide('vc-table', exposed);
|
|
16095
16088
|
return () => {
|
|
16096
16089
|
return createVNode("div", {
|
|
16097
16090
|
"class": [classes.value, tableId, 'vc-table'],
|
|
@@ -16240,22 +16233,19 @@ const cellStarts = {
|
|
|
16240
16233
|
order: ''
|
|
16241
16234
|
},
|
|
16242
16235
|
selection: {
|
|
16243
|
-
width:
|
|
16244
|
-
minWidth:
|
|
16245
|
-
realWidth: 48,
|
|
16236
|
+
width: 60,
|
|
16237
|
+
minWidth: 60,
|
|
16246
16238
|
order: '',
|
|
16247
16239
|
className: 'vc-table-column--selection'
|
|
16248
16240
|
},
|
|
16249
16241
|
expand: {
|
|
16250
|
-
width:
|
|
16251
|
-
minWidth:
|
|
16252
|
-
realWidth: 48,
|
|
16242
|
+
width: 60,
|
|
16243
|
+
minWidth: 60,
|
|
16253
16244
|
order: ''
|
|
16254
16245
|
},
|
|
16255
16246
|
index: {
|
|
16256
|
-
width:
|
|
16257
|
-
minWidth:
|
|
16258
|
-
realWidth: 48,
|
|
16247
|
+
width: 60,
|
|
16248
|
+
minWidth: 60,
|
|
16259
16249
|
order: ''
|
|
16260
16250
|
}
|
|
16261
16251
|
};
|
|
@@ -16281,10 +16271,11 @@ const cellForced = {
|
|
|
16281
16271
|
column,
|
|
16282
16272
|
store,
|
|
16283
16273
|
rowIndex,
|
|
16284
|
-
level
|
|
16274
|
+
level,
|
|
16275
|
+
selected
|
|
16285
16276
|
}) {
|
|
16286
16277
|
return withDirectives(createVNode(Checkbox, {
|
|
16287
|
-
"modelValue":
|
|
16278
|
+
"modelValue": selected,
|
|
16288
16279
|
"disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
|
|
16289
16280
|
"onChange": () => store.rowSelectedChanged(row),
|
|
16290
16281
|
"onClick": e => e.stopPropagation()
|
|
@@ -16422,8 +16413,8 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16422
16413
|
customClass: String,
|
|
16423
16414
|
labelClass: String,
|
|
16424
16415
|
prop: String,
|
|
16425
|
-
width:
|
|
16426
|
-
minWidth:
|
|
16416
|
+
width: Number,
|
|
16417
|
+
minWidth: Number,
|
|
16427
16418
|
renderHeader: Function,
|
|
16428
16419
|
resizable: {
|
|
16429
16420
|
type: Boolean,
|
|
@@ -16457,15 +16448,14 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16457
16448
|
tooltip: [String, Function]
|
|
16458
16449
|
},
|
|
16459
16450
|
setup(props, {
|
|
16460
|
-
slots
|
|
16461
|
-
expose
|
|
16451
|
+
slots
|
|
16462
16452
|
}) {
|
|
16463
16453
|
const instance = getCurrentInstance();
|
|
16464
|
-
const table =
|
|
16465
|
-
const parent =
|
|
16454
|
+
const table = inject('vc-table');
|
|
16455
|
+
const parent = inject('vc-table-column', table);
|
|
16466
16456
|
const isSubColumn = table !== parent; // 用于多久表头
|
|
16467
16457
|
|
|
16468
|
-
const columnId = ref((parent.
|
|
16458
|
+
const columnId = ref((parent.tableId || parent.columnId) + getUid('column'));
|
|
16469
16459
|
const realWidth = computed(() => {
|
|
16470
16460
|
return parseWidth(props.width);
|
|
16471
16461
|
});
|
|
@@ -16495,7 +16485,6 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16495
16485
|
}, {});
|
|
16496
16486
|
return result;
|
|
16497
16487
|
};
|
|
16498
|
-
|
|
16499
16488
|
/**
|
|
16500
16489
|
* compose 1
|
|
16501
16490
|
* 对于特定类型的 column,某些属性不允许设置
|
|
@@ -16565,7 +16554,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16565
16554
|
column.renderCell = data => createVNode("div", {
|
|
16566
16555
|
"class": "vc-table__cell"
|
|
16567
16556
|
}, [originRenderCell(data)]);
|
|
16568
|
-
table.
|
|
16557
|
+
table.renderExpanded.value = data => {
|
|
16569
16558
|
return slots.default ? slots.default(data) : slots.default;
|
|
16570
16559
|
};
|
|
16571
16560
|
} else {
|
|
@@ -16584,7 +16573,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16584
16573
|
style: {}
|
|
16585
16574
|
};
|
|
16586
16575
|
// 存在树形数组,且当前行无箭头图标且处于当前展开列,表格对齐
|
|
16587
|
-
if (!isEmpty$1(table.
|
|
16576
|
+
if (!isEmpty$1(table.store.states.treeData) && !prefix && data.isExpandColumn) {
|
|
16588
16577
|
prefix = createVNode("span", {
|
|
16589
16578
|
"class": "vc-table-un-expand__indent"
|
|
16590
16579
|
}, null);
|
|
@@ -16604,26 +16593,16 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16604
16593
|
}
|
|
16605
16594
|
return column;
|
|
16606
16595
|
};
|
|
16607
|
-
const
|
|
16596
|
+
const registerColumn = () => {
|
|
16608
16597
|
const defaults = {
|
|
16609
16598
|
...cellStarts[props.type],
|
|
16610
|
-
type: props.type,
|
|
16611
16599
|
id: columnId.value,
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
prop: props.prop,
|
|
16615
|
-
showPopover: props.showPopover,
|
|
16616
|
-
// index 列
|
|
16617
|
-
index: props.index
|
|
16600
|
+
realAlign,
|
|
16601
|
+
realHeaderAlign
|
|
16618
16602
|
};
|
|
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 中函数执行的顺序是从右到左
|
|
16603
|
+
let column = merge$1(defaults, getPropsData(Object.keys(props)));
|
|
16604
|
+
|
|
16605
|
+
// minWidth/realWidth/renderHeader
|
|
16627
16606
|
column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
|
|
16628
16607
|
for (const key in column) {
|
|
16629
16608
|
if (hasOwn(column, key)) {
|
|
@@ -16631,34 +16610,39 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16631
16610
|
}
|
|
16632
16611
|
}
|
|
16633
16612
|
};
|
|
16634
|
-
const
|
|
16613
|
+
const registerWatchers = () => {
|
|
16614
|
+
// 赋值
|
|
16615
|
+
Object.keys(props).forEach(k => watch(() => props[k], v => columnConfig[k] = v));
|
|
16616
|
+
|
|
16617
|
+
// 影响布局
|
|
16635
16618
|
watch(() => props.fixed, () => {
|
|
16636
|
-
table.
|
|
16619
|
+
table.store.scheduleLayout(true);
|
|
16637
16620
|
});
|
|
16638
|
-
watch(() => realWidth.value,
|
|
16639
|
-
|
|
16621
|
+
watch(() => realWidth.value, v => {
|
|
16622
|
+
columnConfig['width'] = v;
|
|
16623
|
+
columnConfig['realWidth'] = v;
|
|
16624
|
+
table.store.scheduleLayout(false);
|
|
16640
16625
|
});
|
|
16641
16626
|
watch(() => realMinWidth.value, () => {
|
|
16642
|
-
table.
|
|
16627
|
+
table.store.scheduleLayout(false);
|
|
16643
16628
|
});
|
|
16644
16629
|
};
|
|
16645
16630
|
onBeforeMount(() => {
|
|
16646
|
-
|
|
16647
|
-
|
|
16631
|
+
registerColumn();
|
|
16632
|
+
registerWatchers();
|
|
16648
16633
|
});
|
|
16649
|
-
onUpdated(refreshColumnBasicConfig);
|
|
16650
16634
|
onMounted(() => {
|
|
16651
|
-
const children = isSubColumn ? parent.vnode.el.children : parent.
|
|
16635
|
+
const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
|
|
16652
16636
|
|
|
16653
16637
|
// DOM上
|
|
16654
16638
|
const columnIndex = [...children].indexOf(instance.vnode.el);
|
|
16655
|
-
table.
|
|
16639
|
+
table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
|
|
16656
16640
|
});
|
|
16657
16641
|
onUnmounted(() => {
|
|
16658
16642
|
if (!instance.parent) return;
|
|
16659
|
-
table.
|
|
16643
|
+
table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
|
|
16660
16644
|
});
|
|
16661
|
-
|
|
16645
|
+
provide('vc-table-column', {
|
|
16662
16646
|
columnId,
|
|
16663
16647
|
columnConfig
|
|
16664
16648
|
});
|
|
@@ -16674,7 +16658,8 @@ const TableColumn = /* @__PURE__ */ defineComponent({
|
|
|
16674
16658
|
const renderDefault = slots?.default?.({
|
|
16675
16659
|
row: {},
|
|
16676
16660
|
column: {},
|
|
16677
|
-
|
|
16661
|
+
columnIndex: -1,
|
|
16662
|
+
rowIndex: -1
|
|
16678
16663
|
});
|
|
16679
16664
|
if (renderDefault instanceof Array) {
|
|
16680
16665
|
for (const childNode of renderDefault) {
|