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

// 客户单位列表
export async function handleGetNestingOwnerUnitList(params: any) {
    const data = await request(`/BaseInfo/GetNestingOwnerUnitList`, {
        method: 'GET',
        params
    });

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

    return wrapTreeNode(data.Result_Data.List);
}

// 客户单位编辑新增
export async function handleCreateBusinessMan(params: any) {
    const data = await request(`/BusinessMan/CreateBusinessMan`, {
        method: 'POST',
        data: params
    });

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

    return data;
}


// 客户单位详情
export async function handleGetBusinessManDetail(params: any) {
    const data = await request(`/Merchants/GetBusinessManDetail`, {
        method: 'GET',
        params
    });

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

    return data;
}


// 没有缓存的门店列表
export async function handleGetServerpartShopTree(params: any) {
    const data = await request(`/BaseInfo/GetServerpartShopTree`, {
        method: 'GET',
        params
    });

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

    return wrapTreeNode(data.Result_Data.List);
}


// 商户管理里面的选择门店的树列表
export async function handleGetSPRegionShopTree(params: any) {
    const data = await request(`/BaseInfo/GetSPRegionShopTree`, {
        method: 'GET',
        params
    });

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

    return wrapTreeNode(data.Result_Data.List);
}



export async function handleDeleteBusinessMan(params: any) {
    const data = await request(`/Merchants/DeleteBusinessMan`, {
        method: 'GET',
        params
    });

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

    return data;
}



// 嵌套表最外面一层的删除
export async function handleDeleteAUTOTYPE(params: any) {
    const data = await request(`/BasicConfig/DeleteAUTOTYPE`, {
        method: 'GET',
        params
    });

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

    return data;
}

// 嵌套列表第二层的删除
export async function handleDeleteOWNERSERVERPART(params: any) {
    const data = await request(`/BasicConfig/DeleteOWNERSERVERPART`, {
        method: 'GET',
        params
    });

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

    return data;
}

// 嵌套列表第三层的删除
export async function handleDeleteOWNERSERVERPARTSHOP(params: any) {
    const data = await request(`/BasicConfig/DeleteOWNERSERVERPARTSHOP`, {
        method: 'GET',
        params
    });

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

    return data;
}