import request from 'src/utils/request'

// 查询二维码数据列表
export function listQrcodeIns(query) {
  return request({
    url: '/qrcode/relation/qrcodeIns/list',
    method: 'get',
    params: query
  })
}

// 查询二维码数据详细
export function getQrcodeIns(id) {
  return request({
    url: '/qrcode/relation/qrcodeIns/' + id,
    method: 'get'
  })
}

// 二维码状态校验
export function checkStatus(data) {
    return request({
        url: '/qrcode/relation/api/qrcodeIns/data/pdaCheckStatus',
        method: 'put',
        data: data
    })
}

/** 查询二维码数据列表 */
export function pageQrcodeIns(query) {
    return request({
        url: '/qrcode/relation/qrcodeIns/page',
        method: 'get',
        params: query
    })
}

// 查询二维码数据详细
export function getQrcodeInsByCode(data) {
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/info',
    method: 'post',
    data: data
  })
}
// 查询二维码（两个索引）
// export function getQrcodeInsByCodeTwo(data) {
//   return request({
//     url: '/qrcode/relation/api/qrcodeIns/data/infoTwo',
//     method: 'post',
//     data: data
//   })
// }
// 重码查询
export function getMultipleCodeByCode(data) {
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/multipleCode',
    method: 'post',
    data: data
  })
}
// 查询冷索引二维码数据详细
export function getQrcodeInsByCodeCold(data) {
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/infoCold',
    method: 'post',
    data: data
  })
}

/**
 * 查询二维码所有信息
 */
export function getQrcodeInfoByCode(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/qrcodeinfo',
    method: 'post',
    data: {
      "qrcode":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
/**
 * 校验成功
 */
export function qualitySusses(data){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/info/qualitySusses',
    method: 'post',
    data: {
      "qrCodeIns":data,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}
/**
 * 校验异常
 */
export function qualityError(qrCodeIns,errorQrCode){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/info/qualityError',
    method: 'post',
    data: {
      "qrCodeIns":qrCodeIns,
      "errorQrCode":errorQrCode,
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}

/**
 * 操作记录
 */
export function qualityResult(qrCodeIns,errorId,qrCodeList,errorQrCode){
  return request({
    url: '/qrcode/relation/api/qrcodeIns/data/info/qualityResult',
    method: 'post',
    data: {
      // 原有数据
      "qrCodeIns":qrCodeIns,
      // 已校验二维码
      "qrCodeList":qrCodeList,
      // errorId
      "errorId":errorId,
      // 判断校验异常二维码
      "errorQrCode":errorQrCode,
      // 产线
      "qrCodeProductLine" : JSON.parse(localStorage.getItem('qrCodeProductLine'))
    }
  })
}



// 新增二维码数据
export function addQrcodeIns(data) {
  return request({
    url: '/qrcode/relation/qrcodeIns',
    method: 'post',
    data: data
  })
}

// 修改二维码数据
export function updateQrcodeIns(data) {
  return request({
    url: '/qrcode/relation/qrcodeIns',
    method: 'put',
    data: data
  })
}

// 删除二维码数据
export function delQrcodeIns(id) {
  return request({
    url: '/qrcode/relation/qrcodeIns/' + id,
    method: 'delete'
  })
}
//清除
export function delQrcodeInsAll() {
  return request({
    url: '/qrcode/relation/qrcodeIns/removeAll',
    method: 'delete'
  })
}

