作者 sgj

医院管理

@@ -79,9 +79,56 @@ class HospitalController extends AdminBaseController @@ -79,9 +79,56 @@ class HospitalController extends AdminBaseController
79 } 79 }
80 $hospital=$this->HospitalModel->getHospital($platment_id)->toArray(); 80 $hospital=$this->HospitalModel->getHospital($platment_id)->toArray();
81 $this->assign('hospital',$hospital); 81 $this->assign('hospital',$hospital);
  82 + $this->assign('platform_id',$platment_id);
82 return $this->fetch(); 83 return $this->fetch();
83 } 84 }
84 85
  86 + /**
  87 + *
  88 + * @adminMenu(
  89 + * 'name' => '删除医院',
  90 + * 'parent' => 'default',
  91 + * 'display'=> false,
  92 + * 'hasView'=> true,
  93 + * 'order' => 10000,
  94 + * 'icon' => '',
  95 + * 'remark' => '',
  96 + * 'param' => ''
  97 + * )
  98 + */
  99 + public function hosptialDel(){
  100 + $hosptial_id=input('id');
  101 + if (empty($hosptial_id)){
  102 + return $this->error('操作错误!');
  103 + }
  104 + $result=$this->HospitalModel->hospitalDel($hosptial_id);
  105 + if ($result==1){
  106 + $this->success('删除成功!');
  107 + }else{
  108 + $this->error('删除失败!');
  109 + }
  110 + }
  111 +
  112 + /**
  113 + *
  114 + * @adminMenu(
  115 + * 'name' => '添加医院',
  116 + * 'parent' => 'default',
  117 + * 'display'=> false,
  118 + * 'hasView'=> true,
  119 + * 'order' => 10000,
  120 + * 'icon' => '',
  121 + * 'remark' => '',
  122 + * 'param' => ''
  123 + * )
  124 + */
  125 + public function hospitalAdd(){
  126 + if(\request()->isAjax()){
  127 + /*验证器*/
  128 + }else{
  129 + $this->fetch();
  130 + }
  131 + }
85 132
86 133
87 134
@@ -10,9 +10,13 @@ namespace app\admin\model; @@ -10,9 +10,13 @@ namespace app\admin\model;
10 10
11 11
12 use think\Model; 12 use think\Model;
  13 +use traits\model\SoftDelete;
13 14
14 class HospitalModel extends Model 15 class HospitalModel extends Model
15 { 16 {
  17 +
  18 + use SoftDelete;
  19 + protected $deleteTime = 'delete_time';
16 /** 20 /**
17 * 返回平台信息 21 * 返回平台信息
18 * @return false|\PDOStatement|string|\think\Collection 22 * @return false|\PDOStatement|string|\think\Collection
@@ -27,10 +31,24 @@ class HospitalModel extends Model @@ -27,10 +31,24 @@ class HospitalModel extends Model
27 return $platment; 31 return $platment;
28 } 32 }
29 33
30 - public function getHospital(){  
31 - $map['platment_id']='0';  
32 - $map['deleteTime']='0';  
33 - $hospital=db('hospital')->where($map)->select(); 34 + /**
  35 + * 获取医院
  36 + * @return false|\PDOStatement|string|\think\Collection
  37 + * @throws \think\db\exception\DataNotFoundException
  38 + * @throws \think\db\exception\ModelNotFoundException
  39 + * @throws \think\exception\DbException
  40 + */
  41 + public function getHospital($platform_id){
  42 + $map['platform_id']=$platform_id;
  43 + $hospital=$this->where($map)->select();
34 return $hospital; 44 return $hospital;
35 } 45 }
  46 +
  47 + public function hospitalDel($hosptial_id){
  48 + $result=$this::destroy($hosptial_id);
  49 + return $result;
  50 + }
  51 +
  52 +
  53 +
36 } 54 }
@@ -13,6 +13,6 @@ return [ @@ -13,6 +13,6 @@ return [
13 // 应用调试模式 13 // 应用调试模式
14 'app_debug' => true, 14 'app_debug' => true,
15 // 应用Trace 15 // 应用Trace
16 - 'app_trace' => true, 16 + 'app_trace' => false,
17 17
18 ]; 18 ];
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="">标签管理</a></li>
  7 + <li><a href="{:url('hospitalAdd',['id'=>$platform_id])}">添加医院</a></li>
  8 + </ul>
  9 + <form method="post" class="js-ajax-form margin-top-20">
  10 + <div class="table-actions">
  11 + <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
  12 + </div>
  13 + <table class="table table-hover table-bordered table-list">
  14 + <thead>
  15 + <tr>
  16 + <th width="50">ID</th>
  17 + <th>标签名称</th>
  18 + <th>状态</th>
  19 + <th width="160">操作</th>
  20 + </tr>
  21 + </thead>
  22 + <tbody>
  23 + <foreach name="hospital" item="vo">
  24 + <tr>
  25 + <td>{$vo.id}</td>
  26 + <td>{$vo.name}</td>
  27 + <td><a href="{:url('hospital',['id'=>$vo.id])}">查看医院</a></td>
  28 + <td><a class="js-ajax-delete" href="{:url('hosptialDel',['id'=>$vo.id])}">删除</a></td>
  29 + </tr>
  30 + </foreach>
  31 + </tbody>
  32 + <tfoot>
  33 + <tr>
  34 + <th width="50">ID</th>
  35 + <th>标签名称</th>
  36 + <th>状态</th>
  37 + <th width="160">操作</th>
  38 + </tr>
  39 + </tfoot>
  40 + </table>
  41 + <div class="table-actions">
  42 + <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
  43 + </div>
  44 + </form>
  45 + <ul class="pagination">{$page|default=''}</ul>
  46 +</div>
  47 +<script src="__STATIC__/js/admin.js"></script>
  48 +</body>
  49 +</html>