// 通过classifyid 获取当前目录
export function findItemWithIdAndParents(data, targetId) {
    for (let i = 0; i < data.length; i++) {
        const item = data[i];
        if (item.ClassifyId === targetId) {
            // 找到目标项
            return [item];
        } else if (item.Children) {
            // 在子项中继续查找
            const foundInChild = findItemWithIdAndParents(item.Children, targetId);
            if (foundInChild) {
                // 如果在子项中找到目标项，将当前项添加到父级数组中
                return [item, ...foundInChild];
            }
        }
    }
    return null; // 如果未找到目标项，返回null
}

//去除数组中的children为空数组情况
export function deleteClassifyItemEmpty(arr){
    arr.length&&arr.forEach(item=>{
        item.Children.length&&deleteClassifyItemEmpty(item.Children)
        if(!item.Children.length){
            delete item.Children
        }
    })
}

//生成指标序列数据
export function generateSeriesArray(){
	let result = [];
	const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	for(let i=0;i<26;i++) result.push(String.fromCharCode(65+i))
	for (let i = 0; i < 26; i++) {
		const firstChar = alphabet[i];

		for (let j = 0; j < 26; j++) {
			const secondChar = alphabet[j];
			result.push(firstChar + secondChar);
		}
	}

	return result;
}