HelpApply.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\controller\help;
  3. use app\common\controller\Backend;
  4. /**
  5. * 帮扶人申请管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class HelpApply extends Backend
  10. {
  11. /**
  12. * HelpApply模型对象
  13. * @var \app\admin\model\help\HelpApply
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\help\HelpApply;
  20. $this->view->assign("statusList", $this->model->getStatusList());
  21. }
  22. public function import()
  23. {
  24. parent::import();
  25. }
  26. /**
  27. * 查看
  28. */
  29. public function index()
  30. {
  31. //设置过滤方法
  32. $this->request->filter(['strip_tags', 'trim']);
  33. if ($this->request->isAjax()) {
  34. //如果发送的来源是Selectpage,则转发到Selectpage
  35. if ($this->request->request('keyField')) {
  36. $data = $this->selectpage()->getData();
  37. if(!$this->request->request('keyValue')) {
  38. $data['list'] = array_merge([['id' => 0, 'title' => '无', 'pid' => 0]], $data['list']);
  39. $data['total']++;
  40. }
  41. return $data;
  42. }
  43. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  44. /**
  45. * 获取企业信息
  46. */
  47. $where1 = is_sys_admin();
  48. $list = $this->model
  49. ->where($where)->where($where1)
  50. ->order($sort, $order)
  51. ->paginate($limit);
  52. foreach ($list as $k => $v) {
  53. }
  54. $result = array("total" => $list->total(), "rows" => $list->items());
  55. return json($result);
  56. }
  57. return $this->view->fetch();
  58. }
  59. public function edit($ids=null)
  60. {
  61. if($this->request->isPost()) {
  62. $info = $this->model->where('id', $ids)->find();
  63. if ($info['status']!='0') $this->error('已审核状态,不能修改');
  64. if($this->model->where('help_id',$info['help_id'])->where('status','1')->find())
  65. {
  66. $this->error('该项目已有帮扶人,不能审核为通过');
  67. }
  68. $this->model->where('help_id',$info['help_id'])->where('id','<>',$ids)->update(['status'=>-1]);
  69. \app\admin\model\help\Help::where('id',$info['help_id'])->update(['apply_user_id'=>$info['user_id']]);
  70. }
  71. return parent::edit($ids);
  72. }
  73. /**
  74. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  75. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  76. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  77. */
  78. }