import { DataNode } from "antd/lib/tree";

/**
 * 更新目录
 * @param list 
 * @param key 
 * @param children 
 * @returns 
 */
export const updateTreeData = (list: DataNode[], key: React.Key, children: DataNode[]): DataNode[] => {
    return list.map(node => {
        if (node.key === key) {
            return {
                ...node,
                children,
            };
        }
        if (node.children) {
            return {
                ...node,
                children: updateTreeData(node.children, key, children),
            };
        }
        return node;
    });
}

/** 选择素材 展示字段 */
export const showFieldList = [
    { label: '创建时间', value: 'material.create_time', field: 'create_time' },
    { label: '下单次数', value: 'material_data_day.order_pv', field: 'order_pv' },
    { label: '下单成本', value: 'material_data_day.order_cost', field: 'order_cost' },
    { label: '消耗', value: 'material_data_day.cost', field: 'cost' },
    { label: '点击率', value: 'material_data_day.ctr', field: 'ctr' },
    { label: '目标转化率', value: 'material_data_day.conversions_rate', field: 'conversions_rate' },
    { label: '创意关联数', value: 'material_data_day.adgroup_count', field: 'adgroup_count' },
    { label: '创意关联数', value: 'material_data_day.dynamic_creative_count', field: 'dynamic_creative_count' },
    { label: '备注', value: 'description', field: 'description' }
]


export const showField1List = [
    { label: '创建时间', value: 'material.created_time', field: 'created_time' },
    { label: '下单次数', value: 'material_data_day.order_pv', field: 'order_pv' },
    { label: '下单成本', value: 'material_data_day.order_cost', field: 'order_cost' },
    { label: '消耗', value: 'material_data_day.cost', field: 'cost' },
    { label: '点击率', value: 'material_data_day.ctr', field: 'ctr' },
    { label: '目标转化率', value: 'material_data_day.conversions_rate', field: 'conversions_rate' },
    { label: '创意关联数', value: 'material_data_day.adgroup_count', field: 'adgroup_count' },
    { label: '创意关联数', value: 'material_data_day.dynamic_creative_count', field: 'dynamic_creative_count' },
    { label: '备注', value: 'description', field: 'description' }
]