/*
 * @Author: cclu 1106109051@qq.com
 * @Date: 2024-07-30 13:48:20
 * @LastEditors: cclu 1106109051@qq.com
 * @LastEditTime: 2024-08-30 14:45:00
 * @FilePath: \cloud-platform\src\pages\basicManage\serverpartAssets\service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { wrapTreeNode } from "@/utils/format";
import request from "@/utils/request";
// import requestCode from '@/utils/requestCode'

// 获取服务区资产表列表
export async function handleGetProvinceVehicleDetail(params?: any) {
    const data = await request(`/BaseInfo/GetPROPERTYASSETSList`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data.Result_Data.List;
}

// 获取服务区资产表树形列表
export async function handleGetPROPERTYASSETSTreeList(params?: any) {
    const data = await request(`/BaseInfo/GetPROPERTYASSETSTreeList`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return wrapTreeNode(data.Result_Data.List);
}


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

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data.Result_Data.List;
}


// 同步服务区资产表
export async function handleSynchroPROPERTYASSETS(params?: any) {
    const data = await request(`/BaseInfo/SynchroPROPERTYASSETS`, {
        method: 'POST',
        data: params
    });

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

    return data
}

// 获取服务区资产表明细
export async function handleGetPROPERTYASSETSDetail(params?: any) {
    const data = await request(`/BaseInfo/GetPROPERTYASSETSDetail`, {
        method: 'GET',
        params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data.Result_Data
}

// 删除服务区资产表
export async function handleDeletePROPERTYASSETS(params?: any) {
    const data = await request(`/BaseInfo/DeletePROPERTYASSETS`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data
}


// 拿到门店列表
export async function handleGetServerpartShopList(params?: any) {
    const data = await request(`/BaseInfo/GetServerpartShopList`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data.Result_Data.List
}



// 将资产和门店相关联
export async function handleGetSynchroPROPERTYSHOP(params?: any) {
    const data = await request(`/BaseInfo/SynchroPROPERTYSHOP`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data
}

// 将门店批量与资产关联
export async function handleGetBatchPROPERTYSHOP(params?: any) {
    const data = await request(`/BaseInfo/BatchPROPERTYSHOP`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data
}


// 删除图片
export async function handleDeletePicture(params: any) {

    const data = await request(`/Picture/DeletePicture`, {
        method: 'GET',
        params
    })

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

    return data
}


// 资产变更记录
export async function handleGetPROPERTYASSETSLOGList(params?: any) {
    const data = await request(`/BaseInfo/GetPROPERTYASSETSLOGList`, {
        method: 'POST',
        data: params
    });

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 10,
            total: 0,
            success: false
        }
    }

    return data.Result_Data.List
}




// 删除门店关联
export async function handleDeletePROPERTYSHOP(params?: any) {
    const data = await request(`/BaseInfo/DeletePROPERTYSHOP`, {
        method: 'POST',
        data: params
    });

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

    return data
}

// 历史经营项目的勾选数据
export async function handleGetPROPERTYSHOPList(params?: any) {
    const data = await request(`/BaseInfo/GetPROPERTYSHOPList`, {
        method: 'POST',
        data: params
    });

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

    return data.Result_Data.List
}



