import request from '@/utils/request'

// 注意 URL 已变为 /inbound/product/...

export function getProductList(params: any) {
    return request({
        url: '/inbound/product/list',
        method: 'get',
        params
    })
}

export function createProductInbound(data: any) {
    return request({
        url: '/inbound/product/submit',
        method: 'post',
        data
    })
}

export function updateProductInbound(id: number, data: any) {
    return request({
        url: `/inbound/product/${id}`,
        method: 'put',
        data
    })
}

export function deleteProductInbound(id: number) {
    return request({
        url: `/inbound/product/${id}`,
        method: 'delete'
    })
}

// 搜索基础物料 (已增加 page 参数)
export function searchMaterialBase(keyword: string, page: number = 1) {
    return request({
        url: '/inbound/product/search-base',
        method: 'get',
        params: { keyword, page }
    })
}

// 搜索BOM
export function searchBom(keyword: string) {
    return request({
        url: '/inbound/product/search-bom',
        method: 'get',
        params: { keyword }
    })
}

// 用户建议
export function getUserSuggestions(params: any) {
    return request({
        url: '/inbound/product/suggestions/users',
        method: 'get',
        params
    })
}

// 筛选选项
export function getFilterOptions() {
    return request({
        url: '/inbound/product/options',
        method: 'get'
    })
}

// [新增] 负责人历史记录全局查询
export function getManagerHistory(params: any) {
    return request({
        url: '/inbound/product/suggestions/managers',
        method: 'get',
        params
    })
}

// [新增] BOM 成本自动计算
export function calculateBomCost(params: {bom_code: string, bom_version: string}) {
    return request({
        url: '/inbound/product/calculate-bom-cost',
        method: 'get',
        params
    })
}