TalentLibrary.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace app\enterprise\controller;
  8. use app\enterprise\common\EnterpriseController;
  9. use app\enterprise\api\TalentApi;
  10. use app\common\api\DictApi;
  11. use app\common\api\VerifyApi;
  12. /**
  13. * Description of TalentLibrary
  14. *
  15. * @author sgq
  16. */
  17. class TalentLibrary extends EnterpriseController {
  18. public function index() {
  19. return view("", ["type" => $this->user["type"]]);
  20. }
  21. public function list() {
  22. $res = TalentApi::getList($this->request, 3);
  23. return json($res);
  24. }
  25. public function export() {
  26. $setting = [];
  27. $params = $this->request->param();
  28. $fields = $params["export"];
  29. if (!$fields)
  30. return json(["msg" => "请选择要导出的数据"]);
  31. $names = DictApi::getTalentFields(4, in_array("isMatchZhiren", $fields));
  32. $names["industryFieldNew"] = "产业领域";
  33. $names["enterpriseName"] = "单位名称";
  34. $names["enterpriseTag"] = "单位标签";
  35. $names["street"] = "所属镇街";
  36. $names["breakFaithName"] = "曾被相关主管部门列为失信个人";
  37. $names["identifyMonth"] = "公布入选月份";
  38. $names["certificateNo"] = "人才编号";
  39. $names["activeName"] = "离职状态";
  40. $names["cur_quit_time"] = "离职时间";
  41. $names["first_submit_time"] = "首次确认提交时间";
  42. $names["new_submit_time"] = "最新确认提交时间";
  43. $list = VerifyApi::getExportDatas(7, $params);
  44. foreach ($fields as $field) {
  45. $columns[] = $names[$field];
  46. }
  47. $datas = [];
  48. for ($i = 0; $i < count($list); $i++) {
  49. if(count((array)$list[$i]) > 0){
  50. $data = [];
  51. for ($n = 0; $n < count($fields); $n++) {
  52. $cellValue = $list[$i][$fields[$n]];
  53. $data[] = $cellValue;
  54. }
  55. $datas[] = $data;
  56. }
  57. }
  58. $setting["freeze"] = "A2";
  59. $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
  60. if ($datas) {
  61. export($columns, $datas, "人才认定申报列表导出", $setting);
  62. exit();
  63. }
  64. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  65. }
  66. }