import request from '@/utils/request'
import { download, downloadPdf } from '@/utils/request'

const baseUrl = import.meta.env.VITE_APP_BASE_API

// 查询收回单
export function listReceipt(query) {
	return request({
		url: baseUrl + '/business/returnReceipt/list',
		method: 'get',
		params: query
	})
}

// 查询收回单
export function getReceipt(id) {
	return request({
		url: baseUrl + '/business/returnReceipt/' + id,
		method: 'get'
	})
}

//打印
export function printReturnReceipt(data) {
	downloadPdf(
		baseUrl + "/business/returnReceipt/printDetailPdf",
		{
			...data,
		},
		`外协收回单_${new Date().getTime()}.pdf`
	)
}
// 导出
export function exportReturn(data) {
	download(
		baseUrl + "/business/returnReceipt/export",
		{
			...data,
		},
		`外协收回单_${new Date().getTime()}.xlsx`
	)
}



// 新增收回单
export function addReceipt(data) {
	return request({
		url: baseUrl + '/business/returnReceipt',
		method: 'post',
		data: data
	})
}

// 修改收回单
export function updateReceipt(data) {
	return request({
		url: baseUrl + '/business/returnReceipt',
		method: 'put',
		data: data
	})
}
// 修改收回单主表提交状态
export function updateReceiptSubmitStatus(data) {
	return request({
		url: baseUrl + '/business/returnReceipt/updateReceiptSubmitStatus',
		method: 'put',
		data: data
	})
}

// 删除收回单
export function delReceipt(id) {
	return request({
		url: baseUrl + '/business/returnReceipt/' + id,
		method: 'delete'
	})
}

export function checkFurnace(data) {
	return request({
		url: baseUrl + '/business/returnReceipt/checkFurnace',
		method: 'post',
		data: data
	})
}
export function checkAllowMore(data) {
	return request({
		url: baseUrl + '/business/returnReceipt/checkAllowMore',
		method: 'post',
		data: data
	})
}
