Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'sort' => $this->sort, 'parent_id' => $this->parent_id, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'menu_name', $this->menu_name])->andFilterWhere(['like', 'menu_url', $this->menu_url]);
     return $dataProvider;
 }
Пример #2
0
 public function actionSave()
 {
     try {
         $post = Yii::$app->request->post();
         $id = isset($post['menu_id']) ? $post['menu_id'] : '';
         if (!empty($id)) {
             $model = $this->findModel($id);
             if ($model->load($post) && $model->save()) {
                 $menu_id = $id;
             }
         } else {
             $model = new Menu();
             if ($model->load($post) && $model->save()) {
                 $menu_id = Yii::$app->db->getLastInsertID();
             }
         }
         if (empty($menu_id)) {
             throw new \Exception('写入菜单失败');
         }
     } catch (\Exception $exp) {
         $message = '';
         $error = $model->getErrors();
         $result = ['statusCode' => '300', 'message' => $message, 'navTabId' => 'common_menu_index_id', 'forwardUrl' => '', 'callbackType' => ''];
         echo Json::encode($result);
         exit;
     }
     $result = ['statusCode' => '200', 'message' => '操作成功', 'navTabId' => 'common_menu_index_id', 'forwardUrl' => '', 'callbackType' => 'closeCurrent'];
     echo Json::encode($result);
     exit;
 }
Пример #3
0
                </ul>
            </div>


            <div id="navMenu">
<!--                <ul>-->
<!--                    <li class="selected"><a href="sidebar_1.html"><span>资讯管理</span></a></li>-->
<!--                    <li><a href="sidebar_2.html"><span>订单管理</span></a></li>-->
<!--                    <li><a href="sidebar_1.html"><span>产品管理</span></a></li>-->
<!--                    <li><a href="sidebar_2.html"><span>会员管理</span></a></li>-->
<!--                    <li><a href="sidebar_1.html"><span>服务管理</span></a></li>-->
<!--                    <li><a href="sidebar_2.html"><span>系统设置</span></a></li>-->
<!--                </ul>-->

                <?php 
echo \common\models\common\Menu::getNavMenu();
?>

            </div>
        </div>

        <div id="leftside">
            <div id="sidebar_s">
                <div class="collapse">
                    <div class="toggleCollapse">
                        <div></div>
                    </div>
                </div>
            </div>
            <div id="sidebar">
                <div class="toggleCollapse"><h2>主菜单</h2>