Maintain.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\synth\controller;
  3. use app\common\model\User;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 请假列表
  8. * Class Maintain
  9. * @package app\synth\controller
  10. */
  11. class Maintain extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'Maintain';
  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\OfferType::getAllType();
  32. $all_type = array_merge([['id'=>0,'title'=>'全部']],$all_type);
  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. $this->all_type = \app\common\model\OfferType::getAllType();
  107. if($this->request->isGet() && $this->request->action() == 'edit')
  108. {
  109. $data['user_name'] = User::where('id',$data['user_id'])->value('name');
  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('OfferApprove')
  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. }