/**
 * 根据目标元素获取父元素
 */
export const getParent = (element: any, className: string, max = 10) => {
  let p = null,
    n = 0;
  const run = (element: any, className: string) => {
    if (n++ >= max) return;
    const pClsList = element?.parentNode?.className;
    const pNode = element?.parentNode;
    if (pClsList?.indexOf?.(className) === -1) {
      run(pNode, className);
    } else {
      p = pNode;
    }
  };
  run(element, className);
  return p;
};

export const isTableColumnsOperateNotEmpty = (obj: Record<string, any>) => {
  return Object.keys(obj).length > 0;
};
