import request from '@/utils/request'

// 1. 获取列表
export function getSemiList(params: any) {
    return request({
        url: '/inbound/semi/list',
        method: 'get',
        params
    })
}

// 2. 新增入库
export function createSemiInbound(data: any) {
    return request({
        url: '/inbound/semi/submit',
        method: 'post',
        data
    })
}

// 3. 更新入库
export function updateSemiInbound(id: number, data: any) {
    return request({
        url: `/inbound/semi/${id}`,
        method: 'put',
        data
    })
}

// 4. 删除入库
export function deleteSemiInbound(id: number) {
    return request({
        url: `/inbound/semi/${id}`,
        method: 'delete'
    })
}

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

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

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

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

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

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