master
cody 1 month ago
parent c37f930325
commit f5d2462953

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Exports\BaseExport; use App\Exports\BaseExport;
use App\Exports\CommonExport;
use App\Helpers\ResponseCode; use App\Helpers\ResponseCode;
use App\Models\AppointmentType; use App\Models\AppointmentType;
use App\Models\Book; use App\Models\Book;
@ -35,6 +36,9 @@ class CalendarsController extends BaseController
* tags={"日历管理"}, * tags={"日历管理"},
* summary="列表", * summary="列表",
* description="", * description="",
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
* @OA\Parameter(name="file_name", in="query", @OA\Schema(type="string"), required=false, description="导出文件名"),
* @OA\Parameter(name="month", in="query", @OA\Schema(type="string"), required=true, description="月份"), * @OA\Parameter(name="month", in="query", @OA\Schema(type="string"), required=true, description="月份"),
* @OA\Response( * @OA\Response(
* response="200", * response="200",
@ -55,6 +59,10 @@ class CalendarsController extends BaseController
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
} }
$list = Calendar::with('course', 'courseContent')->where('start_time', 'like', $all['month'] . '%')->orderBy('date')->get(); $list = Calendar::with('course', 'courseContent')->where('start_time', 'like', $all['month'] . '%')->orderBy('date')->get();
if (isset($all['is_export']) && $all['is_export'] == 1) {
$list = $list->toArray();
return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), ($all['file_name'] ?? '') . date('YmdHis') . '.xlsx');
}
return $this->success($list); return $this->success($list);
} }

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Exports\BaseExport; use App\Exports\BaseExport;
use App\Exports\CommonExport;
use App\Helpers\ResponseCode; use App\Helpers\ResponseCode;
use App\Models\CustomForm; use App\Models\CustomForm;
use App\Models\CustomFormField; use App\Models\CustomFormField;
@ -110,12 +111,8 @@ class TeacherController extends BaseController
} }
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc'); })->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc');
if (isset($all['is_export']) && !empty($all['is_export'])) { if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->get()->toArray(); $list = $list->limit(5000)->toArray();
$export_fields = $all['export_fields'] ?? []; return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), ($all['file_name'] ?? '') . date('YmdHis') . '.xlsx');
// 导出文件名字
$tableName = $this->model->getTable();
$filename = (new CustomForm())->getTableComment($tableName);
return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx');
} else { } else {
if (isset($all['theme']) || isset($all['direction'])) { if (isset($all['theme']) || isset($all['direction'])) {
$list = $list->whereHas('courseContents', function ($query) use ($all) { $list = $list->whereHas('courseContents', function ($query) use ($all) {

Loading…
Cancel
Save