vxe-table
Version:
A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.
1,006 lines (1,005 loc) • 43.3 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var body_exports = {};
__export(body_exports, {
default: () => body_default
});
module.exports = __toCommonJS(body_exports);
var import_vue = require("vue");
var import_comp = require("../../ui/src/comp");
var import_xe_utils = __toESM(require("xe-utils"));
var import_core = require("@vxe-ui/core");
var import_util = require("./util");
var import_dom = require("../../ui/src/dom");
var import_utils = require("../../ui/src/utils");
var import_vn = require("../../ui/src/vn");
const { getI18n, renderer, renderEmptyElement } = import_core.VxeUI;
const sourceType = "table";
const renderType = "body";
var body_default = (
/* define-vxe-component start */
(0, import_comp.defineVxeComponent)({
name: "VxeTableBody",
props: {
tableData: Array,
tableColumn: Array,
fixedColumn: Array,
fixedType: {
type: String,
default: ""
}
},
setup(props) {
const $xeTable = (0, import_vue.inject)("$xeTable", {});
const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xeTable;
const {
computeEditOpts,
computeMouseOpts,
computeCellOffsetWidth,
computeAreaOpts,
computeDefaultRowHeight,
computeEmptyOpts,
computeTooltipOpts,
computeRadioOpts,
computeExpandOpts,
computeTreeOpts,
computeCheckboxOpts,
computeCellOpts,
computeValidOpts,
computeRowOpts,
computeColumnOpts,
computeRowDragOpts,
computeResizableOpts,
computeVirtualXOpts,
computeVirtualYOpts,
computeIsBodyRenderOptimize,
computeRendererOpts,
computeShowTreeLine
} = $xeTable.getComputeMaps();
const refElem = (0, import_vue.ref)();
const refBodyScroll = (0, import_vue.ref)();
const refBodyTable = (0, import_vue.ref)();
const refBodyColgroup = (0, import_vue.ref)();
const refBodyTBody = (0, import_vue.ref)();
const refBodyXSpace = (0, import_vue.ref)();
const refBodyYSpace = (0, import_vue.ref)();
const refBodyEmptyBlock = (0, import_vue.ref)();
const isVMScrollProcess = () => {
const { delayHover } = tableProps;
const { isDragResize } = tableReactData;
const { lastSTime } = tableInternalData;
return !!(isDragResize || lastSTime && Date.now() < lastSTime + delayHover);
};
const renderLine = (rowid, params) => {
const { column } = params;
const { treeConfig } = tableProps;
const { slots, treeNode } = column;
const lineVNs = [];
if (treeConfig && treeNode) {
if (slots && slots.line) {
return $xeTable.callSlot(slots.line, params);
}
const treeOpts = computeTreeOpts.value;
const { fullAllDataRowIdData } = tableInternalData;
const { lineType } = treeOpts;
const rowRest = fullAllDataRowIdData[rowid];
const treeLines = rowRest.treeLines;
if (treeLines) {
treeLines.forEach((item, i) => {
lineVNs.push(
(0, import_vue.h)("span", {
key: "le" + i,
class: ["vxe-table--tree-node-line", `type--${lineType || "solid"}`, item.type],
style: item.style
})
);
});
}
}
return lineVNs;
};
const renderTdColumn = (seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) => {
const $xeGrid = $xeTable.xeGrid;
const $xeGantt = $xeTable.xeGantt;
const { columnKey, resizable: allResizable, showOverflow: allShowOverflow, border, height, treeConfig, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig, padding: allPadding } = tableProps;
const { tableData, tableColumn, dragRow, overflowX, overflowY, scrollXLoad, scrollYLoad, mergeBodyFlag, calcCellHeightFlag, resizeHeightFlag, resizeWidthFlag, editStore, isAllOverflow, validErrorMaps, currColFlag } = tableReactData;
const { fullAllDataRowIdData, fullColumnIdData, mergeBodyCellMaps, visibleColumn, afterFullData, mergeBodyList, scrollXStore, scrollYStore, keepUpdateFieldMaps, currentCol } = tableInternalData;
const showTreeLine = computeShowTreeLine.value;
const cellOpts = computeCellOpts.value;
const validOpts = computeValidOpts.value;
const checkboxOpts = computeCheckboxOpts.value;
const editOpts = computeEditOpts.value;
const tooltipOpts = computeTooltipOpts.value;
const resizableOpts = computeResizableOpts.value;
const virtualXOpts = computeVirtualXOpts.value;
const virtualYOpts = computeVirtualYOpts.value;
const rendererOpts = computeRendererOpts.value;
const { isAllColumnDrag, isAllRowDrag } = resizableOpts;
const rowOpts = computeRowOpts.value;
const rowDragOpts = computeRowDragOpts.value;
const defaultRowHeight = computeDefaultRowHeight.value;
const customCellHeight = calcCellHeightFlag ? cellOpts.height || rowOpts.height : 0;
const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts;
const columnOpts = computeColumnOpts.value;
const mouseOpts = computeMouseOpts.value;
const areaOpts = computeAreaOpts.value;
const cellOffsetWidth = computeCellOffsetWidth.value;
const { selectCellToRow } = areaOpts;
const { field, type, cellRender, editRender, align, showOverflow, className, treeNode, rowResize, padding, verticalAlign, slots } = column;
const { verticalAlign: allVerticalAlign, minHeight, maxHeight } = cellOpts;
const { actived } = editStore;
const rowRest = fullAllDataRowIdData[rowid] || {};
const colid = column.id;
const colRest = fullColumnIdData[colid] || {};
const renderOpts = editRender || cellRender;
const compConf = renderOpts && renderOpts.name ? rendererOpts[renderOpts.name] || renderer.get(renderOpts.name) : null;
const compCellClassName = compConf ? compConf.tableCellClassName || compConf.cellClassName : null;
const compCellStyle = compConf ? compConf.tableCellStyle || compConf.cellStyle : "";
const showAllTip = tooltipOpts.showAll;
const columnIndex = colRest.index;
const _columnIndex = colRest._index;
const isEdit = (0, import_utils.isEnableConf)(editRender);
const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0;
let fixedHiddenColumn = overflowX && (fixedType ? column.fixed !== fixedType : !!column.fixed);
const cellPadding = (0, import_utils.getDefaultConfig)(padding, allPadding === null ? cellOpts.padding : allPadding);
const isAllCellPadding = cellPadding === true;
const isCellPaddingTop = cellPadding ? isAllCellPadding || cellPadding.top !== false : false;
const isCellPaddingBottom = cellPadding ? isAllCellPadding || cellPadding.bottom !== false : false;
const isCellPaddingLeft = cellPadding ? isAllCellPadding || cellPadding.left !== false : false;
const isCellPaddingRight = cellPadding ? isAllCellPadding || cellPadding.right !== false : false;
const cellOverflow = (0, import_utils.getDefaultConfig)(showOverflow, allShowOverflow);
const showEllipsis = (cellOverflow === true ? tooltipOpts.mode : cellOverflow) === "ellipsis";
const showTitle = (cellOverflow === true ? tooltipOpts.mode : cellOverflow) === "title";
const showTooltip = (cellOverflow === true ? tooltipOpts.mode : cellOverflow) === "tooltip";
const hasEllipsis = isAllOverflow || showTitle || showTooltip || showEllipsis;
const showResizable = import_xe_utils.default.isBoolean(column.resizable) ? column.resizable : columnOpts.resizable || allResizable;
const isCsHeight = !!customCellHeight;
const isRsHeight = resizeHeight > 0;
let isDirty;
const tdOns = {};
const cellAlign = align || (compConf ? compConf.tableCellAlign : "") || allAlign;
const cellVerticalAlign = import_xe_utils.default.eqNull(verticalAlign) ? allVerticalAlign : verticalAlign;
const errorValidItem = validErrorMaps[`${rowid}:${colid}`];
const showValidTip = editRules && validOpts.showErrorMessage && (validOpts.message === "default" ? height || tableData.length > 1 : validOpts.message === "inline");
const tdAttrs = { colid };
const cellParams = {
$table: $xeTable,
$grid: $xeGrid,
$gantt: $xeGantt,
isEdit: false,
seq,
rowid,
row,
rowIndex,
$rowIndex,
_rowIndex,
column,
columnIndex,
$columnIndex,
_columnIndex,
fixed: fixedType,
source: sourceType,
type: renderType,
isHidden: !!fixedHiddenColumn,
level: rowLevel,
visibleData: afterFullData,
data: tableData,
items
};
let isRowDragCell = false;
let isDisabledDrag = false;
if (rowOpts.drag) {
isRowDragCell = rowDragOpts.trigger === "row" || column.dragSort && rowDragOpts.trigger === "cell";
}
if (isRowDragCell) {
isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams));
}
if (showTitle || showTooltip || showAllTip || tooltipConfig) {
tdOns.onMouseover = (evnt) => {
if (!isVMScrollProcess()) {
if (showTitle) {
(0, import_dom.updateCellTitle)(evnt.currentTarget, column);
} else if (showTooltip || showAllTip) {
$xeTable.triggerBodyTooltipEvent(evnt, cellParams);
}
}
$xeTable.dispatchEvent("cell-mouseenter", Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
};
}
if (showTooltip || showAllTip || tooltipConfig) {
tdOns.onMouseleave = (evnt) => {
if (!isVMScrollProcess()) {
if (showTooltip || showAllTip) {
$xeTable.handleTargetLeaveEvent(evnt);
}
}
$xeTable.dispatchEvent("cell-mouseleave", Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
};
}
if (isRowDragCell || checkboxOpts.range || (0, import_utils.hasEnableConf)(mouseConfig, mouseOpts)) {
tdOns.onMousedown = (evnt) => {
$xeTable.triggerCellMousedownEvent(evnt, cellParams);
};
}
if (isRowDragCell) {
tdOns.onMouseup = $xeTable.triggerCellMouseupEvent;
}
tdOns.onClick = (evnt) => {
$xeTable.triggerCellClickEvent(evnt, cellParams);
};
tdOns.onDblclick = (evnt) => {
$xeTable.triggerCellDblclickEvent(evnt, cellParams);
};
let isMergeCell = false;
let mergeColspan = 1;
let mergeRowspan = 1;
if (mergeBodyFlag && mergeBodyList.length) {
const spanRest = mergeBodyCellMaps[`${_rowIndex}:${_columnIndex}`];
if (spanRest) {
const { rowspan, colspan } = spanRest;
if (!rowspan || !colspan) {
return renderEmptyElement($xeTable);
}
if (rowspan > 1) {
isMergeCell = true;
mergeRowspan = rowspan;
tdAttrs.rowspan = rowspan;
}
if (colspan > 1) {
isMergeCell = true;
mergeColspan = colspan;
tdAttrs.colspan = colspan;
}
}
} else if (spanMethod) {
const { rowspan = 1, colspan = 1 } = spanMethod(cellParams) || {};
if (!rowspan || !colspan) {
return renderEmptyElement($xeTable);
}
if (rowspan > 1) {
isMergeCell = true;
mergeRowspan = rowspan;
tdAttrs.rowspan = rowspan;
}
if (colspan > 1) {
isMergeCell = true;
mergeColspan = colspan;
tdAttrs.colspan = colspan;
}
}
if (fixedHiddenColumn && isMergeCell) {
if (tdAttrs.colspan > 1 || tdAttrs.rowspan > 1) {
fixedHiddenColumn = false;
}
}
if (!fixedHiddenColumn && editConfig && (editOpts.showStatus || editOpts.showUpdateStatus) && keepUpdateFieldMaps[field]) {
isDirty = $xeTable.isUpdateByRow(row, field);
}
const isVNAutoHeight = !hasEllipsis && (scrollYLoad || scrollXLoad);
let cellHeight = (0, import_util.getCellRestHeight)(rowRest, cellOpts, rowOpts, defaultRowHeight);
const isLastColumn = $columnIndex === columns.length - 1;
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === "auto" || column.width === "auto");
let isVNPreEmptyStatus = false;
if (!isMergeCell) {
if (!dragRow || (0, import_util.getRowid)($xeTable, dragRow) !== rowid) {
if (overflowY && scrollYLoad && tableData.length > 16 && !treeConfig && !virtualYOpts.immediate && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
isVNPreEmptyStatus = true;
} else if (overflowX && scrollXLoad && tableColumn.length > 10 && !virtualXOpts.immediate && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
isVNPreEmptyStatus = true;
}
}
}
if (mergeRowspan > 1) {
const mEndRow = afterFullData[_rowIndex + mergeRowspan - 1];
if (mEndRow) {
const meRowRest = fullAllDataRowIdData[(0, import_util.getRowid)($xeTable, mEndRow)];
if (meRowRest) {
cellHeight += meRowRest.oTop + (0, import_util.getCellRestHeight)(meRowRest, cellOpts, rowOpts, defaultRowHeight) - rowRest.oTop - (0, import_util.getCellRestHeight)(rowRest, cellOpts, rowOpts, defaultRowHeight);
}
}
}
const tdStyle = {};
const tcStyle = {};
if (maxHeight) {
tcStyle.maxHeight = maxHeight + "px";
}
if (hasEllipsis && resizeWidthFlag) {
let mergeColWidth = 0;
if (mergeColspan > 1) {
for (let index = 1; index < mergeColspan; index++) {
const nextColumn = visibleColumn[columnIndex + index];
if (nextColumn) {
mergeColWidth += nextColumn.renderWidth;
}
}
}
tcStyle.width = column.renderWidth + mergeColWidth - cellOffsetWidth + "px";
}
if (scrollYLoad || scrollXLoad || hasEllipsis || isCsHeight || isRsHeight) {
tcStyle.height = cellHeight + "px";
tdStyle["--vxe-ui-table-cell-height"] = cellHeight + "px";
} else {
tcStyle.minHeight = cellHeight + "px";
}
if (minHeight) {
tcStyle.minHeight = minHeight + "px";
}
const tdVNs = [];
if (fixedHiddenColumn && isAllOverflow) {
tdVNs.push(
(0, import_vue.h)("div", {
key: "tc",
class: [
"vxe-cell",
{
"c--title": showTitle,
"c--tooltip": showTooltip,
"c--ellipsis": showEllipsis
}
],
style: tcStyle
})
);
} else {
if (treeConfig && showTreeLine) {
tdVNs.push(...renderLine(rowid, cellParams));
}
const clVNs = [];
if (!isVNPreEmptyStatus) {
clVNs.push(
(0, import_vue.h)(
"div",
{
colid,
rowid,
class: "vxe-cell--wrapper vxe-body-cell--wrapper"
},
column.renderCell(cellParams)
)
);
}
tdVNs.push(
(0, import_vue.h)(
"div",
{
key: "tc",
class: [
"vxe-cell",
{
"c--title": showTitle,
"c--tooltip": showTooltip,
"c--ellipsis": showEllipsis
}
],
style: tcStyle,
title: showTitle ? $xeTable.getCellLabel(row, column) : null
},
clVNs
)
);
if (showValidTip && errorValidItem) {
const errRule = errorValidItem.rule;
const validSlot = slots ? slots.valid : null;
const validParams = { ...cellParams, ...errorValidItem, rule: errorValidItem };
tdVNs.push(
(0, import_vue.h)(
"div",
{
key: "tcv",
class: ["vxe-cell--valid-error-tip", (0, import_dom.getPropClass)(validOpts.className, validParams)],
style: errRule && errRule.maxWidth ? {
width: errRule.maxWidth + "px"
} : null
},
[
(0, import_vue.h)(
"div",
{
class: `vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-${validOpts.theme || "normal"}`
},
[
validSlot ? $xeTable.callSlot(validSlot, validParams) : [
(0, import_vue.h)(
"span",
{
class: "vxe-cell--valid-error-msg"
},
errorValidItem.content
)
]
]
)
]
)
);
}
}
let showAreaRowStatus = false;
if ((0, import_utils.hasEnableConf)(mouseConfig, mouseOpts) && mouseOpts.area && !_columnIndex && selectCellToRow) {
showAreaRowStatus = true;
}
if (!fixedHiddenColumn && showResizable && isAllColumnDrag) {
tdVNs.push(
(0, import_vue.h)("div", {
key: "tcc",
class: [
"vxe-cell--col-resizable",
{
"is--line": !border || border === "none"
}
],
onMousedown: (evnt) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
onDblclick: (evnt) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
})
);
}
if ((rowResize || isAllRowDrag) && rowOpts.resizable) {
tdVNs.push(
(0, import_vue.h)("div", {
key: "tcr",
class: "vxe-cell--row-resizable",
onMousedown: (evnt) => $xeTable.handleRowResizeMousedownEvent(evnt, cellParams),
onDblclick: (evnt) => $xeTable.handleRowResizeDblclickEvent(evnt, cellParams)
})
);
}
return (0, import_vue.h)(
"td",
{
class: [
"vxe-table--column vxe-body--column",
colid,
cellVerticalAlign ? `col--vertical-${cellVerticalAlign}` : "",
cellAlign ? `col--${cellAlign}` : "",
type ? `col--${type}` : "",
{
"col--last": isLastColumn,
"col--tree-node": treeNode,
"col--edit": isEdit,
"col--ellipsis": hasEllipsis,
"col--cs-height": isCsHeight,
"col--rs-height": isRsHeight,
"col--to-row": showAreaRowStatus,
"col--auto-height": isVNAutoHeight,
"col--max-height": maxHeight,
"fixed--width": !isAutoCellWidth,
"fixed--hidden": fixedHiddenColumn,
"is--pg-top": isCellPaddingTop,
"is--pg-bottom": isCellPaddingBottom,
"is--pg-left": isCellPaddingLeft,
"is--pg-right": isCellPaddingRight,
"is--progress": fixedHiddenColumn && isAllOverflow || isVNPreEmptyStatus,
"is--drag-cell": isRowDragCell && (isCrossDrag || isPeerDrag || !rowLevel),
"is--drag-disabled": isDisabledDrag,
"col--dirty": isDirty,
"col--active": editConfig && isEdit && actived.row === row && (actived.column === column || editOpts.mode === "row"),
"col--valid-error": !!errorValidItem,
"show--valid-bg": errorValidItem && validOpts.showErrorBackground,
"col--current": currColFlag && currentCol === column
},
(0, import_dom.getPropClass)(compCellClassName, cellParams),
(0, import_dom.getPropClass)(className, cellParams),
(0, import_dom.getPropClass)(allCellClassName, cellParams)
],
key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || rowOpts.useKey || columnOpts.drag ? colid : $columnIndex,
...tdAttrs,
style: Object.assign(tdStyle, import_xe_utils.default.isFunction(compCellStyle) ? compCellStyle(cellParams) : compCellStyle, import_xe_utils.default.isFunction(cellStyle) ? cellStyle(cellParams) : cellStyle),
...tdOns
},
isOptimizeMode && fixedHiddenColumn ? [] : tdVNs
);
};
const renderRows = (fixedType, isOptimizeMode, tableData, tableColumn) => {
const $xeGrid = $xeTable.xeGrid;
const $xeGantt = $xeTable.xeGantt;
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps;
const { hasFixedColumn, treeExpandedFlag, scrollYLoad, isAllOverflow, rowExpandedFlag, expandColumn, selectRadioRow, pendingRowFlag, rowExpandHeightFlag, isRowGroupStatus } = tableReactData;
const { fullAllDataRowIdData, fullColumnIdData, treeExpandedMaps, pendingRowMaps, rowExpandedMaps, currentRow } = tableInternalData;
const checkboxOpts = computeCheckboxOpts.value;
const radioOpts = computeRadioOpts.value;
const treeOpts = computeTreeOpts.value;
const editOpts = computeEditOpts.value;
const rowOpts = computeRowOpts.value;
const columnOpts = computeColumnOpts.value;
const { transform, seqMode } = treeOpts;
const childrenField = treeOpts.children || treeOpts.childrenField;
const rows = [];
const { handleGetRowId } = (0, import_util.createHandleGetRowId)($xeTable);
const isDeepRow = treeConfig || isRowGroupStatus;
tableData.forEach((row, $rowIndex) => {
const rowid = handleGetRowId(row);
const rowRest = fullAllDataRowIdData[rowid] || {};
let rowIndex = $rowIndex;
let rowLevel = 0;
let seq = -1;
let _rowIndex = -1;
const hasRowGroupAggregate = isRowGroupStatus && row.isAggregate;
const trOn = {};
if (rowOpts.isHover || highlightHoverRow) {
trOn.onMouseover = (evnt) => {
if (isVMScrollProcess()) {
return;
}
$xeTable.triggerHoverEvent(evnt, { row, rowIndex });
};
trOn.onMouseleave = () => {
if (isVMScrollProcess()) {
return;
}
$xeTable.clearHoverRow();
};
}
if (rowRest) {
rowIndex = rowRest.index;
_rowIndex = rowRest._index;
rowLevel = rowRest.level;
seq = rowRest.seq;
if (hasRowGroupAggregate || treeConfig && transform && seqMode === "increasing") {
seq = rowRest._index + 1;
} else if (treeConfig && seqMode === "fixed") {
seq = rowRest._tIndex + 1;
}
}
const params = {
$table: $xeTable,
seq,
rowid,
fixed: fixedType,
type: renderType,
level: rowLevel,
row,
rowIndex,
$rowIndex,
_rowIndex
};
const isExpandRow = expandColumn && !!rowExpandedFlag && !!rowExpandedMaps[rowid];
let isExpandTree = false;
let rowChildren = [];
let isNewRow = false;
if (editConfig) {
isNewRow = $xeTable.isInsertByRow(row);
}
if (treeConfig && !scrollYLoad && !transform) {
rowChildren = row[childrenField];
isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid];
}
if (rowOpts.drag && !isRowGroupStatus && (!treeConfig || transform)) {
trOn.onDragstart = $xeTable.handleRowDragDragstartEvent;
trOn.onDragend = $xeTable.handleRowDragDragendEvent;
trOn.onDragover = $xeTable.handleRowDragDragoverEvent;
}
const trClass = [
"vxe-body--row",
isDeepRow ? `row--level-${rowLevel}` : "",
{
"row--stripe": stripe && (_rowIndex + 1) % 2 === 0,
"is--new": isNewRow,
"is--expand-row": isExpandRow,
"is--expand-tree": isExpandTree,
"row--new": isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
"row--radio": radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
"row--checked": checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
"row--pending": !!pendingRowFlag && !!pendingRowMaps[rowid],
"row--group": hasRowGroupAggregate,
"row--current": currentRow && rowid === (0, import_util.getRowid)($xeTable, currentRow)
},
(0, import_dom.getPropClass)(rowClassName, params)
];
const tdVNs = tableColumn.map((column, $columnIndex) => {
return renderTdColumn(seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData);
});
rows.push(
(0, import_vue.h)(
"tr",
{
class: trClass,
rowid,
style: rowStyle ? import_xe_utils.default.isFunction(rowStyle) ? rowStyle(params) : rowStyle : null,
key: rowKey || rowOpts.useKey || rowOpts.drag || columnOpts.drag || isRowGroupStatus || treeConfig ? rowid : $rowIndex,
...trOn
},
tdVNs
)
);
if (isExpandRow) {
const expandOpts = computeExpandOpts.value;
const { height: expandHeight, padding, mode: expandMode } = expandOpts;
if (expandMode === "fixed") {
const currExpHeight = rowRest.expandHeight;
let expHeight = 0;
if (rowExpandHeightFlag) {
if (currExpHeight || expandHeight) {
expHeight = (currExpHeight || expandHeight || 0) + 1;
}
}
rows.push(
(0, import_vue.h)(
"tr",
{
class: "vxe-body--row-expanded-place",
key: `expand_${rowid}`,
rowid
},
[
(0, import_vue.h)("td", {
class: "vxe-body--row-expanded-place-column",
colspan: tableColumn.length,
style: {
height: `${expHeight}px`
}
})
]
)
);
} else {
const cellStyle = {};
if (expandHeight) {
cellStyle.height = `${expandHeight}px`;
}
if (treeConfig) {
cellStyle.paddingLeft = `calc(${rowLevel} * var(--vxe-ui-table-current-tree-node-indent) + 30px)`;
}
const { showOverflow } = expandColumn || {};
const colid = expandColumn.id;
const colRest = fullColumnIdData[colid] || {};
const hasEllipsis = import_xe_utils.default.eqNull(showOverflow) ? isAllOverflow : showOverflow;
let columnIndex = -1;
let $columnIndex = -1;
let _columnIndex = -1;
if (colRest) {
columnIndex = colRest.index;
$columnIndex = colRest.$index;
_columnIndex = colRest._index;
}
const expandParams = {
$table: $xeTable,
$grid: $xeGrid,
$gantt: $xeGantt,
seq,
column: expandColumn,
columnIndex,
$columnIndex,
_columnIndex,
fixed: fixedType,
source: sourceType,
type: renderType,
level: rowLevel,
row,
rowid,
rowIndex,
$rowIndex,
_rowIndex,
isHidden: false,
isEdit: false,
visibleData: [],
data: [],
items: []
};
rows.push(
(0, import_vue.h)(
"tr",
{
class: [
"vxe-body--expanded-row",
{
"is--padding": padding
}
],
key: `expand_${rowid}`
},
[
(0, import_vue.h)(
"td",
{
class: [
"vxe-body--expanded-column",
{
"fixed--hidden": fixedType && !hasFixedColumn,
"col--ellipsis": hasEllipsis
}
],
colspan: tableColumn.length
},
[
(0, import_vue.h)(
"div",
{
class: [
"vxe-body--expanded-cell",
{
"is--ellipsis": expandHeight
}
],
style: cellStyle
},
[expandColumn.renderData(expandParams)]
)
]
)
]
)
);
}
}
if (isExpandTree) {
rows.push(...renderRows(fixedType, isOptimizeMode, rowChildren, tableColumn));
}
});
return rows;
};
(0, import_vue.onMounted)(() => {
(0, import_vue.nextTick)(() => {
const { fixedType } = props;
const { elemStore } = tableInternalData;
const prefix = `${fixedType || "main"}-body-`;
elemStore[`${prefix}wrapper`] = refElem;
elemStore[`${prefix}scroll`] = refBodyScroll;
elemStore[`${prefix}table`] = refBodyTable;
elemStore[`${prefix}colgroup`] = refBodyColgroup;
elemStore[`${prefix}list`] = refBodyTBody;
elemStore[`${prefix}xSpace`] = refBodyXSpace;
elemStore[`${prefix}ySpace`] = refBodyYSpace;
elemStore[`${prefix}emptyBlock`] = refBodyEmptyBlock;
});
});
(0, import_vue.onUnmounted)(() => {
const { fixedType } = props;
const { elemStore } = tableInternalData;
const prefix = `${fixedType || "main"}-body-`;
elemStore[`${prefix}wrapper`] = null;
elemStore[`${prefix}scroll`] = null;
elemStore[`${prefix}table`] = null;
elemStore[`${prefix}colgroup`] = null;
elemStore[`${prefix}list`] = null;
elemStore[`${prefix}xSpace`] = null;
elemStore[`${prefix}ySpace`] = null;
elemStore[`${prefix}emptyBlock`] = null;
});
const renderVN = () => {
const { slots } = tableContext;
const $xeGrid = $xeTable.xeGrid;
const $xeGantt = $xeTable.xeGantt;
const { fixedColumn, fixedType, tableColumn } = props;
const { mouseConfig } = tableProps;
const { isGroup, tableData, isColLoading, overflowX, scrollXLoad, scrollYLoad, dragRow, dragCol } = tableReactData;
const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData;
const emptyOpts = computeEmptyOpts.value;
const mouseOpts = computeMouseOpts.value;
const isBodyRenderOptimize = computeIsBodyRenderOptimize.value;
let renderDataList = tableData;
let renderColumnList = tableColumn;
const isOptimizeMode = isBodyRenderOptimize;
if (!isColLoading && (fixedType || !overflowX)) {
renderColumnList = visibleColumn;
}
if (fixedType) {
if (isOptimizeMode) {
renderColumnList = fixedColumn || [];
}
}
if (scrollYLoad && dragRow) {
if (renderDataList.length > 2) {
const dRowRest = fullAllDataRowIdData[(0, import_util.getRowid)($xeTable, dragRow)];
if (dRowRest) {
const drIndex = dRowRest._index;
const firstRow = renderDataList[0];
const lastRow = renderDataList[renderDataList.length - 1];
const firstRowRest = fullAllDataRowIdData[(0, import_util.getRowid)($xeTable, firstRow)];
const lastRowRest = fullAllDataRowIdData[(0, import_util.getRowid)($xeTable, lastRow)];
if (firstRowRest && lastRowRest) {
const frIndex = firstRowRest._index;
const lrIndex = lastRowRest._index;
if (drIndex < frIndex) {
renderDataList = [dragRow].concat(renderDataList);
} else if (drIndex > lrIndex) {
renderDataList = renderDataList.concat([dragRow]);
}
}
}
}
}
if (!fixedType && !isGroup) {
if (scrollXLoad && dragCol) {
if (renderColumnList.length > 2) {
const dCowRest = fullColumnIdData[dragCol.id];
if (dCowRest) {
const dcIndex = dCowRest._index;
const firstCol = renderColumnList[0];
const lastCol = renderColumnList[renderColumnList.length - 1];
const firstColRest = fullColumnIdData[firstCol.id];
const lastColRest = fullColumnIdData[lastCol.id];
if (firstColRest && lastColRest) {
const fcIndex = firstColRest._index;
const lcIndex = lastColRest._index;
if (dcIndex < fcIndex) {
renderColumnList = [dragCol].concat(renderColumnList);
} else if (dcIndex > lcIndex) {
renderColumnList = renderColumnList.concat([dragCol]);
}
}
}
}
}
}
let emptyContent;
const emptySlot = slots ? slots.empty : null;
const emptyParams = { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt };
if (emptySlot) {
emptyContent = $xeTable.callSlot(emptySlot, emptyParams);
} else {
const rendererOpts = computeRendererOpts.value;
const compConf = emptyOpts.name ? rendererOpts[emptyOpts.name] || renderer.get(emptyOpts.name) : null;
const rtEmptyView = compConf ? compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty : null;
if (rtEmptyView) {
emptyContent = (0, import_vn.getSlotVNs)(rtEmptyView(emptyOpts, emptyParams));
} else {
emptyContent = tableProps.emptyText || getI18n("vxe.table.emptyText");
}
}
return (0, import_vue.h)(
"div",
{
ref: refElem,
class: ["vxe-table--body-wrapper", fixedType ? `fixed-${fixedType}--wrapper` : "body--wrapper"],
xid: xID
},
[
(0, import_vue.h)(
"div",
{
ref: refBodyScroll,
class: "vxe-table--body-inner-wrapper",
onScroll(evnt) {
$xeTable.triggerBodyScrollEvent(evnt, fixedType);
}
},
[
fixedType ? renderEmptyElement($xeTable) : (0, import_vue.h)("div", {
ref: refBodyXSpace,
class: "vxe-body--x-space"
}),
(0, import_vue.h)("div", {
ref: refBodyYSpace,
class: "vxe-body--y-space"
}),
(0, import_vue.h)(
"table",
{
ref: refBodyTable,
class: "vxe-table--body",
xid: xID,
cellspacing: 0,
cellpadding: 0,
border: 0,
xvm: isOptimizeMode ? "1" : null
},
[
/**
* 列宽
*/
(0, import_vue.h)(
"colgroup",
{
ref: refBodyColgroup
},
renderColumnList.map((column, $columnIndex) => {
return (0, import_vue.h)("col", {
name: column.id,
key: $columnIndex,
style: {
width: `${column.renderWidth}px`
}
});
})
),
/**
* 内容
*/
(0, import_vue.h)(
"tbody",
{
ref: refBodyTBody
},
renderRows(fixedType, isOptimizeMode, renderDataList, renderColumnList)
)
]
),
(0, import_vue.h)("div", {
class: "vxe-table--checkbox-range"
}),
(0, import_utils.hasEnableConf)(mouseConfig, mouseOpts) && mouseOpts.area ? (0, import_vue.h)(
"div",
{
class: "vxe-table--cell-area",
xid: xID
},
[
(0, import_vue.h)(
"span",
{
class: "vxe-table--cell-main-area"
},
mouseOpts.extension ? [
(0, import_vue.h)("span", {
class: "vxe-table--cell-main-area-btn",
onDblclick(evnt) {
if ($xeTable.triggerCellAreaExtendDblclickEvent) {
$xeTable.triggerCellAreaExtendDblclickEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType });
}
},
onMousedown(evnt) {
if ($xeTable.triggerCellAreaExtendMousedownEvent) {
$xeTable.triggerCellAreaExtendMousedownEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType });
}
}
})
] : []
),
(0, import_vue.h)("span", {
class: "vxe-table--cell-clip-area"
}),
(0, import_vue.h)("span", {
class: "vxe-table--cell-extend-area"
}),
(0, import_vue.h)("span", {
class: "vxe-table--cell-multi-area"
}),
(0, import_vue.h)("span", {
class: "vxe-table--cell-active-area"
}),
(0, import_vue.h)("span", {
class: "vxe-table--cell-row-status-area"
})
]
) : renderEmptyElement($xeTable),
!fixedType ? (0, import_vue.h)(
"div",
{
class: "vxe-table--empty-block",
ref: refBodyEmptyBlock
},
[
(0, import_vue.h)(
"div",
{
class: "vxe-table--empty-content"
},
emptyContent
)
]
) : renderEmptyElement($xeTable)
]
)
]
);
};
return renderVN;
}
})
);