Officer.php 3.8 KB

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