Officer.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\AdminBaseController;
  4. use app\common\model\OfficerAnswerModel;
  5. use app\common\model\OfficerReviewModel;
  6. class Officer extends AdminBaseController
  7. {
  8. public function index()
  9. {
  10. return view();
  11. }
  12. public function listOfficer()
  13. {
  14. $list = OfficerReviewModel::limit(input('limit'))
  15. ->page(input('page'))
  16. ->select();
  17. $count = OfficerReviewModel::count();
  18. if ($count == 0) {
  19. ajax_return(1, '未查询到数据');
  20. }
  21. list_return($list, $count);
  22. }
  23. /**
  24. * 列表
  25. */
  26. public function detail()
  27. {
  28. $id = input('id');
  29. if (empty($id)) {
  30. return '该测评不存在';
  31. }
  32. return view('', ['id' => $id]);
  33. }
  34. public function listDetail()
  35. {
  36. $id = input('id', 0);
  37. $list = OfficerAnswerModel::where('rid', $id)
  38. ->order('id', 'desc')
  39. ->limit(input('limit'))
  40. ->page(input('page'))
  41. ->append(['status_text'])
  42. ->select();
  43. $count = OfficerAnswerModel::count();
  44. if ($count == 0) {
  45. ajax_return(1, '未查询到数据');
  46. }
  47. list_return($list, $count);
  48. }
  49. public function export()
  50. {
  51. $id = input('id', 0);
  52. $list = OfficerAnswerModel::with(['detail'])
  53. ->where('rid', $id)
  54. ->order('id', 'desc')
  55. ->append(['status_text'])
  56. ->select();
  57. if ($list->isEmpty()) {
  58. return '暂无人答题';
  59. }
  60. $xlsCell = [
  61. ['name', '姓名'],
  62. ['mobile', '手机号'],
  63. ['sex', '性别'],
  64. ['age', '年龄'],
  65. ['marry', '婚姻状况'],
  66. ['education', '学历'],
  67. ['major', '专业'],
  68. ['seniority', '工龄'],
  69. ['leader', '担任领导的累计年限'],
  70. ['industry', '所在行业'],
  71. ['company', '所在单位'],
  72. ['job', '职位'],
  73. ];
  74. $res = [];
  75. foreach ($list as $ak => $answer) {
  76. $item = [];
  77. $item['name'] = $answer['name'];
  78. $item['mobile'] = $answer['mobile'];
  79. $item['sex'] = $answer['sex'];
  80. $item['age'] = $answer['age'];
  81. $item['marry'] = $answer['marry'];
  82. $item['education'] = $answer['education'];
  83. $item['major'] = $answer['major'];
  84. $item['seniority'] = $answer['seniority'];
  85. $item['leader'] = $answer['leader'];
  86. $item['industry'] = $answer['industry'];
  87. if (empty($answer['company_text'])) {
  88. $item['company'] = $answer['company'];
  89. } else {
  90. $item['company'] = $answer['company'] . "({$answer['company_text']})";
  91. }
  92. if (empty($answer['job_text'])) {
  93. $item['job'] = $answer['job'];
  94. } else {
  95. $item['job'] = $answer['job'] . "({$answer['job_text']})";
  96. }
  97. foreach ($answer['detail'] as $k => $v) {
  98. $index = 'part_' . $v['no'];
  99. if ($ak == 0) {
  100. $xlsCell[] = [$index, $index];
  101. }
  102. $item[$index] = $v['score'];
  103. }
  104. $res[] = $item;
  105. }
  106. export_exl("考试明细", $xlsCell, $res);
  107. }
  108. }