Management.php 10.0 KB
<?php

namespace app\school\controller\project_approval;

use app\common\controller\DoubleBase;
use app\school\controller\project_common\ProjectData;
use app\school\model\project_common\ProjectRegister;
use app\school\model\project_common\ProjectReview;
use app\school\model\project_common\ProjectReviewResult;
use think\Db;
use think\Exception;
use think\Session;

class Management extends DoubleBase
{
    protected $containerId = null;
    protected $model = null;
    // 评审阶段(0:立项评审;1:中期检查;2:项目结题)
    protected $reviewStage = 0;
    protected $shopIdAutoCondition = false;

    // 引入获取项目数据的traits
    use ProjectData;
    public function _initialize()
    {
        parent::_initialize();
        $this->containerId = $_COOKIE['container_id'];
        $this->model = new ProjectRegister();
        $login_rule = Session::get("school")['rule_type'];
        $this->assignconfig('review_stage', $this->reviewStage);
        $this->assignconfig('login_rule', $login_rule);
    }

    public function test()
    {
        $info = $this->model->alias('p')
            ->field('p.project_type,p.id,d.project_details,u.student_no,p.custom_form_data,p.project_name,p.project_member_ids,p.project_teacher_ids')
            ->join('user u','p.user_id = u.id')
            ->join('project_register_details d','p.project_details = d.id')
            ->where(['p.school_id'=>6])
            ->select();
        foreach ($info as &$val) {
            $val['info'] = json_decode($val['project_details'],true);
            $val['custom_form_data'] = json_decode($val['custom_form_data'],true);
        }
        dump(collection($info)->toArray());die;
    }
    public function index()
    {
        $stageWhere = [
            'container_id' => $this->containerId,
            'review_stage' => $this->reviewStage
        ];
        $reviewStageIds = (new ProjectReview())->where($stageWhere)->column('id');
        $school = session("school");

        $this->assignconfig('rule_type', $school["rule_type"]);
        $this->assignconfig('review_stage_ids', $reviewStageIds);
        return $this->view->fetch();
    }

    /**
     * 全部项目(未淘汰&已立项)
     * @return array
     */
    public function all()
    {
        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            // 查找中期检查和项目结题状态下的项目(项目立项阶段后的项目一定已经立项)
            $map['a.review_stage'] = ['IN', '0,1,2'];
            $map['a.project_approval_status'] = 3;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }

    /**
     * 学校未审核
     * @return array
     */
    public function schoolNoAudit()
    {

        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            $map['a.project_approval_status'] = 2;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }

    /**
     * 学院未审核
     * @return array
     */
    public function collegeNoAudit()
    {
        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            $map['a.project_approval_status'] = 1;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }

    /**
     * 教师未审核
     * @return array
     */
    public function teacherNoAudit()
    {
        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            $map['a.project_approval_status'] = 0;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }

    /**
     * 退回项目
     * @return array
     */
    public function backRefill()
    {
        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            $map['a.project_status'] = 2;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }

    /**
     * 填报不完整
     * @return array
     */
    public function incomplete()
    {
        // 立项评审阶段无填报不完整的项目
        if ($this->request->isAjax()) {
            return [
              'total' => 0,
              'rows'  => []
            ];
        }
    }

    /**
     * 淘汰项目
     * @return array
     */
    public function out()
    {
        if ($this->request->isAjax()) {
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            $map['a.project_status'] = 1;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }
    public function collegeaudit(){
        if ($this->request->isAjax()) {
            /*============*/
            $filter = json_decode($this->request->get('filter'), true);
            //自定义搜索条件
            if(isset($filter['project_type'])) {
                $map['a.project_type'] =  $filter['project_type'];
            }
            if(isset($filter['project_level'])) {
                $map['a.project_level'] =  $filter['project_level'];
            }
            if(isset($filter['college_id'])) {
                $map['u.college'] =  $filter['college_id'];
            }
            if(isset($filter['username'])) {
                $map['u.nickname'] = ['like',"%{$filter['username']}%"];
            }
            $map['a.project_approval_status'] = 2;
            $map['a.project_status'] = 0;
            if ($this->auth->rule_type == 1){
                //所属学院或部门
                $map['a.project_college'] =  $this->auth->college_id;
            }
            return $this->approvalProjectData($map);
        }
    }
}