BuyHouseRsController.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\TalentHouse;
  5. use App\Models\TalentHouseApply;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. use Illuminate\Http\Request;
  10. class BuyHouseRsController extends Controller
  11. {
  12. use HasResourceActions;
  13. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  14. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  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_rs')->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 TalentHouseApply());
  36. $grid->model()->with('house')->where('type',1)->where('is_back',2)->where('is_draft',2)->orderBy('rs_check_status', 'ASC');
  37. $status_text = $this->status;
  38. $grid->id('ID');
  39. $grid->name('姓名');
  40. $grid->mobile('联系电话');
  41. $grid->talent_level('人才层次');
  42. $grid->column('房源')->display(function () {
  43. return $this->house->name;
  44. });
  45. $grid->rs_check_status('状态')->display(function () use ($status_text) {
  46. return $status_text[$this->rs_check_status];
  47. });
  48. $grid->rs_check_comment('备注');
  49. $grid->actions(function ($actions) {
  50. if ($actions->row['rs_check_status'] == 1) {
  51. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  52. }
  53. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' id=" . $actions->row['id'] . ">详情</button>");
  54. });
  55. $grid->filter(function ($filter) {
  56. $filter->disableIdFilter();
  57. $filter->equal('house_id', '房源')->select(TalentHouse::all()->pluck('name', 'id'));
  58. $status_option = ['全部', '待审核', '审核通过', '审核不通过'];
  59. $filter->where(function ($query) {
  60. if ($this->input > 0) {
  61. $query->where('status', '=', $this->input);
  62. }
  63. }, '状态', 'status')->radio($status_option);
  64. });
  65. return $grid;
  66. }
  67. /**
  68. * 审核
  69. */
  70. public function audit(Request $request)
  71. {
  72. $id = $request->id;
  73. $status = $request->status;
  74. $reason = $request->reason;
  75. $url = empty($request->url) ? admin_base_path('content/buy_house_rs') : $request->url;
  76. if (empty($id)) {
  77. admin_toastr('数据异常', 'error');
  78. return redirect(admin_base_path('content/buy_house_rs'));
  79. }
  80. $result = TalentHouseApply::where('id', '=', $id)
  81. ->update([
  82. 'rs_check_status' => $status,
  83. 'rs_check_comment' => $reason,
  84. 'rs_check_time' => date('Y-m-d H:i:s'),
  85. 'status' => $status == 2 ? 1 : 3,
  86. ]);
  87. if ($result) {
  88. admin_toastr('审核成功', 'success');
  89. } else {
  90. admin_toastr('该信息不存在或已审核', 'error');
  91. }
  92. return redirect($url);
  93. }
  94. /**
  95. * 详情
  96. */
  97. public function detail(Request $request)
  98. {
  99. $id = $request->id;
  100. $info = TalentHouseApply::find($id);;
  101. $info->family = json_decode($info->family);
  102. $info->marry_text = $this->marry[$info->marry];
  103. //layer相册层
  104. $photos = [
  105. 'certificates' => [],
  106. 'marry_prove' => [],
  107. 'household_register' => [],
  108. 'work_prove' => [],
  109. ];
  110. if (!empty(json_decode($info->certificates))) {
  111. $info->certificates = json_decode($info->certificates);
  112. $photo_data = [];
  113. foreach ($info->certificates as $k => $v) {
  114. $photo_data[] = [
  115. 'alt' => $v->name,
  116. 'pid' => $v->uid,
  117. 'src' => $v->response->path,
  118. ];
  119. }
  120. $photos['certificates'] = [
  121. 'title' => '证件信息',
  122. 'id' => 1,
  123. 'start' => 0,
  124. 'data' => $photo_data,
  125. ];
  126. } else {
  127. $info->certificates = [];
  128. }
  129. if (!empty(json_decode($info->marry_prove))) {
  130. $info->marry_prove = json_decode($info->marry_prove);
  131. $photo_data = [];
  132. foreach ($info->marry_prove as $k => $v) {
  133. $photo_data[] = [
  134. 'alt' => $v->name,
  135. 'pid' => $v->uid,
  136. 'src' => $v->response->path,
  137. ];
  138. }
  139. $photos['marry_prove'] = [
  140. 'title' => '婚姻证明',
  141. 'id' => 1,
  142. 'start' => 0,
  143. 'data' => $photo_data,
  144. ];
  145. } else {
  146. $info->marry_prove = [];
  147. }
  148. if (!empty(json_decode($info->household_register))) {
  149. $info->household_register = json_decode($info->household_register);
  150. $photo_data = [];
  151. foreach ($info->household_register as $k => $v) {
  152. $photo_data[] = [
  153. 'alt' => $v->name,
  154. 'pid' => $v->uid,
  155. 'src' => $v->response->path,
  156. ];
  157. }
  158. $photos['household_register'] = [
  159. 'title' => '户口本',
  160. 'id' => 1,
  161. 'start' => 0,
  162. 'data' => $photo_data,
  163. ];
  164. } else {
  165. $info->household_register = [];
  166. }
  167. if (!empty(json_decode($info->work_prove))) {
  168. $info->work_prove = json_decode($info->work_prove);
  169. $photo_data = [];
  170. foreach ($info->work_prove as $k => $v) {
  171. $photo_data[] = [
  172. 'alt' => $v->name,
  173. 'pid' => $v->uid,
  174. 'src' => $v->response->path,
  175. ];
  176. }
  177. $photos['work_prove'] = [
  178. 'title' => '在职证明',
  179. 'id' => 1,
  180. 'start' => 0,
  181. 'data' => $photo_data,
  182. ];
  183. } else {
  184. $info->work_prove = [];
  185. }
  186. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  187. return response()->json(['code' => 1, 'data' => $html]);
  188. }
  189. }