国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

fastadmin 下拉多級分類

這篇具有很好參考價(jià)值的文章主要介紹了fastadmin 下拉多級分類。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

要實(shí)現(xiàn)下圖效果

fastadmin 下拉多級分類,php

?一、先創(chuàng)建數(shù)據(jù)表

fastadmin 下拉多級分類,php

二、在目標(biāo)的controll中引入use fast\Tree;

public function _initialize()
{
    parent::_initialize();
    $this->model = new \app\admin\model\zxdc\Categorys;

    $tree = Tree::instance();
    $tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
    $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
    $categorydata = [0 => ['id' => '0', 'name' => __('None')]];
    foreach ($this->categorylist as $k => $v) {
        $categorydata[$v['id']] = $v;
    }
    $this->view->assign("parentList", $categorydata);


}

public function index()
{
    //設(shè)置過濾方法
    $this->request->filter(['strip_tags']);
    if ($this->request->isAjax()) {
        //構(gòu)造父類select列表選項(xiàng)數(shù)據(jù)
        $list = $this->categorylist;;
        $total = count($list);
        $result = array("total" => $total, "rows" => $list);
        return json($result);
    }
    return $this->view->fetch();
}

/**
 * 編輯
 */
public function edit($ids = null)
{
    $row = $this->model->get($ids);
    if (!$row) {
        $this->error(__('No Results were found'));
    }
    $adminIds = $this->getDataLimitAdminIds();
    if (is_array($adminIds)) {
        if (!in_array($row[$this->dataLimitField], $adminIds)) {
            $this->error(__('You have no permission'));
        }
    }
    if ($this->request->isPost()) {
        $params = $this->request->post("row/a");
        if ($params) {
        if ($params['pid'] == $row['id']) {
                $this->error(__('Can not change the parent to self'));
            }
            $params = $this->preExcludeFields($params);
            $result = false;
            Db::startTrans();
            try {
                //是否采用模型驗(yàn)證
                if ($this->modelValidate) {
                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                    $row->validateFailException(true)->validate($validate);
                }
                $result = $row->allowField(true)->save($params);
                Db::commit();
            } catch (ValidateException $e) {
                Db::rollback();
                $this->error($e->getMessage());
            } catch (PDOException $e) {
                Db::rollback();
                $this->error($e->getMessage());
            } catch (Exception $e) {
                Db::rollback();
                $this->error($e->getMessage());
            }
            if ($result !== false) {
                $this->success();
            } else {
                $this->error(__('No rows were updated'));
            }
        }
        $this->error(__('Parameter %s can not be empty', ''));
    }
    $this->view->assign("row", $row);
    return $this->view->fetch();
}

修改和添加下面兩個(gè)方法

三、

1、在目標(biāo)js中,添加代碼,去掉首頁html字符

fastadmin 下拉多級分類,php

2、 表格字段居左,這樣是為了看效果更加明顯

{field: 'name', title: __('Name'), operate: 'LIKE', align:'left'},

四,在目標(biāo)view中修改add.html和edit.html的pid代碼

add.html

<div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
    <div class="col-xs-12 col-sm-8">
        <select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
            {foreach name="parentList" item="vo"}
            <option  value="{$key}" {in name="key" value=""}selected{/in}>{$vo.name}</option>
            {/foreach}
        </select>

    </div>
</div>

edit.html

<div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
    <div class="col-xs-12 col-sm-8">
        <select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
            {foreach name="parentList" item="vo"}
            <option   value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo.name}</option>
            {/foreach}
        </select>
    </div>
</div>

完成上面步驟后,下拉分類就已完成,但在添加分類商品時(shí),在編輯時(shí)會出現(xiàn)selepage未選中狀態(tài),還要進(jìn)行修改

一、分類商品中用了zxdc_categorys_id字段來做分類ID,在add添加時(shí)一切正常,在edit時(shí)要進(jìn)行修改,在分類商品的controall中重寫edit方法,把分類數(shù)值獲取下發(fā)

/**
 * 編輯
 */
