Officer.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. ->order('id', 'desc')
  43. ->limit(input('limit'))
  44. ->page(input('page'))
  45. ->append(['status_text'])
  46. ->select();
  47. $count = OfficerAnswerModel::count();
  48. if ($count == 0) {
  49. ajax_return(1, '未查询到数据');
  50. }
  51. list_return($list, $count);
  52. }
  53. public function export()
  54. {
  55. $id = input('id', 0);
  56. $list = OfficerAnswerModel::with(['detail'])
  57. ->where('rid', $id)
  58. ->order('id', 'desc')
  59. ->append(['status_text'])
  60. ->select();
  61. if ($list->isEmpty()) {
  62. return '暂无人答题';
  63. }
  64. $xlsCell = [
  65. ['name', '姓名'],
  66. ['mobile', '手机号'],
  67. ['sex', '性别'],
  68. ['age', '年龄'],
  69. ['marry', '婚姻状况'],
  70. ['education', '学历'],
  71. ['major', '专业'],
  72. ['seniority', '工龄'],
  73. ['leader', '担任领导的累计年限'],
  74. ['industry', '所在行业'],
  75. ['company', '所在单位'],
  76. ['job', '职位'],
  77. ];
  78. $res = [];
  79. foreach ($list as $ak => $answer) {
  80. $item = [];
  81. $item['name'] = $answer['name'];
  82. $item['mobile'] = $answer['mobile'];
  83. $item['sex'] = $answer['sex'];
  84. $item['age'] = $answer['age'];
  85. $item['marry'] = $answer['marry'];
  86. $item['education'] = $answer['education'];
  87. $item['major'] = $answer['major'];
  88. $item['seniority'] = $answer['seniority'];
  89. $item['leader'] = $answer['leader'];
  90. $item['industry'] = $answer['industry'];
  91. if (empty($answer['company_text'])) {
  92. $item['company'] = $answer['company'];
  93. } else {
  94. $item['company'] = $answer['company'] . "({$answer['company_text']})";
  95. }
  96. if (empty($answer['job_text'])) {
  97. $item['job'] = $answer['job'];
  98. } else {
  99. $item['job'] = $answer['job'] . "({$answer['job_text']})";
  100. }
  101. foreach ($answer['detail'] as $k => $v) {
  102. $index = 'part_' . $v['no'];
  103. if ($ak == 0) {
  104. $xlsCell[] = [$index, $index];
  105. }
  106. $item[$index] = $v['score'];
  107. }
  108. $res[] = $item;
  109. }
  110. export_exl("考试明细", $xlsCell, $res);
  111. }
  112. /**
  113. * 二维码
  114. */
  115. public function qrcode()
  116. {
  117. $id = input('id/d', 0);
  118. $file_name = "/officer_{$id}.png";
  119. $link = url('/mobile/officer/index') . '?id=' . $id;
  120. $file_url = QrcodeService::getQrcode($file_name, $link, 600);
  121. ajax_return(0, '', $file_url);
  122. }
  123. }