Sfoglia il codice sorgente

8-7前端分页处理

Home 4 anni fa
parent
commit
754ccb4a67

+ 1 - 1
app/admin/controller/Category.php

@@ -20,7 +20,7 @@ class Category extends AdminBase
             "pid" => $pid
         ];
         try {
-            $categorys = (new CategoryBusiness())->getLists($data, 5);
+            $categorys = (new CategoryBusiness())->getLists($data, 1);
         } catch (\Exception $e) {
             $categorys = [];
         }

+ 19 - 11
app/admin/view/category/index.html

@@ -52,7 +52,7 @@
                     <th>标题</th>
                     <th>排序</th>
                     <th class="text-center">创建时间</th>
-                    <th class="text-center">操作时间</th>
+                    <th class="text-center">更新时间</th>
                     <th class="text-center">操作人</th>
                     <th class="text-center">状 态</th>
                     <th>操作管理</th>
@@ -60,42 +60,50 @@
                 </thead>
                 <tbody>
                 <!--一级类目循环-->
+                {volist name="categorys.data" id="vo"}
                 <tr>
                     <td>
-                        1
+                        {$vo.id}
                     </td>
                     <td>
-                        abcd
+                        {$vo.name}
                     </td>
                     <td>
                         <div class="layui-input-inline">
-                            <input type="text" value="1" data-id="1" class="changeSort layui-input">
+                            <input type="text" value="{$vo.listorder}" data-id="{$vo.id}" class="changeSort layui-input">
                         </div>
                     </td>
                     <td>
-                        创建时间
+                        {$vo.create_time}
                     </td>
                     <td>
-                        更新时间
+                        {$vo.update_time}
                     </td>
                     <td>
-                        singwa
+                        {$vo.operate_user}
                     </td>
-                    <td data-id="1"><input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
+                    <td data-id="1"><input type="checkbox" {if $vo.status == 1} checked {/if} name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                     </td>
                     <td>
-                        <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete del-child" data-ptype="1" lay-event="delete" data-id="$id">删除</a>
-                        <a href="{:url('index', ['pid'=>1])}">获取子栏目</a>
+                        <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete del-child" data-ptype="1" lay-event="delete" data-id="{$vo.id}">删除</a>
+                        <a href="{:url('index', ['pid'=>$vo.id])}">获取子栏目</a>
                     </td>
                 </tr>
+                {/volist}
                 <!--一级类目循环 end-->
                 </tbody>
             </table>
         </div>
-        <div id="pages"></div>
+        <div>{$categorys.render|raw}</div>
+<!--        <div id="pages"></div>-->
     </div>
 
 </div>
+<style>
+    .pagination li{display: inline;padding-left: 10px;}
+    .pagination .active{color: red;}
+    .pagination .disabled{color: #DDD;}
+</style>
 <script src="{__STATIC_PATH}admin/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
 <script src="{__STATIC_PATH}admin/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
 <script src="{__STATIC_PATH}admin/js/common.js?v5" charset="utf-8"></script>

+ 3 - 1
app/common/business/Category.php

@@ -69,6 +69,8 @@ class Category
         if (!$list) {
             return [];
         }
-        return $list->toArray();
+        $result = $list->toArray();
+        $result['render'] = $list->render();
+        return $result;
     }
 }