import request from '@/utils/request'

// 备品备件列表
export function getSparePartsList(data) {
    return request({
        url: '/spareParts/queryByPage',
        method: 'post',
        data
    })
}

// 新增备品备件
export function addSpareParts(data) {
    return request({
        url: '/spareParts/add',
        method: 'post',
        data
    })
}

// 备品备件新增弹窗所属系统下拉列表
export function getSystemList() {
    return request({
        url: '/spareParts/owningSystem',
        method: 'post',
    })
}

// 备品备件新增弹窗所属工艺下拉列表
export function getTechnologyList() {
    return request({
        url: '/production/findMaterialsCraft',
        method: 'get',
    })
}


// 编辑备品备件
export function editSpareParts(data) {
    return request({
        url: '/spareParts/edit',
        method: 'post',
        data
    })
}

// 备品备件详情
export function getSparePartsDetail(val) {
    return request({
        url: `/spareParts/queryById/${val}`,
        method: 'post'
    })
}


// 删除备品备件
export function delSpareParts(val) {
    return request({
        url: `spareParts/deleteById/${val}`,
        method: 'post'
    })
}

// 备品备件订单编号生成
export function generateNum(data) {
    return request({
        url: '/spareParts/inOutOrderNumber',
        method: 'post',
        data
    })
}

// 备品备件、易损件出入库
export function outOrInLibrary(data) {
    return request({
        url: '/spareParts/inOut',
        method: 'post',
        data
    })
}

// 备品备件、易损件出入库
export function giveBackLibrary(data) {
    return request({
        url: '/spareParts/giveBack',
        method: 'post',
        data
    })
}

// 备品备件、易损件出入库日志
export function outOrInLibraryLog(params) {
    return request({
        url: '/spareParts/queryItemLog',
        method: 'get',
        params
    })
}

// 备品备件、易损件出入库日志
export function queryPartsLog(params) {
    return request({
        url: '/spareParts/queryPartsLog',
        method: 'get',
        params
    })
}


// 易损件列表
export function getWearingPartsList(data) {
    return request({
        url: '/vulnerableItems/queryByPage',
        method: 'post',
        data
    })
}

// 易损件新增
export function addWearingParts(data) {
    return request({
        url: '/vulnerableItems/add',
        method: 'post',
        data
    })
}

// 易损件编辑
export function editWearingParts(data) {
    return request({
        url: '/vulnerableItems/edit',
        method: 'post',
        data
    })
}

// 易损件详情
export function detailWearingParts(val) {
    return request({
        url: `/vulnerableItems/queryById/${val}`,
        method: 'post'
    })
}

// 易损件删除
export function delWearingParts(val) {
    return request({
        url: `/vulnerableItems/deleteById/${val}`,
        method: 'post'
    })
}

// 关联设备信息查询
export function sparePartsDeviceList(params) {
    return request({
        url: `/spareParts/asso-device-list`,
        method: 'get',
        params
    })
}

// 关联设备信息查询
export function assoDevice(data) {
    return request({
        url: `/spareParts/asso-device`,
        method: 'post',
        data
    })
}

// 取消关联设备信息查询
export function cancelAssoDevice(id) {
    return request({
        url: `/spareParts/cancel-asso-device/${id}`,
        method: 'post'
    })
}

// 查询备件图片列表
export function partImgs(query) {
    return request({
        url: '/spareParts/imgs',
        method: 'get',
        params: query
    })
}


// 修改备件图片列表
export function savePartImgs(data) {
    return request({
        url: '/spareParts/imgs',
        method: 'post',
        data
    })
}
