|
|
|
|
@ -299,7 +299,7 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取学员信息(优化显示格式)
|
|
|
|
|
* 获取学员信息(表格格式显示)
|
|
|
|
|
* @param $data
|
|
|
|
|
*/
|
|
|
|
|
function getUsers($data)
|
|
|
|
|
@ -308,34 +308,67 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list = [];
|
|
|
|
|
$result = [];
|
|
|
|
|
|
|
|
|
|
// 表头
|
|
|
|
|
$header = "序号\t学号\t姓名\t校友\t职位\t手机\t报名课程\t报名时间";
|
|
|
|
|
$result[] = $header;
|
|
|
|
|
$result[] = str_repeat("─", 80); // 分隔线
|
|
|
|
|
|
|
|
|
|
// 数据行
|
|
|
|
|
$index = 1;
|
|
|
|
|
foreach ($data['users'] as $item) {
|
|
|
|
|
// 基本信息行
|
|
|
|
|
$userInfo = [];
|
|
|
|
|
$userInfo[] = "【学员{$index}】";
|
|
|
|
|
$userInfo[] = "学号: " . ($item['no'] ?? '-');
|
|
|
|
|
$userInfo[] = "姓名: " . ($item['username'] ?? '-');
|
|
|
|
|
$userInfo[] = "校友: " . ($item['is_schoolmate_text'] ?? '-');
|
|
|
|
|
$userInfo[] = "职位: " . ($item['company_position'] ?? '-');
|
|
|
|
|
$userInfo[] = "手机: " . ($item['mobile'] ?? '-');
|
|
|
|
|
|
|
|
|
|
// 课程报名信息
|
|
|
|
|
// 如果有多个课程报名,需要展开多行
|
|
|
|
|
if (!empty($item['course_signs'])) {
|
|
|
|
|
$userInfo[] = "报名课程:";
|
|
|
|
|
foreach ($item['course_signs'] as $signIndex => $sign) {
|
|
|
|
|
$courseName = $sign['course']['name'] ?? '-';
|
|
|
|
|
$signDate = $sign['created_at'] ?? '-';
|
|
|
|
|
$userInfo[] = " " . ($signIndex + 1) . ". {$courseName} ({$signDate})";
|
|
|
|
|
$signDate = isset($sign['created_at']) ? substr($sign['created_at'], 0, 10) : '-';
|
|
|
|
|
|
|
|
|
|
if ($signIndex === 0) {
|
|
|
|
|
// 第一行显示完整信息
|
|
|
|
|
$row = implode("\t", [
|
|
|
|
|
$index,
|
|
|
|
|
$item['no'] ?? '-',
|
|
|
|
|
$item['username'] ?? '-',
|
|
|
|
|
$item['is_schoolmate_text'] ?? '-',
|
|
|
|
|
$item['company_position'] ?? '-',
|
|
|
|
|
$item['mobile'] ?? '-',
|
|
|
|
|
$courseName,
|
|
|
|
|
$signDate
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// 后续行只显示课程信息,其他列留空
|
|
|
|
|
$row = implode("\t", [
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
$courseName,
|
|
|
|
|
$signDate
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
$result[] = $row;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 没有课程报名
|
|
|
|
|
$row = implode("\t", [
|
|
|
|
|
$index,
|
|
|
|
|
$item['no'] ?? '-',
|
|
|
|
|
$item['username'] ?? '-',
|
|
|
|
|
$item['is_schoolmate_text'] ?? '-',
|
|
|
|
|
$item['company_position'] ?? '-',
|
|
|
|
|
$item['mobile'] ?? '-',
|
|
|
|
|
'-',
|
|
|
|
|
'-'
|
|
|
|
|
]);
|
|
|
|
|
$result[] = $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[] = implode("\n", $userInfo);
|
|
|
|
|
$index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用分隔线分隔不同学员
|
|
|
|
|
return implode("\n" . str_repeat("-", 40) . "\n", $list);
|
|
|
|
|
return implode("\n", $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|