/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-02-20 14:31:06
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-03-27 10:18:39
 * @FilePath: /BudgetManaSystem/src/utils/tooljs.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */


let parent:any = undefined;

export const getDeepestTreeData:any= (tree:any,childrenName:string)=>{
     
      if(tree[`${childrenName}`]&&tree[`${childrenName}`].length>0){
           parent = tree;
           return getDeepestTreeData(tree[`${childrenName}`][0],childrenName)    
      }

      return  [tree,parent] 
}





/*
 * @param x {Object} 对象1
 * @param y {Object} 对象2
 * @return  {Boolean} true 为相等，false 为不等
 */
export const deepEqual = (x: { [x: string]: any; } | null, y: { [x: string]: any; hasOwnProperty?: any; } | null) => {
      // 指向同一内存时
      if (x === y) {
        return true;
      } else if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) {
        if (Object.keys(x).length !== Object.keys(y).length) {
          return false;
        }
        for (var prop in x) {
          if (y.hasOwnProperty(prop)) {  
            if (!deepEqual(x[prop], y[prop])) return false;
          } else {
            return false;
          }
        }
        return true;
      } else {
        return false;
      }
}
