import { request } from '@/utils/request'

export interface ncCode {
    id?: number,
    ncCode?: string,
    ncName?: string,
    ncContent?: string,
    ncDesc?: string,
    status?: number,
    createTime?: string,
    updateTime?: string,
    remark?: string,
    createBy?: string,
}


//新增代码库
export function addnccode(data:any) {
    return request({ 
        url: '/biz/ncCode', 
        method: 'post',
        data
    })
}

//编辑代码库
export function editccode(data:any) {
    return request({ 
        url: '/biz/ncCode', 
        method: 'put',
        data
    })
}

//列表
export function nccodelist(params:any) {
    return request({ 
        url: `/biz/ncCode/page`, 
        method: 'get',
        params
    })
}

//下发
export function batchIssue(data:any) {
    return request({ 
        url: '/biz/ncCode/issue', 
        method: 'post',
        data
    })
}

//删除
export function deleteIssue(ids:any) {
    return request({ 
        url: `/biz/ncCode/${ids}`, 
        method: 'delete'
    })
}

//复制
export function issuecopy(data:any) {
    return request({ 
        url: `/biz/ncCode/copy`, 
        method: 'post',
        data
    })
}

// 导出
export function exportIssue(params?: { ids?: number[]; id?: number; status?: number }) {
    const p: Record<string, any> = {}
    if (params?.ids?.length) p.ids = params.ids.join(',')
    if (params?.id !== undefined && params?.id !== null) p.id = params.id
    if (params?.status !== undefined && params?.status !== null) p.status = params.status
    return request({ url: `/biz/ncCode/export`, method: 'get', params: p, responseType: 'blob' })
}

//任务树
export function opertree() {
    return request({ 
        url: `biz/ncCode/operationTree`, 
        method: 'get'
    })
}

//生产NC编码
export function generateNccode() {
    return request({ 
        url: `biz/ncCode/generateNcCode`, 
        method: 'get'
    })
}

//导出
export function exportNccode(params:any) {
    return request({ 
        url: `biz/ncCode/export`, 
        method: 'get',
        params
    })
}
