Offer.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 Offer extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'OfferInfo';
  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\OfferType::getAllType();
  33. $all_type = array_merge([['id'=>0,'title'=>'全部']],$all_type);
  34. $this->all_type = array_column($all_type,null,'id');
  35. $this->status_arr = [0=>'全部','1'=>'审批中',2=>'审批通过',3=>'审批拒绝',9=>'已取消'];
  36. $sel_where = [];
  37. $time = explode(' - ',input('create_at'));
  38. if(input('create_at')){
  39. $sel_where[] = ['a.create_at','between time',$time];
  40. }
  41. if($type = input('type')) $sel_where[] = ['a.type','=',$type];
  42. if($status = input('status')) $sel_where[] = ['a.status','=',$status];
  43. if($name = input('name')) $sel_where[] = ['u.name','like','%'.$name.'%'];
  44. $query = $this->_query($this->table)
  45. ->field('a.*,u.name,u.headimg')
  46. ->where($sel_where)
  47. ->alias('a')
  48. ->leftJoin('store_member u','u.id = a.user_id')
  49. ->where('a.is_deleted',0)
  50. ->order('a.id desc')
  51. ->page();
  52. }
  53. /**
  54. * 数据列表处理
  55. * @auth true
  56. * @menu true
  57. * @param array $data
  58. * @throws \think\db\exception\DataNotFoundException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @throws \think\exception\DbException
  61. */
  62. protected function _index_page_filter(&$data)
  63. {
  64. foreach ($data as $k=>&$v){
  65. }
  66. }
  67. /**
  68. * 删除
  69. * @auth true
  70. * @menu true
  71. * @param array $data
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. * @throws \think\exception\DbException
  75. */
  76. public function remove()
  77. {
  78. $this->_save($this->table, ['is_deleted' => '1']);
  79. }
  80. /**
  81. *
  82. * 编辑
  83. * @auth true
  84. * @menu true
  85. * @param array $data
  86. * @throws \think\db\exception\DataNotFoundException
  87. * @throws \think\db\exception\ModelNotFoundException
  88. * @throws \think\exception\DbException
  89. */
  90. public function edit()
  91. {
  92. $this->title = '编辑';
  93. $this->_form($this->table, 'form');
  94. }
  95. /**
  96. *
  97. * 数据处理
  98. * @auth true
  99. * @menu true
  100. * @param array $data
  101. * @throws \think\db\exception\DataNotFoundException
  102. * @throws \think\db\exception\ModelNotFoundException
  103. * @throws \think\exception\DbException
  104. */
  105. protected function _form_filter(&$data)
  106. {
  107. $this->all_type = \app\common\model\OfferType::getAllType();
  108. if($this->request->isGet() && $this->request->action() == 'edit')
  109. {
  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('OfferApprove')
  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. }