lizhen_gitee 8 miesięcy temu
rodzic
commit
9b8199385f

+ 3 - 0
application/admin/controller/unishop/Category.php

@@ -40,6 +40,9 @@ class Category extends Backend
         $this->view->assign("typeList", $typeList);
         $this->view->assign("parentList", $categorydata);
         $this->assignconfig('typeList', $typeList);
+
+        $this->view->assign("isTopList", $this->model->getIsTopList());
+
     }
 
     /**

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

@@ -16,4 +16,7 @@ return [
     'Can not change the parent to child' => '父组别不能是它的子组别',
     'Status'                             => '状态',
     'Product'                             => '产品',
+    'Is_top'              => '是否置顶',
+    'Is_top 0'            => '不置顶',
+    'Is_top 1'            => '置顶'
 ];

+ 14 - 0
application/admin/model/unishop/Category.php

@@ -21,6 +21,7 @@ class Category extends Model
     protected $append = [
         'type_text',
         'flag_text',
+        'is_top_text'
     ];
 
     protected static function init()
@@ -83,6 +84,19 @@ class Category extends Model
         return $list;
     }
 
+    public function getIsTopList()
+    {
+        return ['0' => __('Is_top 0'), '1' => __('Is_top 1')];
+    }
+
+
+    public function getIsTopTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_top']) ? $data['is_top'] : '');
+        $list = $this->getIsTopList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
     /**
      * 关联上一级
      * @return \think\model\relation\HasOne

+ 12 - 0
application/admin/view/unishop/category/add.html

@@ -83,6 +83,18 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_top')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <select  id="c-is_top" data-rule="required" class="form-control selectpicker" name="row[is_top]">
+                {foreach name="isTopList" 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">{:__('Status')}:</label>
         <div class="col-xs-12 col-sm-8">
             {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])}

+ 12 - 0
application/admin/view/unishop/category/edit.html

@@ -81,6 +81,18 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_top')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <select  id="c-is_top" data-rule="required" class="form-control selectpicker" name="row[is_top]">
+                {foreach name="isTopList" item="vo"}
+                <option value="{$key}" {in name="key" value="$row.is_top"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </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">
             {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])}

+ 4 - 3
public/assets/js/backend/unishop/category.js

@@ -31,12 +31,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'type', title: __('Type'), searchList: Config.searchList, formatter: Table.api.formatter.normal},
+//                        {field: 'type', title: __('Type'), searchList: Config.searchList, formatter: Table.api.formatter.normal},
                         {field: 'name', title: __('Name'), align: 'left'},
-                        {field: 'nickname', title: __('Nickname')},
-                        {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag},
+//                        {field: 'nickname', title: __('Nickname')},
+//                        {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag},
                         {field: 'image', title: __('Image'), operate: false, formatter: Table.api.formatter.image},
                         {field: 'weigh', title: __('Weigh')},
+                        {field: 'is_top', title: __('Is_top'), searchList: {"0":__('Is_top 0'),"1":__('Is_top 1')}, formatter: Table.api.formatter.normal},
                         {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]