BuyHouseCheckLogController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\MemberInfo;
  5. use App\Models\TalentHouseCheckLog;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. use Illuminate\Http\Request;
  10. class BuyHouseCheckLogController extends Controller
  11. {
  12. use HasResourceActions;
  13. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  14. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  15. /**
  16. * Index interface.
  17. *
  18. * @param Content $content
  19. * @return Content
  20. */
  21. public function index(Content $content)
  22. {
  23. return $content
  24. ->header('审核日志')
  25. ->description(' ')
  26. ->body(view('admin.content.buy_house_check_log')->with(['grid' => $this->grid()]));
  27. }
  28. /**
  29. * Make a grid builder.
  30. *
  31. * @return Grid
  32. */
  33. protected function grid()
  34. {
  35. $grid = new Grid(new TalentHouseCheckLog());
  36. $grid->model()->orderBy('created_at', 'DESC');
  37. $grid->id('ID');
  38. $grid->house_name('房源');
  39. $grid->user_name('用户');
  40. $grid->check_name('审核人');
  41. $status_text = $this->status;
  42. $grid->check_status('审核结果')->display(function () use ($status_text) {
  43. return $status_text[$this->check_status];
  44. });
  45. $grid->check_comment('审核备注')->style('max-width:400px');
  46. $grid->created_at('审核时间');
  47. $grid->actions(function ($actions) {
  48. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' data-id='{$actions->row['id']}'>数据</button>");
  49. });
  50. $grid->filter(function ($filter) {
  51. $filter->disableIdFilter();
  52. $filter->like('house_name', '房源');
  53. $filter->like('user_name', '用户');
  54. });
  55. return $grid;
  56. }
  57. /**
  58. * 详情
  59. */
  60. public function detail(Request $request)
  61. {
  62. $id = $request->id;
  63. $log = TalentHouseCheckLog::find($id);
  64. $info = json_decode($log->data, true);
  65. $info['family'] = json_decode($info['family']);
  66. $info['marry_text'] = $this->marry[$info['marry']];
  67. //layer相册层
  68. $photos = [
  69. 'certificates' => [],
  70. 'marry_prove' => [],
  71. 'household_register' => [],
  72. 'work_prove' => [],
  73. ];
  74. if (!empty(json_decode($info['certificates']))) {
  75. $info['certificates'] = json_decode($info['certificates']);
  76. $photo_data = [];
  77. foreach ($info['certificates'] as $k => $v) {
  78. $photo_data[] = [
  79. 'alt' => $v->name,
  80. 'pid' => $v->uid,
  81. 'src' => $v->response->path,
  82. ];
  83. }
  84. $photos['certificates'] = [
  85. 'title' => '证件信息',
  86. 'id' => 1,
  87. 'start' => 0,
  88. 'data' => $photo_data,
  89. ];
  90. } else {
  91. $info['certificates'] = [];
  92. }
  93. if (!empty(json_decode($info['marry_prove']))) {
  94. $info['marry_prove'] = json_decode($info['marry_prove']);
  95. $photo_data = [];
  96. foreach ($info['marry_prove'] as $k => $v) {
  97. $photo_data[] = [
  98. 'alt' => $v->name,
  99. 'pid' => $v->uid,
  100. 'src' => $v->response->path,
  101. ];
  102. }
  103. $photos['marry_prove'] = [
  104. 'title' => '婚姻证明',
  105. 'id' => 1,
  106. 'start' => 0,
  107. 'data' => $photo_data,
  108. ];
  109. } else {
  110. $info['marry_prove'] = [];
  111. }
  112. if (!empty(json_decode($info['household_register']))) {
  113. $info['household_register'] = json_decode($info['household_register']);
  114. $photo_data = [];
  115. foreach ($info['household_register'] as $k => $v) {
  116. $photo_data[] = [
  117. 'alt' => $v->name,
  118. 'pid' => $v->uid,
  119. 'src' => $v->response->path,
  120. ];
  121. }
  122. $photos['household_register'] = [
  123. 'title' => '户口本',
  124. 'id' => 1,
  125. 'start' => 0,
  126. 'data' => $photo_data,
  127. ];
  128. } else {
  129. $info['household_register'] = [];
  130. }
  131. if (!empty(json_decode($info['work_prove']))) {
  132. $info['work_prove'] = json_decode($info['work_prove']);
  133. $photo_data = [];
  134. foreach ($info['work_prove'] as $k => $v) {
  135. $photo_data[] = [
  136. 'alt' => $v->name,
  137. 'pid' => $v->uid,
  138. 'src' => $v->response->path,
  139. ];
  140. }
  141. $photos['work_prove'] = [
  142. 'title' => '在职证明',
  143. 'id' => 1,
  144. 'start' => 0,
  145. 'data' => $photo_data,
  146. ];
  147. } else {
  148. $info['work_prove'] = [];
  149. }
  150. $info['idcard'] = MemberInfo::where('uid',$info['user_id'])->first();
  151. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos, 'status' => $this->status])->render();
  152. return response()->json(['code' => 1, 'data' => $html]);
  153. }
  154. }