作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

XIAOPAN

@@ -37,6 +37,49 @@ class AdminCostController extends AdminBaseController{ @@ -37,6 +37,49 @@ class AdminCostController extends AdminBaseController{
37 return $this->fetch(); 37 return $this->fetch();
38 } 38 }
39 39
  40 + public function add(){
  41 + return $this->fetch();
  42 + }
  43 +
  44 +
  45 + public function addPost(){
  46 + $param=$this->request->param();
  47 + if (empty($param['free'])){
  48 + $param['free']=0;
  49 + }else{
  50 + $param['free']=1;
  51 + }
  52 + $cost=[
  53 + 'hospital' =>$param['hospital'],
  54 + 'free' => $param['free'],
  55 + 'cost' => $param['cost'],
  56 + 'ceiling' => $param['ceiling'],
  57 + ];
  58 + $interval=[
  59 + 'hospital' =>$param['hospital'],
  60 + 'start_time' => $param['start_time'],
  61 + 'end_time' => $param['end_time'],
  62 + 'price' => $param['price'],
  63 + ];
  64 +
  65 + $re1=Db::name('cost')->where('id',$param['hospital'])->find();
  66 + $re2=Db::name('interval')->where('id',$param['hospital'])->find();
  67 + if ($re1 || $re2){
  68 + $this->error('医院重复');
  69 + }
  70 +
  71 + try{
  72 + Db::startTrans();
  73 + Db::name('cost')->insert($cost);
  74 + Db::name('interval')->insert($interval);
  75 + }catch (\Exception $exception){
  76 + Db::rollback();
  77 + $this->error('添加失败');
  78 + }
  79 + Db::commit();
  80 + $this->success('添加成功');
  81 + }
  82 +
