Evection.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\synth\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 Evection
  10. * @package app\synth\controller
  11. */
  12. class Evection extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'EvectionInfo';
  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. $this->all_type =[1=>'市内出差',2=>'市外出差'];
  33. $this->status_arr = [0=>'全部','1'=>'审批中',2=>'审批通过',3=>'审批拒绝',9=>'已取消'];
  34. $sel_where = [];
  35. $time = explode(' - ',input('create_at'));
  36. if(input('create_at')){
  37. $sel_where[] = ['a.create_at','between time',$time];
  38. }
  39. if($type = input('type')) $sel_where[] = ['a.type','=',$type];
  40. if($status = input('status')) $sel_where[] = ['a.status','=',$status];
  41. if($name = input('name')) $sel_where[] = ['u.name','like','%'.$name.'%'];
  42. $query = $this->_query($this->table)
  43. ->field('a.*,u.name,u.headimg')
  44. ->where($sel_where)
  45. ->alias('a')
  46. ->leftJoin('store_member u','u.id = a.user_id')
  47. ->where('a.is_deleted',0)
  48. ->order('a.id desc')
  49. ->page();
  50. }
  51. /**
  52. * 数据列表处理
  53. * @auth true
  54. * @menu true
  55. * @param array $data
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. */
  60. protected function _index_page_filter(&$data)
  61. {
  62. foreach ($data as $k=>&$v){
  63. }
  64. }
  65. /**
  66. * 删除
  67. * @auth true
  68. * @menu true
  69. * @param array $data
  70. * @throws \think\db\exception\DataNotFoundException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. * @throws \think\exception\DbException
  73. */
  74. public function remove()
  75. {
  76. $this->_save($this->table, ['is_deleted' => '1']);
  77. }
  78. /**
  79. *
  80. * 编辑
  81. * @auth true
  82. * @menu true
  83. * @param array $data
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\ModelNotFoundException
  86. * @throws \think\exception\DbException
  87. */
  88. public function edit()
  89. {
  90. $this->title = '编辑';
  91. $this->_form($this->table, 'form');
  92. }
  93. /**
  94. *
  95. * 数据处理
  96. * @auth true
  97. * @menu true
  98. * @param array $data
  99. * @throws \think\db\exception\DataNotFoundException
  100. * @throws \think\db\exception\ModelNotFoundException
  101. * @throws \think\exception\DbException
  102. */
  103. protected function _form_filter(&$data)
  104. {
  105. if($this->request->isGet() && $this->request->action() == 'edit')
  106. {
  107. $data['user_name'] = User::where('id',$data['user_id'])->value('name');
  108. $peer_list = $data['peer_user'] ? User::getUserList($data['peer_user'],'id,name,phone'):[];
  109. $this->peer_list = $peer_list;
  110. }
  111. }
  112. /**
  113. *
  114. * 审批记录
  115. * @auth true
  116. * @menu true
  117. * @param array $data
  118. * @throws \think\db\exception\DataNotFoundException
  119. * @throws \think\db\exception\ModelNotFoundException
  120. * @throws \think\exception\DbException
  121. */
  122. public function approve()
  123. {
  124. $id = input('id');
  125. $list = $this->_query('EvectionApprove')
  126. ->alias('r')
  127. ->field('r.*,u.name,u.phone,u.headimg')
  128. ->leftJoin('store_member u','u.id = r.approve_user')
  129. ->where('r.info_id',$id)
  130. ->order('r.id asc')->page(false);
  131. $this->assign('list',$list);
  132. $this->fetch();
  133. }
  134. }