Document.php 3.7 KB

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