CarInfo.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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)
  45. ->order('a.id desc')
  46. ->page();
  47. }
  48. /**
  49. * 数据列表处理
  50. * @auth true
  51. * @menu true
  52. * @param array $data
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @throws \think\exception\DbException
  56. */
  57. protected function _index_page_filter(&$data)
  58. {
  59. foreach ($data as $k=>&$v){
  60. }
  61. }
  62. /**
  63. * 删除
  64. * @auth true
  65. * @menu true
  66. * @param array $data
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. * @throws \think\exception\DbException
  70. */
  71. public function remove()
  72. {
  73. $this->_save($this->table, ['is_deleted' => '1']);
  74. }
  75. /**
  76. *
  77. * 编辑
  78. * @auth true
  79. * @menu true
  80. * @param array $data
  81. * @throws \think\db\exception\DataNotFoundException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. * @throws \think\exception\DbException
  84. */
  85. public function edit()
  86. {
  87. $this->title = '编辑';
  88. $this->_form($this->table, 'form');
  89. }
  90. /**
  91. *
  92. * 数据处理
  93. * @auth true
  94. * @menu true
  95. * @param array $data
  96. * @throws \think\db\exception\DataNotFoundException
  97. * @throws \think\db\exception\ModelNotFoundException
  98. * @throws \think\exception\DbException
  99. */
  100. protected function _form_filter(&$data)
  101. {
  102. if($this->request->isGet() && $this->request->action() == 'edit')
  103. {
  104. $data['user_name'] = User::where('id',$data['user_id'])->value('name');
  105. }
  106. }
  107. /**
  108. *
  109. * 审批记录
  110. * @auth true
  111. * @menu true
  112. * @param array $data
  113. * @throws \think\db\exception\DataNotFoundException
  114. * @throws \think\db\exception\ModelNotFoundException
  115. * @throws \think\exception\DbException
  116. */
  117. public function approve()
  118. {
  119. $id = input('id');
  120. $list = $this->_query('CarApprove')
  121. ->alias('r')
  122. ->field('r.*,u.name,u.phone,u.headimg')
  123. ->leftJoin('store_member u','u.id = r.approve_user')
  124. ->where('r.car_id',$id)
  125. ->order('r.id asc')->page(false);
  126. $this->assign('list',$list);
  127. $this->fetch();
  128. }
  129. }