我正在使用laravel-dompdf为我的应用程序生成PDF报告。我在同一个应用程序中使用过它,它工作得很好……这个模型是用来生成空白PDF的。
查询返回数据,所以这不是问题所在……我的代码:
public function serviceReport(Request $request){
$title = 'Servicio';
$meta = [
'N°' => '1'
];
$query = Service::query();
$query->select(\DB::raw('services.id as serviceid'), \DB::raw('customers.name as customername'))
->leftJoin('customers', 'customers.id', '=', 'services.id_customers')
->where('services.id', '=', '1')
->get();
$columns = [
'Servicio' => 'serviceid',
'Cliente' => 'customername'
];
return PdfReport::of($title, $meta, $query, $columns)
->limit(20)
->download('filename');
}我的vuejs函数:
getReport(){
var name = 'Reporte Servicio.pdf';
this.service.post('/api/service/report', {responseType: 'blob'})
.then((response) => {
var fileURL = window.URL.createObjectURL(new Blob([response.data]));
var fileLink = document.createElement('a');
fileLink.href = fileURL;
fileLink.setAttribute('download', name);
document.body.appendChild(fileLink);
fileLink.click();
})
.catch(function (error) {
console.log(error);
})
},PDF格式:

发布于 2020-04-11 22:53:49
问题出在vForm上。我已经更改为正常的axios请求并开始工作。
https://stackoverflow.com/questions/61052096
复制相似问题