public function edit($ids = null)
{
    $test = new \app\admin\model\zxdc\Categorys;
    $tree = Tree::instance();
    $tree->init(collection($test->order('id desc')->select())->toArray(), 'pid');
    $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
    $categorydata = [0 => ['id' => '0', 'name' => __('None')]];
    foreach ($this->categorylist as $k => $v) {
        $categorydata[$v['id']] = $v;
    }
    $this->view->assign("parentList", $categorydata);

    $row = $this->model->get($ids);
    if (!$row) {
        $this->error(__('No Results were found'));
    }
    $adminIds = $this->getDataLimitAdminIds();
    if (is_array($adminIds)) {
        if (!in_array($row[$this->dataLimitField], $adminIds)) {
            $this->error(__('You have no permission'));
        }
    }
    if ($this->request->isPost()) {
        $params = $this->request->post("row/a");
        if ($params) {
            $params = $this->preExcludeFields($params);
            $result = false;
            Db::startTrans();
            try {
                //是否采用模型驗(yàn)證
                if ($this->modelValidate) {
                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                    $row->validateFailException(true)->validate($validate);
                }
                $result = $row->allowField(true)->save($params);
                Db::commit();
            } catch (ValidateException $e) {
                Db::rollback();
                $this->error($e->getMessage());
            } catch (PDOException $e) {
                Db::rollback();
                $this->error($e->getMessage());
            } catch (Exception $e) {
                Db::rollback();
                $this->error($e->getMessage());
            }
            if ($result !== false) {
                $this->success();
            } else {
                $this->error(__('No rows were updated'));
            }
        }
        $this->error(__('Parameter %s can not be empty', ''));
    }
    $this->view->assign("row", $row);
    return $this->view->fetch();
}

二、在對應(yīng)的view的edit.html中,修改文章來源地址http://www.zghlxwxcb.cn/news/detail-653330.html

<div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">{:__('Zxdc_categorys_id')}:</label>
    <div class="col-xs-12 col-sm-8">
        <select id="c-zxdc_categorys_id" data-rule="required" class="form-control selectpicker" name="row[zxdc_categorys_id]">
            {foreach name="parentList" item="vo"}
            <option   value="{$key}" {in name="key" value="$row.zxdc_categorys_id"}selected{/in}>{$vo.name}</option>
            {/foreach}
        </select>
    </div>
</div>

