import request from '@/utils/request'

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

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

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

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

// 5. [新增] 获取筛选下拉选项（类别、类型）
export function getFilterOptions() {
    return request({
        url: '/inbound/buy/options',
        method: 'get'
    })
}

// 6. 搜索基础物料
export function searchMaterialBase(keyword: string, page: number = 1) {
    return request({
        url: '/inbound/buy/search-base',
        method: 'get',
        params: { keyword, page }
    })
}

// 7. 文件上传
export function uploadFile(data: FormData) {
    return request({
        url: '/common/upload',
        method: 'post',
        data,
        headers: { 'Content-Type': 'multipart/form-data' }
    })
}

// 8. 文件删除
export function deleteFile(filename: string) {
    return request({
        url: `/common/files/${filename}`,
        method: 'delete'
    })
}

// 9. 供应商建议
export function getSupplierSuggestions(params: any) {
    return request({
        url: '/inbound/buy/suggestions/suppliers',
        method: 'get',
        params
    })
}

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

// 11. 链接建议
export function getLinkSuggestions(params: any) {
    return request({
        url: '/inbound/buy/suggestions/links',
        method: 'get',
        params
    })
}

// 12. 库位建议
export function getLocationSuggestions(params: any) {
    return request({
        url: '/inbound/buy/suggestions/locations',
        method: 'get',
        params
    })
}