<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                本模型采用 `adminCategoryTableTree` 方法 >說明:此模型需要用到 `Tree` 類。有關 `Tree` 類的使用會在附件中說明并使用! 思路:這里我們只需要遍歷數組,再形成帶有管理功能的數組。利用`Tree`類`init`方法初始化,再用`getTree`方法獲取遍歷數組即可!根本不再需要用更多的方法來操作了! 是不是很簡單的呢! 這里可以根據實際情況將 `$tpl` 進行默認更改! ## 代碼 這里先介紹代碼,下邊會講到一些關鍵性知識。 ``` <?php namespace app\agent\model; use think\Model; use tree\Tree; class AgentCategoryModel extends Model { /** * 獲取表格樹 * @param int|array $currentIds * @param string $tpl * @return string */ public function adminCategoryTableTree($currentIds = 0, $tpl = '') { $where = ['delete_time' => 0]; $categories = $this->order("list_order ASC")->where($where)->select()->toArray(); if (!is_array($currentIds)) { $currentIds = [$currentIds]; } $newCategories = []; foreach ($categories as $item) { $item['checked'] = in_array($item['id'], $currentIds) ? "checked" : ""; $item['url'] = url('agent/List/index', ['id' => $item['id']]);; $item['str_action'] = '<a href="' . url("AdminCategory/add", ["parent" => $item['id']]) . '">添加子分類</a> <a href="' . url("AdminCategory/edit", ["id" => $item['id']]) . '">' . lang('EDIT') . '</a> <a class="js-ajax-delete" href="' . url("AdminCategory/delete", ["id" => $item['id']]) . '">' . lang('DELETE') . '</a> '; array_push($newCategories, $item); } $tree = new Tree(); $tree->icon = ['&nbsp;&nbsp;│', '&nbsp;&nbsp;├─', '&nbsp;&nbsp;└─']; $tree->nbsp = '&nbsp;&nbsp;'; $tree->init($newCategories); if (empty($tpl)) { $tpl = "<tr> <td><input name='list_orders[\$id]' type='text' size='3' value='\$list_order' class='input-order'></td> <td>\$id</td> <td>\$spacer <a href='\$url' target='_blank'>\$name</a></td> <td>\$description</td> <td>\$str_action</td> </tr>"; } $treeStr = $tree->getTree(0, $tpl); return $treeStr; } } ``` ## 關鍵知識一 這里關鍵的是怎樣把 `$categories` 更改為 `$newCategories` 數組。 那么這兩種的數據分別是什么呢? `$categories` 是單純的數組,如圖所示: ![mark](http://olbhidnfa.bkt.clouddn.com/blog/20171014-224446553.png) `$newCategories` 是具有操作性的數組,如圖所示: ![mark](http://olbhidnfa.bkt.clouddn.com/blog/20171014-224553397.png) ## 關鍵知識二
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看