You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.1 KiB
79 lines
2.1 KiB
<?php |
|
|
|
|
|
namespace App\Admin\Extensions\Exporter; |
|
|
|
|
|
use App\Models\CompletedOnLineStepView; |
|
use App\Models\Config; |
|
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
|
use Maatwebsite\Excel\Concerns\Exportable; |
|
use Maatwebsite\Excel\Concerns\FromCollection; |
|
use Maatwebsite\Excel\Concerns\WithHeadings; |
|
use Maatwebsite\Excel\Concerns\WithMapping; |
|
|
|
class ImportCompletedOnLineStepView extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
|
{ |
|
use Exportable; |
|
protected $fileName = '已完成线上报到名单'; |
|
protected $titles = []; |
|
|
|
public function __construct() |
|
{ |
|
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
|
$this->titles = [ |
|
'name'=> '姓名', |
|
'mobile'=> '手机', |
|
'idcard'=> '身份证', |
|
'sex'=> '性别', |
|
'speciality_name'=> '专业', |
|
'conllege_name'=> '二级学院', |
|
'annual_session'=> '年份', |
|
]; |
|
parent::__construct(); |
|
} |
|
|
|
public function export() |
|
{ |
|
// TODO: Implement export() method. |
|
$this->download($this->fileName)->prepare(request())->send(); |
|
exit; |
|
} |
|
|
|
public function collection() |
|
{ |
|
// TODO: Implement collection() method. |
|
// return collect($this->buildData()); |
|
|
|
//取出当前年份 |
|
$config = Config::query()->where([ |
|
"unique_identification" => "annual_session" |
|
])->first(); |
|
|
|
$list = CompletedOnLineStepView::query()->where([ |
|
"annual_session" => $config->data, |
|
])->get()->toArray(); |
|
|
|
return collect($list); |
|
} |
|
|
|
public function headings(): array |
|
{ |
|
// TODO: Implement headings() method. |
|
return $this->titles(); |
|
} |
|
|
|
public function map($row): array |
|
{ |
|
// TODO: Implement map() method. |
|
return [ |
|
$row["name"], |
|
$row["mobile"], |
|
"'".$row['idcard'].'', |
|
$row["sex"], |
|
$row["speciality_name"], |
|
$row["conllege_name"], |
|
$row["annual_session"], |
|
]; |
|
} |
|
}
|
|
|