Vanessa 2025-07-30 17:35:53 +08:00
parent 2a07997ba2
commit e4959774e8
2 changed files with 18 additions and 20 deletions

View file

@ -206,8 +206,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex,
});
contentHTML += "<div></div></div>";
});
return {
contentHTML: contentHTML + `<div class="av__row--util${data.rowCount > data.rows.length ? " av__readonly--show" : ""}">
return `${contentHTML}<div class="av__row--util${data.rowCount > data.rows.length ? " av__readonly--show" : ""}">
<div class="av__colsticky">
<button class="b3-button av__button" data-type="av-add-bottom">
<svg><use xlink:href="#iconAdd"></use></svg>
@ -220,9 +219,8 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex,
<svg data-type="set-page-size" data-size="${data.pageSize}"><use xlink:href="#iconMore"></use></svg>
</button>
</div>
</div>`,
footerHTML: `<div class="av__row--footer${hasCalc ? " av__readonly--show" : ""}">${calcHTML}</div>`
};
</div>
<div class="av__row--footer${hasCalc ? " av__readonly--show" : ""}">${calcHTML}</div>`;
};
const renderGroupTable = (options: ITableOptions) => {
@ -239,7 +237,7 @@ const renderGroupTable = (options: ITableOptions) => {
<svg class="${group.groupFolded ? "" : "av__group-arrow--open"}"><use xlink:href="#iconRight"></use></svg>
</div><span class="fn__space"></span>${group.name}<span class="${group.rows.length === 0 ? "fn__none" : "counter"}">${group.rows.length}</span>
</div>
<div data-group-id="${group.id}" style="float: left" class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement).contentHTML}</div>`;
<div data-group-id="${group.id}" style="float: left" class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement)}</div>`;
}
});
if (options.renderAll) {
@ -485,10 +483,8 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: (data: IAV) =
if (!e.dataset.pageSize) {
e.dataset.pageSize = data.pageSize.toString();
}
const tableHTMLs = getTableHTMLs(data, e);
const avBodyHTML = `<div class="av__body" style="float: left">
${tableHTMLs.contentHTML}
${tableHTMLs.footerHTML}
${getTableHTMLs(data, e)}
</div>`;
if (renderAll) {
e.firstElementChild.outerHTML = `<div class="av__container">

View file

@ -288,19 +288,21 @@ export const stickyRow = (blockElement: HTMLElement, elementRect: DOMRect, statu
});
}
const footerElement = blockElement.querySelector(".av__row--footer") as HTMLElement;
if (footerElement && (status === "bottom" || status === "all")) {
if (footerElement.querySelector(".av__calc--ashow")) {
const bodyRect = footerElement.parentElement.getBoundingClientRect();
const distance = Math.ceil(elementRect.bottom - bodyRect.bottom);
if (distance < 0 && -distance < bodyRect.height) {
footerElement.style.transform = `translateY(${distance}px)`;
const footerElements = blockElement.querySelectorAll(".av__row--footer");
if (footerElements.length > 0 && (status === "bottom" || status === "all")) {
footerElements.forEach((item: HTMLElement) => {
if (item.querySelector(".av__calc--ashow")) {
const bodyRect = item.parentElement.getBoundingClientRect();
const distance = Math.ceil(elementRect.bottom - bodyRect.bottom);
if (distance < 0 && -distance < bodyRect.height - item.clientHeight) {
item.style.transform = `translateY(${distance}px)`;
} else {
item.style.transform = "";
}
} else {
footerElement.style.transform = "";
item.style.transform = "";
}
} else {
footerElement.style.transform = "";
}
});
}
};