TalentLibrary.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $data = [];
  50. for ($n = 0; $n < count($fields); $n++) {
  51. $cellValue = $list[$i][$fields[$n]];
  52. $data[] = $cellValue;
  53. }
  54. $datas[] = $data;
  55. }
  56. $setting["freeze"] = "A2";
  57. $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
  58. if ($datas) {
  59. export($columns, $datas, "人才认定申报列表导出", $setting);
  60. exit();
  61. }
  62. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  63. }
  64. }