<?php

use qcbase\assets\MenuAsset;
use yii\helpers\Url;
use yii\web\Request;

$this->title = '菜单管理';

//默认值
if ($model->isNewRecord) {
    $cookies = Yii::$app->request->cookies;
    $cookie = $cookies->getValue('menuDefault');
    $model->status = 1; //默认启用
    $model->is_auth = 2; //默认不建立节点
    $model->show_scope= 0; //默认不显示权限范围
    $model->sort = 0; //默认建立节点
    $app_name = Yii::$app->request->get('app_name');
    $parent_id = Yii::$app->request->get('menu_id');
    $model->app_name = empty($app_name) ? $cookie['app_name'] : $app_name;
    $model->parent_id = empty($parent_id) ? $cookie['parent_id'] : $parent_id;
}
MenuAsset::register($this);
?>

<div class="nav">
    <!--<div class="return"><a href="">返回上一级</a></div>-->
    <ul class="cc">
        <li ><a href="<?= Url::to(['menu/index']) ?>">菜单管理</a></li>
        <li class="current"><a href="<?= Url::to(['menu/create']) ?>">添加菜单</a></li>
    </ul>
</div>


<?php
echo $this->render('_form', ['model' => $model, 'action' => $action]);
?>
<script>
    var appMenuUrl = "<?= Url::to(['menu/get-app-menu']) ?>"
    var parent_id = "<?= $model->parent_id ?>";
    var disabled_id = "<?= $model->menu_id ?>";
    var csrfToken = "<?= Yii::$app->request->getCsrfToken() ?>";
</script>
