下载
This commit is contained in:
@@ -45,14 +45,32 @@ class CustomerController extends BaseController
|
||||
{
|
||||
try {
|
||||
$param = $request->all();
|
||||
$corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||||
$param['corp_abbr'] = $corp->id;
|
||||
// $param['corp_abbr'] = $request->basic_data['corp_abbr'];
|
||||
// $corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||||
// $param['corp_abbr'] = $corp->id;
|
||||
|
||||
$result = (new CustomerService())->export($param);
|
||||
|
||||
// 检查文件是否存在
|
||||
if (!file_exists($result['filepath'])) {
|
||||
return $this->error('导出文件生成失败');
|
||||
}
|
||||
|
||||
// 获取文件信息
|
||||
$fileSize = filesize($result['filepath']);
|
||||
$filename = $result['filename'];
|
||||
|
||||
return $this->success($this->page($result));
|
||||
// 设置响应头
|
||||
$response = response()->file($result['filepath']);
|
||||
$response->header('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
$response->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
$response->header('Content-Length', $fileSize);
|
||||
$response->header('Cache-Control', 'no-cache, must-revalidate');
|
||||
$response->header('Pragma', 'no-cache');
|
||||
|
||||
return $response;
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage().$e->getFile().$e->getLine().$e->getTraceAsString());
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +86,8 @@ class CustomerController extends BaseController
|
||||
if (empty($param['id'])) {
|
||||
return $this->error('ID'.trans('not_null'));
|
||||
}
|
||||
if (in_array($param['scene'],['delete','report'])) {
|
||||
|
||||
if (!in_array($param['scene'],['delete','report'])) {
|
||||
return $this->error('scene 不合法');
|
||||
}
|
||||
$result = (new CustomerService())->audit($param);
|
||||
|
||||
Reference in New Issue
Block a user