import { wrapTreeNode } from "@/utils/format";
import request from "@/utils/request";

// 获取服务区类别嵌套列表
export async function handleGetNestingSERVERPARTTYPEList(params?: any) {
    const data = await request(`/BasicConfig/GetNestingSERVERPARTTYPEList`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return wrapTreeNode(data.Result_Data.List);
}


// 同步服务区类别
export async function handleSynchroSERVERPARTTYPE(params?: any) {
    const data = await request(`/BasicConfig/SynchroSERVERPARTTYPE`, {
        method: 'POST',
        data: params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data;
}



// 查看服务区详情 拿到已经关联了的门店
export async function handleGetSERVERPARTTYPEDetail(params?: any) {
    const data = await request(`/BasicConfig/GetSERVERPARTTYPEDetail`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data.Result_Data;
}

// 删除类别详情
export async function handleDeleteSERVERPARTTYPE(params?: any) {
    const data = await request(`/BasicConfig/DeleteSERVERPARTTYPE`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data;
}


// 拿到服务区列表
export async function handleGetServerpartDDL(params?: any) {
    const data = await request(`/BaseInfo/GetServerpartDDL`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data.Result_Data.List;
}


// 更新服务区类别关联关系
export async function handleModifyRTServerpartType(params?: any) {
    const data = await request(`/BasicConfig/ModifyRTServerpartType`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data
}


// 拿到片区下的服务区

export async function handleGetServerpartTree(params?: any) {
    const data = await request(`/BaseInfo/GetServerpartTree`, {
        method: 'GET',
        params,
    });

    if (data.Result_Code !== 100) {
        return data
    }

    return data.Result_Data.List
}