LeaveInfo.php 3.5 KB

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