Fault.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * sim-故障管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Fault extends Backend
  10. {
  11. /**
  12. * Fault模型对象
  13. * @var \app\admin\model\Fault
  14. */
  15. protected $model = null;
  16. protected $noNeedRight = ['getdatalist','selectpage'];
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Fault;
  21. }
  22. /**
  23. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  24. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  25. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  26. */
  27. //根据 模拟器类型,选择模拟器二级和三级列表
  28. public function getdatalist()
  29. {
  30. $simtype = input('simtype','simtype');
  31. if(!$simtype){
  32. $this->error('模拟器类型有误');
  33. }
  34. $where = [
  35. 'sim_type' => $simtype,
  36. 'fault_type' => 1,
  37. 'fault_state'=>0
  38. ];
  39. $selectData = $this->model->where($where)->select();
  40. foreach ($selectData as $key => $value){
  41. $children = $this->model->where(['parent_fault_id'=>$value['fault_id'],'fault_type' => 3,'fault_state'=>0])->select();
  42. $selectData[$key]['children'] = $children;
  43. }
  44. unset($value);
  45. $selectData = collection($selectData)->toArray();
  46. $result = array("code" => 1,"msg" => '获取成功', "data" => $selectData);
  47. return json($result);
  48. }
  49. /**
  50. * 下拉搜索
  51. */
  52. public function selectpage()
  53. {
  54. // $this->dataLimit = 'auth';
  55. $this->dataLimitField = 'fault_id';
  56. return parent::selectpage();
  57. }
  58. }