rabin 1 年間 前
コミット
fbeb997c81

+ 14 - 3
src/place/lib/Cate.php

@@ -32,7 +32,7 @@ class Cate
                     }
                 }
                 $data['cate_child'][] = array('id' => $parent_id, 'name' => '全部');
-                $data['cate_child'] = array_merge($data['cate_child'], $this->getList($parent_id));
+                $data['cate_child'] = array_merge($data['cate_child'], $this->getList($parent_id, 10));
                 if ($data['cate_child']) {
                     foreach ($data['cate_child'] as &$v) {
                         $v['selected'] = 2;
@@ -42,14 +42,25 @@ class Cate
                     }
                 }
             }
+        } else {
+            $data['cate_child'] = $this->getList(array('>', 0), 10);
+            if ($data['cate_child']) {
+                foreach ($data['cate_child'] as &$v) {
+                    $v['selected'] = 2;
+                }
+            }
         }
         return $data;
     }
 
     # 获取分类列表
-    public function getList($parent_id = 0)
+    public function getList($parent_id = 0, $num = false)
     {
-        return $this->db->select(array('parent_id' => $parent_id, 'status' => 1), array('col' => 'id,name,cdate,parent_id,`desc`'));
+        $set = array();
+        if ($num) {
+            $set['limit'] = '0, ' . $num;
+        }
+        return $this->db->select(array('parent_id' => $parent_id, 'status' => 1), array('col' => 'id,name,icon,cdate,parent_id,`desc`'), $set);
     }
 
     # 获取分类信息

+ 20 - 4
src/resource/content/manage/cate.php

@@ -6,8 +6,12 @@ return array
         'field'      => array
         (
             'name',
-            'key',
-            'sort' => 'input',
+            //'key',
+            'sort' => array
+            (
+                'type' => 'input',
+                'tips' => '双击修改排序',
+            ),
             'status' => array
             (
                 'type' => 'switch',
@@ -20,11 +24,11 @@ return array
         'tree' => array('parent_id', '0', 'id'),
         'button' => array
         (
-            '新增主分类' => array('fastadd', array('parent_id' => '0')),
+            '新增主分类' => array('add', array('parent_id' => '0')),
         ),
         'data_button' => array
         (
-            '编辑' => array('fastedit', 'name,key,desc,sort,status'),
+            '编辑' => array('edit', 'name,key,desc,icon,sort,status'),
             '新增子分类' => array('fastadd', array('parent_id' => 'id'), '', 'parent_id=0'),
         ),
         'search'    => array
@@ -42,12 +46,24 @@ return array
             (
                 'rules' => true,
             ),
+            /*
             'key' => array
             (
                 'desc' => '如果为空,将自动按照名称首字母生成',
             ),
+            */
             'parent_id',
             'desc' => 'textarea',
+            'icon' => array
+            (
+                'type' => 'upload',
+                'upload' => '1',
+                'yun' => true,
+                'multiple' => false,
+                'limit' => 1,
+                'style' => 'list',
+                'desc' => '可以到"https://www.iconfont.cn/"下载之后上传',
+            ),
             'status' => array
             (
                 'type' => 'radio',

+ 6 - 1
src/resource/content/table/cate.php

@@ -24,9 +24,14 @@ return array
         ),
         'desc' => array
         (
-            'name'      => '分类描述',
+            'name'      => '分类介绍',
             'type'      => 'varchar(800)',
         ),
+        'icon' => array
+        (
+            'name'      => '分类图标',
+            'type'      => 'varchar(150)',
+        ),
         'status' => array
         (
             'name'      => '状态',