import request from 'src/utils/request'

// 报废二维码
export function discard(code,isAll){
    return request({
      url: '/qrcode/relation/api/qrcodeIns/info/discard',
      method: 'post',
      data: {
        "code":code,
        "isAll":isAll,
        "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
      }
    })
}

// 批量报废二维码
export function batchDiscardCode(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/batchDiscard',
    method: 'post',
    data: data
  })
}

// 解绑 二维码
export function unboundByUser(code){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/unboundByUser',
    method: 'post',
    data: {
      "code":code,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
// 全解绑 二维码
export function unboundByUserAll(code){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/unboundByUserAll',
    method: 'post',
    data: {
      "code":code,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

// 关联关系
export function related(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/related',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

// 关联关系
export function relatedBefore(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/relatedBefore',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

// 条烟换货
export function barterQrCodeIns(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/barterQrCodeIns',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
// 条烟换货或盒条上报
export function barterOrUpQrCodeIns(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/barterOrUpQrCodeIns',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
//件码激活
export function pieceActivate(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/pieceActivate',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

/**
 * 关联重组
 */
export function updateAndAddQrCodeIns(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/updateAndAddQrCodeIns',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
/**
 * 件码替换
 */
export function changePiece(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/changePiece',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
/**
 * 盒条上报
 */
export function barQrcodeUp(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/barQrcodeUp',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

/**
 * 出库(工业)
 */
export function barterIndQrCodeIns(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/barterIndQrCodeIns',
    method: 'post',
    data: {
      "manualAssociationList":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}



/**
 * 单条(盒)解绑
 */
export function unbondQrCodeOne(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/unbondQrCodeOne',
    method: 'post',
    data: data
  })
}
/**
 * 查询重码A件烟
 */
export function getAPiece(qrCode){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/info/getAPiece',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'  // 设置内容类型为表单数据
    },
    data: new URLSearchParams({ qrCode })  // 将 qrCode 封装为表单数据
  })
}

/**
 * 插入操作记录
 */
export function insertQrCodeDisassociation(data){
  return request({
    url: '/qrcode/relation/api/qrcodeOperation/info/insertQrCodeDisassociation',
    method: 'post',
    data: data
  })
}

/**
 * 查询申请换货操作记录
 */
export function recordList(query) {
  return request({
    url: '/qrcode/relation/api/record/task/list',
    method: 'get',
    params: query
  })
}

// 查询产量同步明细列表
export function recordDetailInfo(data){
  return request({
    url: '/qrcode/relation/api/record/detail/list',
    method: 'post',
    data: data
  })
}

// 修改产量同步明细
export function editRecordDetail(data) {
  return request({
    url: 'qrcode/relation/api/record/detail',
    method: 'post',
    data: data
  })
}