CompanyExport.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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\Company;
  9. use App\Admin\Exports\RowExport;
  10. use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
  11. use APP\Models\Jobs;
  12. class CompanyExport extends RowExport
  13. {
  14. /**
  15. * 设置标题,返回标题数组
  16. * @return array
  17. */
  18. public function headings(): array
  19. {
  20. return [
  21. '企业ID',
  22. '企业名称',
  23. '所属分站',
  24. '认证状态',
  25. '公司地址',
  26. '企业性质',
  27. '所属行业',
  28. '企业规模',
  29. '企业联系人',
  30. '手机号码',
  31. '固定号码',
  32. 'email',
  33. '套餐名称',
  34. '社会统一信用码',
  35. '创建时间'
  36. ];
  37. }
  38. /**
  39. * 处理行数据
  40. * @param Model $row
  41. * @return array
  42. */
  43. public function map($row): array
  44. {
  45. $result['id'] = $row->id;
  46. $result['companyname'] = $row->companyname;
  47. $result['subsite_id'] = $row->subsite_id==0?"总站":get_subsite_sitename($row->subsite_id);
  48. switch ($row->audit) {
  49. case 0:
  50. $result['audit'] = '未审核';
  51. break;
  52. case 1:
  53. $result['audit'] = '审核通过';
  54. break;
  55. case 2:
  56. $result['audit'] = '审核中';
  57. break;
  58. case 3:
  59. $result['audit'] = '审核未通过';
  60. break;
  61. }
  62. $result['address'] = $row->address;
  63. $result['nature'] = get_category($row->nature)?:"无";
  64. $result['trade'] = get_category($row->trade)?:"无";
  65. $result['scale'] = get_category($row->scale)?:"无";
  66. $result['contact'] = $row->contact;
  67. $result['mobile'] = $row->mobile;
  68. $result['landline_tel'] = $row->landline_tel;
  69. $result['email'] = $row->email;
  70. $result['setmeal_name'] = $row->setmeal_name;
  71. $result['organization_code'] = $row->organization_code;
  72. $result['created_at'] = $row->created_at;
  73. return $result;
  74. }
  75. /**
  76. * 设置文件名
  77. * @return string
  78. */
  79. public function getFilename(): string
  80. {
  81. return "company.xlsx";
  82. }
  83. /**
  84. * 格式化指定列.
  85. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  86. * @return array
  87. */
  88. public function columnFormats(): array
  89. {
  90. return [
  91. ];
  92. }
  93. }