From 802c5b5006abf9a11cec383bdab2bf3eeb59f3d8 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Tue, 8 Nov 2016 17:29:02 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E6=88=90=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=87=AA=E5=8A=A8=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Menu.php | 20 ++++---------- public/admin/static/js/template/table.js | 34 +++++++++++++++++------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index c9bb726..29fe0fb 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -57,18 +57,18 @@ class Menu extends Base { [ 'info' => '编辑', 'href' => url('Menu/edit'), - 'class'=> 'success', + 'class'=> 'btn-warning', 'param'=> [$this->primaryKey], - 'icon' => 'check', + 'icon' => 'fa fa-pencil', 'confirm' => 0, 'show' => '' ], [ 'info' => '删除', 'href' => url('Menu/del'), - 'class'=> 'danger', + 'class'=> 'btn-danger', 'param'=> [$this->primaryKey], - 'icon' => 'trash', + 'icon' => 'fa fa-trash', 'confirm' => 1, 'show' => '' ] @@ -109,17 +109,7 @@ class Menu extends Base { ] ] ], - 'data' => [ - [ - 'id' => 1, - 'name' => '测试', - 'url' => 'ssssss', - 'type' => 1, - 'hide' => 1, - 'level' => 3, - 'sort' => 4 - ] - ] + 'data' => [] //这个数据应该是从数据库中查出来 ]; $this->result($table,200); } diff --git a/public/admin/static/js/template/table.js b/public/admin/static/js/template/table.js index 7ad95e0..157dfa2 100644 --- a/public/admin/static/js/template/table.js +++ b/public/admin/static/js/template/table.js @@ -47,14 +47,7 @@ var topHtml = '
'; if( tableObj.topButton ){ $.each(tableObj.topButton, function(index, value) { - if( value.confirm ){ - value.class += ' confirm'; - } - if( value.icon ){ - topHtml += ''; - }else{ - topHtml += ''; - } + topHtml += createButton(value); }); } topHtml += '
'; @@ -67,16 +60,21 @@ * @returns {string} */ function buildDataList( tableObj ) { + var paramStr; var dataListHtml = ''; $.each(tableObj.data, function (dataIndex, dataValue) { $.each(tableObj.header, function (fieldIndex, fieldValue) { var fieldName = fieldValue.field; if( fieldName == 'action' ){ - + dataListHtml += '
'; + $.each(tableObj.rightButton, function(buttonIndex, buttonValue) { + dataListHtml += createButton(buttonValue, dataValue); + }); + dataListHtml += '
'; }else{ if( tableObj.typeRule[fieldName] ){ var rule = tableObj.typeRule[fieldName]; - var styleList ,detailInfo, paramStr; + var styleList ,detailInfo; switch (rule.module){ case 'label': if( rule.rule[dataValue[fieldName]] ){ @@ -107,6 +105,22 @@ return dataListHtml; } + function createButton( buttonValue, dataValue ) { + var paramStr = '', buttonStr = ''; + if( buttonValue.confirm ){ + buttonValue.class += ' confirm'; + } + if( dataValue ){ + paramStr = prepareParamStr( buttonValue, dataValue ); + } + if( buttonValue.icon ){ + buttonStr = ''; + }else{ + buttonStr = ''; + } + return buttonStr; + } + function prepareInfo( styleList, dataValue, fieldName ) { var detailInfo; if( styleList['info'] && styleList['info'].length ){