todo download
This commit is contained in:
parent
630aaf6beb
commit
33350cfd47
@ -110,7 +110,8 @@ class Admin extends BaseController
|
|||||||
return SuccessResponse::create($data->toArray());
|
return SuccessResponse::create($data->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadEvaluation(){
|
public function downloadEvaluation()
|
||||||
|
{
|
||||||
$resultType = $this->request->get('resultType');
|
$resultType = $this->request->get('resultType');
|
||||||
if ($resultType == null) $resultType = EvaluationService::ResultAll;
|
if ($resultType == null) $resultType = EvaluationService::ResultAll;
|
||||||
list($page, $size) = $this->getPageParam();
|
list($page, $size) = $this->getPageParam();
|
||||||
@ -126,8 +127,29 @@ class Admin extends BaseController
|
|||||||
|
|
||||||
$excel = new Spreadsheet();
|
$excel = new Spreadsheet();
|
||||||
$sheet = $excel->getActiveSheet();
|
$sheet = $excel->getActiveSheet();
|
||||||
// $rowNumber =
|
$rowNumber = 1;
|
||||||
$sheet->setCellValue('A1', 'Hello World !');
|
$titles = [
|
||||||
|
'A' => ['text' => '自评时间', 'key' => 'create_time'],
|
||||||
|
'B' => ['text' => '姓名', 'key' => 'realname'],
|
||||||
|
'C' => ['text' => '头痛症状', 'key' => 'headache'],
|
||||||
|
'D' => ['text' => '胃肠道症状', 'key' => 'gastrointestinal'],
|
||||||
|
'E' => ['text' => '劳累或疲劳', 'key' => 'tired'],
|
||||||
|
'F' => ['text' => '头晕或眩晕', 'key' => 'dizzy'],
|
||||||
|
'G' => ['text' => '总分', 'key' => 'score'],
|
||||||
|
'H' => ['text' => '评估结果', 'key' => 'resultType'],
|
||||||
|
'I' => ['text' => '性别', 'key' => 'gender'],
|
||||||
|
'J' => ['text' => '年龄', 'key' => 'age']
|
||||||
|
];
|
||||||
|
$fields = explode(',', 'A,B,C,D,E,F,G.H');
|
||||||
|
foreach ($fields as $f) {
|
||||||
|
$sheet->setCellValue($f . $rowNumber, $titles[$f]);
|
||||||
|
}
|
||||||
|
foreach ($data->dataList as $item) {
|
||||||
|
$rowNumber++;
|
||||||
|
foreach ($fields as $f) {
|
||||||
|
$sheet->setCellValue($f . $rowNumber, $item[$f]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
$filename = urlencode("评估记录_") . date('mdHi');
|
$filename = urlencode("评估记录_") . date('mdHi');
|
||||||
|
@ -11,16 +11,22 @@ namespace app\util;
|
|||||||
|
|
||||||
class ListCountData
|
class ListCountData
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
public $totalCount;
|
public $totalCount;
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $dataList;
|
public $dataList;
|
||||||
|
|
||||||
public function __construct(int $count, $data)
|
public function __construct(int $count,array $data)
|
||||||
{
|
{
|
||||||
$this->totalCount = $count;
|
$this->totalCount = $count;
|
||||||
$this->dataList = $data;
|
$this->dataList = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Create(int $count, $data)
|
public static function Create(int $count, array $data)
|
||||||
{
|
{
|
||||||
return new ListCountData($count, $data);
|
return new ListCountData($count, $data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user