LeaveInfo.php 4.0 KB

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