import request from '@/utils/request'
const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
import { download, downloadPdf } from '@/utils/request'

// 查询合格证列表
export function listCertificate(query) {
  return request({
    url: baseUrl + '/business/certificate/list',
    method: 'get',
    params: query
  })
}

// 查询合格证详细
export function getCertificate(id) {
  return request({
    url: baseUrl + '/business/certificate/' + id,
    method: 'get'
  })
}

// 新增合格证
export function addCertificate(data) {
  return request({
    url: baseUrl + '/business/certificate',
    method: 'post',
    data: data
  })
}

// 修改合格证
export function updateCertificate(data) {
  return request({
    url: baseUrl + '/business/certificate',
    method: 'put',
    data: data
  })
}

// 删除合格证
export function delCertificate(id) {
  return request({
    url: baseUrl + '/business/certificate/' + id,
    method: 'delete'
  })
}
export function generateQrCode(data) {
  return request({
    url: baseUrl + '/business/certificate/generate',
    method: 'post',
    data: data
  })
}

export function printPdf(data) {
  return downloadPdf(
    baseUrl + "/business/certificate/printPdf",
    {
      ...data
    },
    `合格证_${new Date().getTime()}.pdf`
  )
}

export function getDayworkList(data) {
  return request({
    url: baseUrl + "/business/certificate/getDayworkList",
    method: "get",
    params: data
  });
}

export function newCertificate(data) {
  return request({
    url: baseUrl + "/business/certificate/newCertificate",
    method: "post",
    data: data
  });
}

export function copyCertificate(data) {
  return request({
    url: baseUrl + "/business/certificate/copyCertificate",
    method: "post",
    data: data
  });
}