CarInfo.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace app\car\controller;
  3. use app\common\model\User;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 用车列表
  8. * Class CarInfo
  9. * @package app\car\controller
  10. */
  11. class CarInfo extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'CarInfo';
  18. /**
  19. * 类型列表
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '列表管理';
  31. $this->status_arr = [0=>'全部','1'=>'审批中',2=>'审批通过',3=>'审批拒绝',9=>'已取消'];
  32. $sel_where = [];
  33. if($name = input('name')) $sel_where[] = ['u.name','like','%'.$name.'%'];
  34. if($status = input('status')) $sel_where[] = ['u.status','=',$status];
  35. $time = explode(' - ',input('create_at'));
  36. if(input('create_at')){
  37. $sel_where[] = ['a.create_at','between time',$time];
  38. }
  39. $query = $this->_query($this->table)
  40. ->field('a.*,u.name,u.headimg')
  41. ->where($sel_where)
  42. ->alias('a')
  43. ->leftJoin('store_member u','u.id = a.user_id')
  44. ->where('a.is_deleted',0)->page();
  45. }
  46. /**
  47. * 数据列表处理
  48. * @auth true
  49. * @menu true
  50. * @param array $data
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @throws \think\exception\DbException
  54. */
  55. protected function _index_page_filter(&$data)
  56. {
  57. foreach ($data as $k=>&$v){
  58. }
  59. }
  60. /**
  61. * 删除
  62. * @auth true
  63. * @menu true
  64. * @param array $data
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. * @throws \think\exception\DbException
  68. */
  69. public function remove()
  70. {
  71. $this->_save($this->table, ['is_deleted' => '1']);
  72. }
  73. /**
  74. *
  75. * 编辑
  76. * @auth true
  77. * @menu true
  78. * @param array $data
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\ModelNotFoundException
  81. * @throws \think\exception\DbException
  82. */
  83. public function edit()
  84. {
  85. $this->title = '编辑';
  86. $this->_form($this->table, 'form');
  87. }
  88. /**
  89. *
  90. * 数据处理
  91. * @auth true
  92. * @menu true
  93. * @param array $data
  94. * @throws \think\db\exception\DataNotFoundException
  95. * @throws \think\db\exception\ModelNotFoundException
  96. * @throws \think\exception\DbException
  97. */
  98. protected function _form_filter(&$data)
  99. {
  100. if($this->request->isGet() && $this->request->action() == 'edit')
  101. {
  102. $data['user_name'] = User::where('id',$data['user_id'])->value('name');
  103. }
  104. }
  105. /**
  106. *
  107. * 审批记录
  108. * @auth true
  109. * @menu true
  110. * @param array $data
  111. * @throws \think\db\exception\DataNotFoundException
  112. * @throws \think\db\exception\ModelNotFoundException
  113. * @throws \think\exception\DbException
  114. */
  115. public function approve()
  116. {
  117. $id = input('id');
  118. $list = $this->_query('CarApprove')
  119. ->alias('r')
  120. ->field('r.*,u.name,u.phone,u.headimg')
  121. ->leftJoin('store_member u','u.id = r.approve_user')
  122. ->where('r.car_id',$id)
  123. ->order('r.id desc')->page(false);
  124. $this->assign('list',$list);
  125. $this->fetch();
  126. }
  127. }