lizhen_gitee 9 месяцев назад
Родитель
Сommit
48704348d6

+ 37 - 2
application/admin/controller/Videotype.php

@@ -5,7 +5,7 @@ namespace app\admin\controller;
 use app\common\controller\Backend;
 
 /**
- * 视频类型(暂弃)
+ * 视频类型
  *
  * @icon fa fa-circle-o
  */
@@ -22,7 +22,8 @@ class Videotype extends Backend
     {
         parent::_initialize();
         $this->model = new \app\admin\model\Videotype;
-        $this->view->assign("typeList", $this->model->getTypeList());
+        $this->view->assign("statusList", $this->model->getStatusList());
+        $this->view->assign("showtypeList", $this->model->getShowtypeList());
     }
 
 
@@ -34,4 +35,38 @@ class Videotype extends Backend
      */
 
 
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['cate'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('cate')->visible(['catename']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
 }

+ 16 - 10
application/admin/lang/zh-cn/videotype.php

@@ -1,14 +1,20 @@
 <?php
 
 return [
-    'Id'         => 'ID',
-    'Type'       => '分类类型',
-    'Type 0'     => '老年大学',
-    'Type 1'     => '普法课堂',
-    'Type 3'     => '精彩专题',
-    'Name'       => '类型名称',
-    'Image'      => '图片',
-    'Weigh'      => '权重排序',
-    'Createtime' => '创建时间',
-    'Updatetime' => '更新时间'
+    'Id'            => 'ID',
+    'Type'          => '专题',
+    'Name'          => '类型名称',
+    'Image'         => '图片',
+    'Weigh'         => '权重排序',
+    'Createtime'    => '创建时间',
+    'Updatetime'    => '更新时间',
+    'Status'        => '上下架',
+    'Status 0'      => '下架',
+    'Status 1'      => '上架',
+    'Showtype'      => '分布',
+    'Showtype 1'    => '左一右四',
+    'Showtype 2'    => '两行八个',
+    'Showtype 3'    => '一行四个',
+    'Showtype 4'    => '一行三个',
+    'Cate.catename' => '专题'
 ];

+ 24 - 6
application/admin/model/Videotype.php

@@ -25,7 +25,8 @@ class Videotype extends Model
 
     // 追加属性
     protected $append = [
-        'type_text'
+        'status_text',
+        'showtype_text'
     ];
     
 
@@ -38,20 +39,37 @@ class Videotype extends Model
     }
 
     
-    public function getTypeList()
+    public function getStatusList()
     {
-        return ['0' => __('Type 0'), '1' => __('Type 1'), '3' => __('Type 3')];
+        return ['0' => __('Status 0'), '1' => __('Status 1')];
+    }
+
+    public function getShowtypeList()
+    {
+        return ['1' => __('Showtype 1'), '2' => __('Showtype 2'), '3' => __('Showtype 3'), '4' => __('Showtype 4')];
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
     }
 
 
-    public function getTypeTextAttr($value, $data)
+    public function getShowtypeTextAttr($value, $data)
     {
-        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
-        $list = $this->getTypeList();
+        $value = $value ? $value : (isset($data['showtype']) ? $data['showtype'] : '');
+        $list = $this->getShowtypeList();
         return isset($list[$value]) ? $list[$value] : '';
     }
 
 
 
 
+    public function cate()
+    {
+        return $this->belongsTo('app\admin\model\Videocate', 'type', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 2 - 2
application/admin/view/videocate/index.html

@@ -17,7 +17,7 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('videocate/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('videocate/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                         <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('videocate/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('videocate/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         
@@ -28,7 +28,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </div>

+ 25 - 7
application/admin/view/videotype/add.html

@@ -3,13 +3,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
         <div class="col-xs-12 col-sm-8">
-                        
-            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
-                {foreach name="typeList" item="vo"}
-                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
-                {/foreach}
-            </select>
-
+            <input id="c-type" data-rule="required" class="form-control selectpage" data-source="videocate/index" data-field="catename" name="row[type]">
         </div>
     </div>
     <div class="form-group">
@@ -38,6 +32,30 @@
             <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showtype')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-showtype" data-rule="required" class="form-control selectpicker" name="row[showtype]">
+                {foreach name="showtypeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 25 - 7
application/admin/view/videotype/edit.html

@@ -3,13 +3,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
         <div class="col-xs-12 col-sm-8">
-                        
-            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
-                {foreach name="typeList" item="vo"}
-                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
-                {/foreach}
-            </select>
-
+            <input id="c-type" data-rule="required" class="form-control selectpage" name="row[type]" data-source="videocate/index" data-field="catename" value="{$row.type|htmlentities}">
         </div>
     </div>
     <div class="form-group">
@@ -38,6 +32,30 @@
             <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showtype')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-showtype" data-rule="required" class="form-control selectpicker" name="row[showtype]">
+                {foreach name="showtypeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.showtype"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 11 - 1
application/admin/view/videotype/index.html

@@ -1,5 +1,15 @@
 <div class="panel panel-default panel-intro">
-    {:build_heading()}
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="status">
+            <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="statusList" item="vo"}
+            <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
 
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">

+ 1 - 1
public/assets/js/backend/videocate.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     index_url: 'videocate/index' + location.search,
                     add_url: 'videocate/add',
                     edit_url: 'videocate/edit',
-                    del_url: 'videocate/del',
+//                    del_url: 'videocate/del',
                     multi_url: 'videocate/multi',
                     import_url: 'videocate/import',
                     table: 'video_cate',

+ 4 - 1
public/assets/js/backend/videotype.js

@@ -26,12 +26,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
+//                        {field: 'type', title: __('Type')},
+                        {field: 'cate.catename', title: __('Cate.catename'), operate: 'LIKE'},
                         {field: 'name', title: __('Name'), operate: 'LIKE'},
                         {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                         {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
+                        {field: 'showtype', title: __('Showtype'), searchList: {"1":__('Showtype 1'),"2":__('Showtype 2'),"3":__('Showtype 3'),"4":__('Showtype 4')}, formatter: Table.api.formatter.normal},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]