Task.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\admin\controller\task;
  3. use app\common\controller\Backend;
  4. use fast\Tree;
  5. /**
  6. * 任务管理
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Task extends Backend
  11. {
  12. /**
  13. * Task模型对象
  14. * @var \app\admin\model\Task
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Task;
  21. $this->view->assign("statusList", $this->model->getStatusList());
  22. }
  23. /**
  24. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  25. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  26. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  27. */
  28. public function detail(){
  29. if ($this->request->isAjax()) {
  30. if (!$this->auth->isSuperAdmin()) {
  31. $this->error(__('Access is allowed only to the super management group'));
  32. }
  33. $this->model = model('AuthRule');
  34. // 必须将结果集转换为数组
  35. $ruleList = \think\Db::name("task_steps")->order('weigh DESC,id ASC')->select();
  36. foreach ($ruleList as $k => &$v) {
  37. $v['name'] = __($v['name']);
  38. }
  39. unset($v);
  40. Tree::instance()->init($ruleList)->icon = ['&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;'];
  41. $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name');
  42. $list = $this->rulelist;
  43. $total = count($this->rulelist);
  44. $result = array("total" => $total, "rows" => $list);
  45. return json($result);
  46. }
  47. return $this->view->fetch();
  48. }
  49. }