<?php

namespace app\admin\controller;

use app\admin\common\AdminController;

/**
 * Description of Dept
 *
 * @author sgq
 */
class Dept extends AdminController {

    /**
     * 树形
     * @return type
     */
    function treelist() {
        $list = getTreeList(\app\admin\api\DeptApi::getList([]));
        $format_list = [];
        foreach ($list as $item) {
            $format_list[] = [
                "checked" => false,
                "id" => $item["id"],
                "isOpen" => true,
                "name" => $item["simplename"],
                "open" => $item["pid"] == 0 ? true : false,
                "pId" => $item["pid"]
            ];
        }
        $format_list[] = ["checked" => true, "id" => "0", "isOpen" => true, "name" => "顶级", "open" => true, "pId" => "0"];
        return $format_list;
    }

}
