ApproveInfo.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\approve\controller;
  15. use app\common\constant\CommonConstant;
  16. use app\common\constant\OfferConstant;
  17. use app\common\service\CommonService;
  18. use app\common\service\UserService;
  19. use app\common\model\ApproveInfo as model;
  20. use library\Controller;
  21. /**
  22. * 审批申请
  23. */
  24. class ApproveInfo extends Controller
  25. {
  26. /**
  27. * 绑定数据表
  28. * @var string
  29. */
  30. protected $table = 'ApproveInfo';
  31. /**
  32. * 控制器初始化
  33. */
  34. protected function initialize()
  35. {
  36. $this->get_module_list = CommonConstant::get_module_list();
  37. $this->get_approve_status_list = CommonConstant::get_approve_status_list();
  38. $this->get_degree_list = OfferConstant::get_degree_list();
  39. }
  40. /**
  41. * 列表
  42. * @auth true
  43. * @menu true
  44. * @throws \think\Exception
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\ModelNotFoundException
  47. * @throws \think\exception\DbException
  48. */
  49. public function index()
  50. {
  51. $this->module = $module = input('module');
  52. $status = input('status');
  53. $create_at = input('create_at');
  54. $order_no = input('order_no');
  55. $reason = input('reason');
  56. $type = input('type');
  57. $desc = input('desc');
  58. $create_data = [];
  59. if($create_at){
  60. foreach (explode(' - ',$create_at) as $key=>$val){
  61. $create_data[] = $key == 0 ? "{$val} 00:00:00" : "{$val} 23:59:59";
  62. }
  63. }
  64. $this->title = $this->get_module_list[$this->module] . '列表';
  65. $this->get_type_list = CommonService::get_type_list($this->module);
  66. $data = model::field('is_deleted', true)
  67. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  68. ->where('module', $this->module)
  69. ->when($status > 0,function ($query) use($status){
  70. $query->where('status',$status);
  71. })
  72. ->when($create_data,function ($query) use($create_data){
  73. $query->where('create_at','BETWEEN',$create_data);
  74. })
  75. ->when($order_no,function ($query) use($order_no){
  76. $query->where('order_no','like','%'.$order_no.'%');
  77. })
  78. ->when($reason,function ($query) use($reason){
  79. $query->where('reason','like','%'.$reason.'%');
  80. })
  81. ->when($type > 0,function ($query) use($type){
  82. $query->where('type',$type);
  83. })
  84. ->when($desc,function ($query) use($desc,$module){
  85. if($module == CommonConstant::MODULE_10){
  86. $query->where('desc','like','%'.$desc.'%');
  87. } else{
  88. $query->where('desc',$desc);
  89. }
  90. })
  91. ->with([
  92. 'approveInfoUser' => function ($query) {
  93. $query->field('userid,name,mobile');
  94. },
  95. ])
  96. ->order('id desc');
  97. self::init($data);
  98. }
  99. public function init($data, $page = true, $display = true, $total = false, $limit = 0)
  100. {
  101. $this->page = $page;
  102. $this->total = $total;
  103. $this->limit = $limit;
  104. $this->display = $display;
  105. $this->query = $data;
  106. // 列表分页及结果集处理
  107. if ($this->page) {
  108. // 分页每页显示记录数
  109. $limit = intval($this->request->get('limit', cookie('page-limit')));
  110. cookie('page-limit', $limit = $limit >= 10 ? $limit : 20);
  111. if ($this->limit > 0) $limit = $this->limit;
  112. $rows = [];
  113. $page = $data->paginate($limit, $this->total, ['query' => ($query = $this->request->get())]);
  114. foreach ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200] as $num) {
  115. list($query['limit'], $query['page'], $selected) = [$num, '1', $limit === $num ? 'selected' : ''];
  116. // 由于加上 / 如做绑定admin模块单独入口 会导致找不到模块 在此去掉 /
  117. $url = rtrim(url('@admin'), '/') . '#' . $this->request->baseUrl() . '?' . urldecode(http_build_query($query));
  118. array_push($rows, "<option data-num='{$num}' value='{$url}' {$selected}>{$num}</option>");
  119. }
  120. $selects = "<select onchange='location.href=this.options[this.selectedIndex].value' data-auto-none>" . join('', $rows) . "</select>";
  121. $pagetext = lang('think_library_page_html', [$page->total(), $selects, $page->lastPage(), $page->currentPage()]);
  122. $pagehtml = "<div class='pagination-container nowrap'><span>{$pagetext}</span>{$page->render()}</div>";
  123. $pagehtml = preg_replace('|href="(.*?)"|', 'data-open="$1" onclick="return false" href="$1"', $pagehtml);
  124. // 由于部分自动生成的分页是href是带单引号的
  125. $pagehtml = preg_replace("|href='(.*?)'|", 'data-open="$1" onclick="return false" href="$1"', $pagehtml);
  126. $this->assign('pagehtml', $pagehtml);
  127. $result = ['page' => ['limit' => intval($limit), 'total' => intval($page->total()), 'pages' => intval($page->lastPage()), 'current' => intval($page->currentPage())], 'list' => $page->items()];
  128. } else {
  129. $result = ['list' => $data->select()];
  130. }
  131. if ($this->display) {
  132. return $this->fetch('', $result);
  133. } else {
  134. return $result;
  135. }
  136. }
  137. /**
  138. * 列表数据处理
  139. * @param array $data
  140. * @throws \Exception
  141. */
  142. protected function _index_page_filter(&$data)
  143. {
  144. foreach ($data as &$value) {
  145. }
  146. }
  147. /**
  148. * 编辑
  149. * @auth true
  150. * @throws \think\Exception
  151. * @throws \think\db\exception\DataNotFoundException
  152. * @throws \think\db\exception\ModelNotFoundException
  153. * @throws \think\exception\DbException
  154. * @throws \think\exception\PDOException
  155. */
  156. public function edit()
  157. {
  158. $this->title = '详情';
  159. $this->_form($this->table, 'form');
  160. }
  161. /**
  162. * 表单处理
  163. * @param array $data
  164. * @throws \think\db\exception\DataNotFoundException
  165. * @throws \think\db\exception\ModelNotFoundException
  166. * @throws \think\exception\DbException
  167. */
  168. protected function _form_filter(&$data)
  169. {
  170. if ($this->request->isGet()) {
  171. }
  172. if ($this->request->isPost()) {
  173. }
  174. }
  175. }