到了這里,關(guān)于fastadmin 下拉多級分類的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • QT實(shí)現(xiàn)多級下拉列表導(dǎo)航菜單,可折疊(QTreewidget實(shí)現(xiàn))

    QT實(shí)現(xiàn)多級下拉列表導(dǎo)航菜單,可折疊(QTreewidget實(shí)現(xiàn))

    目錄 創(chuàng)建多級列表 在ui中拖入一個(gè)QTreewidget控件。 雙擊該控件,打開編輯樹窗口部件。?編輯?編輯 進(jìn)行列表控件設(shè)置: 在項(xiàng)目前添加圖標(biāo): 效果: QT實(shí)現(xiàn)多級下拉列表,可折疊 做項(xiàng)目的時(shí)候需要實(shí)現(xiàn)一個(gè)可折疊的多級下拉列表,用QTreewidget就可以實(shí)現(xiàn),而且直接在ui文件

    2024年02月16日
    瀏覽(44)
  • java eazyexcel 實(shí)現(xiàn)excel的動態(tài)多級聯(lián)動下拉列表(1)使用名稱管理器+INDIRECT函數(shù)

    java eazyexcel 實(shí)現(xiàn)excel的動態(tài)多級聯(lián)動下拉列表(1)使用名稱管理器+INDIRECT函數(shù)

    將數(shù)據(jù)源放到一個(gè)新建的隱藏的sheet中 將選項(xiàng)的子選項(xiàng)的對應(yīng)字典設(shè)置到名稱管理器中(名稱是當(dāng)前選項(xiàng)的內(nèi)容,值是他對應(yīng)的子菜單的單元格范圍,在1里面的sheet中) 子菜單的數(shù)據(jù)根據(jù)INDIRECT函數(shù)去左邊那個(gè)單元格獲取內(nèi)容,根據(jù)內(nèi)容去名稱管理器中獲取字典的key,也就是

    2024年01月22日
    瀏覽(25)
  • uniapp實(shí)戰(zhàn) —— 豎排多級分類展示

    uniapp實(shí)戰(zhàn) —— 豎排多級分類展示

    srctypesglobal.d.ts

    2024年02月05日
    瀏覽(12)
  • mysql數(shù)據(jù)庫遞歸查詢樹形結(jié)構(gòu)(適用場景:菜單多級分類,多級關(guān)聯(lián)評論查詢),用strea流把list轉(zhuǎn)成樹的方法詳解

    mysql數(shù)據(jù)庫遞歸查詢樹形結(jié)構(gòu)(適用場景:菜單多級分類,多級關(guān)聯(lián)評論查詢),用strea流把list轉(zhuǎn)成樹的方法詳解

    層次關(guān)系: 現(xiàn)在的需求是把這個(gè)層級關(guān)系,在前端顯示出來,后端的處理方法有兩種: 1.直接把全部的數(shù)據(jù)從數(shù)據(jù)庫中拿到,然后在java代碼里面使用樹形結(jié)構(gòu)來進(jìn)行解析,但是這種做法只能在數(shù)據(jù)量比較小的時(shí)候使用,然后數(shù)據(jù)量一大會造成內(nèi)存溢出 2.在mysql中創(chuàng)建一個(gè)函數(shù)

    2024年02月05日
    瀏覽(24)
  • 微信小程序 列表多選 下拉分頁 滑動切換分類

    微信小程序 列表多選 下拉分頁 滑動切換分類

    1、卡片列表 2、分頁(下拉頁面加載分頁數(shù)據(jù)) 3、分類(頁面間互不干擾,數(shù)據(jù)也不干擾) 4、左右滑動可切換分類 5、列表搜索 6、單選模式(默認(rèn)單選模式,即點(diǎn)擊卡片,回寫所選數(shù)據(jù)) 7、 多選 模式(實(shí)現(xiàn)微信聊天多選效果) 長按 列表或 點(diǎn)擊多選 ,進(jìn)入多選模式;

    2024年02月03日
    瀏覽(22)
  • 微信小程序?qū)W習(xí)實(shí)錄2(下拉刷新、下拉加載更多、小程序事件、PHP后端代碼、刷新無數(shù)據(jù)解決方案)

    微信小程序?qū)W習(xí)實(shí)錄2(下拉刷新、下拉加載更多、小程序事件、PHP后端代碼、刷新無數(shù)據(jù)解決方案)

    lazyCodeLoading基礎(chǔ)庫 2.11.1 及以上版本支持,2.11.1 以下兼容但無優(yōu)化效果 通常情況下,在小程序啟動期間,所有頁面及自定義組件的代碼都會進(jìn)行注入,當(dāng)前頁面沒有使用到的自定義組件和頁面在注入后其實(shí)并沒有被使用。自基礎(chǔ)庫版本 2.11.1 起,小程序支持有選擇地注入必要

    2024年02月05日
    瀏覽(20)
  • 微信小程序uniapp+vue校園垃圾分類系統(tǒng)django/springboot/php/

    微信小程序uniapp+vue校園垃圾分類系統(tǒng)django/springboot/php/

    在對系統(tǒng)進(jìn)行功能需求分析,首先要了解系統(tǒng)的使用場合和使用人群。本系統(tǒng)是針對現(xiàn)垃圾分類中的問題而開發(fā)的一套微信小程序的校園垃圾分類識別系統(tǒng)。基于小程序的形式完成對管理。本系統(tǒng)分為三個(gè)權(quán)限:系統(tǒng)管理員、求助人、用戶。 (1)?? ?系統(tǒng)管理員的功能:

    2024年03月14日
    瀏覽(33)
  • 安裝FastAdmin時(shí)報(bào)1146 Table 'fastadmin.fa_admin' doesn't exist錯(cuò)誤

    Fastadmin的安裝 安裝路徑 /public/install.php 有部分小伙伴在安裝FastAdmin時(shí)報(bào)以下錯(cuò)誤 SQLSTATE[42S02]: Base table or view not found: 1146 Table \\\'fastadmin.fa_admin\\\' doesn\\\'t exist 這基本上是由于你的數(shù)據(jù)庫不支持Innodb引擎造成的。 解決辦法: 打開Mysql配置文件,找到 skip-innodb 項(xiàng),將其改成 #skip-inno

    2024年02月03日
    瀏覽(26)
  • fastadmin 項(xiàng)目gitee管理

    fastadmin 項(xiàng)目gitee管理

    gitee創(chuàng)建一個(gè)倉庫 使用sourcetree等工具拉取代碼 使用phpstorm遠(yuǎn)程同步代碼到本地 設(shè)置忽略代碼文件 注意:如果是直接把遠(yuǎn)程代碼同步到本地,默認(rèn)是你在 .gitignore中設(shè)置是無效的,代碼一樣會提交,需要先使用上面的截圖去掉緩存,提交push,在pull,后面就可以正常處理了? 備

    2024年02月16日
    瀏覽(23)
  • fastadmin前臺分片漏洞

    fastadmin前臺分片漏洞

    參考鏈接: fastadmin安裝 fastadmin安裝 前臺分片漏洞復(fù)現(xiàn): https://blog.csdn.net/weixin_43288600/article/details/121192252 https://blog.csdn.net/u013921288/article/details/117670844 https://xz.aliyun.com/t/9395 FastAdmin最新RCE漏洞復(fù)現(xiàn) https://www.secpulse.com/archives/157307.html 搭建好環(huán)境后,查看服務(wù)器ip: 注冊賬號,

    2024年02月07日
    瀏覽(15)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包