Browse Source

体检套餐

Panda 3 months ago
parent
commit
4612c86b4f

+ 1 - 0
application/admin/controller/Hotel.php

@@ -22,6 +22,7 @@ class Hotel extends Backend
     {
         parent::_initialize();
         $this->model = new \app\admin\model\Hotel;
+        $this->view->assign("isHomeList", $this->model->getIsHomeList());
         $this->view->assign("statusList", $this->model->getStatusList());
     }
 

+ 3 - 0
application/admin/lang/zh-cn/hotel.php

@@ -1,6 +1,9 @@
 <?php
 
 return [
+    'Is_home'        => '首页',
+    'Is_home 1'      => '首页',
+    'Is_home 0'      => '默认',
     'Name'           => '名称',
     'Image'          => '列表图',
     'Images'         => '轮播图',

+ 14 - 0
application/admin/model/Hotel.php

@@ -25,6 +25,7 @@ class Hotel extends Model
 
     // 追加属性
     protected $append = [
+        'is_home_text',
         'status_text',
         'create_time_text',
         'update_time_text'
@@ -40,12 +41,25 @@ class Hotel extends Model
     }
 
     
+    public function getIsHomeList()
+    {
+        return ['1' => __('Is_home 1'), '0' => __('Is_home 0')];
+    }
+
     public function getStatusList()
     {
         return ['1' => __('Status 1'), '0' => __('Status 0')];
     }
 
 
+    public function getIsHomeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_home']) ? $data['is_home'] : '');
+        $list = $this->getIsHomeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
     public function getStatusTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');

+ 12 - 0
application/admin/view/hotel/add.html

@@ -1,6 +1,18 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_home')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-is_home" data-rule="required" class="form-control selectpicker" name="row[is_home]">
+                {foreach name="isHomeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">

+ 12 - 0
application/admin/view/hotel/edit.html

@@ -1,6 +1,18 @@
 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_home')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-is_home" data-rule="required" class="form-control selectpicker" name="row[is_home]">
+                {foreach name="isHomeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.is_home"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">

+ 4 - 0
application/api/controller/Hotel.php

@@ -40,6 +40,10 @@ class Hotel extends Api
         }
         $query    = HotelModel::field($field);
 
+        if (!empty($params['is_home'])){
+            $query->where('is_home',$params['is_home']);
+        }
+
         if (!empty($params['lng']) && !empty($params['lng'])){
             if ($params['sort_distance'] == 1){
                 $query->order('distance asc');

+ 1 - 0
public/assets/js/backend/hotel.js

@@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
+                        {field: 'is_home', title: __('Is_home'), searchList: {"1":__('Is_home 1'),"0":__('Is_home 0')}, formatter: Table.api.formatter.normal},
                         {field: 'name', title: __('Name'), operate: 'LIKE'},
                         {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                         {field: 'price', title: __('Price'), operate:'BETWEEN'},