fastadmin中的分类

1.在controller中的初始化方法中构造分类的层级数

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


        $tree = Tree::instance();  //初始化树状类
        $tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid');//1.按照父id进行分类
        //2.按照父id处理后的分类名称字段
        $this->jobClasslist = $tree->getTreeList($tree->getTreeArray(0), 'job_class');
        //3.构造下拉选项的参水 jobClassdata
        foreach ($this->jobClasslist as $k => $v) {
            $jobClassdata[$v['id']] = $v;
        }

        $this->view->assign("jobClassdata", $jobClassdata);

    }

index的查看方法

    */
    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags']);
        if ($this->request->isAjax()) {
            $search = $this->request->request("search");
            $type   = $this->request->request("type");

            //构造父类select列表选项数据
            $list = [];

            foreach ($this->jobClasslist as $k => &$v) {
                $v['job_class'] = html_entity_decode($v['job_class'] );//去除空格符号
                if ($search) {
                        if ( stripos($v['job_class'], $search) !== false) {
                                $list = $this->jobClasslist;
                        }
                } else {
                        $list = $this->jobClasslist;
                }
            }
            // halt($list);

            $total = count($list);
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

去除FastAdmin 树型表格被转义的问题   在js文件中  

表格中escape设置成false

 

发布了20 篇原创文章 · 获赞 3 · 访问量 9185
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览