优化导出类的代码语义

This commit is contained in:
2022-08-12 18:02:10 +08:00
parent bba154a1df
commit 54a52e68d8
3 changed files with 4 additions and 4 deletions

View File

@@ -19,7 +19,7 @@
$select_fields = json_decode($select_fields, true);
$date_fields = json_decode($date_fields, true);
$content = \app\common\tools\ExcelTools::exportModel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields);
$content = \app\common\tools\ExportTools::excel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields);
return download($content, $this->model->getName() . date('YmdHis') . '.xlsx', true);
}

View File

@@ -118,7 +118,7 @@ trait Curd
$select_fields = json_decode($select_fields, true);
$date_fields = json_decode($date_fields, true);
$content = \app\common\tools\ExcelTools::exportModel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields);
$content = \app\common\tools\ExportTools::excel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields);
return download($content, $this->model->getName() . date('YmdHis') . '.xlsx', true);
}

View File

@@ -4,9 +4,9 @@ namespace app\common\tools;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
class ExcelTools
class ExportTools
{
public static function exportModel($model, $where = [], $fields = [], $image_fields = [], $select_fields = [], $date_fields = [])
public static function excel($model, $where = [], $fields = [], $image_fields = [], $select_fields = [], $date_fields = [])
{
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();