refactor: getVxePopupContainer

This commit is contained in:
dap 2025-04-06 17:24:18 +08:00
parent 63db3ba143
commit 3f037f146b

View File

@ -12,27 +12,18 @@ export function getPopupContainer(node?: HTMLElement): HTMLElement {
/**
* VxeTable专用弹窗层
* 解决问题: https://gitee.com/dapppp/ruoyi-plus-vben5/issues/IB1DM3
* getPopupContainer一样
* (body下) ID & ID参数传入该函数
* <BasicTable id="xxx" />
* getVxePopupContainer="(node) => getVxePopupContainer(node, 'xxx')"
* @param _node
* @param id id ()>= ID
* @returns
*/
export function getVxePopupContainer(
_node?: HTMLElement,
id?: string,
): HTMLElement {
let selector = '.vxe-table--row-expanded-wrapper';
if (id) {
selector = `div#${id} ${selector}`;
}
// 挂载到vxe-table的滚动区域
const vxeTableContainerNode = document.querySelector(selector);
if (!vxeTableContainerNode) {
console.warn('无法找到vxe-table元素, 将会挂载到body.');
export function getVxePopupContainer(_node?: HTMLElement): HTMLElement {
/**
* parent会导致展开宽度不正常
* body ()
*
*/
if (_node?.closest('td.fixed--width')) {
return document.body;
}
return vxeTableContainerNode as HTMLElement;
// 返回parent元素
return _node?.parentElement ?? document.body;
}