Officer.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. ['mobile', '手机号'],
  71. ['sex', '性别'],
  72. ['age', '年龄'],
  73. ['marry', '婚姻状况'],
  74. ['education', '学历'],
  75. ['major', '专业'],
  76. ['seniority', '工龄'],
  77. ['leader', '担任领导的累计年限'],
  78. ['industry', '所在行业'],
  79. ['company', '所在单位'],
  80. ['job', '职位'],
  81. ];
  82. $res = [];
  83. foreach ($list as $ak => $answer) {
  84. $item = [];
  85. $item['name'] = $answer['name'];
  86. $item['mobile'] = $answer['mobile'];
  87. $item['sex'] = $answer['sex'];
  88. $item['age'] = $answer['age'];
  89. $item['marry'] = $answer['marry'];
  90. $item['education'] = $answer['education'];
  91. $item['major'] = $answer['major'];
  92. $item['seniority'] = $answer['seniority'];
  93. $item['leader'] = $answer['leader'];
  94. $item['industry'] = $answer['industry'];
  95. if (empty($answer['company_text'])) {
  96. $item['company'] = $answer['company'];
  97. } else {
  98. $item['company'] = $answer['company'] . "({$answer['company_text']})";
  99. }
  100. if (empty($answer['job_text'])) {
  101. $item['job'] = $answer['job'];
  102. } else {
  103. $item['job'] = $answer['job'] . "({$answer['job_text']})";
  104. }
  105. foreach ($answer['detail'] as $k => $v) {
  106. $index = 'part_' . $v['no'];
  107. if ($ak == 0) {
  108. $xlsCell[] = [$index, $index];
  109. }
  110. $item[$index] = $v['score'];
  111. }
  112. $res[] = $item;
  113. }
  114. export_exl("考试明细", $xlsCell, $res);
  115. }
  116. /**
  117. * 二维码
  118. */
  119. public function qrcode()
  120. {
  121. $id = input('id/d', 0);
  122. $file_name = "/officer_{$id}.png";
  123. $link = url('/mobile/officer/index') . '?id=' . $id;
  124. $file_url = QrcodeService::getQrcode($file_name, $link, 600);
  125. ajax_return(0, '', $file_url);
  126. }
  127. }