LeaveInfo.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. $sel_where = [];
  34. if($type = input('type')) $sel_where[] = ['a.type','=',$type];
  35. if($name = input('name')) $sel_where[] = ['u.name','like','%'.$name.'%'];
  36. $query = $this->_query($this->table)
  37. ->field('a.*,u.name,u.headimg')
  38. ->where($sel_where)
  39. ->alias('a')
  40. ->leftJoin('store_member u','u.id = a.user_id')
  41. ->where('a.is_deleted',0)->page();
  42. }
  43. /**
  44. * 数据列表处理
  45. * @auth true
  46. * @menu true
  47. * @param array $data
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. * @throws \think\exception\DbException
  51. */
  52. protected function _index_page_filter(&$data)
  53. {
  54. foreach ($data as $k=>&$v){
  55. }
  56. }
  57. /**
  58. * 删除
  59. * @auth true
  60. * @menu true
  61. * @param array $data
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\ModelNotFoundException
  64. * @throws \think\exception\DbException
  65. */
  66. public function remove()
  67. {
  68. $this->_save($this->table, ['is_deleted' => '1']);
  69. }
  70. /**
  71. *
  72. * 编辑
  73. * @auth true
  74. * @menu true
  75. * @param array $data
  76. * @throws \think\db\exception\DataNotFoundException
  77. * @throws \think\db\exception\ModelNotFoundException
  78. * @throws \think\exception\DbException
  79. */
  80. public function edit()
  81. {
  82. $this->title = '编辑';
  83. $this->_form($this->table, 'form');
  84. }
  85. /**
  86. *
  87. * 数据处理
  88. * @auth true
  89. * @menu true
  90. * @param array $data
  91. * @throws \think\db\exception\DataNotFoundException
  92. * @throws \think\db\exception\ModelNotFoundException
  93. * @throws \think\exception\DbException
  94. */
  95. protected function _form_filter(&$data)
  96. {
  97. }
  98. public function approve()
  99. {
  100. $id = input('id');
  101. $list = LeaveApprove::field('a.*,u.name')
  102. ->where('a.leave_id',$id)
  103. ->leftJoin('store_member u','u,id = a.approve_user')
  104. ->select()->toArray();
  105. $this->assign('list',$list);
  106. $this->fetch();
  107. }
  108. }