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.ad_monetization_amount', field: 'ad_monetization_amount' },
    { label: '广告变现ROI', value: 'material_data_day.ad_monetization_roi', field: 'ad_monetization_roi' },
    { 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: '广告变现ROI', value: 'material_data_day.ad_monetization_roi', field: 'ad_monetization_roi' },
    { label: '广告变现金额', value: 'material_data_day.ad_monetization_amount', field: 'ad_monetization_amount' },
    { label: '备注', value: 'description', field: 'description' }
]


export const showField2List = [
    { label: '创建时间', value: 'createdTime', field: 'createdTime' },
    { label: '组件ID', value: 'componentId', field: 'componentId' },
    { label: '来源', value: 'generationType', field: 'generationType' },
    { label: '消耗', value: 'cost', field: 'cost' },
    { label: '一键起量消耗', value: 'acquisitionCost', field: 'acquisitionCost' },
    { label: '千次展现均价', value: 'thousandDisplayPrice', field: 'thousandDisplayPrice' },
    { label: '点击率', value: 'ctr', field: 'ctr' },
    { label: '公众号关注成本（点击归因）', value: 'fromFollowByClickCost', field: 'fromFollowByClickCost' },
    { label: '公众号关注人数（点击归因）', value: 'fromFollowByClickUv', field: 'fromFollowByClickUv' },
    { label: '公众号关注成本（平台上报）', value: 'bizFollowCost', field: 'bizFollowCost' },
    { label: '公众号关注人数（平台上报）', value: 'bizFollowUv', field: 'bizFollowUv' },
    { label: '加企业微信客服成本（人数）', value: 'scanFollowUserCost', field: 'scanFollowUserCost' },
    { label: '加企业微信客服人数', value: 'scanFollowUserCount', field: 'scanFollowUserCount' },
    { label: '下单次数（点击归因）', value: 'orderByClickCount', field: 'orderByClickCount' },
    { label: '下单成本（点击归因）', value: 'orderByClickCost', field: 'orderByClickCost' },
    { label: '下单率（点击归因）', value: 'orderByClickRate', field: 'orderByClickRate' },
    { label: '点击首日付费ROI', value: 'cheoutFdReward', field: 'cheoutFdReward' },
    { label: '点击3日付费ROI', value: 'cheoutTdReward', field: 'cheoutTdReward' },
    { label: '点击7日付费ROI', value: 'cheoutOwReward', field: 'cheoutOwReward' },
    { label: '点击14日付费ROI', value: 'cheoutTwReward', field: 'cheoutTwReward' },
    { label: '点击30日付费ROI', value: 'cheoutOmReward', field: 'cheoutOmReward' }
]