BuyHouseRsController.php 6.9 KB

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