PutJobsExport.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/4/13
  6. * Time: 10:29
  7. */
  8. namespace App\Admin\Exports\Jobfair;
  9. use App\Admin\Exports\RowExport;
  10. use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
  11. class PutJobsExport extends RowExport
  12. {
  13. /**
  14. * 设置标题,返回标题数组
  15. * @return array
  16. */
  17. public function headings(): array
  18. {
  19. if(get_subsite_open()){
  20. return [
  21. '职位名称',
  22. '发布公司',
  23. '招聘会标题',
  24. '招聘人数',
  25. '工作地区',
  26. '所属分站',
  27. '性别',
  28. '年龄',
  29. '学历',
  30. '工资',
  31. '报名时间',
  32. ];
  33. }else {
  34. return [
  35. '职位名称',
  36. '发布公司',
  37. '招聘会标题',
  38. '招聘人数',
  39. '工作地区',
  40. '性别',
  41. '年龄',
  42. '学历',
  43. '工资',
  44. '报名时间',
  45. ];
  46. }
  47. }
  48. /**
  49. * 处理行数据
  50. * @param Model $row
  51. * @return array
  52. */
  53. public function map($row): array
  54. {
  55. $result['jobs_name'] = $row->jobs_name;
  56. $result['company_name'] = $row->company_name;
  57. $result['title'] = $row->jobfairs->title;
  58. $result['amount'] = empty($row->amount) ? '若干': $row->amount;$row->amount;
  59. $result['district_cn'] = empty($row->district_cn) ? '不限': $row->district_cn;$row->district_cn;
  60. if(get_subsite_open()) {
  61. $result['subsite'] = empty($row->jobfairs->sitename->sitename) ? '总站': $row->jobfairs->sitename->sitename;
  62. }
  63. $result['sex'] = empty($row->sex_cn) ? '不限': $row->sex_cn;
  64. $result['age'] = $row->age == '-'|| empty($row->age) ? '不限' :$row->age;
  65. $result['education'] = empty($row->education_cn) ? '不限': $row->education_cn;
  66. $result['wage_cn'] = empty($row->wage_cn) ? '不限': $row->wage_cn;
  67. $result['created_at'] = $row->created_at;
  68. return $result;
  69. }
  70. /**
  71. * 设置文件名
  72. * @return string
  73. */
  74. public function getFilename(): string
  75. {
  76. return "jobfair_put_jobs.xlsx";
  77. }
  78. /**
  79. * 格式化指定列.
  80. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  81. * @return array
  82. */
  83. public function columnFormats(): array
  84. {
  85. return [
  86. ];
  87. }
  88. }