modified 完善JS脚本,避免数据带来的语法错误

This commit is contained in:
zhaoxiang 2016-11-08 10:21:03 +08:00
parent 7493f0f0c3
commit edecf5db77
3 changed files with 11 additions and 10 deletions

View File

@ -35,10 +35,6 @@ class Menu extends Base {
[
'field' => 'sort',
'info' => '排序'
],
[
'field' => 'action',
'info' => '操作'
]
],
'topButton' => [
@ -46,14 +42,14 @@ class Menu extends Base {
'href' => url('Menu/add'),
'class'=> 'btn-success',
'info'=> '新增',
'icon' => 'plus',
'icon' => 'fa fa-plus',
'confirm' => 0,
],
[
'href' => url('Menu/del'),
'class'=> 'btn-danger',
'info'=> '删除',
'icon' => 'trash',
'icon' => 'fa fa-trash',
'confirm' => 1,
]
],

View File

@ -88,7 +88,9 @@ function refresh( url ) {
success: function(data){
if( data.code == 200 ){
if( data.data.tempType == 'table' ){
$.getScript('/static/js/template/table.js');
$.getScript('/static/js/template/table.js', function (){
$('#content').html($.buildTable(data.data));
});
}
}else{
$.alertMsg('请求失败!')

View File

@ -4,14 +4,17 @@
(function ($) {
$.buildTable = function ( tableObj ) {
var tableHtml = '<div class="box"><div class="box-body">';
if( tableObj.topButton ){
if( tableObj.rightButton && tableObj.rightButton.length ){
tableObj.header.push({field:"action",info:"操作"});
}
if( tableObj.topButton && tableObj.topButton.length ){
tableHtml += buildTopButton( tableObj );
}
tableHtml += '<table class="table table-bordered"> <tbody>';
if( tableObj.header ){
if( tableObj.header && tableObj.header.length ){
tableHtml += buildHeader( tableObj );
}
if( tableObj.data ){
if( tableObj.data && tableObj.data.length ){
tableHtml += buildDataList( tableObj );
}else{
tableHtml += buildEmptyTable( tableObj );