@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.cjs
CHANGED
|
@@ -794,7 +794,7 @@ const COMPONENT_NAME$1T = 'vc-alert';
|
|
|
794
794
|
|
|
795
795
|
// [color, borderColor, backgroundColor], -> CSS
|
|
796
796
|
const THEME_MAP = {
|
|
797
|
-
info: ['#
|
|
797
|
+
info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
|
|
798
798
|
success: ['#52c41a', '#b7eb8f', '#f6ffed'],
|
|
799
799
|
error: ['#ed4014', '#ffb08f', '#fbe9e9'],
|
|
800
800
|
warning: ['#ffbf00', '#ffe58f', '#fffbe6']
|
|
@@ -8008,6 +8008,7 @@ const Track = /* @__PURE__ */ vue.defineComponent({
|
|
|
8008
8008
|
isVisible.value = cursorDown.value;
|
|
8009
8009
|
};
|
|
8010
8010
|
const refreshThumb = () => Utils.raf(() => {
|
|
8011
|
+
if (!thumb.value) return;
|
|
8011
8012
|
thumb.value.style[$__namespace.prefixStyle('transform').camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
|
|
8012
8013
|
});
|
|
8013
8014
|
const refreshThrottleThumb = lodashEs.throttle(refreshThumb, 10);
|
|
@@ -12143,7 +12144,7 @@ const props$m = {
|
|
|
12143
12144
|
color: {
|
|
12144
12145
|
type: [Object, String],
|
|
12145
12146
|
default: () => ({
|
|
12146
|
-
normal: "#
|
|
12147
|
+
normal: "#2B72FD",
|
|
12147
12148
|
success: "#52c41a",
|
|
12148
12149
|
error: "#f5222d"
|
|
12149
12150
|
})
|
|
@@ -13168,6 +13169,7 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
|
|
|
13168
13169
|
|
|
13169
13170
|
// 设置data首个元素的在originalData索引值
|
|
13170
13171
|
const setFirstItemIndex = () => {
|
|
13172
|
+
if (!wrapper.value) return;
|
|
13171
13173
|
const position = wrapper.value[K.scrollAxis];
|
|
13172
13174
|
let item;
|
|
13173
13175
|
for (let i = 0; i < rebuildData.value.length; i++) {
|
|
@@ -13348,6 +13350,7 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
|
|
|
13348
13350
|
|
|
13349
13351
|
// 图片撑开时,会影响布局, 节流结束后调用
|
|
13350
13352
|
const handleResize = Utils.throttle(async () => {
|
|
13353
|
+
if (!wrapper.value) return;
|
|
13351
13354
|
const isNeedRefreshLayout = rebuildData.value.some(i => !i.isPlaceholder);
|
|
13352
13355
|
if (isNeedRefreshLayout) {
|
|
13353
13356
|
const oldFirstItemIndex = firstItemIndex.value;
|
|
@@ -13381,6 +13384,8 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
|
|
|
13381
13384
|
});
|
|
13382
13385
|
if (!originalData.length) {
|
|
13383
13386
|
rebuildData.value = [];
|
|
13387
|
+
} else {
|
|
13388
|
+
rebuildData.value = originalData.slice();
|
|
13384
13389
|
}
|
|
13385
13390
|
offsetPageSize.value = 0;
|
|
13386
13391
|
await refreshLayout(0, originalData.length);
|
|
@@ -13785,88 +13790,65 @@ const MSwitch = /* @__PURE__ */ vue.defineComponent({
|
|
|
13785
13790
|
}
|
|
13786
13791
|
});
|
|
13787
13792
|
|
|
13788
|
-
const parseHeight = (
|
|
13789
|
-
if (typeof
|
|
13790
|
-
return
|
|
13793
|
+
const parseHeight = (v) => {
|
|
13794
|
+
if (typeof v === "number") {
|
|
13795
|
+
return v;
|
|
13791
13796
|
}
|
|
13792
|
-
if (
|
|
13793
|
-
if (/^\d+(?:px)?/.test(
|
|
13794
|
-
return parseInt(
|
|
13797
|
+
if (v && typeof v === "string") {
|
|
13798
|
+
if (/^\d+(?:px)?/.test(v)) {
|
|
13799
|
+
return parseInt(v, 10);
|
|
13795
13800
|
}
|
|
13796
13801
|
throw new VcError("table", "Invalid Height");
|
|
13797
13802
|
}
|
|
13798
13803
|
return null;
|
|
13799
13804
|
};
|
|
13800
|
-
const parseWidth = (
|
|
13801
|
-
if (
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
+
const parseWidth = (v) => {
|
|
13806
|
+
if (typeof v === "number") {
|
|
13807
|
+
return v;
|
|
13808
|
+
}
|
|
13809
|
+
let v1;
|
|
13810
|
+
if (typeof v !== "undefined") {
|
|
13811
|
+
v1 = parseInt(v, 10);
|
|
13812
|
+
if (isNaN(v1)) {
|
|
13813
|
+
v1 = null;
|
|
13805
13814
|
}
|
|
13806
13815
|
}
|
|
13807
|
-
return
|
|
13816
|
+
return v1;
|
|
13808
13817
|
};
|
|
13809
|
-
const parseMinWidth = (
|
|
13810
|
-
if (typeof
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13818
|
+
const parseMinWidth = (v) => {
|
|
13819
|
+
if (typeof v === "number") {
|
|
13820
|
+
return v;
|
|
13821
|
+
}
|
|
13822
|
+
let v1;
|
|
13823
|
+
if (typeof v !== "undefined") {
|
|
13824
|
+
v1 = parseWidth(v);
|
|
13825
|
+
if (isNaN(v1)) {
|
|
13826
|
+
v = 80;
|
|
13814
13827
|
}
|
|
13815
13828
|
}
|
|
13816
|
-
return
|
|
13829
|
+
return v1;
|
|
13817
13830
|
};
|
|
13818
|
-
const
|
|
13831
|
+
const getRowValue = (row, primaryKey) => {
|
|
13819
13832
|
if (row.__KEY__) return row.__KEY__;
|
|
13820
13833
|
if (!row) throw new VcError("table", "row is required when get row identity");
|
|
13821
|
-
if (typeof
|
|
13822
|
-
if (!
|
|
13823
|
-
return row[
|
|
13834
|
+
if (typeof primaryKey === "string") {
|
|
13835
|
+
if (!primaryKey.includes(".")) {
|
|
13836
|
+
return row[primaryKey];
|
|
13824
13837
|
}
|
|
13825
|
-
const key =
|
|
13838
|
+
const key = primaryKey.split(".");
|
|
13826
13839
|
let current = row;
|
|
13827
13840
|
for (let i = 0; i < key.length; i++) {
|
|
13828
13841
|
current = current[key[i]];
|
|
13829
13842
|
}
|
|
13830
13843
|
return current;
|
|
13831
|
-
} else if (typeof
|
|
13832
|
-
return
|
|
13833
|
-
}
|
|
13834
|
-
};
|
|
13835
|
-
const walkTreeNode = (root, cb, opts = {}) => {
|
|
13836
|
-
const {
|
|
13837
|
-
childrenKey = "children",
|
|
13838
|
-
lazyKey = "hasChildren",
|
|
13839
|
-
level: baseLevel = 0
|
|
13840
|
-
} = opts;
|
|
13841
|
-
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
13842
|
-
function _walker(parent, children, level) {
|
|
13843
|
-
cb(parent, children, level);
|
|
13844
|
-
children.forEach((item) => {
|
|
13845
|
-
if (item[lazyKey]) {
|
|
13846
|
-
cb(item, null, level + 1);
|
|
13847
|
-
return;
|
|
13848
|
-
}
|
|
13849
|
-
const $children = item[childrenKey];
|
|
13850
|
-
if (!isNil($children)) {
|
|
13851
|
-
_walker(item, $children, level + 1);
|
|
13852
|
-
}
|
|
13853
|
-
});
|
|
13844
|
+
} else if (typeof primaryKey === "function") {
|
|
13845
|
+
return primaryKey.call(null, row);
|
|
13854
13846
|
}
|
|
13855
|
-
root.forEach((item) => {
|
|
13856
|
-
if (item[lazyKey]) {
|
|
13857
|
-
cb(item, null, baseLevel);
|
|
13858
|
-
return;
|
|
13859
|
-
}
|
|
13860
|
-
const children = item[childrenKey];
|
|
13861
|
-
if (!isNil(children)) {
|
|
13862
|
-
_walker(item, children, baseLevel);
|
|
13863
|
-
}
|
|
13864
|
-
});
|
|
13865
13847
|
};
|
|
13866
|
-
const
|
|
13848
|
+
const getValuesMap = (array = [], primaryKey) => {
|
|
13867
13849
|
const arrayMap = {};
|
|
13868
13850
|
array.forEach((row, index) => {
|
|
13869
|
-
arrayMap[
|
|
13851
|
+
arrayMap[getRowValue(row, primaryKey)] = { row, index };
|
|
13870
13852
|
});
|
|
13871
13853
|
return arrayMap;
|
|
13872
13854
|
};
|
|
@@ -13879,23 +13861,75 @@ const getColumnById = (columns, columnId) => {
|
|
|
13879
13861
|
});
|
|
13880
13862
|
return column;
|
|
13881
13863
|
};
|
|
13882
|
-
const getColumnByCell = (
|
|
13864
|
+
const getColumnByCell = (columns, cell) => {
|
|
13883
13865
|
const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
|
|
13884
13866
|
if (matches) {
|
|
13885
|
-
return getColumnById(
|
|
13867
|
+
return getColumnById(columns, matches[0]);
|
|
13886
13868
|
}
|
|
13887
13869
|
return null;
|
|
13888
13870
|
};
|
|
13889
|
-
const getCell = (
|
|
13890
|
-
let cell =
|
|
13871
|
+
const getCell = (e) => {
|
|
13872
|
+
let cell = e.target;
|
|
13891
13873
|
while (cell && cell.tagName.toUpperCase() !== "HTML") {
|
|
13892
|
-
if (cell.
|
|
13874
|
+
if (cell.classList.contains("vc-table__td")) {
|
|
13893
13875
|
return cell;
|
|
13894
13876
|
}
|
|
13895
13877
|
cell = cell.parentNode;
|
|
13896
13878
|
}
|
|
13897
13879
|
return null;
|
|
13898
13880
|
};
|
|
13881
|
+
|
|
13882
|
+
const getAllColumns = (columns) => {
|
|
13883
|
+
const result = [];
|
|
13884
|
+
columns.forEach((column) => {
|
|
13885
|
+
if (column.children) {
|
|
13886
|
+
result.push(column);
|
|
13887
|
+
result.push(...getAllColumns(column.children));
|
|
13888
|
+
} else {
|
|
13889
|
+
result.push(column);
|
|
13890
|
+
}
|
|
13891
|
+
});
|
|
13892
|
+
return result;
|
|
13893
|
+
};
|
|
13894
|
+
const columnsToRowsEffect = (v) => {
|
|
13895
|
+
let maxLevel = 1;
|
|
13896
|
+
const traverse = (column, parent) => {
|
|
13897
|
+
if (parent) {
|
|
13898
|
+
column.level = parent.level + 1;
|
|
13899
|
+
if (maxLevel < column.level) {
|
|
13900
|
+
maxLevel = column.level;
|
|
13901
|
+
}
|
|
13902
|
+
}
|
|
13903
|
+
if (column.children) {
|
|
13904
|
+
let colSpan = 0;
|
|
13905
|
+
column.children.forEach((subColumn) => {
|
|
13906
|
+
traverse(subColumn, column);
|
|
13907
|
+
colSpan += subColumn.colSpan;
|
|
13908
|
+
});
|
|
13909
|
+
column.colSpan = colSpan;
|
|
13910
|
+
} else {
|
|
13911
|
+
column.colSpan = 1;
|
|
13912
|
+
}
|
|
13913
|
+
};
|
|
13914
|
+
v.forEach((column) => {
|
|
13915
|
+
column.level = 1;
|
|
13916
|
+
traverse(column);
|
|
13917
|
+
});
|
|
13918
|
+
const rows = [];
|
|
13919
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
13920
|
+
rows.push([]);
|
|
13921
|
+
}
|
|
13922
|
+
const allColumns = getAllColumns(v);
|
|
13923
|
+
allColumns.forEach((column) => {
|
|
13924
|
+
if (!column.children) {
|
|
13925
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
13926
|
+
} else {
|
|
13927
|
+
column.rowSpan = 1;
|
|
13928
|
+
}
|
|
13929
|
+
rows[column.level - 1].push(column);
|
|
13930
|
+
});
|
|
13931
|
+
return rows;
|
|
13932
|
+
};
|
|
13899
13933
|
const flattenData = (data, opts = {}) => {
|
|
13900
13934
|
const result = [];
|
|
13901
13935
|
data.forEach((item) => {
|
|
@@ -13908,6 +13942,37 @@ const flattenData = (data, opts = {}) => {
|
|
|
13908
13942
|
});
|
|
13909
13943
|
return result;
|
|
13910
13944
|
};
|
|
13945
|
+
const walkTreeNode = (root, cb, opts = {}) => {
|
|
13946
|
+
const {
|
|
13947
|
+
childrenKey = "children",
|
|
13948
|
+
lazyKey = "hasChildren",
|
|
13949
|
+
level: baseLevel = 0
|
|
13950
|
+
} = opts;
|
|
13951
|
+
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
13952
|
+
function _walker(parent, children, level) {
|
|
13953
|
+
cb(parent, children, level);
|
|
13954
|
+
children.forEach((item) => {
|
|
13955
|
+
if (item[lazyKey]) {
|
|
13956
|
+
cb(item, null, level + 1);
|
|
13957
|
+
return;
|
|
13958
|
+
}
|
|
13959
|
+
const $children = item[childrenKey];
|
|
13960
|
+
if (!isNil($children)) {
|
|
13961
|
+
_walker(item, $children, level + 1);
|
|
13962
|
+
}
|
|
13963
|
+
});
|
|
13964
|
+
}
|
|
13965
|
+
root.forEach((item) => {
|
|
13966
|
+
if (item[lazyKey]) {
|
|
13967
|
+
cb(item, null, baseLevel);
|
|
13968
|
+
return;
|
|
13969
|
+
}
|
|
13970
|
+
const children = item[childrenKey];
|
|
13971
|
+
if (!isNil(children)) {
|
|
13972
|
+
_walker(item, children, baseLevel);
|
|
13973
|
+
}
|
|
13974
|
+
});
|
|
13975
|
+
};
|
|
13911
13976
|
|
|
13912
13977
|
class BaseWatcher {
|
|
13913
13978
|
states = vue.reactive({
|
|
@@ -13915,23 +13980,14 @@ class BaseWatcher {
|
|
|
13915
13980
|
_data: [],
|
|
13916
13981
|
data: [],
|
|
13917
13982
|
list: [],
|
|
13918
|
-
//
|
|
13919
|
-
|
|
13920
|
-
// 列
|
|
13983
|
+
// 表头数据
|
|
13984
|
+
headerRows: [],
|
|
13985
|
+
// 列 动态收集vc-table-column中的columnConfig
|
|
13921
13986
|
_columns: [],
|
|
13922
|
-
// 动态收集vc-table-column中的columnConfig
|
|
13923
13987
|
originColumns: [],
|
|
13924
|
-
|
|
13925
|
-
columns: [],
|
|
13926
|
-
// 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
|
|
13988
|
+
notFixedColumns: [],
|
|
13927
13989
|
leftFixedColumns: [],
|
|
13928
13990
|
rightFixedColumns: [],
|
|
13929
|
-
leafColumns: [],
|
|
13930
|
-
leftFixedLeafColumns: [],
|
|
13931
|
-
rightFixedLeafColumns: [],
|
|
13932
|
-
leafColumnsLength: 0,
|
|
13933
|
-
leftFixedLeafColumnsLength: 0,
|
|
13934
|
-
rightFixedLeafColumnsLength: 0,
|
|
13935
13991
|
// 选择
|
|
13936
13992
|
isAllSelected: false,
|
|
13937
13993
|
selection: [],
|
|
@@ -13953,7 +14009,17 @@ class BaseWatcher {
|
|
|
13953
14009
|
treeLazyData: [],
|
|
13954
14010
|
// 源数据展开
|
|
13955
14011
|
treeLazyColumnIdentifier: "hasChildren",
|
|
13956
|
-
treeChildrenColumnName: "children"
|
|
14012
|
+
treeChildrenColumnName: "children",
|
|
14013
|
+
// compputeds
|
|
14014
|
+
isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
|
|
14015
|
+
isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
|
|
14016
|
+
columns: vue.computed(() => lodash.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
|
|
14017
|
+
leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
|
|
14018
|
+
leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
|
|
14019
|
+
rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
|
|
14020
|
+
leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
|
|
14021
|
+
leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
|
|
14022
|
+
rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
|
|
13957
14023
|
});
|
|
13958
14024
|
}
|
|
13959
14025
|
|
|
@@ -13964,14 +14030,14 @@ class Expand {
|
|
|
13964
14030
|
}
|
|
13965
14031
|
update() {
|
|
13966
14032
|
const store = this.store;
|
|
13967
|
-
const {
|
|
14033
|
+
const { primaryKey, defaultExpandAll } = this.store.table.props;
|
|
13968
14034
|
const { data = [], expandRows } = store.states;
|
|
13969
14035
|
if (defaultExpandAll) {
|
|
13970
14036
|
store.states.expandRows = data.slice();
|
|
13971
|
-
} else if (
|
|
13972
|
-
const expandRowsMap =
|
|
14037
|
+
} else if (primaryKey) {
|
|
14038
|
+
const expandRowsMap = getValuesMap(expandRows, primaryKey);
|
|
13973
14039
|
store.states.expandRows = data.reduce((prev, row) => {
|
|
13974
|
-
const rowId =
|
|
14040
|
+
const rowId = getRowValue(row, primaryKey);
|
|
13975
14041
|
const rowInfo = expandRowsMap[rowId];
|
|
13976
14042
|
if (rowInfo) {
|
|
13977
14043
|
prev.push(row);
|
|
@@ -13993,10 +14059,10 @@ class Expand {
|
|
|
13993
14059
|
}
|
|
13994
14060
|
reset(ids) {
|
|
13995
14061
|
const store = this.store;
|
|
13996
|
-
store.
|
|
13997
|
-
const {
|
|
14062
|
+
store.checkPrimaryKey();
|
|
14063
|
+
const { primaryKey } = store.table.props;
|
|
13998
14064
|
const { data } = store.states;
|
|
13999
|
-
const keysMap =
|
|
14065
|
+
const keysMap = getValuesMap(data, primaryKey);
|
|
14000
14066
|
store.states.expandRows = ids.reduce((prev, cur) => {
|
|
14001
14067
|
const info = keysMap[cur];
|
|
14002
14068
|
if (info) {
|
|
@@ -14006,11 +14072,11 @@ class Expand {
|
|
|
14006
14072
|
}, []);
|
|
14007
14073
|
}
|
|
14008
14074
|
isExpanded(row) {
|
|
14009
|
-
const {
|
|
14075
|
+
const { primaryKey } = this.store.table.props;
|
|
14010
14076
|
const { expandRows = [] } = this.store.states;
|
|
14011
|
-
if (
|
|
14012
|
-
const expandMap =
|
|
14013
|
-
return !!expandMap[
|
|
14077
|
+
if (primaryKey) {
|
|
14078
|
+
const expandMap = getValuesMap(expandRows, primaryKey);
|
|
14079
|
+
return !!expandMap[getRowValue(row, primaryKey)];
|
|
14014
14080
|
}
|
|
14015
14081
|
return expandRows.indexOf(row) !== -1;
|
|
14016
14082
|
}
|
|
@@ -14023,22 +14089,22 @@ class Current {
|
|
|
14023
14089
|
}
|
|
14024
14090
|
reset(id) {
|
|
14025
14091
|
const store = this.store;
|
|
14026
|
-
const {
|
|
14027
|
-
store.
|
|
14092
|
+
const { primaryKey } = store.table.props;
|
|
14093
|
+
store.checkPrimaryKey();
|
|
14028
14094
|
const { data = [] } = store.states;
|
|
14029
|
-
const currentRow = data.find((item) =>
|
|
14095
|
+
const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
|
|
14030
14096
|
store.states.currentRow = currentRow || null;
|
|
14031
14097
|
}
|
|
14032
14098
|
update() {
|
|
14033
14099
|
const store = this.store;
|
|
14034
|
-
const {
|
|
14100
|
+
const { primaryKey } = store.table.props;
|
|
14035
14101
|
const { data = [], currentRow } = store.states;
|
|
14036
14102
|
const oldCurrentRow = currentRow;
|
|
14037
14103
|
if (oldCurrentRow && !data.includes(oldCurrentRow)) {
|
|
14038
14104
|
let newCurrentRow = null;
|
|
14039
|
-
if (
|
|
14105
|
+
if (primaryKey) {
|
|
14040
14106
|
newCurrentRow = data.find((item) => {
|
|
14041
|
-
return
|
|
14107
|
+
return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
|
|
14042
14108
|
});
|
|
14043
14109
|
}
|
|
14044
14110
|
store.states.currentRow = newCurrentRow;
|
|
@@ -14057,8 +14123,8 @@ let Tree$1 = class Tree {
|
|
|
14057
14123
|
* { id: { level, children } }
|
|
14058
14124
|
*/
|
|
14059
14125
|
normalizedData = vue.computed(() => {
|
|
14060
|
-
const {
|
|
14061
|
-
if (!
|
|
14126
|
+
const { primaryKey } = this.store.table.props;
|
|
14127
|
+
if (!primaryKey) return {};
|
|
14062
14128
|
return this.normalize(this.store.states.data || []);
|
|
14063
14129
|
});
|
|
14064
14130
|
/**
|
|
@@ -14066,7 +14132,7 @@ let Tree$1 = class Tree {
|
|
|
14066
14132
|
* { id: { children } }
|
|
14067
14133
|
*/
|
|
14068
14134
|
normalizedLazyNode = vue.computed(() => {
|
|
14069
|
-
const {
|
|
14135
|
+
const { primaryKey } = this.store.table.props;
|
|
14070
14136
|
const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
|
|
14071
14137
|
const keys = Object.keys(treelazyNodeMap);
|
|
14072
14138
|
const res = {};
|
|
@@ -14075,7 +14141,7 @@ let Tree$1 = class Tree {
|
|
|
14075
14141
|
if (treelazyNodeMap[key].length) {
|
|
14076
14142
|
const item = { children: [] };
|
|
14077
14143
|
treelazyNodeMap[key].forEach((row) => {
|
|
14078
|
-
const id =
|
|
14144
|
+
const id = getRowValue(row, primaryKey);
|
|
14079
14145
|
item.children.push(id);
|
|
14080
14146
|
const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
|
|
14081
14147
|
if (hasChildren && !res[id]) {
|
|
@@ -14095,16 +14161,16 @@ let Tree$1 = class Tree {
|
|
|
14095
14161
|
);
|
|
14096
14162
|
}
|
|
14097
14163
|
normalize(data) {
|
|
14098
|
-
const {
|
|
14164
|
+
const { primaryKey } = this.store.table.props;
|
|
14099
14165
|
const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
|
|
14100
14166
|
const res = {};
|
|
14101
14167
|
walkTreeNode(
|
|
14102
14168
|
data,
|
|
14103
14169
|
(parent, children, level) => {
|
|
14104
|
-
const parentId =
|
|
14170
|
+
const parentId = getRowValue(parent, primaryKey);
|
|
14105
14171
|
if (Array.isArray(children)) {
|
|
14106
14172
|
res[parentId] = {
|
|
14107
|
-
children: children.map((row) =>
|
|
14173
|
+
children: children.map((row) => getRowValue(row, primaryKey)),
|
|
14108
14174
|
level
|
|
14109
14175
|
};
|
|
14110
14176
|
} else if (treeLazy) {
|
|
@@ -14124,7 +14190,7 @@ let Tree$1 = class Tree {
|
|
|
14124
14190
|
}
|
|
14125
14191
|
// 获取当前展开最大的level
|
|
14126
14192
|
getMaxLevel() {
|
|
14127
|
-
const {
|
|
14193
|
+
const { primaryKey } = this.store.table.props;
|
|
14128
14194
|
const { data, treeData } = this.store.states;
|
|
14129
14195
|
const levels = data.map((item) => {
|
|
14130
14196
|
const traverse = (source) => {
|
|
@@ -14135,7 +14201,7 @@ let Tree$1 = class Tree {
|
|
|
14135
14201
|
return source.level;
|
|
14136
14202
|
}
|
|
14137
14203
|
};
|
|
14138
|
-
const id =
|
|
14204
|
+
const id = getRowValue(item, primaryKey);
|
|
14139
14205
|
return traverse(treeData[id]);
|
|
14140
14206
|
});
|
|
14141
14207
|
return lodashEs.max(levels) || 0;
|
|
@@ -14197,10 +14263,10 @@ let Tree$1 = class Tree {
|
|
|
14197
14263
|
this.update();
|
|
14198
14264
|
}
|
|
14199
14265
|
toggle(row, expanded) {
|
|
14200
|
-
this.store.
|
|
14201
|
-
const {
|
|
14266
|
+
this.store.checkPrimaryKey();
|
|
14267
|
+
const { primaryKey } = this.store.table.props;
|
|
14202
14268
|
const { treeData } = this.store.states;
|
|
14203
|
-
const id =
|
|
14269
|
+
const id = getRowValue(row, primaryKey);
|
|
14204
14270
|
const data = id && treeData[id];
|
|
14205
14271
|
if (id && data && "expanded" in data) {
|
|
14206
14272
|
const oldExpanded = data.expanded;
|
|
@@ -14213,10 +14279,10 @@ let Tree$1 = class Tree {
|
|
|
14213
14279
|
}
|
|
14214
14280
|
}
|
|
14215
14281
|
loadOrToggle(row) {
|
|
14216
|
-
this.store.
|
|
14217
|
-
const {
|
|
14282
|
+
this.store.checkPrimaryKey();
|
|
14283
|
+
const { primaryKey } = this.store.table.props;
|
|
14218
14284
|
const { treeLazy, treeData } = this.store.states;
|
|
14219
|
-
const id =
|
|
14285
|
+
const id = getRowValue(row, primaryKey);
|
|
14220
14286
|
const data = treeData[id];
|
|
14221
14287
|
if (treeLazy && data && "loaded" in data && !data.loaded) {
|
|
14222
14288
|
this.loadData(row, id, data);
|
|
@@ -14225,9 +14291,9 @@ let Tree$1 = class Tree {
|
|
|
14225
14291
|
}
|
|
14226
14292
|
}
|
|
14227
14293
|
loadData(row, key, treeNode) {
|
|
14228
|
-
this.store.
|
|
14294
|
+
this.store.checkPrimaryKey();
|
|
14229
14295
|
const { table } = this.store;
|
|
14230
|
-
const {
|
|
14296
|
+
const { primaryKey } = table.props;
|
|
14231
14297
|
const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
|
|
14232
14298
|
if (table.props.loadExpand && !treeData[key].loaded) {
|
|
14233
14299
|
this.store.states.treeData[key].loading = true;
|
|
@@ -14242,7 +14308,7 @@ let Tree$1 = class Tree {
|
|
|
14242
14308
|
walkTreeNode(
|
|
14243
14309
|
data,
|
|
14244
14310
|
(parent, _, level) => {
|
|
14245
|
-
const id =
|
|
14311
|
+
const id = getRowValue(parent, primaryKey);
|
|
14246
14312
|
Object.defineProperty(parent, "__KEY__", {
|
|
14247
14313
|
value: `${level}__${id}`,
|
|
14248
14314
|
writable: false
|
|
@@ -14312,27 +14378,13 @@ class Layout {
|
|
|
14312
14378
|
if (!this.store) {
|
|
14313
14379
|
throw new VcError("table", "Table Layout 必须包含store实例");
|
|
14314
14380
|
}
|
|
14315
|
-
this.updateScroller = this.updateScroller.bind(this);
|
|
14316
|
-
this.updateColumns = this.updateColumns.bind(this);
|
|
14317
|
-
vue.onMounted(() => {
|
|
14318
|
-
this.updateColumns();
|
|
14319
|
-
this.updateScroller();
|
|
14320
|
-
});
|
|
14321
|
-
let __updated__;
|
|
14322
|
-
vue.onUpdated(() => {
|
|
14323
|
-
if (__updated__) return;
|
|
14324
|
-
this.updateColumns();
|
|
14325
|
-
this.updateScroller();
|
|
14326
|
-
__updated__ = true;
|
|
14327
|
-
});
|
|
14328
14381
|
}
|
|
14329
14382
|
updateScrollY() {
|
|
14330
14383
|
const { height, bodyHeight } = this.states;
|
|
14331
14384
|
if (height === null || bodyHeight === null) return;
|
|
14332
|
-
const
|
|
14333
|
-
if (this.table.vnode.el &&
|
|
14334
|
-
|
|
14335
|
-
this.states.scrollY = body.offsetHeight > bodyHeight;
|
|
14385
|
+
const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
|
|
14386
|
+
if (this.table.vnode.el && bodyYWrapper) {
|
|
14387
|
+
this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
|
|
14336
14388
|
}
|
|
14337
14389
|
}
|
|
14338
14390
|
setHeight(value, prop = "height") {
|
|
@@ -14349,18 +14401,6 @@ class Layout {
|
|
|
14349
14401
|
setMaxHeight(value) {
|
|
14350
14402
|
this.setHeight(value, "max-height");
|
|
14351
14403
|
}
|
|
14352
|
-
getFlattenColumns() {
|
|
14353
|
-
const flattenColumns = [];
|
|
14354
|
-
const columns = this.store.states.columns;
|
|
14355
|
-
columns.forEach((column) => {
|
|
14356
|
-
if (column.isColumnGroup) {
|
|
14357
|
-
flattenColumns.push(...column.columns);
|
|
14358
|
-
} else {
|
|
14359
|
-
flattenColumns.push(column);
|
|
14360
|
-
}
|
|
14361
|
-
});
|
|
14362
|
-
return flattenColumns;
|
|
14363
|
-
}
|
|
14364
14404
|
updateElsHeight() {
|
|
14365
14405
|
if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
|
|
14366
14406
|
const table = this.table.exposed;
|
|
@@ -14383,13 +14423,12 @@ class Layout {
|
|
|
14383
14423
|
this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
|
14384
14424
|
}
|
|
14385
14425
|
this.updateScrollY();
|
|
14386
|
-
this.updateScroller();
|
|
14387
14426
|
}
|
|
14388
14427
|
updateColumnsWidth() {
|
|
14389
14428
|
if (vcShared.IS_SERVER) return;
|
|
14390
14429
|
const bodyWidth = this.table.vnode.el.clientWidth;
|
|
14391
14430
|
let bodyMinWidth = 0;
|
|
14392
|
-
const flattenColumns = this.
|
|
14431
|
+
const flattenColumns = this.store.states.columns;
|
|
14393
14432
|
const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
|
|
14394
14433
|
const { fit } = this.table.props;
|
|
14395
14434
|
if (flexColumns.length > 0 && fit) {
|
|
@@ -14415,7 +14454,7 @@ class Layout {
|
|
|
14415
14454
|
}
|
|
14416
14455
|
} else {
|
|
14417
14456
|
this.states.scrollX = true;
|
|
14418
|
-
flexColumns.forEach(
|
|
14457
|
+
flexColumns.forEach((column) => {
|
|
14419
14458
|
column.realWidth = column.width || column.minWidth;
|
|
14420
14459
|
});
|
|
14421
14460
|
}
|
|
@@ -14449,12 +14488,6 @@ class Layout {
|
|
|
14449
14488
|
});
|
|
14450
14489
|
this.states.rightFixedWidth = rightFixedWidth;
|
|
14451
14490
|
}
|
|
14452
|
-
this.updateColumns();
|
|
14453
|
-
}
|
|
14454
|
-
// v2.x中的 notifyObservers
|
|
14455
|
-
updateColumns() {
|
|
14456
|
-
}
|
|
14457
|
-
updateScroller() {
|
|
14458
14491
|
}
|
|
14459
14492
|
}
|
|
14460
14493
|
|
|
@@ -14464,7 +14497,7 @@ class Store extends BaseWatcher {
|
|
|
14464
14497
|
expand;
|
|
14465
14498
|
tree;
|
|
14466
14499
|
layout;
|
|
14467
|
-
|
|
14500
|
+
flatData = vue.computed(() => {
|
|
14468
14501
|
if (this.table.props.expandSelectable) {
|
|
14469
14502
|
return lodash.concat(
|
|
14470
14503
|
flattenData(this.states.data, { parent: true, cascader: true }),
|
|
@@ -14495,17 +14528,24 @@ class Store extends BaseWatcher {
|
|
|
14495
14528
|
const dataInstanceChanged = this.states._data !== data;
|
|
14496
14529
|
this.states._data = data;
|
|
14497
14530
|
this.states.data = data;
|
|
14531
|
+
const caches = /* @__PURE__ */ new Map();
|
|
14532
|
+
this.states.list.forEach((item) => {
|
|
14533
|
+
item.rows.forEach((row) => {
|
|
14534
|
+
caches.set(row.data, row);
|
|
14535
|
+
});
|
|
14536
|
+
});
|
|
14498
14537
|
this.states.list = data.reduce((pre, row, index) => {
|
|
14538
|
+
const cache = caches.get(row) || { heightMap: {} };
|
|
14499
14539
|
pre.push({
|
|
14500
14540
|
rows: [
|
|
14501
14541
|
{
|
|
14502
14542
|
index,
|
|
14503
14543
|
data: row,
|
|
14504
|
-
height: "",
|
|
14544
|
+
height: cache.height || "",
|
|
14505
14545
|
heightMap: {
|
|
14506
|
-
left: "",
|
|
14507
|
-
main: "",
|
|
14508
|
-
right: ""
|
|
14546
|
+
left: cache.heightMap.left || "",
|
|
14547
|
+
main: cache.heightMap.main || "",
|
|
14548
|
+
right: cache.heightMap.right || ""
|
|
14509
14549
|
}
|
|
14510
14550
|
}
|
|
14511
14551
|
],
|
|
@@ -14513,6 +14553,7 @@ class Store extends BaseWatcher {
|
|
|
14513
14553
|
});
|
|
14514
14554
|
return pre;
|
|
14515
14555
|
}, []);
|
|
14556
|
+
caches.clear();
|
|
14516
14557
|
this.current.update();
|
|
14517
14558
|
this.expand.update();
|
|
14518
14559
|
if (!this.states.reserveSelection) {
|
|
@@ -14522,7 +14563,7 @@ class Store extends BaseWatcher {
|
|
|
14522
14563
|
this.cleanSelection();
|
|
14523
14564
|
}
|
|
14524
14565
|
} else {
|
|
14525
|
-
this.
|
|
14566
|
+
this.checkPrimaryKey();
|
|
14526
14567
|
this.updateSelectionByRowKey();
|
|
14527
14568
|
}
|
|
14528
14569
|
this.updateAllSelected();
|
|
@@ -14544,10 +14585,10 @@ class Store extends BaseWatcher {
|
|
|
14544
14585
|
}
|
|
14545
14586
|
}
|
|
14546
14587
|
/**
|
|
14547
|
-
* 检查
|
|
14588
|
+
* 检查 primaryKey 是否存在
|
|
14548
14589
|
*/
|
|
14549
|
-
|
|
14550
|
-
const {
|
|
14590
|
+
checkPrimaryKey() {
|
|
14591
|
+
const { primaryKey } = this.table.props;
|
|
14551
14592
|
}
|
|
14552
14593
|
/**
|
|
14553
14594
|
* states
|
|
@@ -14608,22 +14649,20 @@ class Store extends BaseWatcher {
|
|
|
14608
14649
|
updateColumns() {
|
|
14609
14650
|
const { states } = this;
|
|
14610
14651
|
const _columns = states._columns || [];
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
if (
|
|
14652
|
+
const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
14653
|
+
const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
|
|
14654
|
+
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
14614
14655
|
_columns[0].fixed = true;
|
|
14615
|
-
|
|
14656
|
+
leftFixedColumns.unshift(_columns[0]);
|
|
14616
14657
|
}
|
|
14617
14658
|
const notFixedColumns = _columns.filter((column) => !column.fixed);
|
|
14618
|
-
|
|
14619
|
-
const
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
states.
|
|
14623
|
-
states.
|
|
14624
|
-
states.
|
|
14625
|
-
states.columns = lodash.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
|
|
14626
|
-
states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
|
14659
|
+
const originColumns = lodash.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
14660
|
+
const headerRows = columnsToRowsEffect(originColumns);
|
|
14661
|
+
states.leftFixedColumns = leftFixedColumns;
|
|
14662
|
+
states.notFixedColumns = notFixedColumns;
|
|
14663
|
+
states.rightFixedColumns = rightFixedColumns;
|
|
14664
|
+
states.originColumns = originColumns;
|
|
14665
|
+
states.headerRows = headerRows;
|
|
14627
14666
|
}
|
|
14628
14667
|
// 选择
|
|
14629
14668
|
isSelected(row) {
|
|
@@ -14647,13 +14686,13 @@ class Store extends BaseWatcher {
|
|
|
14647
14686
|
* 清理选择
|
|
14648
14687
|
*/
|
|
14649
14688
|
cleanSelection() {
|
|
14650
|
-
const {
|
|
14651
|
-
const { selection = [] } = this.states;
|
|
14689
|
+
const { primaryKey } = this.table.props;
|
|
14690
|
+
const { selection = [], data } = this.states;
|
|
14652
14691
|
let deleted;
|
|
14653
|
-
if (
|
|
14692
|
+
if (primaryKey) {
|
|
14654
14693
|
deleted = [];
|
|
14655
|
-
const selectedMap =
|
|
14656
|
-
const dataMap =
|
|
14694
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14695
|
+
const dataMap = getValuesMap(data, primaryKey);
|
|
14657
14696
|
for (const key in selectedMap) {
|
|
14658
14697
|
if (Utils.hasOwn(selectedMap, key) && !dataMap[key]) {
|
|
14659
14698
|
deleted.push(selectedMap[key].row);
|
|
@@ -14661,7 +14700,7 @@ class Store extends BaseWatcher {
|
|
|
14661
14700
|
}
|
|
14662
14701
|
} else {
|
|
14663
14702
|
deleted = selection.filter((item) => {
|
|
14664
|
-
return !this.
|
|
14703
|
+
return !this.flatData.value.includes(item);
|
|
14665
14704
|
});
|
|
14666
14705
|
}
|
|
14667
14706
|
deleted.forEach((deletedItem) => {
|
|
@@ -14722,7 +14761,7 @@ class Store extends BaseWatcher {
|
|
|
14722
14761
|
const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
|
|
14723
14762
|
this.states.isAllSelected = value;
|
|
14724
14763
|
let selectionChanged = false;
|
|
14725
|
-
this.
|
|
14764
|
+
this.flatData.value.forEach((row, index) => {
|
|
14726
14765
|
if (selectable) {
|
|
14727
14766
|
if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
|
|
14728
14767
|
selectionChanged = true;
|
|
@@ -14753,11 +14792,11 @@ class Store extends BaseWatcher {
|
|
|
14753
14792
|
this.tree.expand(val);
|
|
14754
14793
|
}
|
|
14755
14794
|
updateSelectionByRowKey() {
|
|
14756
|
-
const {
|
|
14795
|
+
const { primaryKey } = this.table.props;
|
|
14757
14796
|
const { selection } = this.states;
|
|
14758
|
-
const selectedMap =
|
|
14759
|
-
this.states.selection = this.
|
|
14760
|
-
const rowId =
|
|
14797
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
14798
|
+
this.states.selection = this.flatData.value.reduce((prev, row) => {
|
|
14799
|
+
const rowId = getRowValue(row, primaryKey);
|
|
14761
14800
|
const rowInfo = selectedMap[rowId];
|
|
14762
14801
|
if (rowInfo) {
|
|
14763
14802
|
prev.push(row);
|
|
@@ -14773,7 +14812,7 @@ class Store extends BaseWatcher {
|
|
|
14773
14812
|
}
|
|
14774
14813
|
let isAllSelected = true;
|
|
14775
14814
|
let selectedCount = 0;
|
|
14776
|
-
const temp = this.
|
|
14815
|
+
const temp = this.flatData.value;
|
|
14777
14816
|
for (let i = 0, j = temp.length; i < j; i++) {
|
|
14778
14817
|
const row = temp[i];
|
|
14779
14818
|
const isRowSelectable = selectable && selectable.call(null, row, i);
|
|
@@ -14828,8 +14867,10 @@ const COMPONENT_NAME$h = 'vc-table-normal-list';
|
|
|
14828
14867
|
const NormalList = /* @__PURE__ */ vue.defineComponent({
|
|
14829
14868
|
name: COMPONENT_NAME$h,
|
|
14830
14869
|
props: {
|
|
14831
|
-
data:
|
|
14832
|
-
|
|
14870
|
+
data: {
|
|
14871
|
+
type: Array,
|
|
14872
|
+
default: () => []
|
|
14873
|
+
}
|
|
14833
14874
|
},
|
|
14834
14875
|
emits: ['row-resize'],
|
|
14835
14876
|
setup(props, {
|
|
@@ -14871,7 +14912,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
14871
14912
|
expose
|
|
14872
14913
|
}) {
|
|
14873
14914
|
const instance = vue.getCurrentInstance();
|
|
14874
|
-
const table =
|
|
14915
|
+
const table = vue.inject('vc-table');
|
|
14875
14916
|
const states = useStates({
|
|
14876
14917
|
data: 'data',
|
|
14877
14918
|
list: 'list',
|
|
@@ -14888,6 +14929,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
14888
14929
|
type
|
|
14889
14930
|
}) => type === 'default')
|
|
14890
14931
|
});
|
|
14932
|
+
const wrapper = vue.ref();
|
|
14891
14933
|
vue.watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
|
|
14892
14934
|
if (!props.store.states.isComplex || vcShared.IS_SERVER) return;
|
|
14893
14935
|
Utils.raf(() => {
|
|
@@ -14898,12 +14940,12 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
14898
14940
|
newRow && $.addClass(newRow, 'hover-row');
|
|
14899
14941
|
});
|
|
14900
14942
|
});
|
|
14901
|
-
const
|
|
14943
|
+
const getValueOfRow = (row, index) => {
|
|
14902
14944
|
const {
|
|
14903
|
-
|
|
14945
|
+
primaryKey
|
|
14904
14946
|
} = table.props;
|
|
14905
|
-
if (
|
|
14906
|
-
return
|
|
14947
|
+
if (primaryKey) {
|
|
14948
|
+
return getRowValue(row, primaryKey);
|
|
14907
14949
|
}
|
|
14908
14950
|
return index;
|
|
14909
14951
|
};
|
|
@@ -14968,7 +15010,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
14968
15010
|
return cellStyle;
|
|
14969
15011
|
};
|
|
14970
15012
|
const getCellClass = (rowIndex, columnIndex, row, column) => {
|
|
14971
|
-
const classes = [column.
|
|
15013
|
+
const classes = [column.realAlign, column.className];
|
|
14972
15014
|
if (isColumnHidden(columnIndex)) {
|
|
14973
15015
|
classes.push('is-hidden');
|
|
14974
15016
|
}
|
|
@@ -14994,7 +15036,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
14994
15036
|
column,
|
|
14995
15037
|
row
|
|
14996
15038
|
};
|
|
14997
|
-
table.
|
|
15039
|
+
table.hoverState.value = hoverState;
|
|
14998
15040
|
table.emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, e);
|
|
14999
15041
|
}
|
|
15000
15042
|
|
|
@@ -15027,8 +15069,8 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15027
15069
|
const handleCellMouseLeave = e => {
|
|
15028
15070
|
const cell = getCell(e);
|
|
15029
15071
|
if (!cell) return;
|
|
15030
|
-
const oldHoverState = table.
|
|
15031
|
-
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell,
|
|
15072
|
+
const oldHoverState = table.hoverState.value || {};
|
|
15073
|
+
table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
|
|
15032
15074
|
};
|
|
15033
15075
|
const handleMouseEnter = lodashEs.debounce(index => {
|
|
15034
15076
|
props.store.setHoverRow(index);
|
|
@@ -15064,7 +15106,8 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15064
15106
|
const {
|
|
15065
15107
|
columns
|
|
15066
15108
|
} = states;
|
|
15067
|
-
const key =
|
|
15109
|
+
const key = getValueOfRow(row, rowIndex);
|
|
15110
|
+
const selected = props.store.isSelected(row);
|
|
15068
15111
|
return vue.createVNode("div", {
|
|
15069
15112
|
"key": key,
|
|
15070
15113
|
"class": [getRowClass(row, rowIndex), 'vc-table__tr'],
|
|
@@ -15085,10 +15128,12 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15085
15128
|
};
|
|
15086
15129
|
if (columnsHidden.value[columnIndex]) {
|
|
15087
15130
|
return vue.createVNode("div", {
|
|
15131
|
+
"key": column.id,
|
|
15088
15132
|
"style": [sizeStyle]
|
|
15089
15133
|
}, null);
|
|
15090
15134
|
}
|
|
15091
15135
|
return vue.createVNode("div", {
|
|
15136
|
+
"key": column.id,
|
|
15092
15137
|
"style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
|
|
15093
15138
|
"class": [getCellClass(rowIndex, columnIndex, row, column), 'vc-table__td'],
|
|
15094
15139
|
"onMouseenter": e => handleCellMouseEnter(e, row),
|
|
@@ -15098,7 +15143,8 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15098
15143
|
column,
|
|
15099
15144
|
rowIndex,
|
|
15100
15145
|
columnIndex,
|
|
15101
|
-
store: props.store
|
|
15146
|
+
store: props.store,
|
|
15147
|
+
selected
|
|
15102
15148
|
})]);
|
|
15103
15149
|
})]);
|
|
15104
15150
|
};
|
|
@@ -15128,13 +15174,12 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15128
15174
|
}
|
|
15129
15175
|
});
|
|
15130
15176
|
};
|
|
15131
|
-
const wrapper = vue.ref();
|
|
15132
15177
|
expose({
|
|
15133
15178
|
wrapper,
|
|
15134
15179
|
getRootElement: () => instance.vnode.el
|
|
15135
15180
|
});
|
|
15181
|
+
const layout = table.layout;
|
|
15136
15182
|
return () => {
|
|
15137
|
-
const layout = table.exposed.layout;
|
|
15138
15183
|
return vue.createVNode("div", {
|
|
15139
15184
|
"class": "vc-table__body"
|
|
15140
15185
|
}, [table.props.height ? vue.createVNode(RecycleList, {
|
|
@@ -15143,7 +15188,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15143
15188
|
"disabled": true,
|
|
15144
15189
|
"class": "vc-table__tbody",
|
|
15145
15190
|
"scrollerOptions": {
|
|
15146
|
-
barTo: `.${table.
|
|
15191
|
+
barTo: `.${table.tableId}`,
|
|
15147
15192
|
native: false,
|
|
15148
15193
|
always: false,
|
|
15149
15194
|
showBar: !props.fixed,
|
|
@@ -15179,57 +15224,6 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
|
|
|
15179
15224
|
|
|
15180
15225
|
const TableSort = 'div';
|
|
15181
15226
|
const TableFilter = 'div';
|
|
15182
|
-
const getAllColumns = columns => {
|
|
15183
|
-
const result = [];
|
|
15184
|
-
columns.forEach(column => {
|
|
15185
|
-
if (column.children) {
|
|
15186
|
-
result.push(column);
|
|
15187
|
-
result.push(...getAllColumns(column.children));
|
|
15188
|
-
} else {
|
|
15189
|
-
result.push(column);
|
|
15190
|
-
}
|
|
15191
|
-
});
|
|
15192
|
-
return result;
|
|
15193
|
-
};
|
|
15194
|
-
const convertToRows = originColumns => {
|
|
15195
|
-
let maxLevel = 1;
|
|
15196
|
-
const traverse = (column, parent) => {
|
|
15197
|
-
if (parent) {
|
|
15198
|
-
column.level = parent.level + 1;
|
|
15199
|
-
if (maxLevel < column.level) {
|
|
15200
|
-
maxLevel = column.level;
|
|
15201
|
-
}
|
|
15202
|
-
}
|
|
15203
|
-
if (column.children) {
|
|
15204
|
-
let colSpan = 0;
|
|
15205
|
-
column.children.forEach(subColumn => {
|
|
15206
|
-
traverse(subColumn, column);
|
|
15207
|
-
colSpan += subColumn.colSpan;
|
|
15208
|
-
});
|
|
15209
|
-
column.colSpan = colSpan;
|
|
15210
|
-
} else {
|
|
15211
|
-
column.colSpan = 1;
|
|
15212
|
-
}
|
|
15213
|
-
};
|
|
15214
|
-
originColumns.forEach(column => {
|
|
15215
|
-
column.level = 1;
|
|
15216
|
-
traverse(column);
|
|
15217
|
-
});
|
|
15218
|
-
const rows = [];
|
|
15219
|
-
for (let i = 0; i < maxLevel; i++) {
|
|
15220
|
-
rows.push([]);
|
|
15221
|
-
}
|
|
15222
|
-
const allColumns = getAllColumns(originColumns);
|
|
15223
|
-
allColumns.forEach(column => {
|
|
15224
|
-
if (!column.children) {
|
|
15225
|
-
column.rowSpan = maxLevel - column.level + 1;
|
|
15226
|
-
} else {
|
|
15227
|
-
column.rowSpan = 1;
|
|
15228
|
-
}
|
|
15229
|
-
rows[column.level - 1].push(column);
|
|
15230
|
-
});
|
|
15231
|
-
return rows;
|
|
15232
|
-
};
|
|
15233
15227
|
const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
15234
15228
|
name: 'vc-table-header',
|
|
15235
15229
|
props: {
|
|
@@ -15246,7 +15240,7 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15246
15240
|
}
|
|
15247
15241
|
},
|
|
15248
15242
|
setup(props) {
|
|
15249
|
-
const table =
|
|
15243
|
+
const table = vue.inject('vc-table');
|
|
15250
15244
|
const instance = vue.getCurrentInstance();
|
|
15251
15245
|
const draggingColumn = vue.ref(null);
|
|
15252
15246
|
const dragging = vue.ref(false);
|
|
@@ -15256,16 +15250,18 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15256
15250
|
isAllSelected: 'isAllSelected',
|
|
15257
15251
|
leftFixedLeafCount: 'leftFixedLeafColumnsLength',
|
|
15258
15252
|
rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
|
15253
|
+
isGroup: 'isGroup',
|
|
15254
|
+
headerRows: 'headerRows',
|
|
15259
15255
|
columnsCount: $states => $states.columns.length,
|
|
15260
15256
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15261
15257
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15262
15258
|
});
|
|
15263
|
-
const
|
|
15259
|
+
const isColumnHidden = index => {
|
|
15264
15260
|
let start = 0;
|
|
15265
15261
|
for (let i = 0; i < index; i++) {
|
|
15266
|
-
start += columns[i].colSpan;
|
|
15262
|
+
start += states.columns[i].colSpan;
|
|
15267
15263
|
}
|
|
15268
|
-
const after = start + columns[index].colSpan - 1;
|
|
15264
|
+
const after = start + states.columns[index].colSpan - 1;
|
|
15269
15265
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15270
15266
|
return after >= states.leftFixedLeafCount;
|
|
15271
15267
|
} else if (props.fixed === 'right') {
|
|
@@ -15274,6 +15270,9 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15274
15270
|
return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
|
|
15275
15271
|
}
|
|
15276
15272
|
};
|
|
15273
|
+
const columnsHidden = vue.computed(() => {
|
|
15274
|
+
return states.columns.map((_, index) => isColumnHidden(index));
|
|
15275
|
+
});
|
|
15277
15276
|
const getHeaderRowStyle = rowIndex => {
|
|
15278
15277
|
const {
|
|
15279
15278
|
headerRowStyle
|
|
@@ -15314,8 +15313,8 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15314
15313
|
return headerCellStyle;
|
|
15315
15314
|
};
|
|
15316
15315
|
const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
|
|
15317
|
-
const classes = [column.id, column.order, column.
|
|
15318
|
-
if (rowIndex === 0 &&
|
|
15316
|
+
const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
|
|
15317
|
+
if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
|
|
15319
15318
|
classes.push('is-hidden');
|
|
15320
15319
|
}
|
|
15321
15320
|
if (!column.children) {
|
|
@@ -15348,7 +15347,7 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15348
15347
|
/* istanbul ignore if */
|
|
15349
15348
|
if (draggingColumn.value && props.border) {
|
|
15350
15349
|
dragging.value = true;
|
|
15351
|
-
table.
|
|
15350
|
+
table.resizeProxyVisible.value = true;
|
|
15352
15351
|
const tableEl = table.vnode.el;
|
|
15353
15352
|
const tableLeft = tableEl.getBoundingClientRect().left;
|
|
15354
15353
|
const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
|
|
@@ -15361,7 +15360,7 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15361
15360
|
startColumnLeft: columnRect.left - tableLeft,
|
|
15362
15361
|
tableLeft
|
|
15363
15362
|
};
|
|
15364
|
-
const resizeProxy = table.
|
|
15363
|
+
const resizeProxy = table.resizeProxy.value;
|
|
15365
15364
|
resizeProxy.style.left = dragState.value.startLeft + 'px';
|
|
15366
15365
|
document.onselectstart = () => false;
|
|
15367
15366
|
document.ondragstart = () => false;
|
|
@@ -15455,37 +15454,27 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15455
15454
|
});
|
|
15456
15455
|
};
|
|
15457
15456
|
return () => {
|
|
15458
|
-
const {
|
|
15459
|
-
originColumns
|
|
15460
|
-
} = props.store.states;
|
|
15461
|
-
const columnRows = convertToRows(originColumns);
|
|
15462
|
-
|
|
15463
|
-
// 是否拥有多级表头
|
|
15464
|
-
const isGroup = columnRows.length > 1;
|
|
15465
|
-
if (isGroup) table.exposed.isGroup.value = true;
|
|
15466
15457
|
return vue.createVNode("div", {
|
|
15467
15458
|
"class": "vc-table__header"
|
|
15468
15459
|
}, [vue.createVNode("div", {
|
|
15469
15460
|
"class": [{
|
|
15470
|
-
'is-group': isGroup
|
|
15461
|
+
'is-group': states.isGroup
|
|
15471
15462
|
}, 'vc-table__thead']
|
|
15472
15463
|
}, [
|
|
15473
15464
|
// renderList
|
|
15474
|
-
|
|
15465
|
+
states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
|
|
15475
15466
|
"style": getHeaderRowStyle(rowIndex),
|
|
15476
15467
|
"class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
|
|
15477
|
-
}, [columns.map((column,
|
|
15478
|
-
"
|
|
15479
|
-
"rowspan": column.rowSpan,
|
|
15480
|
-
"onMousemove": $event => handleMouseMove($event, column),
|
|
15468
|
+
}, [columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
15469
|
+
"onMousemove": e => handleMouseMove(e, column),
|
|
15481
15470
|
"onMouseout": handleMouseOut,
|
|
15482
|
-
"onMousedown":
|
|
15483
|
-
"onClick":
|
|
15484
|
-
"onContextmenu":
|
|
15485
|
-
"style": [getHeaderCellStyle(rowIndex,
|
|
15471
|
+
"onMousedown": e => handleMouseDown(e, column),
|
|
15472
|
+
"onClick": e => handleHeaderClick(e, column),
|
|
15473
|
+
"onContextmenu": e => handleHeaderContextMenu(e, column),
|
|
15474
|
+
"style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
|
|
15486
15475
|
width: `${column.realWidth}px`
|
|
15487
15476
|
}],
|
|
15488
|
-
"class": [getHeaderCellClass(rowIndex,
|
|
15477
|
+
"class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
|
|
15489
15478
|
"key": column.id
|
|
15490
15479
|
}, [vue.createVNode("div", {
|
|
15491
15480
|
"class": ['vc-table__cell',
|
|
@@ -15495,10 +15484,8 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
|
15495
15484
|
column.labelClass]
|
|
15496
15485
|
}, [column.renderHeader ? column.renderHeader({
|
|
15497
15486
|
column,
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
store: props.store,
|
|
15501
|
-
_self: instance
|
|
15487
|
+
columnIndex,
|
|
15488
|
+
store: props.store
|
|
15502
15489
|
}) : column.label, column.tooltip ? vue.createVNode(Icon, {
|
|
15503
15490
|
"type": "o-info",
|
|
15504
15491
|
"onMouseenter": e => handleCellMouseEnter(e, column)
|
|
@@ -15540,28 +15527,28 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
|
|
|
15540
15527
|
leftFixedCount: $states => $states.leftFixedColumns.length,
|
|
15541
15528
|
rightFixedCount: $states => $states.rightFixedColumns.length
|
|
15542
15529
|
});
|
|
15543
|
-
const
|
|
15530
|
+
const isColumnHidden = (column, index) => {
|
|
15544
15531
|
if (props.fixed === true || props.fixed === 'left') {
|
|
15545
15532
|
return index >= states.leftFixedLeafCount;
|
|
15546
15533
|
} else if (props.fixed === 'right') {
|
|
15547
15534
|
let before = 0;
|
|
15548
15535
|
for (let i = 0; i < index; i++) {
|
|
15549
|
-
before += columns[i].colSpan;
|
|
15536
|
+
before += states.columns[i].colSpan;
|
|
15550
15537
|
}
|
|
15551
15538
|
return before < states.columnsCount - states.rightFixedLeafCount;
|
|
15552
15539
|
} else if (!props.fixed && column.fixed) {
|
|
15553
|
-
// hide cell when footer instance is not fixed and column is fixed
|
|
15554
15540
|
return true;
|
|
15555
15541
|
} else {
|
|
15556
15542
|
return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
|
|
15557
15543
|
}
|
|
15558
15544
|
};
|
|
15559
|
-
const
|
|
15560
|
-
|
|
15545
|
+
const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
|
|
15546
|
+
const getRowClasses = (column, columnIndex) => {
|
|
15547
|
+
const classes = [column.realAlign, column.labelClass];
|
|
15561
15548
|
if (column.className) {
|
|
15562
15549
|
classes.push(column.className);
|
|
15563
15550
|
}
|
|
15564
|
-
if (
|
|
15551
|
+
if (columnsHidden.value[columnIndex]) {
|
|
15565
15552
|
classes.push('is-hidden');
|
|
15566
15553
|
}
|
|
15567
15554
|
if (!column.children) {
|
|
@@ -15569,17 +15556,17 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
|
|
|
15569
15556
|
}
|
|
15570
15557
|
return classes;
|
|
15571
15558
|
};
|
|
15572
|
-
|
|
15573
|
-
let
|
|
15559
|
+
const sums = vue.computed(() => {
|
|
15560
|
+
let v = [];
|
|
15574
15561
|
if (props.getSummary) {
|
|
15575
|
-
|
|
15562
|
+
v = props.getSummary({
|
|
15576
15563
|
columns: states.columns,
|
|
15577
15564
|
data: states.data
|
|
15578
15565
|
});
|
|
15579
15566
|
} else {
|
|
15580
15567
|
states.columns.forEach((column, index) => {
|
|
15581
15568
|
if (index === 0) {
|
|
15582
|
-
|
|
15569
|
+
v[index] = props.sumText;
|
|
15583
15570
|
return;
|
|
15584
15571
|
}
|
|
15585
15572
|
const values = states.data.map(item => Number(item[column.prop]));
|
|
@@ -15594,7 +15581,7 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
|
|
|
15594
15581
|
});
|
|
15595
15582
|
const precision = Math.max.apply(null, precisions);
|
|
15596
15583
|
if (!notNumber) {
|
|
15597
|
-
|
|
15584
|
+
v[index] = values.reduce((prev, curr) => {
|
|
15598
15585
|
const value = Number(curr);
|
|
15599
15586
|
if (!isNaN(value)) {
|
|
15600
15587
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -15603,10 +15590,13 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
|
|
|
15603
15590
|
}
|
|
15604
15591
|
}, 0);
|
|
15605
15592
|
} else {
|
|
15606
|
-
|
|
15593
|
+
v[index] = '';
|
|
15607
15594
|
}
|
|
15608
15595
|
});
|
|
15609
15596
|
}
|
|
15597
|
+
return v;
|
|
15598
|
+
});
|
|
15599
|
+
return () => {
|
|
15610
15600
|
return vue.createVNode("div", {
|
|
15611
15601
|
"class": "vc-table__footer",
|
|
15612
15602
|
"cellspacing": "0",
|
|
@@ -15616,17 +15606,15 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
|
|
|
15616
15606
|
"class": "vc-table__tbody"
|
|
15617
15607
|
}, [vue.createVNode("div", {
|
|
15618
15608
|
"class": "vc-table__tr"
|
|
15619
|
-
}, [states.columns.map((column,
|
|
15620
|
-
"key":
|
|
15621
|
-
"
|
|
15622
|
-
"rowspan": column.rowSpan,
|
|
15623
|
-
"class": [getRowClasses(column, cellIndex), 'vc-table__td'],
|
|
15609
|
+
}, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
15610
|
+
"key": columnIndex,
|
|
15611
|
+
"class": [getRowClasses(column, columnIndex), 'vc-table__td'],
|
|
15624
15612
|
"style": [{
|
|
15625
15613
|
width: `${column.realWidth}px`
|
|
15626
15614
|
}]
|
|
15627
15615
|
}, [vue.createVNode("div", {
|
|
15628
15616
|
"class": ['vc-table__cell', column.labelClass]
|
|
15629
|
-
}, [sums[
|
|
15617
|
+
}, [sums.value[columnIndex]])]))])])]);
|
|
15630
15618
|
};
|
|
15631
15619
|
}
|
|
15632
15620
|
});
|
|
@@ -15654,7 +15642,7 @@ const props$c = {
|
|
|
15654
15642
|
type: Number,
|
|
15655
15643
|
default: 10
|
|
15656
15644
|
},
|
|
15657
|
-
|
|
15645
|
+
primaryKey: [String, Function],
|
|
15658
15646
|
// 是否显示表头
|
|
15659
15647
|
showHeader: {
|
|
15660
15648
|
type: Boolean,
|
|
@@ -15731,7 +15719,8 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
15731
15719
|
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'],
|
|
15732
15720
|
setup(props, {
|
|
15733
15721
|
slots,
|
|
15734
|
-
expose
|
|
15722
|
+
expose,
|
|
15723
|
+
emit
|
|
15735
15724
|
}) {
|
|
15736
15725
|
const instance = vue.getCurrentInstance();
|
|
15737
15726
|
const store = new Store({
|
|
@@ -15771,23 +15760,21 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
15771
15760
|
const rightFixedBody = vue.ref(null);
|
|
15772
15761
|
const rightFixedFooterWrapper = vue.ref(null);
|
|
15773
15762
|
const resizeProxy = vue.ref(null);
|
|
15774
|
-
|
|
15775
|
-
// 是否拥有多级表头, 由table-header控制
|
|
15776
|
-
const isGroup = vue.ref(false);
|
|
15777
15763
|
const scrollPosition = vue.ref('left');
|
|
15778
15764
|
const hoverState = vue.ref(null);
|
|
15779
15765
|
const isReady = vue.ref(false);
|
|
15780
15766
|
const states = useStates({
|
|
15781
15767
|
columns: 'columns',
|
|
15782
15768
|
leftFixedColumns: 'leftFixedColumns',
|
|
15783
|
-
rightFixedColumns: 'rightFixedColumns'
|
|
15769
|
+
rightFixedColumns: 'rightFixedColumns',
|
|
15770
|
+
isGroup: 'isGroup'
|
|
15784
15771
|
}, store);
|
|
15785
15772
|
const classes = vue.computed(() => {
|
|
15786
15773
|
return {
|
|
15787
15774
|
'vc-table--fit': props.fit,
|
|
15788
15775
|
'vc-table--striped': props.stripe,
|
|
15789
|
-
'vc-table--border': props.border || isGroup
|
|
15790
|
-
'vc-table--group': isGroup
|
|
15776
|
+
'vc-table--border': props.border || states.isGroup,
|
|
15777
|
+
'vc-table--group': states.isGroup,
|
|
15791
15778
|
'vc-table--fluid-height': props.maxHeight,
|
|
15792
15779
|
'vc-table--scrollable-x': layout.states.scrollX,
|
|
15793
15780
|
'vc-table--scrollable-y': layout.states.scrollY,
|
|
@@ -16048,13 +16035,13 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
16048
16035
|
immediate: true
|
|
16049
16036
|
});
|
|
16050
16037
|
vue.watch(() => props.currentRowValue, v => {
|
|
16051
|
-
if (!props.
|
|
16038
|
+
if (!props.primaryKey) return;
|
|
16052
16039
|
store.current.reset(v);
|
|
16053
16040
|
}, {
|
|
16054
16041
|
immediate: true
|
|
16055
16042
|
});
|
|
16056
|
-
vue.watch(() => props.data,
|
|
16057
|
-
store.setData(
|
|
16043
|
+
vue.watch(() => [props.data, props.data.length], () => {
|
|
16044
|
+
store.setData(props.data);
|
|
16058
16045
|
isReady.value && vue.nextTick(refreshLayout);
|
|
16059
16046
|
}, {
|
|
16060
16047
|
immediate: true
|
|
@@ -16077,6 +16064,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
16077
16064
|
}, {
|
|
16078
16065
|
immediate: true
|
|
16079
16066
|
});
|
|
16067
|
+
const tableId = Utils.getUid('table');
|
|
16080
16068
|
vue.onMounted(() => {
|
|
16081
16069
|
bindEvents();
|
|
16082
16070
|
store.updateColumns();
|
|
@@ -16087,12 +16075,13 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
16087
16075
|
};
|
|
16088
16076
|
isReady.value = true;
|
|
16089
16077
|
});
|
|
16090
|
-
vue.
|
|
16078
|
+
vue.onUnmounted(() => {
|
|
16091
16079
|
isUnMount = true;
|
|
16092
16080
|
unbindEvents();
|
|
16093
16081
|
});
|
|
16094
|
-
const
|
|
16095
|
-
|
|
16082
|
+
const exposed = {
|
|
16083
|
+
bodyXWrapper,
|
|
16084
|
+
bodyYWrapper,
|
|
16096
16085
|
tableId,
|
|
16097
16086
|
store,
|
|
16098
16087
|
layout,
|
|
@@ -16112,8 +16101,12 @@ const Table = /* @__PURE__ */ vue.defineComponent({
|
|
|
16112
16101
|
isReady,
|
|
16113
16102
|
hoverState,
|
|
16114
16103
|
renderExpanded,
|
|
16115
|
-
hiddenColumns
|
|
16116
|
-
|
|
16104
|
+
hiddenColumns,
|
|
16105
|
+
props,
|
|
16106
|
+
emit
|
|
16107
|
+
};
|
|
16108
|
+
expose(exposed);
|
|
16109
|
+
vue.provide('vc-table', exposed);
|
|
16117
16110
|
return () => {
|
|
16118
16111
|
return vue.createVNode("div", {
|
|
16119
16112
|
"class": [classes.value, tableId, 'vc-table'],
|
|
@@ -16262,22 +16255,19 @@ const cellStarts = {
|
|
|
16262
16255
|
order: ''
|
|
16263
16256
|
},
|
|
16264
16257
|
selection: {
|
|
16265
|
-
width:
|
|
16266
|
-
minWidth:
|
|
16267
|
-
realWidth: 48,
|
|
16258
|
+
width: 60,
|
|
16259
|
+
minWidth: 60,
|
|
16268
16260
|
order: '',
|
|
16269
16261
|
className: 'vc-table-column--selection'
|
|
16270
16262
|
},
|
|
16271
16263
|
expand: {
|
|
16272
|
-
width:
|
|
16273
|
-
minWidth:
|
|
16274
|
-
realWidth: 48,
|
|
16264
|
+
width: 60,
|
|
16265
|
+
minWidth: 60,
|
|
16275
16266
|
order: ''
|
|
16276
16267
|
},
|
|
16277
16268
|
index: {
|
|
16278
|
-
width:
|
|
16279
|
-
minWidth:
|
|
16280
|
-
realWidth: 48,
|
|
16269
|
+
width: 60,
|
|
16270
|
+
minWidth: 60,
|
|
16281
16271
|
order: ''
|
|
16282
16272
|
}
|
|
16283
16273
|
};
|
|
@@ -16303,10 +16293,11 @@ const cellForced = {
|
|
|
16303
16293
|
column,
|
|
16304
16294
|
store,
|
|
16305
16295
|
rowIndex,
|
|
16306
|
-
level
|
|
16296
|
+
level,
|
|
16297
|
+
selected
|
|
16307
16298
|
}) {
|
|
16308
16299
|
return vue.withDirectives(vue.createVNode(Checkbox, {
|
|
16309
|
-
"modelValue":
|
|
16300
|
+
"modelValue": selected,
|
|
16310
16301
|
"disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
|
|
16311
16302
|
"onChange": () => store.rowSelectedChanged(row),
|
|
16312
16303
|
"onClick": e => e.stopPropagation()
|
|
@@ -16444,8 +16435,8 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16444
16435
|
customClass: String,
|
|
16445
16436
|
labelClass: String,
|
|
16446
16437
|
prop: String,
|
|
16447
|
-
width:
|
|
16448
|
-
minWidth:
|
|
16438
|
+
width: Number,
|
|
16439
|
+
minWidth: Number,
|
|
16449
16440
|
renderHeader: Function,
|
|
16450
16441
|
resizable: {
|
|
16451
16442
|
type: Boolean,
|
|
@@ -16479,15 +16470,14 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16479
16470
|
tooltip: [String, Function]
|
|
16480
16471
|
},
|
|
16481
16472
|
setup(props, {
|
|
16482
|
-
slots
|
|
16483
|
-
expose
|
|
16473
|
+
slots
|
|
16484
16474
|
}) {
|
|
16485
16475
|
const instance = vue.getCurrentInstance();
|
|
16486
|
-
const table =
|
|
16487
|
-
const parent =
|
|
16476
|
+
const table = vue.inject('vc-table');
|
|
16477
|
+
const parent = vue.inject('vc-table-column', table);
|
|
16488
16478
|
const isSubColumn = table !== parent; // 用于多久表头
|
|
16489
16479
|
|
|
16490
|
-
const columnId = vue.ref((parent.
|
|
16480
|
+
const columnId = vue.ref((parent.tableId || parent.columnId) + Utils.getUid('column'));
|
|
16491
16481
|
const realWidth = vue.computed(() => {
|
|
16492
16482
|
return parseWidth(props.width);
|
|
16493
16483
|
});
|
|
@@ -16517,7 +16507,6 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16517
16507
|
}, {});
|
|
16518
16508
|
return result;
|
|
16519
16509
|
};
|
|
16520
|
-
|
|
16521
16510
|
/**
|
|
16522
16511
|
* compose 1
|
|
16523
16512
|
* 对于特定类型的 column,某些属性不允许设置
|
|
@@ -16587,7 +16576,7 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16587
16576
|
column.renderCell = data => vue.createVNode("div", {
|
|
16588
16577
|
"class": "vc-table__cell"
|
|
16589
16578
|
}, [originRenderCell(data)]);
|
|
16590
|
-
table.
|
|
16579
|
+
table.renderExpanded.value = data => {
|
|
16591
16580
|
return slots.default ? slots.default(data) : slots.default;
|
|
16592
16581
|
};
|
|
16593
16582
|
} else {
|
|
@@ -16606,7 +16595,7 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16606
16595
|
style: {}
|
|
16607
16596
|
};
|
|
16608
16597
|
// 存在树形数组,且当前行无箭头图标且处于当前展开列,表格对齐
|
|
16609
|
-
if (!lodashEs.isEmpty(table.
|
|
16598
|
+
if (!lodashEs.isEmpty(table.store.states.treeData) && !prefix && data.isExpandColumn) {
|
|
16610
16599
|
prefix = vue.createVNode("span", {
|
|
16611
16600
|
"class": "vc-table-un-expand__indent"
|
|
16612
16601
|
}, null);
|
|
@@ -16626,26 +16615,16 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16626
16615
|
}
|
|
16627
16616
|
return column;
|
|
16628
16617
|
};
|
|
16629
|
-
const
|
|
16618
|
+
const registerColumn = () => {
|
|
16630
16619
|
const defaults = {
|
|
16631
16620
|
...cellStarts[props.type],
|
|
16632
|
-
type: props.type,
|
|
16633
16621
|
id: columnId.value,
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
prop: props.prop,
|
|
16637
|
-
showPopover: props.showPopover,
|
|
16638
|
-
// index 列
|
|
16639
|
-
index: props.index
|
|
16622
|
+
realAlign,
|
|
16623
|
+
realHeaderAlign
|
|
16640
16624
|
};
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
const filterProps = ['filters', 'filteredValue', 'filterMultiple', 'filter', 'filterIcon', 'filterPopupClass'];
|
|
16645
|
-
let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
|
|
16646
|
-
column = lodashEs.merge(defaults, column);
|
|
16647
|
-
|
|
16648
|
-
// 注意 compose 中函数执行的顺序是从右到左
|
|
16625
|
+
let column = lodashEs.merge(defaults, getPropsData(Object.keys(props)));
|
|
16626
|
+
|
|
16627
|
+
// minWidth/realWidth/renderHeader
|
|
16649
16628
|
column = helperFp.compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
|
|
16650
16629
|
for (const key in column) {
|
|
16651
16630
|
if (Utils.hasOwn(column, key)) {
|
|
@@ -16653,34 +16632,39 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16653
16632
|
}
|
|
16654
16633
|
}
|
|
16655
16634
|
};
|
|
16656
|
-
const
|
|
16635
|
+
const registerWatchers = () => {
|
|
16636
|
+
// 赋值
|
|
16637
|
+
Object.keys(props).forEach(k => vue.watch(() => props[k], v => columnConfig[k] = v));
|
|
16638
|
+
|
|
16639
|
+
// 影响布局
|
|
16657
16640
|
vue.watch(() => props.fixed, () => {
|
|
16658
|
-
table.
|
|
16641
|
+
table.store.scheduleLayout(true);
|
|
16659
16642
|
});
|
|
16660
|
-
vue.watch(() => realWidth.value,
|
|
16661
|
-
|
|
16643
|
+
vue.watch(() => realWidth.value, v => {
|
|
16644
|
+
columnConfig['width'] = v;
|
|
16645
|
+
columnConfig['realWidth'] = v;
|
|
16646
|
+
table.store.scheduleLayout(false);
|
|
16662
16647
|
});
|
|
16663
16648
|
vue.watch(() => realMinWidth.value, () => {
|
|
16664
|
-
table.
|
|
16649
|
+
table.store.scheduleLayout(false);
|
|
16665
16650
|
});
|
|
16666
16651
|
};
|
|
16667
16652
|
vue.onBeforeMount(() => {
|
|
16668
|
-
|
|
16669
|
-
|
|
16653
|
+
registerColumn();
|
|
16654
|
+
registerWatchers();
|
|
16670
16655
|
});
|
|
16671
|
-
vue.onUpdated(refreshColumnBasicConfig);
|
|
16672
16656
|
vue.onMounted(() => {
|
|
16673
|
-
const children = isSubColumn ? parent.vnode.el.children : parent.
|
|
16657
|
+
const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
|
|
16674
16658
|
|
|
16675
16659
|
// DOM上
|
|
16676
16660
|
const columnIndex = [...children].indexOf(instance.vnode.el);
|
|
16677
|
-
table.
|
|
16661
|
+
table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
|
|
16678
16662
|
});
|
|
16679
16663
|
vue.onUnmounted(() => {
|
|
16680
16664
|
if (!instance.parent) return;
|
|
16681
|
-
table.
|
|
16665
|
+
table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
|
|
16682
16666
|
});
|
|
16683
|
-
|
|
16667
|
+
vue.provide('vc-table-column', {
|
|
16684
16668
|
columnId,
|
|
16685
16669
|
columnConfig
|
|
16686
16670
|
});
|
|
@@ -16696,7 +16680,8 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
|
|
|
16696
16680
|
const renderDefault = slots?.default?.({
|
|
16697
16681
|
row: {},
|
|
16698
16682
|
column: {},
|
|
16699
|
-
|
|
16683
|
+
columnIndex: -1,
|
|
16684
|
+
rowIndex: -1
|
|
16700
16685
|
});
|
|
16701
16686
|
if (renderDefault instanceof Array) {
|
|
16702
16687
|
for (const childNode of renderDefault) {
|