diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index 13f66cf..6415a79 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -121,9 +121,9 @@ class Menu extends Base { $form = [ 'tempType' => 'add', 'formAttr' => [ - 'target' => '', - 'formId' => '', - 'backUrl' => '', + 'target' => url('Menu/add'), + 'formId' => 'add-menu-form', + 'backUrl' => url('Menu/index'), ], 'formList' => [ [ @@ -153,7 +153,10 @@ class Menu extends Base { 'attr' => [ 'name' => 'level', 'value' => '', - 'options' => [] + 'options' => [ + '普通认证', + 'Log记录' + ] ] ], [ @@ -163,7 +166,10 @@ class Menu extends Base { 'attr' => [ 'name' => 'type', 'value' => '', - 'options' => [] + 'options' => [ + '模块类功能', + '方法类功能' + ] ] ], [ @@ -173,7 +179,10 @@ class Menu extends Base { 'attr' => [ 'name' => 'hide', 'value' => '', - 'options' => [] + 'options' => [ + '显示菜单', + '隐藏菜单', + ] ] ], [ @@ -183,7 +192,10 @@ class Menu extends Base { 'attr' => [ 'name' => 'recommend', 'value' => '', - 'options' => [] + 'options' => [ + '普通模块', + '推荐模块' + ] ] ], [ diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index 759869a..6f9edd3 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -1,32 +1,78 @@ {extend name="public/base" /} {block name="content"} -
-
-

General Elements

+
+
+

新增菜单

+
+
+
+
+
+ + +
+
+ Info +
-
- -
- - -
-
- - -
- -
- - -
-
- - -
- +
+
+ + +
+
+ Info +
+
+
+
+ +
+ + + +
+
+
+ Info +
+
+
+
+ +
+ + + +
+
+
+ Info +
-
+ + +
+ {/block} {block name="myScript"} diff --git a/public/admin/static/js/template.js b/public/admin/static/js/template.js index 7c38084..8b316d7 100644 --- a/public/admin/static/js/template.js +++ b/public/admin/static/js/template.js @@ -99,15 +99,15 @@ } } if( data.data.tempType == 'add' ){ - if( $.buildAddForm ){ - $('#content').html($.buildAddForm(data.data)); - $('#formBox').hide().fadeIn(800); - }else{ + // if( $.buildAddForm ){ + // $('#content').html($.buildAddForm(data.data)); + // $('#formBox').hide().fadeIn(800); + // }else{ $.getScript(JS_PATH + '/template/form.js', function (){ $('#content').html($.buildAddForm(data.data)); $('#formBox').hide().fadeIn(800); }); - } + // } } if( data.data.tempType == 'edit' ){ if( $.buildEditForm ){ diff --git a/public/admin/static/js/template/form.js b/public/admin/static/js/template/form.js index e245d12..f83c7d1 100644 --- a/public/admin/static/js/template/form.js +++ b/public/admin/static/js/template/form.js @@ -2,28 +2,132 @@ * Created by 7d-vision on 2016/11/7. */ (function ($) { - - $.buildForm = function ( formObj ) { - var formHtml = '
'; - - formHtml += '
'; - return formHtml; + /** + * 创建新增表单 + * @param formObj + * @returns {string} + */ + $.buildAddForm = function ( formObj ) { + return buildForm(formObj, 'box-success'); }; + /** + * 创建编辑表单 + * @param formObj + * @returns {string} + */ + $.buildEditForm = function ( formObj ) { + return buildForm(formObj, 'box-warning'); + }; + + /** + * 根据规则创建表单 + * @param formObj 表单数据对象 + * @param boxType box样式 + * @returns {string} + */ + function buildForm( formObj, boxType ) { + var formHtml = '
'; + formHtml += '

新增菜单

'; + formHtml += '
'; + $.each(formObj.formList, function (index, value) { + switch (value.module){ + case 'text': + formHtml += buildInput(value); + break; + case 'select': + formHtml += buildSelect(value); + break; + case 'radio': + formHtml += buildRadio(value); + break; + } + }); + formHtml += '
'; + return formHtml; + } + + /** + * 创建文本框 + * @param inputObj + * @returns {string} + */ function buildInput( inputObj ) { - + var formHtml = '
'; + var placeholder = '', value = ''; + if( inputObj.attr.placeholder && inputObj.attr.placeholder.length ){ + placeholder = 'placeholder="'+ inputObj.attr.placeholder +'"'; + } + if( inputObj.attr.value && inputObj.attr.value.length ){ + value = 'value="'+ inputObj.attr.value +'"'; + } + formHtml += '
'; + if( inputObj.description && inputObj.description.length ){ + formHtml += '
'+ inputObj.description +'
'; + } + formHtml += '
'; + return formHtml; } - function buildButton( buttonObj ) { - + /** + * 创建单选框 + * @param radioObj + * @returns {string} + */ + function buildRadio( radioObj ) { + var formHtml = '
'; + formHtml += '
'; + formHtml += '
'; + if( radioObj.attr.options ){ + $.each(radioObj.attr.options, function (index, value) { + if( index == radioObj.attr.value ){ + formHtml += ' '; + }else{ + formHtml += ' '; + } + }); + } + formHtml += '
'; + if( radioObj.description && radioObj.description.length ){ + formHtml += '
'+ radioObj.description +'
'; + } + formHtml += '
'; + return formHtml; } - function buildTextarea() { + function buildTextarea( textareaObj ) { } - - function buildSelect() { - + + /** + * 创建下拉菜单 + * @param selectObj + * @returns {string} + */ + function buildSelect( selectObj ) { + var formHtml = '
'; + formHtml += '
'; + if( selectObj.attr.options ){ + formHtml += ''; + } + formHtml += '
'; + if( selectObj.description && selectObj.description.length ){ + formHtml += '
'+ selectObj.description +'
'; + } + formHtml += '
'; + return formHtml; } function buildEditors() {