Officer.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. use app\common\service\QrcodeService;
  7. class Officer extends AdminBaseController
  8. {
  9. public function index()
  10. {
  11. return view();
  12. }
  13. public function listOfficer()
  14. {
  15. $list = OfficerReviewModel::limit(input('limit'))
  16. ->page(input('page'))
  17. ->select();
  18. $count = OfficerReviewModel::count();
  19. if ($count == 0) {
  20. ajax_return(1, '未查询到数据');
  21. }
  22. foreach ($list as $v) {
  23. $v['name'] = strip_tags($v['name']);
  24. }
  25. list_return($list, $count);
  26. }
  27. /**
  28. * 列表
  29. */
  30. public function detail()
  31. {
  32. $id = input('id');
  33. if (empty($id)) {
  34. return '该测评不存在';
  35. }
  36. return view('', ['id' => $id]);
  37. }
  38. public function listDetail()
  39. {
  40. $id = input('id', 0);
  41. $list = OfficerAnswerModel::where('rid', $id)
  42. ->where('status', 2)
  43. ->order('id', 'desc')
  44. ->limit(input('limit'))
  45. ->page(input('page'))
  46. ->append(['status_text'])
  47. ->select();
  48. $count = OfficerAnswerModel::where('rid', $id)
  49. ->where('status', 2)
  50. ->count();
  51. if ($count == 0) {
  52. ajax_return(1, '未查询到数据');
  53. }
  54. list_return($list, $count);
  55. }
  56. public function export()
  57. {
  58. $id = input('id', 0);
  59. $list = OfficerAnswerModel::with(['detail'])
  60. ->where('rid', $id)
  61. ->where('status', 2)
  62. ->order('id', 'desc')
  63. ->append(['status_text'])
  64. ->select();
  65. if ($list->isEmpty()) {
  66. return '暂无人答题';
  67. }
  68. $xlsCell = [
  69. ['name', '姓名'],
  70. ['sex', '性别'],
  71. ['age', '年龄'],
  72. ['current_position', '当前岗位'],
  73. ['education', '学历'],
  74. ['major', '专业'],
  75. ['seniority', '工龄'],
  76. ['leader', '担任领导的累计年限'],
  77. ['industry', '所在行业'],
  78. ['company', '所在单位'],
  79. ['job', '职位'],
  80. ];
  81. $res = [];
  82. foreach ($list as $ak => $answer) {
  83. $item = [];
  84. $item['name'] = $answer['name'];
  85. $item['sex'] = $answer['sex'];
  86. $item['age'] = $answer['age'];
  87. $item['current_position'] = $answer['current_position'];
  88. $item['education'] = $answer['education'];
  89. $item['major'] = $answer['major'];
  90. $item['seniority'] = $answer['seniority'];
  91. $item['leader'] = $answer['leader'];
  92. $item['industry'] = $answer['industry'];
  93. if (empty($answer['company_text'])) {
  94. $item['company'] = $answer['company'];
  95. } else {
  96. $item['company'] = $answer['company'] . "({$answer['company_text']})";
  97. }
  98. if (empty($answer['job_text'])) {
  99. $item['job'] = $answer['job'];
  100. } else {
  101. $item['job'] = $answer['job'] . "({$answer['job_text']})";
  102. }
  103. foreach ($answer['detail'] as $k => $v) {
  104. $index = 'item_' . $v['no'];
  105. if ($ak == 0) {
  106. $xlsCell[] = [$index, $index];
  107. }
  108. $item[$index] = $v['score'];
  109. }
  110. $res[] = $item;
  111. }
  112. // $xlsCell = array_merge($xlsCell, [
  113. // ['name', '姓名'],
  114. // ['mobile', '手机号'],
  115. // ['sex', '性别'],
  116. // ['age', '年龄'],
  117. // ['marry', '婚姻状况'],
  118. // ['education', '学历'],
  119. // ['major', '专业'],
  120. // ['seniority', '工龄'],
  121. // ['leader', '担任领导的累计年限'],
  122. // ['industry', '所在行业'],
  123. // ['company', '所在单位'],
  124. // ['job', '职位'],]);
  125. export_exl("考试明细", $xlsCell, $res);
  126. }
  127. /**
  128. * 二维码
  129. */
  130. public function qrcode()
  131. {
  132. $id = input('id/d', 0);
  133. $file_name = "/officer_{$id}.png";
  134. $link = url('/mobile/officer/index') . '?id=' . $id;
  135. $file_url = QrcodeService::getQrcode($file_name, $link, 600);
  136. ajax_return(0, '', $file_url);
  137. }
  138. }