@deot/vc 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.d.ts +12 -12
- package/dist/index.iife.js +347 -360
- package/dist/index.umd.cjs +347 -360
- package/package.json +4 -4
package/dist/index.iife.js
CHANGED
|
@@ -24841,7 +24841,7 @@ var Vc = (function (exports, vue) {
|
|
|
24841
24841
|
});
|
|
24842
24842
|
const COMPONENT_NAME$1T = "vc-alert";
|
|
24843
24843
|
const THEME_MAP = {
|
|
24844
|
-
info: ["#
|
|
24844
|
+
info: ["#2B72FD", "#91d5ff", "#e6f7ff"],
|
|
24845
24845
|
success: ["#52c41a", "#b7eb8f", "#f6ffed"],
|
|
24846
24846
|
error: ["#ed4014", "#ffb08f", "#fbe9e9"],
|
|
24847
24847
|
warning: ["#ffbf00", "#ffe58f", "#fffbe6"]
|
|
@@ -31718,6 +31718,7 @@ var Vc = (function (exports, vue) {
|
|
|
31718
31718
|
isVisible.value = cursorDown.value;
|
|
31719
31719
|
};
|
|
31720
31720
|
const refreshThumb = () => raf(() => {
|
|
31721
|
+
if (!thumb.value) return;
|
|
31721
31722
|
thumb.value.style[prefixStyle("transform").camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
|
|
31722
31723
|
});
|
|
31723
31724
|
const refreshThrottleThumb = throttle$2(refreshThumb, 10);
|
|
@@ -35557,7 +35558,7 @@ var Vc = (function (exports, vue) {
|
|
|
35557
35558
|
color: {
|
|
35558
35559
|
type: [Object, String],
|
|
35559
35560
|
default: () => ({
|
|
35560
|
-
normal: "#
|
|
35561
|
+
normal: "#2B72FD",
|
|
35561
35562
|
success: "#52c41a",
|
|
35562
35563
|
error: "#f5222d"
|
|
35563
35564
|
})
|
|
@@ -36510,6 +36511,7 @@ var Vc = (function (exports, vue) {
|
|
|
36510
36511
|
columnFillSize.value = sizes.map((i) => contentMaxSize.value - i);
|
|
36511
36512
|
};
|
|
36512
36513
|
const setFirstItemIndex = () => {
|
|
36514
|
+
if (!wrapper.value) return;
|
|
36513
36515
|
const position = wrapper.value[K.scrollAxis];
|
|
36514
36516
|
let item;
|
|
36515
36517
|
for (let i = 0; i < rebuildData.value.length; i++) {
|
|
@@ -36674,6 +36676,7 @@ var Vc = (function (exports, vue) {
|
|
|
36674
36676
|
await refreshLayout(0, rebuildData.value.length);
|
|
36675
36677
|
};
|
|
36676
36678
|
const handleResize = throttle$1(async () => {
|
|
36679
|
+
if (!wrapper.value) return;
|
|
36677
36680
|
const isNeedRefreshLayout = rebuildData.value.some((i) => !i.isPlaceholder);
|
|
36678
36681
|
if (isNeedRefreshLayout) {
|
|
36679
36682
|
const oldFirstItemIndex = firstItemIndex.value;
|
|
@@ -36702,6 +36705,8 @@ var Vc = (function (exports, vue) {
|
|
|
36702
36705
|
});
|
|
36703
36706
|
if (!originalData.length) {
|
|
36704
36707
|
rebuildData.value = [];
|
|
36708
|
+
} else {
|
|
36709
|
+
rebuildData.value = originalData.slice();
|
|
36705
36710
|
}
|
|
36706
36711
|
offsetPageSize.value = 0;
|
|
36707
36712
|
await refreshLayout(0, originalData.length);
|
|
@@ -37077,88 +37082,65 @@ var Vc = (function (exports, vue) {
|
|
|
37077
37082
|
};
|
|
37078
37083
|
}
|
|
37079
37084
|
});
|
|
37080
|
-
const parseHeight = (
|
|
37081
|
-
if (typeof
|
|
37082
|
-
return
|
|
37085
|
+
const parseHeight = (v) => {
|
|
37086
|
+
if (typeof v === "number") {
|
|
37087
|
+
return v;
|
|
37083
37088
|
}
|
|
37084
|
-
if (
|
|
37085
|
-
if (/^\d+(?:px)?/.test(
|
|
37086
|
-
return parseInt(
|
|
37089
|
+
if (v && typeof v === "string") {
|
|
37090
|
+
if (/^\d+(?:px)?/.test(v)) {
|
|
37091
|
+
return parseInt(v, 10);
|
|
37087
37092
|
}
|
|
37088
37093
|
throw new VcError("table", "Invalid Height");
|
|
37089
37094
|
}
|
|
37090
37095
|
return null;
|
|
37091
37096
|
};
|
|
37092
|
-
const parseWidth = (
|
|
37093
|
-
if (
|
|
37094
|
-
|
|
37095
|
-
|
|
37096
|
-
|
|
37097
|
+
const parseWidth = (v) => {
|
|
37098
|
+
if (typeof v === "number") {
|
|
37099
|
+
return v;
|
|
37100
|
+
}
|
|
37101
|
+
let v1;
|
|
37102
|
+
if (typeof v !== "undefined") {
|
|
37103
|
+
v1 = parseInt(v, 10);
|
|
37104
|
+
if (isNaN(v1)) {
|
|
37105
|
+
v1 = null;
|
|
37097
37106
|
}
|
|
37098
37107
|
}
|
|
37099
|
-
return
|
|
37108
|
+
return v1;
|
|
37100
37109
|
};
|
|
37101
|
-
const parseMinWidth = (
|
|
37102
|
-
if (typeof
|
|
37103
|
-
|
|
37104
|
-
|
|
37105
|
-
|
|
37110
|
+
const parseMinWidth = (v) => {
|
|
37111
|
+
if (typeof v === "number") {
|
|
37112
|
+
return v;
|
|
37113
|
+
}
|
|
37114
|
+
let v1;
|
|
37115
|
+
if (typeof v !== "undefined") {
|
|
37116
|
+
v1 = parseWidth(v);
|
|
37117
|
+
if (isNaN(v1)) {
|
|
37118
|
+
v = 80;
|
|
37106
37119
|
}
|
|
37107
37120
|
}
|
|
37108
|
-
return
|
|
37121
|
+
return v1;
|
|
37109
37122
|
};
|
|
37110
|
-
const
|
|
37123
|
+
const getRowValue = (row, primaryKey) => {
|
|
37111
37124
|
if (row.__KEY__) return row.__KEY__;
|
|
37112
37125
|
if (!row) throw new VcError("table", "row is required when get row identity");
|
|
37113
|
-
if (typeof
|
|
37114
|
-
if (!
|
|
37115
|
-
return row[
|
|
37126
|
+
if (typeof primaryKey === "string") {
|
|
37127
|
+
if (!primaryKey.includes(".")) {
|
|
37128
|
+
return row[primaryKey];
|
|
37116
37129
|
}
|
|
37117
|
-
const key =
|
|
37130
|
+
const key = primaryKey.split(".");
|
|
37118
37131
|
let current = row;
|
|
37119
37132
|
for (let i = 0; i < key.length; i++) {
|
|
37120
37133
|
current = current[key[i]];
|
|
37121
37134
|
}
|
|
37122
37135
|
return current;
|
|
37123
|
-
} else if (typeof
|
|
37124
|
-
return
|
|
37136
|
+
} else if (typeof primaryKey === "function") {
|
|
37137
|
+
return primaryKey.call(null, row);
|
|
37125
37138
|
}
|
|
37126
37139
|
};
|
|
37127
|
-
const
|
|
37128
|
-
const {
|
|
37129
|
-
childrenKey = "children",
|
|
37130
|
-
lazyKey = "hasChildren",
|
|
37131
|
-
level: baseLevel = 0
|
|
37132
|
-
} = opts;
|
|
37133
|
-
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
37134
|
-
function _walker(parent, children, level) {
|
|
37135
|
-
cb(parent, children, level);
|
|
37136
|
-
children.forEach((item) => {
|
|
37137
|
-
if (item[lazyKey]) {
|
|
37138
|
-
cb(item, null, level + 1);
|
|
37139
|
-
return;
|
|
37140
|
-
}
|
|
37141
|
-
const $children = item[childrenKey];
|
|
37142
|
-
if (!isNil($children)) {
|
|
37143
|
-
_walker(item, $children, level + 1);
|
|
37144
|
-
}
|
|
37145
|
-
});
|
|
37146
|
-
}
|
|
37147
|
-
root.forEach((item) => {
|
|
37148
|
-
if (item[lazyKey]) {
|
|
37149
|
-
cb(item, null, baseLevel);
|
|
37150
|
-
return;
|
|
37151
|
-
}
|
|
37152
|
-
const children = item[childrenKey];
|
|
37153
|
-
if (!isNil(children)) {
|
|
37154
|
-
_walker(item, children, baseLevel);
|
|
37155
|
-
}
|
|
37156
|
-
});
|
|
37157
|
-
};
|
|
37158
|
-
const getKeysMap = (array = [], rowKey) => {
|
|
37140
|
+
const getValuesMap = (array = [], primaryKey) => {
|
|
37159
37141
|
const arrayMap = {};
|
|
37160
37142
|
array.forEach((row, index) => {
|
|
37161
|
-
arrayMap[
|
|
37143
|
+
arrayMap[getRowValue(row, primaryKey)] = { row, index };
|
|
37162
37144
|
});
|
|
37163
37145
|
return arrayMap;
|
|
37164
37146
|
};
|
|
@@ -37171,23 +37153,74 @@ var Vc = (function (exports, vue) {
|
|
|
37171
37153
|
});
|
|
37172
37154
|
return column;
|
|
37173
37155
|
};
|
|
37174
|
-
const getColumnByCell = (
|
|
37156
|
+
const getColumnByCell = (columns, cell) => {
|
|
37175
37157
|
const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
|
|
37176
37158
|
if (matches) {
|
|
37177
|
-
return getColumnById(
|
|
37159
|
+
return getColumnById(columns, matches[0]);
|
|
37178
37160
|
}
|
|
37179
37161
|
return null;
|
|
37180
37162
|
};
|
|
37181
|
-
const getCell = (
|
|
37182
|
-
let cell =
|
|
37163
|
+
const getCell = (e) => {
|
|
37164
|
+
let cell = e.target;
|
|
37183
37165
|
while (cell && cell.tagName.toUpperCase() !== "HTML") {
|
|
37184
|
-
if (cell.
|
|
37166
|
+
if (cell.classList.contains("vc-table__td")) {
|
|
37185
37167
|
return cell;
|
|
37186
37168
|
}
|
|
37187
37169
|
cell = cell.parentNode;
|
|
37188
37170
|
}
|
|
37189
37171
|
return null;
|
|
37190
37172
|
};
|
|
37173
|
+
const getAllColumns = (columns) => {
|
|
37174
|
+
const result = [];
|
|
37175
|
+
columns.forEach((column) => {
|
|
37176
|
+
if (column.children) {
|
|
37177
|
+
result.push(column);
|
|
37178
|
+
result.push(...getAllColumns(column.children));
|
|
37179
|
+
} else {
|
|
37180
|
+
result.push(column);
|
|
37181
|
+
}
|
|
37182
|
+
});
|
|
37183
|
+
return result;
|
|
37184
|
+
};
|
|
37185
|
+
const columnsToRowsEffect = (v) => {
|
|
37186
|
+
let maxLevel = 1;
|
|
37187
|
+
const traverse = (column, parent) => {
|
|
37188
|
+
if (parent) {
|
|
37189
|
+
column.level = parent.level + 1;
|
|
37190
|
+
if (maxLevel < column.level) {
|
|
37191
|
+
maxLevel = column.level;
|
|
37192
|
+
}
|
|
37193
|
+
}
|
|
37194
|
+
if (column.children) {
|
|
37195
|
+
let colSpan = 0;
|
|
37196
|
+
column.children.forEach((subColumn) => {
|
|
37197
|
+
traverse(subColumn, column);
|
|
37198
|
+
colSpan += subColumn.colSpan;
|
|
37199
|
+
});
|
|
37200
|
+
column.colSpan = colSpan;
|
|
37201
|
+
} else {
|
|
37202
|
+
column.colSpan = 1;
|
|
37203
|
+
}
|
|
37204
|
+
};
|
|
37205
|
+
v.forEach((column) => {
|
|
37206
|
+
column.level = 1;
|
|
37207
|
+
traverse(column);
|
|
37208
|
+
});
|
|
37209
|
+
const rows = [];
|
|
37210
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
37211
|
+
rows.push([]);
|
|
37212
|
+
}
|
|
37213
|
+
const allColumns = getAllColumns(v);
|
|
37214
|
+
allColumns.forEach((column) => {
|
|
37215
|
+
if (!column.children) {
|
|
37216
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
37217
|
+
} else {
|
|
37218
|
+
column.rowSpan = 1;
|
|
37219
|
+
}
|
|
37220
|
+
rows[column.level - 1].push(column);
|
|
37221
|
+
});
|
|
37222
|
+
return rows;
|
|
37223
|
+
};
|
|
37191
37224
|
const flattenData = (data, opts = {}) => {
|
|
37192
37225
|
const result = [];
|
|
37193
37226
|
data.forEach((item) => {
|
|
@@ -37200,29 +37233,51 @@ var Vc = (function (exports, vue) {
|
|
|
37200
37233
|
});
|
|
37201
37234
|
return result;
|
|
37202
37235
|
};
|
|
37236
|
+
const walkTreeNode = (root, cb, opts = {}) => {
|
|
37237
|
+
const {
|
|
37238
|
+
childrenKey = "children",
|
|
37239
|
+
lazyKey = "hasChildren",
|
|
37240
|
+
level: baseLevel = 0
|
|
37241
|
+
} = opts;
|
|
37242
|
+
const isNil = (array) => !(Array.isArray(array) && array.length);
|
|
37243
|
+
function _walker(parent, children, level) {
|
|
37244
|
+
cb(parent, children, level);
|
|
37245
|
+
children.forEach((item) => {
|
|
37246
|
+
if (item[lazyKey]) {
|
|
37247
|
+
cb(item, null, level + 1);
|
|
37248
|
+
return;
|
|
37249
|
+
}
|
|
37250
|
+
const $children = item[childrenKey];
|
|
37251
|
+
if (!isNil($children)) {
|
|
37252
|
+
_walker(item, $children, level + 1);
|
|
37253
|
+
}
|
|
37254
|
+
});
|
|
37255
|
+
}
|
|
37256
|
+
root.forEach((item) => {
|
|
37257
|
+
if (item[lazyKey]) {
|
|
37258
|
+
cb(item, null, baseLevel);
|
|
37259
|
+
return;
|
|
37260
|
+
}
|
|
37261
|
+
const children = item[childrenKey];
|
|
37262
|
+
if (!isNil(children)) {
|
|
37263
|
+
_walker(item, children, baseLevel);
|
|
37264
|
+
}
|
|
37265
|
+
});
|
|
37266
|
+
};
|
|
37203
37267
|
class BaseWatcher {
|
|
37204
37268
|
states = vue.reactive({
|
|
37205
37269
|
// 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
|
|
37206
37270
|
_data: [],
|
|
37207
37271
|
data: [],
|
|
37208
37272
|
list: [],
|
|
37209
|
-
//
|
|
37210
|
-
|
|
37211
|
-
// 列
|
|
37273
|
+
// 表头数据
|
|
37274
|
+
headerRows: [],
|
|
37275
|
+
// 列 动态收集vc-table-column中的columnConfig
|
|
37212
37276
|
_columns: [],
|
|
37213
|
-
// 动态收集vc-table-column中的columnConfig
|
|
37214
37277
|
originColumns: [],
|
|
37215
|
-
|
|
37216
|
-
columns: [],
|
|
37217
|
-
// 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
|
|
37278
|
+
notFixedColumns: [],
|
|
37218
37279
|
leftFixedColumns: [],
|
|
37219
37280
|
rightFixedColumns: [],
|
|
37220
|
-
leafColumns: [],
|
|
37221
|
-
leftFixedLeafColumns: [],
|
|
37222
|
-
rightFixedLeafColumns: [],
|
|
37223
|
-
leafColumnsLength: 0,
|
|
37224
|
-
leftFixedLeafColumnsLength: 0,
|
|
37225
|
-
rightFixedLeafColumnsLength: 0,
|
|
37226
37281
|
// 选择
|
|
37227
37282
|
isAllSelected: false,
|
|
37228
37283
|
selection: [],
|
|
@@ -37244,7 +37299,17 @@ var Vc = (function (exports, vue) {
|
|
|
37244
37299
|
treeLazyData: [],
|
|
37245
37300
|
// 源数据展开
|
|
37246
37301
|
treeLazyColumnIdentifier: "hasChildren",
|
|
37247
|
-
treeChildrenColumnName: "children"
|
|
37302
|
+
treeChildrenColumnName: "children",
|
|
37303
|
+
// compputeds
|
|
37304
|
+
isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
|
|
37305
|
+
isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
|
|
37306
|
+
columns: vue.computed(() => lodashExports.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
|
|
37307
|
+
leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
|
|
37308
|
+
leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
|
|
37309
|
+
rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
|
|
37310
|
+
leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
|
|
37311
|
+
leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
|
|
37312
|
+
rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
|
|
37248
37313
|
});
|
|
37249
37314
|
}
|
|
37250
37315
|
class Expand {
|
|
@@ -37254,14 +37319,14 @@ var Vc = (function (exports, vue) {
|
|
|
37254
37319
|
}
|
|
37255
37320
|
update() {
|
|
37256
37321
|
const store = this.store;
|
|
37257
|
-
const {
|
|
37322
|
+
const { primaryKey, defaultExpandAll } = this.store.table.props;
|
|
37258
37323
|
const { data = [], expandRows } = store.states;
|
|
37259
37324
|
if (defaultExpandAll) {
|
|
37260
37325
|
store.states.expandRows = data.slice();
|
|
37261
|
-
} else if (
|
|
37262
|
-
const expandRowsMap =
|
|
37326
|
+
} else if (primaryKey) {
|
|
37327
|
+
const expandRowsMap = getValuesMap(expandRows, primaryKey);
|
|
37263
37328
|
store.states.expandRows = data.reduce((prev, row) => {
|
|
37264
|
-
const rowId =
|
|
37329
|
+
const rowId = getRowValue(row, primaryKey);
|
|
37265
37330
|
const rowInfo = expandRowsMap[rowId];
|
|
37266
37331
|
if (rowInfo) {
|
|
37267
37332
|
prev.push(row);
|
|
@@ -37283,10 +37348,10 @@ var Vc = (function (exports, vue) {
|
|
|
37283
37348
|
}
|
|
37284
37349
|
reset(ids) {
|
|
37285
37350
|
const store = this.store;
|
|
37286
|
-
store.
|
|
37287
|
-
const {
|
|
37351
|
+
store.checkPrimaryKey();
|
|
37352
|
+
const { primaryKey } = store.table.props;
|
|
37288
37353
|
const { data } = store.states;
|
|
37289
|
-
const keysMap =
|
|
37354
|
+
const keysMap = getValuesMap(data, primaryKey);
|
|
37290
37355
|
store.states.expandRows = ids.reduce((prev, cur) => {
|
|
37291
37356
|
const info2 = keysMap[cur];
|
|
37292
37357
|
if (info2) {
|
|
@@ -37296,11 +37361,11 @@ var Vc = (function (exports, vue) {
|
|
|
37296
37361
|
}, []);
|
|
37297
37362
|
}
|
|
37298
37363
|
isExpanded(row) {
|
|
37299
|
-
const {
|
|
37364
|
+
const { primaryKey } = this.store.table.props;
|
|
37300
37365
|
const { expandRows = [] } = this.store.states;
|
|
37301
|
-
if (
|
|
37302
|
-
const expandMap =
|
|
37303
|
-
return !!expandMap[
|
|
37366
|
+
if (primaryKey) {
|
|
37367
|
+
const expandMap = getValuesMap(expandRows, primaryKey);
|
|
37368
|
+
return !!expandMap[getRowValue(row, primaryKey)];
|
|
37304
37369
|
}
|
|
37305
37370
|
return expandRows.indexOf(row) !== -1;
|
|
37306
37371
|
}
|
|
@@ -37312,22 +37377,22 @@ var Vc = (function (exports, vue) {
|
|
|
37312
37377
|
}
|
|
37313
37378
|
reset(id) {
|
|
37314
37379
|
const store = this.store;
|
|
37315
|
-
const {
|
|
37316
|
-
store.
|
|
37380
|
+
const { primaryKey } = store.table.props;
|
|
37381
|
+
store.checkPrimaryKey();
|
|
37317
37382
|
const { data = [] } = store.states;
|
|
37318
|
-
const currentRow = data.find((item) =>
|
|
37383
|
+
const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
|
|
37319
37384
|
store.states.currentRow = currentRow || null;
|
|
37320
37385
|
}
|
|
37321
37386
|
update() {
|
|
37322
37387
|
const store = this.store;
|
|
37323
|
-
const {
|
|
37388
|
+
const { primaryKey } = store.table.props;
|
|
37324
37389
|
const { data = [], currentRow } = store.states;
|
|
37325
37390
|
const oldCurrentRow = currentRow;
|
|
37326
37391
|
if (oldCurrentRow && !data.includes(oldCurrentRow)) {
|
|
37327
37392
|
let newCurrentRow = null;
|
|
37328
|
-
if (
|
|
37393
|
+
if (primaryKey) {
|
|
37329
37394
|
newCurrentRow = data.find((item) => {
|
|
37330
|
-
return
|
|
37395
|
+
return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
|
|
37331
37396
|
});
|
|
37332
37397
|
}
|
|
37333
37398
|
store.states.currentRow = newCurrentRow;
|
|
@@ -37345,8 +37410,8 @@ var Vc = (function (exports, vue) {
|
|
|
37345
37410
|
* { id: { level, children } }
|
|
37346
37411
|
*/
|
|
37347
37412
|
normalizedData = vue.computed(() => {
|
|
37348
|
-
const {
|
|
37349
|
-
if (!
|
|
37413
|
+
const { primaryKey } = this.store.table.props;
|
|
37414
|
+
if (!primaryKey) return {};
|
|
37350
37415
|
return this.normalize(this.store.states.data || []);
|
|
37351
37416
|
});
|
|
37352
37417
|
/**
|
|
@@ -37354,7 +37419,7 @@ var Vc = (function (exports, vue) {
|
|
|
37354
37419
|
* { id: { children } }
|
|
37355
37420
|
*/
|
|
37356
37421
|
normalizedLazyNode = vue.computed(() => {
|
|
37357
|
-
const {
|
|
37422
|
+
const { primaryKey } = this.store.table.props;
|
|
37358
37423
|
const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
|
|
37359
37424
|
const keys = Object.keys(treelazyNodeMap);
|
|
37360
37425
|
const res = {};
|
|
@@ -37363,7 +37428,7 @@ var Vc = (function (exports, vue) {
|
|
|
37363
37428
|
if (treelazyNodeMap[key].length) {
|
|
37364
37429
|
const item = { children: [] };
|
|
37365
37430
|
treelazyNodeMap[key].forEach((row) => {
|
|
37366
|
-
const id =
|
|
37431
|
+
const id = getRowValue(row, primaryKey);
|
|
37367
37432
|
item.children.push(id);
|
|
37368
37433
|
const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
|
|
37369
37434
|
if (hasChildren && !res[id]) {
|
|
@@ -37383,16 +37448,16 @@ var Vc = (function (exports, vue) {
|
|
|
37383
37448
|
);
|
|
37384
37449
|
}
|
|
37385
37450
|
normalize(data) {
|
|
37386
|
-
const {
|
|
37451
|
+
const { primaryKey } = this.store.table.props;
|
|
37387
37452
|
const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
|
|
37388
37453
|
const res = {};
|
|
37389
37454
|
walkTreeNode(
|
|
37390
37455
|
data,
|
|
37391
37456
|
(parent, children, level) => {
|
|
37392
|
-
const parentId =
|
|
37457
|
+
const parentId = getRowValue(parent, primaryKey);
|
|
37393
37458
|
if (Array.isArray(children)) {
|
|
37394
37459
|
res[parentId] = {
|
|
37395
|
-
children: children.map((row) =>
|
|
37460
|
+
children: children.map((row) => getRowValue(row, primaryKey)),
|
|
37396
37461
|
level
|
|
37397
37462
|
};
|
|
37398
37463
|
} else if (treeLazy) {
|
|
@@ -37412,7 +37477,7 @@ var Vc = (function (exports, vue) {
|
|
|
37412
37477
|
}
|
|
37413
37478
|
// 获取当前展开最大的level
|
|
37414
37479
|
getMaxLevel() {
|
|
37415
|
-
const {
|
|
37480
|
+
const { primaryKey } = this.store.table.props;
|
|
37416
37481
|
const { data, treeData } = this.store.states;
|
|
37417
37482
|
const levels = data.map((item) => {
|
|
37418
37483
|
const traverse = (source) => {
|
|
@@ -37423,7 +37488,7 @@ var Vc = (function (exports, vue) {
|
|
|
37423
37488
|
return source.level;
|
|
37424
37489
|
}
|
|
37425
37490
|
};
|
|
37426
|
-
const id =
|
|
37491
|
+
const id = getRowValue(item, primaryKey);
|
|
37427
37492
|
return traverse(treeData[id]);
|
|
37428
37493
|
});
|
|
37429
37494
|
return max$2(levels) || 0;
|
|
@@ -37485,10 +37550,10 @@ var Vc = (function (exports, vue) {
|
|
|
37485
37550
|
this.update();
|
|
37486
37551
|
}
|
|
37487
37552
|
toggle(row, expanded) {
|
|
37488
|
-
this.store.
|
|
37489
|
-
const {
|
|
37553
|
+
this.store.checkPrimaryKey();
|
|
37554
|
+
const { primaryKey } = this.store.table.props;
|
|
37490
37555
|
const { treeData } = this.store.states;
|
|
37491
|
-
const id =
|
|
37556
|
+
const id = getRowValue(row, primaryKey);
|
|
37492
37557
|
const data = id && treeData[id];
|
|
37493
37558
|
if (id && data && "expanded" in data) {
|
|
37494
37559
|
const oldExpanded = data.expanded;
|
|
@@ -37501,10 +37566,10 @@ var Vc = (function (exports, vue) {
|
|
|
37501
37566
|
}
|
|
37502
37567
|
}
|
|
37503
37568
|
loadOrToggle(row) {
|
|
37504
|
-
this.store.
|
|
37505
|
-
const {
|
|
37569
|
+
this.store.checkPrimaryKey();
|
|
37570
|
+
const { primaryKey } = this.store.table.props;
|
|
37506
37571
|
const { treeLazy, treeData } = this.store.states;
|
|
37507
|
-
const id =
|
|
37572
|
+
const id = getRowValue(row, primaryKey);
|
|
37508
37573
|
const data = treeData[id];
|
|
37509
37574
|
if (treeLazy && data && "loaded" in data && !data.loaded) {
|
|
37510
37575
|
this.loadData(row, id, data);
|
|
@@ -37513,9 +37578,9 @@ var Vc = (function (exports, vue) {
|
|
|
37513
37578
|
}
|
|
37514
37579
|
}
|
|
37515
37580
|
loadData(row, key, treeNode) {
|
|
37516
|
-
this.store.
|
|
37581
|
+
this.store.checkPrimaryKey();
|
|
37517
37582
|
const { table } = this.store;
|
|
37518
|
-
const {
|
|
37583
|
+
const { primaryKey } = table.props;
|
|
37519
37584
|
const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
|
|
37520
37585
|
if (table.props.loadExpand && !treeData[key].loaded) {
|
|
37521
37586
|
this.store.states.treeData[key].loading = true;
|
|
@@ -37530,7 +37595,7 @@ var Vc = (function (exports, vue) {
|
|
|
37530
37595
|
walkTreeNode(
|
|
37531
37596
|
data,
|
|
37532
37597
|
(parent, _, level) => {
|
|
37533
|
-
const id =
|
|
37598
|
+
const id = getRowValue(parent, primaryKey);
|
|
37534
37599
|
Object.defineProperty(parent, "__KEY__", {
|
|
37535
37600
|
value: `${level}__${id}`,
|
|
37536
37601
|
writable: false
|
|
@@ -37599,27 +37664,13 @@ var Vc = (function (exports, vue) {
|
|
|
37599
37664
|
if (!this.store) {
|
|
37600
37665
|
throw new VcError("table", "Table Layout 必须包含store实例");
|
|
37601
37666
|
}
|
|
37602
|
-
this.updateScroller = this.updateScroller.bind(this);
|
|
37603
|
-
this.updateColumns = this.updateColumns.bind(this);
|
|
37604
|
-
vue.onMounted(() => {
|
|
37605
|
-
this.updateColumns();
|
|
37606
|
-
this.updateScroller();
|
|
37607
|
-
});
|
|
37608
|
-
let __updated__;
|
|
37609
|
-
vue.onUpdated(() => {
|
|
37610
|
-
if (__updated__) return;
|
|
37611
|
-
this.updateColumns();
|
|
37612
|
-
this.updateScroller();
|
|
37613
|
-
__updated__ = true;
|
|
37614
|
-
});
|
|
37615
37667
|
}
|
|
37616
37668
|
updateScrollY() {
|
|
37617
37669
|
const { height, bodyHeight } = this.states;
|
|
37618
37670
|
if (height === null || bodyHeight === null) return;
|
|
37619
|
-
const
|
|
37620
|
-
if (this.table.vnode.el &&
|
|
37621
|
-
|
|
37622
|
-
this.states.scrollY = body.offsetHeight > bodyHeight;
|
|
37671
|
+
const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
|
|
37672
|
+
if (this.table.vnode.el && bodyYWrapper) {
|
|
37673
|
+
this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
|
|
37623
37674
|
}
|
|
37624
37675
|
}
|
|
37625
37676
|
setHeight(value, prop = "height") {
|
|
@@ -37636,18 +37687,6 @@ var Vc = (function (exports, vue) {
|
|
|
37636
37687
|
setMaxHeight(value) {
|
|
37637
37688
|
this.setHeight(value, "max-height");
|
|
37638
37689
|
}
|
|
37639
|
-
getFlattenColumns() {
|
|
37640
|
-
const flattenColumns = [];
|
|
37641
|
-
const columns = this.store.states.columns;
|
|
37642
|
-
columns.forEach((column) => {
|
|
37643
|
-
if (column.isColumnGroup) {
|
|
37644
|
-
flattenColumns.push(...column.columns);
|
|
37645
|
-
} else {
|
|
37646
|
-
flattenColumns.push(column);
|
|
37647
|
-
}
|
|
37648
|
-
});
|
|
37649
|
-
return flattenColumns;
|
|
37650
|
-
}
|
|
37651
37690
|
updateElsHeight() {
|
|
37652
37691
|
if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
|
|
37653
37692
|
const table = this.table.exposed;
|
|
@@ -37670,13 +37709,12 @@ var Vc = (function (exports, vue) {
|
|
|
37670
37709
|
this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
|
37671
37710
|
}
|
|
37672
37711
|
this.updateScrollY();
|
|
37673
|
-
this.updateScroller();
|
|
37674
37712
|
}
|
|
37675
37713
|
updateColumnsWidth() {
|
|
37676
37714
|
if (IS_SERVER$3) return;
|
|
37677
37715
|
const bodyWidth = this.table.vnode.el.clientWidth;
|
|
37678
37716
|
let bodyMinWidth = 0;
|
|
37679
|
-
const flattenColumns = this.
|
|
37717
|
+
const flattenColumns = this.store.states.columns;
|
|
37680
37718
|
const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
|
|
37681
37719
|
const { fit } = this.table.props;
|
|
37682
37720
|
if (flexColumns.length > 0 && fit) {
|
|
@@ -37702,7 +37740,7 @@ var Vc = (function (exports, vue) {
|
|
|
37702
37740
|
}
|
|
37703
37741
|
} else {
|
|
37704
37742
|
this.states.scrollX = true;
|
|
37705
|
-
flexColumns.forEach(
|
|
37743
|
+
flexColumns.forEach((column) => {
|
|
37706
37744
|
column.realWidth = column.width || column.minWidth;
|
|
37707
37745
|
});
|
|
37708
37746
|
}
|
|
@@ -37736,12 +37774,6 @@ var Vc = (function (exports, vue) {
|
|
|
37736
37774
|
});
|
|
37737
37775
|
this.states.rightFixedWidth = rightFixedWidth;
|
|
37738
37776
|
}
|
|
37739
|
-
this.updateColumns();
|
|
37740
|
-
}
|
|
37741
|
-
// v2.x中的 notifyObservers
|
|
37742
|
-
updateColumns() {
|
|
37743
|
-
}
|
|
37744
|
-
updateScroller() {
|
|
37745
37777
|
}
|
|
37746
37778
|
}
|
|
37747
37779
|
class Store extends BaseWatcher {
|
|
@@ -37750,7 +37782,7 @@ var Vc = (function (exports, vue) {
|
|
|
37750
37782
|
expand;
|
|
37751
37783
|
tree;
|
|
37752
37784
|
layout;
|
|
37753
|
-
|
|
37785
|
+
flatData = vue.computed(() => {
|
|
37754
37786
|
if (this.table.props.expandSelectable) {
|
|
37755
37787
|
return lodashExports.concat(
|
|
37756
37788
|
flattenData(this.states.data, { parent: true, cascader: true }),
|
|
@@ -37781,17 +37813,24 @@ var Vc = (function (exports, vue) {
|
|
|
37781
37813
|
const dataInstanceChanged = this.states._data !== data;
|
|
37782
37814
|
this.states._data = data;
|
|
37783
37815
|
this.states.data = data;
|
|
37816
|
+
const caches = /* @__PURE__ */ new Map();
|
|
37817
|
+
this.states.list.forEach((item) => {
|
|
37818
|
+
item.rows.forEach((row) => {
|
|
37819
|
+
caches.set(row.data, row);
|
|
37820
|
+
});
|
|
37821
|
+
});
|
|
37784
37822
|
this.states.list = data.reduce((pre, row, index) => {
|
|
37823
|
+
const cache = caches.get(row) || { heightMap: {} };
|
|
37785
37824
|
pre.push({
|
|
37786
37825
|
rows: [
|
|
37787
37826
|
{
|
|
37788
37827
|
index,
|
|
37789
37828
|
data: row,
|
|
37790
|
-
height: "",
|
|
37829
|
+
height: cache.height || "",
|
|
37791
37830
|
heightMap: {
|
|
37792
|
-
left: "",
|
|
37793
|
-
main: "",
|
|
37794
|
-
right: ""
|
|
37831
|
+
left: cache.heightMap.left || "",
|
|
37832
|
+
main: cache.heightMap.main || "",
|
|
37833
|
+
right: cache.heightMap.right || ""
|
|
37795
37834
|
}
|
|
37796
37835
|
}
|
|
37797
37836
|
],
|
|
@@ -37799,6 +37838,7 @@ var Vc = (function (exports, vue) {
|
|
|
37799
37838
|
});
|
|
37800
37839
|
return pre;
|
|
37801
37840
|
}, []);
|
|
37841
|
+
caches.clear();
|
|
37802
37842
|
this.current.update();
|
|
37803
37843
|
this.expand.update();
|
|
37804
37844
|
if (!this.states.reserveSelection) {
|
|
@@ -37808,7 +37848,7 @@ var Vc = (function (exports, vue) {
|
|
|
37808
37848
|
this.cleanSelection();
|
|
37809
37849
|
}
|
|
37810
37850
|
} else {
|
|
37811
|
-
this.
|
|
37851
|
+
this.checkPrimaryKey();
|
|
37812
37852
|
this.updateSelectionByRowKey();
|
|
37813
37853
|
}
|
|
37814
37854
|
this.updateAllSelected();
|
|
@@ -37830,10 +37870,10 @@ var Vc = (function (exports, vue) {
|
|
|
37830
37870
|
}
|
|
37831
37871
|
}
|
|
37832
37872
|
/**
|
|
37833
|
-
* 检查
|
|
37873
|
+
* 检查 primaryKey 是否存在
|
|
37834
37874
|
*/
|
|
37835
|
-
|
|
37836
|
-
const {
|
|
37875
|
+
checkPrimaryKey() {
|
|
37876
|
+
const { primaryKey } = this.table.props;
|
|
37837
37877
|
}
|
|
37838
37878
|
/**
|
|
37839
37879
|
* states
|
|
@@ -37894,22 +37934,20 @@ var Vc = (function (exports, vue) {
|
|
|
37894
37934
|
updateColumns() {
|
|
37895
37935
|
const { states } = this;
|
|
37896
37936
|
const _columns = states._columns || [];
|
|
37897
|
-
|
|
37898
|
-
|
|
37899
|
-
if (
|
|
37937
|
+
const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
37938
|
+
const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
|
|
37939
|
+
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
37900
37940
|
_columns[0].fixed = true;
|
|
37901
|
-
|
|
37941
|
+
leftFixedColumns.unshift(_columns[0]);
|
|
37902
37942
|
}
|
|
37903
37943
|
const notFixedColumns = _columns.filter((column) => !column.fixed);
|
|
37904
|
-
|
|
37905
|
-
const
|
|
37906
|
-
|
|
37907
|
-
|
|
37908
|
-
states.
|
|
37909
|
-
states.
|
|
37910
|
-
states.
|
|
37911
|
-
states.columns = lodashExports.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
|
|
37912
|
-
states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
|
37944
|
+
const originColumns = lodashExports.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
37945
|
+
const headerRows = columnsToRowsEffect(originColumns);
|
|
37946
|
+
states.leftFixedColumns = leftFixedColumns;
|
|
37947
|
+
states.notFixedColumns = notFixedColumns;
|
|
37948
|
+
states.rightFixedColumns = rightFixedColumns;
|
|
37949
|
+
states.originColumns = originColumns;
|
|
37950
|
+
states.headerRows = headerRows;
|
|
37913
37951
|
}
|
|
37914
37952
|
// 选择
|
|
37915
37953
|
isSelected(row) {
|
|
@@ -37933,13 +37971,13 @@ var Vc = (function (exports, vue) {
|
|
|
37933
37971
|
* 清理选择
|
|
37934
37972
|
*/
|
|
37935
37973
|
cleanSelection() {
|
|
37936
|
-
const {
|
|
37937
|
-
const { selection = [] } = this.states;
|
|
37974
|
+
const { primaryKey } = this.table.props;
|
|
37975
|
+
const { selection = [], data } = this.states;
|
|
37938
37976
|
let deleted;
|
|
37939
|
-
if (
|
|
37977
|
+
if (primaryKey) {
|
|
37940
37978
|
deleted = [];
|
|
37941
|
-
const selectedMap =
|
|
37942
|
-
const dataMap =
|
|
37979
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
37980
|
+
const dataMap = getValuesMap(data, primaryKey);
|
|
37943
37981
|
for (const key in selectedMap) {
|
|
37944
37982
|
if (hasOwn$1(selectedMap, key) && !dataMap[key]) {
|
|
37945
37983
|
deleted.push(selectedMap[key].row);
|
|
@@ -37947,7 +37985,7 @@ var Vc = (function (exports, vue) {
|
|
|
37947
37985
|
}
|
|
37948
37986
|
} else {
|
|
37949
37987
|
deleted = selection.filter((item) => {
|
|
37950
|
-
return !this.
|
|
37988
|
+
return !this.flatData.value.includes(item);
|
|
37951
37989
|
});
|
|
37952
37990
|
}
|
|
37953
37991
|
deleted.forEach((deletedItem) => {
|
|
@@ -38008,7 +38046,7 @@ var Vc = (function (exports, vue) {
|
|
|
38008
38046
|
const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
|
|
38009
38047
|
this.states.isAllSelected = value;
|
|
38010
38048
|
let selectionChanged = false;
|
|
38011
|
-
this.
|
|
38049
|
+
this.flatData.value.forEach((row, index) => {
|
|
38012
38050
|
if (selectable) {
|
|
38013
38051
|
if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
|
|
38014
38052
|
selectionChanged = true;
|
|
@@ -38039,11 +38077,11 @@ var Vc = (function (exports, vue) {
|
|
|
38039
38077
|
this.tree.expand(val);
|
|
38040
38078
|
}
|
|
38041
38079
|
updateSelectionByRowKey() {
|
|
38042
|
-
const {
|
|
38080
|
+
const { primaryKey } = this.table.props;
|
|
38043
38081
|
const { selection } = this.states;
|
|
38044
|
-
const selectedMap =
|
|
38045
|
-
this.states.selection = this.
|
|
38046
|
-
const rowId =
|
|
38082
|
+
const selectedMap = getValuesMap(selection, primaryKey);
|
|
38083
|
+
this.states.selection = this.flatData.value.reduce((prev, row) => {
|
|
38084
|
+
const rowId = getRowValue(row, primaryKey);
|
|
38047
38085
|
const rowInfo = selectedMap[rowId];
|
|
38048
38086
|
if (rowInfo) {
|
|
38049
38087
|
prev.push(row);
|
|
@@ -38059,7 +38097,7 @@ var Vc = (function (exports, vue) {
|
|
|
38059
38097
|
}
|
|
38060
38098
|
let isAllSelected = true;
|
|
38061
38099
|
let selectedCount = 0;
|
|
38062
|
-
const temp = this.
|
|
38100
|
+
const temp = this.flatData.value;
|
|
38063
38101
|
for (let i = 0, j = temp.length; i < j; i++) {
|
|
38064
38102
|
const row = temp[i];
|
|
38065
38103
|
const isRowSelectable = selectable && selectable.call(null, row, i);
|
|
@@ -38110,8 +38148,10 @@ var Vc = (function (exports, vue) {
|
|
|
38110
38148
|
const NormalList = /* @__PURE__ */ vue.defineComponent({
|
|
38111
38149
|
name: COMPONENT_NAME$h,
|
|
38112
38150
|
props: {
|
|
38113
|
-
data:
|
|
38114
|
-
|
|
38151
|
+
data: {
|
|
38152
|
+
type: Array,
|
|
38153
|
+
default: () => []
|
|
38154
|
+
}
|
|
38115
38155
|
},
|
|
38116
38156
|
emits: ["row-resize"],
|
|
38117
38157
|
setup(props2, {
|
|
@@ -38152,7 +38192,7 @@ var Vc = (function (exports, vue) {
|
|
|
38152
38192
|
expose
|
|
38153
38193
|
}) {
|
|
38154
38194
|
const instance = vue.getCurrentInstance();
|
|
38155
|
-
const table =
|
|
38195
|
+
const table = vue.inject("vc-table");
|
|
38156
38196
|
const states = useStates({
|
|
38157
38197
|
data: "data",
|
|
38158
38198
|
list: "list",
|
|
@@ -38169,6 +38209,7 @@ var Vc = (function (exports, vue) {
|
|
|
38169
38209
|
type
|
|
38170
38210
|
}) => type === "default")
|
|
38171
38211
|
});
|
|
38212
|
+
const wrapper = vue.ref();
|
|
38172
38213
|
vue.watch(() => props2.store.states.hoverRowIndex, (v, oldV) => {
|
|
38173
38214
|
if (!props2.store.states.isComplex || IS_SERVER$3) return;
|
|
38174
38215
|
raf(() => {
|
|
@@ -38179,12 +38220,12 @@ var Vc = (function (exports, vue) {
|
|
|
38179
38220
|
newRow && addClass(newRow, "hover-row");
|
|
38180
38221
|
});
|
|
38181
38222
|
});
|
|
38182
|
-
const
|
|
38223
|
+
const getValueOfRow = (row, index) => {
|
|
38183
38224
|
const {
|
|
38184
|
-
|
|
38225
|
+
primaryKey
|
|
38185
38226
|
} = table.props;
|
|
38186
|
-
if (
|
|
38187
|
-
return
|
|
38227
|
+
if (primaryKey) {
|
|
38228
|
+
return getRowValue(row, primaryKey);
|
|
38188
38229
|
}
|
|
38189
38230
|
return index;
|
|
38190
38231
|
};
|
|
@@ -38249,7 +38290,7 @@ var Vc = (function (exports, vue) {
|
|
|
38249
38290
|
return cellStyle;
|
|
38250
38291
|
};
|
|
38251
38292
|
const getCellClass = (rowIndex, columnIndex, row, column) => {
|
|
38252
|
-
const classes = [column.
|
|
38293
|
+
const classes = [column.realAlign, column.className];
|
|
38253
38294
|
if (isColumnHidden(columnIndex)) {
|
|
38254
38295
|
classes.push("is-hidden");
|
|
38255
38296
|
}
|
|
@@ -38275,7 +38316,7 @@ var Vc = (function (exports, vue) {
|
|
|
38275
38316
|
column,
|
|
38276
38317
|
row
|
|
38277
38318
|
};
|
|
38278
|
-
table.
|
|
38319
|
+
table.hoverState.value = hoverState;
|
|
38279
38320
|
table.emit("cell-mouse-enter", hoverState.row, hoverState.column, hoverState.cell, e);
|
|
38280
38321
|
}
|
|
38281
38322
|
const cellChild = e.target.querySelector(".vc-table__cell");
|
|
@@ -38304,8 +38345,8 @@ var Vc = (function (exports, vue) {
|
|
|
38304
38345
|
const handleCellMouseLeave = (e) => {
|
|
38305
38346
|
const cell = getCell(e);
|
|
38306
38347
|
if (!cell) return;
|
|
38307
|
-
const oldHoverState = table.
|
|
38308
|
-
table.emit("cell-mouse-leave", oldHoverState.row, oldHoverState.column, oldHoverState.cell,
|
|
38348
|
+
const oldHoverState = table.hoverState.value || {};
|
|
38349
|
+
table.emit("cell-mouse-leave", oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
|
|
38309
38350
|
};
|
|
38310
38351
|
const handleMouseEnter = debounce$1((index) => {
|
|
38311
38352
|
props2.store.setHoverRow(index);
|
|
@@ -38341,7 +38382,8 @@ var Vc = (function (exports, vue) {
|
|
|
38341
38382
|
const {
|
|
38342
38383
|
columns
|
|
38343
38384
|
} = states;
|
|
38344
|
-
const key =
|
|
38385
|
+
const key = getValueOfRow(row, rowIndex);
|
|
38386
|
+
const selected = props2.store.isSelected(row);
|
|
38345
38387
|
return vue.createVNode("div", {
|
|
38346
38388
|
"key": key,
|
|
38347
38389
|
"class": [getRowClass(row, rowIndex), "vc-table__tr"],
|
|
@@ -38362,10 +38404,12 @@ var Vc = (function (exports, vue) {
|
|
|
38362
38404
|
};
|
|
38363
38405
|
if (columnsHidden.value[columnIndex]) {
|
|
38364
38406
|
return vue.createVNode("div", {
|
|
38407
|
+
"key": column.id,
|
|
38365
38408
|
"style": [sizeStyle]
|
|
38366
38409
|
}, null);
|
|
38367
38410
|
}
|
|
38368
38411
|
return vue.createVNode("div", {
|
|
38412
|
+
"key": column.id,
|
|
38369
38413
|
"style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
|
|
38370
38414
|
"class": [getCellClass(rowIndex, columnIndex, row, column), "vc-table__td"],
|
|
38371
38415
|
"onMouseenter": (e) => handleCellMouseEnter(e, row),
|
|
@@ -38375,7 +38419,8 @@ var Vc = (function (exports, vue) {
|
|
|
38375
38419
|
column,
|
|
38376
38420
|
rowIndex,
|
|
38377
38421
|
columnIndex,
|
|
38378
|
-
store: props2.store
|
|
38422
|
+
store: props2.store,
|
|
38423
|
+
selected
|
|
38379
38424
|
})]);
|
|
38380
38425
|
})]);
|
|
38381
38426
|
};
|
|
@@ -38405,13 +38450,12 @@ var Vc = (function (exports, vue) {
|
|
|
38405
38450
|
}
|
|
38406
38451
|
});
|
|
38407
38452
|
};
|
|
38408
|
-
const wrapper = vue.ref();
|
|
38409
38453
|
expose({
|
|
38410
38454
|
wrapper,
|
|
38411
38455
|
getRootElement: () => instance.vnode.el
|
|
38412
38456
|
});
|
|
38457
|
+
const layout = table.layout;
|
|
38413
38458
|
return () => {
|
|
38414
|
-
const layout = table.exposed.layout;
|
|
38415
38459
|
return vue.createVNode("div", {
|
|
38416
38460
|
"class": "vc-table__body"
|
|
38417
38461
|
}, [table.props.height ? vue.createVNode(RecycleList, {
|
|
@@ -38420,7 +38464,7 @@ var Vc = (function (exports, vue) {
|
|
|
38420
38464
|
"disabled": true,
|
|
38421
38465
|
"class": "vc-table__tbody",
|
|
38422
38466
|
"scrollerOptions": {
|
|
38423
|
-
barTo: `.${table.
|
|
38467
|
+
barTo: `.${table.tableId}`,
|
|
38424
38468
|
native: false,
|
|
38425
38469
|
always: false,
|
|
38426
38470
|
showBar: !props2.fixed,
|
|
@@ -38456,57 +38500,6 @@ var Vc = (function (exports, vue) {
|
|
|
38456
38500
|
});
|
|
38457
38501
|
const TableSort = "div";
|
|
38458
38502
|
const TableFilter = "div";
|
|
38459
|
-
const getAllColumns = (columns) => {
|
|
38460
|
-
const result = [];
|
|
38461
|
-
columns.forEach((column) => {
|
|
38462
|
-
if (column.children) {
|
|
38463
|
-
result.push(column);
|
|
38464
|
-
result.push(...getAllColumns(column.children));
|
|
38465
|
-
} else {
|
|
38466
|
-
result.push(column);
|
|
38467
|
-
}
|
|
38468
|
-
});
|
|
38469
|
-
return result;
|
|
38470
|
-
};
|
|
38471
|
-
const convertToRows = (originColumns) => {
|
|
38472
|
-
let maxLevel = 1;
|
|
38473
|
-
const traverse = (column, parent) => {
|
|
38474
|
-
if (parent) {
|
|
38475
|
-
column.level = parent.level + 1;
|
|
38476
|
-
if (maxLevel < column.level) {
|
|
38477
|
-
maxLevel = column.level;
|
|
38478
|
-
}
|
|
38479
|
-
}
|
|
38480
|
-
if (column.children) {
|
|
38481
|
-
let colSpan = 0;
|
|
38482
|
-
column.children.forEach((subColumn) => {
|
|
38483
|
-
traverse(subColumn, column);
|
|
38484
|
-
colSpan += subColumn.colSpan;
|
|
38485
|
-
});
|
|
38486
|
-
column.colSpan = colSpan;
|
|
38487
|
-
} else {
|
|
38488
|
-
column.colSpan = 1;
|
|
38489
|
-
}
|
|
38490
|
-
};
|
|
38491
|
-
originColumns.forEach((column) => {
|
|
38492
|
-
column.level = 1;
|
|
38493
|
-
traverse(column);
|
|
38494
|
-
});
|
|
38495
|
-
const rows = [];
|
|
38496
|
-
for (let i = 0; i < maxLevel; i++) {
|
|
38497
|
-
rows.push([]);
|
|
38498
|
-
}
|
|
38499
|
-
const allColumns = getAllColumns(originColumns);
|
|
38500
|
-
allColumns.forEach((column) => {
|
|
38501
|
-
if (!column.children) {
|
|
38502
|
-
column.rowSpan = maxLevel - column.level + 1;
|
|
38503
|
-
} else {
|
|
38504
|
-
column.rowSpan = 1;
|
|
38505
|
-
}
|
|
38506
|
-
rows[column.level - 1].push(column);
|
|
38507
|
-
});
|
|
38508
|
-
return rows;
|
|
38509
|
-
};
|
|
38510
38503
|
const TableHeader = /* @__PURE__ */ vue.defineComponent({
|
|
38511
38504
|
name: "vc-table-header",
|
|
38512
38505
|
props: {
|
|
@@ -38523,7 +38516,7 @@ var Vc = (function (exports, vue) {
|
|
|
38523
38516
|
}
|
|
38524
38517
|
},
|
|
38525
38518
|
setup(props2) {
|
|
38526
|
-
const table =
|
|
38519
|
+
const table = vue.inject("vc-table");
|
|
38527
38520
|
const instance = vue.getCurrentInstance();
|
|
38528
38521
|
const draggingColumn = vue.ref(null);
|
|
38529
38522
|
const dragging = vue.ref(false);
|
|
@@ -38533,16 +38526,18 @@ var Vc = (function (exports, vue) {
|
|
|
38533
38526
|
isAllSelected: "isAllSelected",
|
|
38534
38527
|
leftFixedLeafCount: "leftFixedLeafColumnsLength",
|
|
38535
38528
|
rightFixedLeafCount: "rightFixedLeafColumnsLength",
|
|
38529
|
+
isGroup: "isGroup",
|
|
38530
|
+
headerRows: "headerRows",
|
|
38536
38531
|
columnsCount: ($states) => $states.columns.length,
|
|
38537
38532
|
leftFixedCount: ($states) => $states.leftFixedColumns.length,
|
|
38538
38533
|
rightFixedCount: ($states) => $states.rightFixedColumns.length
|
|
38539
38534
|
});
|
|
38540
|
-
const
|
|
38535
|
+
const isColumnHidden = (index) => {
|
|
38541
38536
|
let start = 0;
|
|
38542
38537
|
for (let i = 0; i < index; i++) {
|
|
38543
|
-
start += columns[i].colSpan;
|
|
38538
|
+
start += states.columns[i].colSpan;
|
|
38544
38539
|
}
|
|
38545
|
-
const after = start + columns[index].colSpan - 1;
|
|
38540
|
+
const after = start + states.columns[index].colSpan - 1;
|
|
38546
38541
|
if (props2.fixed === true || props2.fixed === "left") {
|
|
38547
38542
|
return after >= states.leftFixedLeafCount;
|
|
38548
38543
|
} else if (props2.fixed === "right") {
|
|
@@ -38551,6 +38546,9 @@ var Vc = (function (exports, vue) {
|
|
|
38551
38546
|
return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
|
|
38552
38547
|
}
|
|
38553
38548
|
};
|
|
38549
|
+
const columnsHidden = vue.computed(() => {
|
|
38550
|
+
return states.columns.map((_, index) => isColumnHidden(index));
|
|
38551
|
+
});
|
|
38554
38552
|
const getHeaderRowStyle = (rowIndex) => {
|
|
38555
38553
|
const {
|
|
38556
38554
|
headerRowStyle
|
|
@@ -38591,8 +38589,8 @@ var Vc = (function (exports, vue) {
|
|
|
38591
38589
|
return headerCellStyle;
|
|
38592
38590
|
};
|
|
38593
38591
|
const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
|
|
38594
|
-
const classes = [column.id, column.order, column.
|
|
38595
|
-
if (rowIndex === 0 &&
|
|
38592
|
+
const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
|
|
38593
|
+
if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
|
|
38596
38594
|
classes.push("is-hidden");
|
|
38597
38595
|
}
|
|
38598
38596
|
if (!column.children) {
|
|
@@ -38624,7 +38622,7 @@ var Vc = (function (exports, vue) {
|
|
|
38624
38622
|
if (column.children && column.children.length > 0) return;
|
|
38625
38623
|
if (draggingColumn.value && props2.border) {
|
|
38626
38624
|
dragging.value = true;
|
|
38627
|
-
table.
|
|
38625
|
+
table.resizeProxyVisible.value = true;
|
|
38628
38626
|
const tableEl = table.vnode.el;
|
|
38629
38627
|
const tableLeft = tableEl.getBoundingClientRect().left;
|
|
38630
38628
|
const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
|
|
@@ -38637,7 +38635,7 @@ var Vc = (function (exports, vue) {
|
|
|
38637
38635
|
startColumnLeft: columnRect.left - tableLeft,
|
|
38638
38636
|
tableLeft
|
|
38639
38637
|
};
|
|
38640
|
-
const resizeProxy = table.
|
|
38638
|
+
const resizeProxy = table.resizeProxy.value;
|
|
38641
38639
|
resizeProxy.style.left = dragState.value.startLeft + "px";
|
|
38642
38640
|
document.onselectstart = () => false;
|
|
38643
38641
|
document.ondragstart = () => false;
|
|
@@ -38731,35 +38729,27 @@ var Vc = (function (exports, vue) {
|
|
|
38731
38729
|
});
|
|
38732
38730
|
};
|
|
38733
38731
|
return () => {
|
|
38734
|
-
const {
|
|
38735
|
-
originColumns
|
|
38736
|
-
} = props2.store.states;
|
|
38737
|
-
const columnRows = convertToRows(originColumns);
|
|
38738
|
-
const isGroup = columnRows.length > 1;
|
|
38739
|
-
if (isGroup) table.exposed.isGroup.value = true;
|
|
38740
38732
|
return vue.createVNode("div", {
|
|
38741
38733
|
"class": "vc-table__header"
|
|
38742
38734
|
}, [vue.createVNode("div", {
|
|
38743
38735
|
"class": [{
|
|
38744
|
-
"is-group": isGroup
|
|
38736
|
+
"is-group": states.isGroup
|
|
38745
38737
|
}, "vc-table__thead"]
|
|
38746
38738
|
}, [
|
|
38747
38739
|
// renderList
|
|
38748
|
-
|
|
38740
|
+
states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
|
|
38749
38741
|
"style": getHeaderRowStyle(rowIndex),
|
|
38750
38742
|
"class": [getHeaderRowClass(rowIndex), "vc-table__tr"]
|
|
38751
|
-
}, [columns.map((column,
|
|
38752
|
-
"
|
|
38753
|
-
"rowspan": column.rowSpan,
|
|
38754
|
-
"onMousemove": ($event) => handleMouseMove($event, column),
|
|
38743
|
+
}, [columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
38744
|
+
"onMousemove": (e) => handleMouseMove(e, column),
|
|
38755
38745
|
"onMouseout": handleMouseOut,
|
|
38756
|
-
"onMousedown": (
|
|
38757
|
-
"onClick": (
|
|
38758
|
-
"onContextmenu": (
|
|
38759
|
-
"style": [getHeaderCellStyle(rowIndex,
|
|
38746
|
+
"onMousedown": (e) => handleMouseDown(e, column),
|
|
38747
|
+
"onClick": (e) => handleHeaderClick(e, column),
|
|
38748
|
+
"onContextmenu": (e) => handleHeaderContextMenu(e, column),
|
|
38749
|
+
"style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
|
|
38760
38750
|
width: `${column.realWidth}px`
|
|
38761
38751
|
}],
|
|
38762
|
-
"class": [getHeaderCellClass(rowIndex,
|
|
38752
|
+
"class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), "vc-table__th"],
|
|
38763
38753
|
"key": column.id
|
|
38764
38754
|
}, [vue.createVNode("div", {
|
|
38765
38755
|
"class": [
|
|
@@ -38771,10 +38761,8 @@ var Vc = (function (exports, vue) {
|
|
|
38771
38761
|
]
|
|
38772
38762
|
}, [column.renderHeader ? column.renderHeader({
|
|
38773
38763
|
column,
|
|
38774
|
-
|
|
38775
|
-
|
|
38776
|
-
store: props2.store,
|
|
38777
|
-
_self: instance
|
|
38764
|
+
columnIndex,
|
|
38765
|
+
store: props2.store
|
|
38778
38766
|
}) : column.label, column.tooltip ? vue.createVNode(Icon, {
|
|
38779
38767
|
"type": "o-info",
|
|
38780
38768
|
"onMouseenter": (e) => handleCellMouseEnter(e, column)
|
|
@@ -38816,13 +38804,13 @@ var Vc = (function (exports, vue) {
|
|
|
38816
38804
|
leftFixedCount: ($states) => $states.leftFixedColumns.length,
|
|
38817
38805
|
rightFixedCount: ($states) => $states.rightFixedColumns.length
|
|
38818
38806
|
});
|
|
38819
|
-
const
|
|
38807
|
+
const isColumnHidden = (column, index) => {
|
|
38820
38808
|
if (props2.fixed === true || props2.fixed === "left") {
|
|
38821
38809
|
return index >= states.leftFixedLeafCount;
|
|
38822
38810
|
} else if (props2.fixed === "right") {
|
|
38823
38811
|
let before = 0;
|
|
38824
38812
|
for (let i = 0; i < index; i++) {
|
|
38825
|
-
before += columns[i].colSpan;
|
|
38813
|
+
before += states.columns[i].colSpan;
|
|
38826
38814
|
}
|
|
38827
38815
|
return before < states.columnsCount - states.rightFixedLeafCount;
|
|
38828
38816
|
} else if (!props2.fixed && column.fixed) {
|
|
@@ -38831,12 +38819,13 @@ var Vc = (function (exports, vue) {
|
|
|
38831
38819
|
return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
|
|
38832
38820
|
}
|
|
38833
38821
|
};
|
|
38834
|
-
const
|
|
38835
|
-
|
|
38822
|
+
const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
|
|
38823
|
+
const getRowClasses = (column, columnIndex) => {
|
|
38824
|
+
const classes = [column.realAlign, column.labelClass];
|
|
38836
38825
|
if (column.className) {
|
|
38837
38826
|
classes.push(column.className);
|
|
38838
38827
|
}
|
|
38839
|
-
if (
|
|
38828
|
+
if (columnsHidden.value[columnIndex]) {
|
|
38840
38829
|
classes.push("is-hidden");
|
|
38841
38830
|
}
|
|
38842
38831
|
if (!column.children) {
|
|
@@ -38844,17 +38833,17 @@ var Vc = (function (exports, vue) {
|
|
|
38844
38833
|
}
|
|
38845
38834
|
return classes;
|
|
38846
38835
|
};
|
|
38847
|
-
|
|
38848
|
-
let
|
|
38836
|
+
const sums = vue.computed(() => {
|
|
38837
|
+
let v = [];
|
|
38849
38838
|
if (props2.getSummary) {
|
|
38850
|
-
|
|
38839
|
+
v = props2.getSummary({
|
|
38851
38840
|
columns: states.columns,
|
|
38852
38841
|
data: states.data
|
|
38853
38842
|
});
|
|
38854
38843
|
} else {
|
|
38855
38844
|
states.columns.forEach((column, index) => {
|
|
38856
38845
|
if (index === 0) {
|
|
38857
|
-
|
|
38846
|
+
v[index] = props2.sumText;
|
|
38858
38847
|
return;
|
|
38859
38848
|
}
|
|
38860
38849
|
const values = states.data.map((item) => Number(item[column.prop]));
|
|
@@ -38869,7 +38858,7 @@ var Vc = (function (exports, vue) {
|
|
|
38869
38858
|
});
|
|
38870
38859
|
const precision = Math.max.apply(null, precisions);
|
|
38871
38860
|
if (!notNumber) {
|
|
38872
|
-
|
|
38861
|
+
v[index] = values.reduce((prev, curr) => {
|
|
38873
38862
|
const value = Number(curr);
|
|
38874
38863
|
if (!isNaN(value)) {
|
|
38875
38864
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -38878,10 +38867,13 @@ var Vc = (function (exports, vue) {
|
|
|
38878
38867
|
}
|
|
38879
38868
|
}, 0);
|
|
38880
38869
|
} else {
|
|
38881
|
-
|
|
38870
|
+
v[index] = "";
|
|
38882
38871
|
}
|
|
38883
38872
|
});
|
|
38884
38873
|
}
|
|
38874
|
+
return v;
|
|
38875
|
+
});
|
|
38876
|
+
return () => {
|
|
38885
38877
|
return vue.createVNode("div", {
|
|
38886
38878
|
"class": "vc-table__footer",
|
|
38887
38879
|
"cellspacing": "0",
|
|
@@ -38891,17 +38883,15 @@ var Vc = (function (exports, vue) {
|
|
|
38891
38883
|
"class": "vc-table__tbody"
|
|
38892
38884
|
}, [vue.createVNode("div", {
|
|
38893
38885
|
"class": "vc-table__tr"
|
|
38894
|
-
}, [states.columns.map((column,
|
|
38895
|
-
"key":
|
|
38896
|
-
"
|
|
38897
|
-
"rowspan": column.rowSpan,
|
|
38898
|
-
"class": [getRowClasses(column, cellIndex), "vc-table__td"],
|
|
38886
|
+
}, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
|
|
38887
|
+
"key": columnIndex,
|
|
38888
|
+
"class": [getRowClasses(column, columnIndex), "vc-table__td"],
|
|
38899
38889
|
"style": [{
|
|
38900
38890
|
width: `${column.realWidth}px`
|
|
38901
38891
|
}]
|
|
38902
38892
|
}, [vue.createVNode("div", {
|
|
38903
38893
|
"class": ["vc-table__cell", column.labelClass]
|
|
38904
|
-
}, [sums[
|
|
38894
|
+
}, [sums.value[columnIndex]])]))])])]);
|
|
38905
38895
|
};
|
|
38906
38896
|
}
|
|
38907
38897
|
});
|
|
@@ -38928,7 +38918,7 @@ var Vc = (function (exports, vue) {
|
|
|
38928
38918
|
type: Number,
|
|
38929
38919
|
default: 10
|
|
38930
38920
|
},
|
|
38931
|
-
|
|
38921
|
+
primaryKey: [String, Function],
|
|
38932
38922
|
// 是否显示表头
|
|
38933
38923
|
showHeader: {
|
|
38934
38924
|
type: Boolean,
|
|
@@ -39002,7 +38992,8 @@ var Vc = (function (exports, vue) {
|
|
|
39002
38992
|
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"],
|
|
39003
38993
|
setup(props2, {
|
|
39004
38994
|
slots,
|
|
39005
|
-
expose
|
|
38995
|
+
expose,
|
|
38996
|
+
emit
|
|
39006
38997
|
}) {
|
|
39007
38998
|
const instance = vue.getCurrentInstance();
|
|
39008
38999
|
const store = new Store({
|
|
@@ -39038,21 +39029,21 @@ var Vc = (function (exports, vue) {
|
|
|
39038
39029
|
const rightFixedBody = vue.ref(null);
|
|
39039
39030
|
const rightFixedFooterWrapper = vue.ref(null);
|
|
39040
39031
|
const resizeProxy = vue.ref(null);
|
|
39041
|
-
const isGroup = vue.ref(false);
|
|
39042
39032
|
const scrollPosition = vue.ref("left");
|
|
39043
39033
|
const hoverState = vue.ref(null);
|
|
39044
39034
|
const isReady = vue.ref(false);
|
|
39045
39035
|
const states = useStates({
|
|
39046
39036
|
columns: "columns",
|
|
39047
39037
|
leftFixedColumns: "leftFixedColumns",
|
|
39048
|
-
rightFixedColumns: "rightFixedColumns"
|
|
39038
|
+
rightFixedColumns: "rightFixedColumns",
|
|
39039
|
+
isGroup: "isGroup"
|
|
39049
39040
|
}, store);
|
|
39050
39041
|
const classes = vue.computed(() => {
|
|
39051
39042
|
return {
|
|
39052
39043
|
"vc-table--fit": props2.fit,
|
|
39053
39044
|
"vc-table--striped": props2.stripe,
|
|
39054
|
-
"vc-table--border": props2.border || isGroup
|
|
39055
|
-
"vc-table--group": isGroup
|
|
39045
|
+
"vc-table--border": props2.border || states.isGroup,
|
|
39046
|
+
"vc-table--group": states.isGroup,
|
|
39056
39047
|
"vc-table--fluid-height": props2.maxHeight,
|
|
39057
39048
|
"vc-table--scrollable-x": layout.states.scrollX,
|
|
39058
39049
|
"vc-table--scrollable-y": layout.states.scrollY,
|
|
@@ -39296,13 +39287,13 @@ var Vc = (function (exports, vue) {
|
|
|
39296
39287
|
immediate: true
|
|
39297
39288
|
});
|
|
39298
39289
|
vue.watch(() => props2.currentRowValue, (v) => {
|
|
39299
|
-
if (!props2.
|
|
39290
|
+
if (!props2.primaryKey) return;
|
|
39300
39291
|
store.current.reset(v);
|
|
39301
39292
|
}, {
|
|
39302
39293
|
immediate: true
|
|
39303
39294
|
});
|
|
39304
|
-
vue.watch(() => props2.data, (
|
|
39305
|
-
store.setData(
|
|
39295
|
+
vue.watch(() => [props2.data, props2.data.length], () => {
|
|
39296
|
+
store.setData(props2.data);
|
|
39306
39297
|
isReady.value && vue.nextTick(refreshLayout);
|
|
39307
39298
|
}, {
|
|
39308
39299
|
immediate: true
|
|
@@ -39323,6 +39314,7 @@ var Vc = (function (exports, vue) {
|
|
|
39323
39314
|
}, {
|
|
39324
39315
|
immediate: true
|
|
39325
39316
|
});
|
|
39317
|
+
const tableId = getUid("table");
|
|
39326
39318
|
vue.onMounted(() => {
|
|
39327
39319
|
bindEvents();
|
|
39328
39320
|
store.updateColumns();
|
|
@@ -39333,12 +39325,13 @@ var Vc = (function (exports, vue) {
|
|
|
39333
39325
|
};
|
|
39334
39326
|
isReady.value = true;
|
|
39335
39327
|
});
|
|
39336
|
-
vue.
|
|
39328
|
+
vue.onUnmounted(() => {
|
|
39337
39329
|
isUnMount = true;
|
|
39338
39330
|
unbindEvents();
|
|
39339
39331
|
});
|
|
39340
|
-
const
|
|
39341
|
-
|
|
39332
|
+
const exposed = {
|
|
39333
|
+
bodyXWrapper,
|
|
39334
|
+
bodyYWrapper,
|
|
39342
39335
|
tableId,
|
|
39343
39336
|
store,
|
|
39344
39337
|
layout,
|
|
@@ -39358,8 +39351,12 @@ var Vc = (function (exports, vue) {
|
|
|
39358
39351
|
isReady,
|
|
39359
39352
|
hoverState,
|
|
39360
39353
|
renderExpanded,
|
|
39361
|
-
hiddenColumns
|
|
39362
|
-
|
|
39354
|
+
hiddenColumns,
|
|
39355
|
+
props: props2,
|
|
39356
|
+
emit
|
|
39357
|
+
};
|
|
39358
|
+
expose(exposed);
|
|
39359
|
+
vue.provide("vc-table", exposed);
|
|
39363
39360
|
return () => {
|
|
39364
39361
|
return vue.createVNode("div", {
|
|
39365
39362
|
"class": [classes.value, tableId, "vc-table"],
|
|
@@ -39507,22 +39504,19 @@ var Vc = (function (exports, vue) {
|
|
|
39507
39504
|
order: ""
|
|
39508
39505
|
},
|
|
39509
39506
|
selection: {
|
|
39510
|
-
width:
|
|
39511
|
-
minWidth:
|
|
39512
|
-
realWidth: 48,
|
|
39507
|
+
width: 60,
|
|
39508
|
+
minWidth: 60,
|
|
39513
39509
|
order: "",
|
|
39514
39510
|
className: "vc-table-column--selection"
|
|
39515
39511
|
},
|
|
39516
39512
|
expand: {
|
|
39517
|
-
width:
|
|
39518
|
-
minWidth:
|
|
39519
|
-
realWidth: 48,
|
|
39513
|
+
width: 60,
|
|
39514
|
+
minWidth: 60,
|
|
39520
39515
|
order: ""
|
|
39521
39516
|
},
|
|
39522
39517
|
index: {
|
|
39523
|
-
width:
|
|
39524
|
-
minWidth:
|
|
39525
|
-
realWidth: 48,
|
|
39518
|
+
width: 60,
|
|
39519
|
+
minWidth: 60,
|
|
39526
39520
|
order: ""
|
|
39527
39521
|
}
|
|
39528
39522
|
};
|
|
@@ -39546,10 +39540,11 @@ var Vc = (function (exports, vue) {
|
|
|
39546
39540
|
column,
|
|
39547
39541
|
store,
|
|
39548
39542
|
rowIndex,
|
|
39549
|
-
level
|
|
39543
|
+
level,
|
|
39544
|
+
selected
|
|
39550
39545
|
}) {
|
|
39551
39546
|
return vue.withDirectives(vue.createVNode(Checkbox, {
|
|
39552
|
-
"modelValue":
|
|
39547
|
+
"modelValue": selected,
|
|
39553
39548
|
"disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
|
|
39554
39549
|
"onChange": () => store.rowSelectedChanged(row),
|
|
39555
39550
|
"onClick": (e) => e.stopPropagation()
|
|
@@ -39682,8 +39677,8 @@ var Vc = (function (exports, vue) {
|
|
|
39682
39677
|
customClass: String,
|
|
39683
39678
|
labelClass: String,
|
|
39684
39679
|
prop: String,
|
|
39685
|
-
width:
|
|
39686
|
-
minWidth:
|
|
39680
|
+
width: Number,
|
|
39681
|
+
minWidth: Number,
|
|
39687
39682
|
renderHeader: Function,
|
|
39688
39683
|
resizable: {
|
|
39689
39684
|
type: Boolean,
|
|
@@ -39717,14 +39712,13 @@ var Vc = (function (exports, vue) {
|
|
|
39717
39712
|
tooltip: [String, Function]
|
|
39718
39713
|
},
|
|
39719
39714
|
setup(props2, {
|
|
39720
|
-
slots
|
|
39721
|
-
expose
|
|
39715
|
+
slots
|
|
39722
39716
|
}) {
|
|
39723
39717
|
const instance = vue.getCurrentInstance();
|
|
39724
|
-
const table =
|
|
39725
|
-
const parent =
|
|
39718
|
+
const table = vue.inject("vc-table");
|
|
39719
|
+
const parent = vue.inject("vc-table-column", table);
|
|
39726
39720
|
const isSubColumn = table !== parent;
|
|
39727
|
-
const columnId = vue.ref((parent.
|
|
39721
|
+
const columnId = vue.ref((parent.tableId || parent.columnId) + getUid("column"));
|
|
39728
39722
|
const realWidth = vue.computed(() => {
|
|
39729
39723
|
return parseWidth(props2.width);
|
|
39730
39724
|
});
|
|
@@ -39788,7 +39782,7 @@ var Vc = (function (exports, vue) {
|
|
|
39788
39782
|
column.renderCell = (data) => vue.createVNode("div", {
|
|
39789
39783
|
"class": "vc-table__cell"
|
|
39790
39784
|
}, [originRenderCell(data)]);
|
|
39791
|
-
table.
|
|
39785
|
+
table.renderExpanded.value = (data) => {
|
|
39792
39786
|
return slots.default ? slots.default(data) : slots.default;
|
|
39793
39787
|
};
|
|
39794
39788
|
} else {
|
|
@@ -39805,7 +39799,7 @@ var Vc = (function (exports, vue) {
|
|
|
39805
39799
|
class: "vc-table__cell",
|
|
39806
39800
|
style: {}
|
|
39807
39801
|
};
|
|
39808
|
-
if (!isEmpty$1(table.
|
|
39802
|
+
if (!isEmpty$1(table.store.states.treeData) && !prefix2 && data.isExpandColumn) {
|
|
39809
39803
|
prefix2 = vue.createVNode("span", {
|
|
39810
39804
|
"class": "vc-table-un-expand__indent"
|
|
39811
39805
|
}, null);
|
|
@@ -39825,24 +39819,14 @@ var Vc = (function (exports, vue) {
|
|
|
39825
39819
|
}
|
|
39826
39820
|
return column;
|
|
39827
39821
|
};
|
|
39828
|
-
const
|
|
39822
|
+
const registerColumn = () => {
|
|
39829
39823
|
const defaults2 = {
|
|
39830
39824
|
...cellStarts[props2.type],
|
|
39831
|
-
type: props2.type,
|
|
39832
39825
|
id: columnId.value,
|
|
39833
|
-
|
|
39834
|
-
|
|
39835
|
-
prop: props2.prop,
|
|
39836
|
-
showPopover: props2.showPopover,
|
|
39837
|
-
// index 列
|
|
39838
|
-
index: props2.index
|
|
39826
|
+
realAlign,
|
|
39827
|
+
realHeaderAlign
|
|
39839
39828
|
};
|
|
39840
|
-
|
|
39841
|
-
const selectProps = ["selectable", "reserveSelection"];
|
|
39842
|
-
const sortProps = ["sortable"];
|
|
39843
|
-
const filterProps = ["filters", "filteredValue", "filterMultiple", "filter", "filterIcon", "filterPopupClass"];
|
|
39844
|
-
let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
|
|
39845
|
-
column = merge$1(defaults2, column);
|
|
39829
|
+
let column = merge$1(defaults2, getPropsData(Object.keys(props2)));
|
|
39846
39830
|
column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
|
|
39847
39831
|
for (const key in column) {
|
|
39848
39832
|
if (hasOwn$1(column, key)) {
|
|
@@ -39850,32 +39834,34 @@ var Vc = (function (exports, vue) {
|
|
|
39850
39834
|
}
|
|
39851
39835
|
}
|
|
39852
39836
|
};
|
|
39853
|
-
const
|
|
39837
|
+
const registerWatchers = () => {
|
|
39838
|
+
Object.keys(props2).forEach((k) => vue.watch(() => props2[k], (v) => columnConfig[k] = v));
|
|
39854
39839
|
vue.watch(() => props2.fixed, () => {
|
|
39855
|
-
table.
|
|
39840
|
+
table.store.scheduleLayout(true);
|
|
39856
39841
|
});
|
|
39857
|
-
vue.watch(() => realWidth.value, () => {
|
|
39858
|
-
|
|
39842
|
+
vue.watch(() => realWidth.value, (v) => {
|
|
39843
|
+
columnConfig["width"] = v;
|
|
39844
|
+
columnConfig["realWidth"] = v;
|
|
39845
|
+
table.store.scheduleLayout(false);
|
|
39859
39846
|
});
|
|
39860
39847
|
vue.watch(() => realMinWidth.value, () => {
|
|
39861
|
-
table.
|
|
39848
|
+
table.store.scheduleLayout(false);
|
|
39862
39849
|
});
|
|
39863
39850
|
};
|
|
39864
39851
|
vue.onBeforeMount(() => {
|
|
39865
|
-
|
|
39866
|
-
|
|
39852
|
+
registerColumn();
|
|
39853
|
+
registerWatchers();
|
|
39867
39854
|
});
|
|
39868
|
-
vue.onUpdated(refreshColumnBasicConfig);
|
|
39869
39855
|
vue.onMounted(() => {
|
|
39870
|
-
const children = isSubColumn ? parent.vnode.el.children : parent.
|
|
39856
|
+
const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
|
|
39871
39857
|
const columnIndex = [...children].indexOf(instance.vnode.el);
|
|
39872
|
-
table.
|
|
39858
|
+
table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
|
|
39873
39859
|
});
|
|
39874
39860
|
vue.onUnmounted(() => {
|
|
39875
39861
|
if (!instance.parent) return;
|
|
39876
|
-
table.
|
|
39862
|
+
table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
|
|
39877
39863
|
});
|
|
39878
|
-
|
|
39864
|
+
vue.provide("vc-table-column", {
|
|
39879
39865
|
columnId,
|
|
39880
39866
|
columnConfig
|
|
39881
39867
|
});
|
|
@@ -39885,7 +39871,8 @@ var Vc = (function (exports, vue) {
|
|
|
39885
39871
|
const renderDefault = slots?.default?.({
|
|
39886
39872
|
row: {},
|
|
39887
39873
|
column: {},
|
|
39888
|
-
|
|
39874
|
+
columnIndex: -1,
|
|
39875
|
+
rowIndex: -1
|
|
39889
39876
|
});
|
|
39890
39877
|
if (renderDefault instanceof Array) {
|
|
39891
39878
|
for (const childNode of renderDefault) {
|