modified 完善表单信息

This commit is contained in:
zhaoxiang 2016-11-10 18:46:25 +08:00
parent 5a5d158aec
commit e712577b65
3 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,8 @@
*/ */
namespace app\admin\controller; namespace app\admin\controller;
use app\admin\model\User;
use app\admin\model\Menu;
use think\Controller; use think\Controller;
class Base extends Controller { class Base extends Controller {
@ -14,6 +15,9 @@ class Base extends Controller {
public $primaryKey; public $primaryKey;
public $uid; public $uid;
public $userInfo; public $userInfo;
public $url;
public $menuInfo;
private $superUrl = [ private $superUrl = [
'User/login' 'User/login'
]; ];
@ -43,13 +47,12 @@ class Base extends Controller {
* 系统初始化函数(登陆状态检测,权限检测,初始化菜单) * 系统初始化函数(登陆状态检测,权限检测,初始化菜单)
*/ */
private function iniSystem(){ private function iniSystem(){
$url = $this->request->controller().'/'.$this->request->action(); $this->url = $this->request->controller().'/'.$this->request->action();
if( !in_array($url, $this->superUrl) ){ if( !in_array($this->url, $this->superUrl) ){
// $this->allMenu = D('Menu')->order('sort asc')->select(); $this->menuInfo = Menu::where(['url' => $this->url])->find()->toArray();
// $this->menuInfo = D('Menu')->where(['url' => $this->url])->find(); if( empty($this->menuInfo) ){
// if( empty($this->menuInfo) ){ $this->error( '目录:'.$this->url.'不存在!' );
// $this->error( 'Menu'.L('_SELECT_NOT_EXIST_') ); }
// }
$this->checkLogin(); $this->checkLogin();
// $this->checkRule(); // $this->checkRule();
} }

View File

@ -217,6 +217,7 @@ class Menu extends Base {
$data = array_column($data, 'name', $this->primaryKey); $data = array_column($data, 'name', $this->primaryKey);
$defaultFather = $this->request->get($this->primaryKey); $defaultFather = $this->request->get($this->primaryKey);
$form = [ $form = [
'formTitle' => $this->menuInfo['name'],
'tempType' => 'add', 'tempType' => 'add',
'formAttr' => [ 'formAttr' => [
'target' => url('Menu/add'), 'target' => url('Menu/add'),
@ -365,6 +366,7 @@ class Menu extends Base {
$data = array_column($data, 'name', $this->primaryKey); $data = array_column($data, 'name', $this->primaryKey);
$detail = \app\admin\model\Menu::get($this->request->get($this->primaryKey))->toArray(); $detail = \app\admin\model\Menu::get($this->request->get($this->primaryKey))->toArray();
$form = [ $form = [
'formTitle' => $this->menuInfo['name'],
'tempType' => 'edit', 'tempType' => 'edit',
'formAttr' => [ 'formAttr' => [
'target' => url('Menu/edit'), 'target' => url('Menu/edit'),

View File

@ -29,7 +29,7 @@
*/ */
function buildForm( formObj, boxType, method ) { function buildForm( formObj, boxType, method ) {
var formHtml = '<div class="box '+ boxType +'" id="formBox"><div class="box-body">'; var formHtml = '<div class="box '+ boxType +'" id="formBox"><div class="box-body">';
formHtml += '<div class="box-header with-border"><h3 class="box-title">新增菜单</h3></div>'; formHtml += '<div class="box-header with-border"><h3 class="box-title">'+formObj.formTitle+'</h3></div>';
formHtml += '<form id="'+ formObj.formAttr.formId +'" action="'+ formObj.formAttr.target +'"><div class="box-body">'; formHtml += '<form id="'+ formObj.formAttr.formId +'" action="'+ formObj.formAttr.target +'"><div class="box-body">';
$.each(formObj.formList, function (index, value) { $.each(formObj.formList, function (index, value) {
switch (value.module){ switch (value.module){