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.
87 lines
2.3 KiB
87 lines
2.3 KiB
<?php |
|
|
|
|
|
namespace App\Admin\Extensions\Exporter; |
|
|
|
|
|
use App\Models\LoanStudentsList; |
|
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 ImportLoanExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
|
{ |
|
use Exportable; |
|
protected $fileName = '已导入贷款名单'; |
|
protected $titles = []; |
|
|
|
public function __construct() |
|
{ |
|
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
|
$this->titles = [ |
|
'sfzh'=>'身份证', |
|
'xh'=>'学号', |
|
'xm'=>'姓名', |
|
'annual_session'=>'年份', |
|
'fylx'=>'费用类型', |
|
'total'=>'贷款总额', |
|
'xfje'=>'抵扣学费金额', |
|
'zsje'=>'抵扣住宿费金额', |
|
'is_push'=>'是否已推送', |
|
'is_five_year'=>'是否为五年制一贯制', |
|
"create_time" => "导入时间", |
|
]; |
|
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()); |
|
} |
|
|
|
public function headings(): array |
|
{ |
|
// TODO: Implement headings() method. |
|
return $this->titles(); |
|
} |
|
|
|
public function map($row): array |
|
{ |
|
|
|
$fylx = "贷款计划"; |
|
if($row['fylx'] == LoanStudentsList::FYLX_DZ) $fylx = "贷款到账"; |
|
|
|
$is_push = "未推送"; |
|
if($row['is_push'] == LoanStudentsList::IS_PUSH_YES) $is_push = "已推送"; |
|
|
|
$is_five_year = "否"; |
|
if($row['is_five_year'] == LoanStudentsList::IS_FIVE_YEAR_YES) $is_five_year = "是"; |
|
|
|
// TODO: Implement map() method. |
|
return [ |
|
"'".$row['sfzh'].'', |
|
$row["xh"], |
|
$row["xm"], |
|
$row["annual_session"], |
|
$fylx, |
|
$row["total"], |
|
$row["xfje"], |
|
$row["zsje"], |
|
$is_push, |
|
$is_five_year, |
|
date("Y-m-d H:i:s", $row['create_time']), |
|
]; |
|
} |
|
|
|
}
|
|
|