40 83
41 public function edit(){ 84 public function edit(){
42 $param=$this->request->param(); 85 $param=$this->request->param();
@@ -77,4 +120,12 @@ class AdminCostController extends AdminBaseController{ @@ -77,4 +120,12 @@ class AdminCostController extends AdminBaseController{
77 Db::commit(); 120 Db::commit();
78 $this->success('保存成功'); 121 $this->success('保存成功');
79 } 122 }
  123 +
  124 +
  125 + public function delete(){
  126 + $param=$this->request->param();
  127 + Db::name('cost')->where('id',$param['id'])->delete();
  128 + Db::name('interval')->where('id',$param['id'])->delete();
  129 + $this->success('删除成功');
  130 + }
80 } 131 }
  1 +<include file="public@header"/>
  2 +<style type="text/css">
  3 + .pic-list li {
  4 + margin-bottom: 5px;
  5 + }
  6 +</style>
  7 +</head>
  8 +<body>
  9 +<div class="wrap js-check-wrap">
  10 + <ul class="nav nav-tabs">
  11 + <li><a href="{:url('AdminCost/index')}">费用管理</a></li>
  12 + <li class="active"><a>添加费用管理</a></li>
  13 + </ul>
  14 + <!--js-ajax-form margin-top-20-->
  15 + <form action="{:url('AdminCost/addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  16 + <div class="row">
  17 + <div class="col-md-3">
  18 + <table class="table table-bordered">
  19 + <tr>
  20 + <td>
  21 + 医院名称<input style="width: 10rem" type="text" name="hospital" value="">
  22 + </td>
  23 + </tr>
  24 + <tr>
  25 + <th>免费设置</th>
  26 + </tr>
  27 + <tr>
  28 + <td>
  29 + <input type="checkbox" name="free" value="1">第一小时免费</label><br/>
  30 + </td>
  31 + </tr>
  32 + <tr>
  33 + <th>每小时费用</th>
  34 + </tr>
  35 + <tr>
  36 + <td>
  37 + 每小时费用<input style="width: 5rem" type="number" name="cost" value="">
  38 + </td>
  39 + </tr>
  40 + <tr>
  41 + <th>费用上限</th>
  42 + </tr>
  43 + <tr>
  44 + <td>
  45 + 每天费用上限<input style="width: 5rem" type="number" name="ceiling" value="">
  46 + </td>
  47 + </tr>
  48 + </table>
  49 + </div>
  50 + <div class="col-md-9">
  51 + <table class="table table-bordered">
  52 + <thead>
  53 + <tr>
  54 + <th colspan="6">固定收费时间段设置</th>
  55 + </tr>
  56 + </thead>
  57 + <tbody>
  58 + <tr>
  59 + <th>开始时间</th>
  60 + <td><input class="form-control" type="time" name="start_time" value=""></td>
  61 + <th>结束时间</th>
  62 + <td><input class="form-control" type="time" name="end_time" value=""></td>
  63 + <th>每小时费用</th>
  64 + <td><input class="form-control" type="number" name="price" value=""></td>
  65 + </tr>
  66 + </tbody>
  67 + <tfoot>
  68 + <tr>
  69 + <!--<th colspan="6" style="text-align: right">-->
  70 + <!--<a class="btn btn-default btn-sm" id="addattr">添加属性</a>-->
  71 + <!--</th>-->
  72 + <th colspan="6">
  73 + <span class="form-required">
  74 + <p style="text-indent: 2em; text-align: left;">
  75 + 说明:此时间段设置为跨越夜间凌晨0点的时间段。如果您想要对不跨天的时间端进行设置时,请调转开始时间与结束时间。并将时间段的每小时费用与左侧的每小时费用进行对调。
  76 + </p>
  77 + <p style="text-indent: 2em; text-align: left;">
  78 + 例如:要设置9点到21点是金额为10元,其余时间的金额为5元。则在时间段的开始时间填入21点,结束时间填入9点,每小时金额为5元,并在左侧的每小时费用填入10元,即可达到您想要的效果。
  79 + </p>
  80 + </span>
  81 + </th>
  82 + </tr>
  83 + </tfoot>
  84 + </table>
  85 + </div>
  86 + </div>
  87 + <div class="form-group">
  88 + <div class="col-sm-offset-2 col-sm-10" style="text-align: center">
  89 + <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  90 + <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
  91 + </div>
  92 + </div>
  93 + </form>
  94 +</div>
  95 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  96 +<script type="text/javascript">
  97 + //编辑器路径定义
  98 + var editorURL = GV.WEB_ROOT;
  99 +</script>
  100 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  101 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  102 +<script type="text/javascript">
  103 + $(function () {
  104 +
  105 + editorcontent = new baidu.editor.ui.Editor();
  106 + editorcontent.render('content');
  107 + try {
  108 + editorcontent.sync();
  109 + } catch (err) {
  110 + }
  111 +
  112 + $('.btn-cancel-thumbnail').click(function () {
  113 + $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  114 + $('#thumbnail').val('');
  115 + });
  116 +
  117 + $('#more-template-select').val("{$post.more.template|default=''}");
  118 + });
  119 +</script>
  120 +</body>
  121 +</html>
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 <div class="row"> 16 <div class="row">
17 <div class="col-md-3"> 17 <div class="col-md-3">
18 <table class="table table-bordered"> 18 <table class="table table-bordered">
  19 + <input hidden type="hidden" name="id" value="{$cost.id}">
19 <tr> 20 <tr>
20 <td> 21 <td>
21 医院名称<input style="width: 10rem" type="text" name="hospital" value="{$cost.hospital}"> 22 医院名称<input style="width: 10rem" type="text" name="hospital" value="{$cost.hospital}">
@@ -21,8 +21,8 @@ @@ -21,8 +21,8 @@
21 <tr> 21 <tr>
22 <td><b>{$vo.id}</b></td> 22 <td><b>{$vo.id}</b></td>
23 <td>{$vo.hospital}</td> 23 <td>{$vo.hospital}</td>
24 - <td>{$vo.cost}</td>  
25 - <td>{$vo.ceiling}</td> 24 + <td>{$vo.cost}元</td>
  25 + <td>{$vo.ceiling}元</td>
26 <td> 26 <td>
27 <a href="{:url('AdminCost/edit',array('id'=>$vo['id']))}">编辑</a>&nbsp; 27 <a href="{:url('AdminCost/edit',array('id'=>$vo['id']))}">编辑</a>&nbsp;
28 <a href="{:url('AdminCost/delete',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn">删除</a> 28 <a href="{:url('AdminCost/delete',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn">删除</a>