HospitalController.php 7.0 KB
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2018/11/25
 * Time: 11:49
 */

namespace app\admin\controller;


use app\admin\model\HospitalModel;
use app\admin\model\JobModel;
use app\admin\model\OfficeModel;
use cmf\controller\AdminBaseController;
use think\db;
use think\Request;

/**
 * Class HosptialController
 * @package app\admin\controller
 * @adminMenuRoot(
 *     'name'   =>'医院管理',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'医院管理'
 * )
 */
class HospitalController extends AdminBaseController
{
    protected $HospitalModel;
    protected $OfficeModel;


    public function __construct(HospitalModel $HospitalModel)
    {
        parent::__construct();
        $this->HospitalModel = $HospitalModel;
        $this->OfficeModel =new OfficeModel();
    }

    /**
     *医院列表
     * @adminMenu(
     *     'name'   => '医院列表',
     *     'parent' => 'default',
     *     'display'=> true,
     *	   'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '密码修改',
     *     'param'  => ''
     * )
     */
      public function index(){
          $platment_id=input('id');
          if (empty($platment_id)){
             // return $this->error();
          }
          $hospital=$this->HospitalModel->getHospital($platment_id)->toArray();
          $this->assign('hospital',$hospital);
          $this->assign('platform_id',$platment_id);
          return $this->fetch('hospital');
      }


        /**
         *平台列表
         * @adminMenu(
         *     'name'   => '医院列表',
         *     'parent' => 'default',
         *     'display'=> false,
         *	   'hasView'=> true,
         *     'order'  => 10000,
         *     'icon'   => '',
         *     'remark' => '',
         *     'param'  => ''
         * )
         */
        public function hospital(){

        }

        /**
         *
         * @adminMenu(
         *     'name'   => '删除医院',
         *     'parent' => 'default',
         *     'display'=> false,
         *	   'hasView'=> true,
         *     'order'  => 10000,
         *     'icon'   => '',
         *     'remark' => '',
         *     'param'  => ''
         * )
         */
        public function hosptialDel(){
            $hosptial_id=input('id');
            if (empty($hosptial_id)){
                return $this->error('操作错误!');
            }
            $result=$this->HospitalModel->hospitalDel($hosptial_id);
            if ($result==1){
                $this->success('删除成功!');
            }else{
                $this->error('删除失败!');
            }
        }

    /**
     *
     * @adminMenu(
     *     'name'   => '添加医院',
     *     'parent' => 'default',
     *     'display'=> false,
     *	   'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '',
     *     'param'  => ''
     * )
     */
        public function hospitalAdd(){
            if(\request()->isAjax()){
                  /*验证器*/
                $post=input();
                $result = $this->validate($post, 'HospitalAdd');
                if ($result !== true) {
                    $this->error($result);
                }
                $result=$this->HospitalModel->hospitalAdd($post['name']);
                if ($result==1){
                    $this->success('添加成功!');
                }else{
                    $this->error('添加失败!');
                }
            }else{
                $platform_id=input('id');
                /*查询本平台信息*/
                $fatherPlatment=$this->HospitalModel->getPlatment($platform_id)->toArray();
                /*查询所有平台信息*/

                return $this->fetch();
            }
        }

    /**
     * @adminMenu(
     *     'name'   => '科室展示',
     *     'parent' => 'default',
     *     'display'=> false,
     *	   'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '',
     *     'param'  => ''
     * )
     */
        public function office(){
            $hospital_id=input('id');
            if (empty($hospital_id)){
                return $this->error();
            }
            $office=$this->OfficeModel->getOffice($hospital_id)->toArray();
            $this->assign('office',$office);
            $this->assign('hospital_id',$hospital_id);
            return $this->fetch();
        }


    /**
     * @adminMenu(
     *     'name'   => '科室添加',
     *     'parent' => 'default',
     *     'display'=> false,
     *	   'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '',
     *     'param'  => ''
     * )
     */
        public function officeAdd(){
            if(\request()->isAjax()){
                /*验证器*/
                $post=input();
                $result = $this->validate($post, 'HospitalAdd');
                if ($result !== true) {
                    $this->error($result);
                }
                $result=$this->OfficeModel->officeAdd($post['id'],$post['name'],$post['platform']);
                if ($result==1){
                    $this->success('添加成功!');
                }else{
                    $this->error('添加失败!');
                }
            }else{
                $hospital_id=input('id');
                /*查询本平台信息*/
                $fatherPlatment=$this->OfficeModel->getHospital($hospital_id)->toArray();
                /*查询所有平台信息*/
                //$allPlatment=$this->HospitalModel->getPlatment()->toArray();
                $this->assign('fatherPlatment',$fatherPlatment);
                $allPlatment=$this->HospitalModel->getPlatment()->toArray();
                $this->assign('allPlatment',$allPlatment);
           //     $this->assign('allPlatment',$allPlatment);
                return $this->fetch();
            }
        }
    /**
     * @adminMenu(
     *     'name'   => '职位管理',
     *     'parent' => 'default',
     *     'display'=> true,
     *	   'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '',
     *     'param'  => ''
     * )
     */
     public function job(){
         $Job=new JobModel();
         $jobs=$Job->getJOb()->toArray();
         $this->assign('jobs',$jobs);
         return $this->fetch();
     }
    /**
     * @adminMenu(
     *     'name'   => '职位添加',
     *     'parent' => 'default',
     *     'display'=> false,
     *	   'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '',
     *     'param'  => ''
     * )
     */
     public function jobAdd(){
         if (\request()->isAjax()){
             $insert=input('name');
             $Job=new JobModel();
             $result=$Job->addJob($insert);
             if ($result==1){
                 $this->success('添加成功!');
             }
             $this->error('添加失败!');
         }
         return $this->fetch();
     }




}