作者 sgj

医院管理

... ... @@ -79,9 +79,56 @@ class HospitalController extends AdminBaseController
}
$hospital=$this->HospitalModel->getHospital($platment_id)->toArray();
$this->assign('hospital',$hospital);
$this->assign('platform_id',$platment_id);
return $this->fetch();
}
/**
*
* @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()){
/*验证器*/
}else{
$this->fetch();
}
}
... ...
... ... @@ -10,9 +10,13 @@ namespace app\admin\model;
use think\Model;
use traits\model\SoftDelete;
class HospitalModel extends Model
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* 返回平台信息
* @return false|\PDOStatement|string|\think\Collection
... ... @@ -27,10 +31,24 @@ class HospitalModel extends Model
return $platment;
}
public function getHospital(){
$map['platment_id']='0';
$map['deleteTime']='0';
$hospital=db('hospital')->where($map)->select();
/**
* 获取医院
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHospital($platform_id){
$map['platform_id']=$platform_id;
$hospital=$this->where($map)->select();
return $hospital;
}
public function hospitalDel($hosptial_id){
$result=$this::destroy($hosptial_id);
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -13,6 +13,6 @@ return [
// 应用调试模式
'app_debug' => true,
// 应用Trace
'app_trace' => true,
'app_trace' => false,
];
\ No newline at end of file
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="">标签管理</a></li>
<li><a href="{:url('hospitalAdd',['id'=>$platform_id])}">添加医院</a></li>
</ul>
<form method="post" class="js-ajax-form margin-top-20">
<div class="table-actions">
<!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
</div>
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="50">ID</th>
<th>标签名称</th>
<th>状态</th>
<th width="160">操作</th>
</tr>
</thead>
<tbody>
<foreach name="hospital" item="vo">
<tr>
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td><a href="{:url('hospital',['id'=>$vo.id])}">查看医院</a></td>
<td><a class="js-ajax-delete" href="{:url('hosptialDel',['id'=>$vo.id])}">删除</a></td>
</tr>
</foreach>
</tbody>
<tfoot>
<tr>
<th width="50">ID</th>
<th>标签名称</th>
<th>状态</th>
<th width="160">操作</th>
</tr>
</tfoot>
</table>
<div class="table-actions">
<!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
</div>
</form>
<ul class="pagination">{$page|default=''}</ul>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...