123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\approve\controller;
- use app\common\constant\CommonConstant;
- use app\common\constant\OfferConstant;
- use app\common\service\CommonService;
- use app\common\service\UserService;
- use app\common\model\ApproveInfo as model;
- use library\Controller;
- /**
- * 审批申请
- */
- class ApproveInfo extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'ApproveInfo';
- /**
- * 控制器初始化
- */
- protected function initialize()
- {
- $this->get_module_list = CommonConstant::get_module_list();
- $this->get_approve_status_list = CommonConstant::get_approve_status_list();
- $this->get_degree_list = OfferConstant::get_degree_list();
- }
- /**
- * 列表
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function index()
- {
- $this->module = $module = input('module');
- $status = input('status');
- $create_at = input('create_at');
- $order_no = input('order_no');
- $reason = input('reason');
- $type = input('type');
- $desc = input('desc');
- $create_data = [];
- if($create_at){
- foreach (explode(' - ',$create_at) as $key=>$val){
- $create_data[] = $key == 0 ? "{$val} 00:00:00" : "{$val} 23:59:59";
- }
- }
- $this->title = $this->get_module_list[$this->module] . '列表';
- $this->get_type_list = CommonService::get_type_list($this->module);
- $data = model::field('is_deleted', true)
- ->where('is_deleted', CommonConstant::IS_DELETED_0)
- ->where('module', $this->module)
- ->when($status > 0,function ($query) use($status){
- $query->where('status',$status);
- })
- ->when($create_data,function ($query) use($create_data){
- $query->where('create_at','BETWEEN',$create_data);
- })
- ->when($order_no,function ($query) use($order_no){
- $query->where('order_no','like','%'.$order_no.'%');
- })
- ->when($reason,function ($query) use($reason){
- $query->where('reason','like','%'.$reason.'%');
- })
- ->when($type > 0,function ($query) use($type){
- $query->where('type',$type);
- })
- ->when($desc,function ($query) use($desc,$module){
- if($module == CommonConstant::MODULE_10){
- $query->where('desc','like','%'.$desc.'%');
- } else{
- $query->where('desc',$desc);
- }
- })
- ->with([
- 'approveInfoUser' => function ($query) {
- $query->field('userid,name,mobile');
- },
- ])
- ->order('id desc');
- self::init($data);
- }
- public function init($data, $page = true, $display = true, $total = false, $limit = 0)
- {
- $this->page = $page;
- $this->total = $total;
- $this->limit = $limit;
- $this->display = $display;
- $this->query = $data;
- // 列表分页及结果集处理
- if ($this->page) {
- // 分页每页显示记录数
- $limit = intval($this->request->get('limit', cookie('page-limit')));
- cookie('page-limit', $limit = $limit >= 10 ? $limit : 20);
- if ($this->limit > 0) $limit = $this->limit;
- $rows = [];
- $page = $data->paginate($limit, $this->total, ['query' => ($query = $this->request->get())]);
- foreach ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200] as $num) {
- list($query['limit'], $query['page'], $selected) = [$num, '1', $limit === $num ? 'selected' : ''];
- // 由于加上 / 如做绑定admin模块单独入口 会导致找不到模块 在此去掉 /
- $url = rtrim(url('@admin'), '/') . '#' . $this->request->baseUrl() . '?' . urldecode(http_build_query($query));
- array_push($rows, "<option data-num='{$num}' value='{$url}' {$selected}>{$num}</option>");
- }
- $selects = "<select onchange='location.href=this.options[this.selectedIndex].value' data-auto-none>" . join('', $rows) . "</select>";
- $pagetext = lang('think_library_page_html', [$page->total(), $selects, $page->lastPage(), $page->currentPage()]);
- $pagehtml = "<div class='pagination-container nowrap'><span>{$pagetext}</span>{$page->render()}</div>";
- $pagehtml = preg_replace('|href="(.*?)"|', 'data-open="$1" onclick="return false" href="$1"', $pagehtml);
- // 由于部分自动生成的分页是href是带单引号的
- $pagehtml = preg_replace("|href='(.*?)'|", 'data-open="$1" onclick="return false" href="$1"', $pagehtml);
- $this->assign('pagehtml', $pagehtml);
- $result = ['page' => ['limit' => intval($limit), 'total' => intval($page->total()), 'pages' => intval($page->lastPage()), 'current' => intval($page->currentPage())], 'list' => $page->items()];
- } else {
- $result = ['list' => $data->select()];
- }
- if ($this->display) {
- return $this->fetch('', $result);
- } else {
- return $result;
- }
- }
- /**
- * 列表数据处理
- * @param array $data
- * @throws \Exception
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as &$value) {
- }
- }
- /**
- * 编辑
- * @auth true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function edit()
- {
- $this->title = '详情';
- $this->_form($this->table, 'form');
- }
- /**
- * 表单处理
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _form_filter(&$data)
- {
- if ($this->request->isGet()) {
- }
- if ($this->request->isPost()) {
- }
- }
- }
|