mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 完善js生成表格数据的实现
This commit is contained in:
parent
6d9bb7e319
commit
7493f0f0c3
@ -43,18 +43,18 @@ class Menu extends Base {
|
|||||||
],
|
],
|
||||||
'topButton' => [
|
'topButton' => [
|
||||||
[
|
[
|
||||||
'href' => 'Menu/add',
|
'href' => url('Menu/add'),
|
||||||
'class'=> 'am-btn-success',
|
'class'=> 'btn-success',
|
||||||
'info'=> '新增',
|
'info'=> '新增',
|
||||||
'icon' => 'plus',
|
'icon' => 'plus',
|
||||||
'ajax' => 0,
|
'confirm' => 0,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'href' => 'Menu/del',
|
'href' => url('Menu/del'),
|
||||||
'class'=> 'am-btn-danger del-all',
|
'class'=> 'btn-danger',
|
||||||
'info'=> '删除',
|
'info'=> '删除',
|
||||||
'icon' => 'trash',
|
'icon' => 'trash',
|
||||||
'ajax' => 1,
|
'confirm' => 1,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'rightButton' => [
|
'rightButton' => [
|
||||||
@ -92,15 +92,13 @@ class Menu extends Base {
|
|||||||
'module' => 'label',
|
'module' => 'label',
|
||||||
'rule' => [
|
'rule' => [
|
||||||
[
|
[
|
||||||
'info' => '显示',
|
'info' => '隐藏',
|
||||||
'class' => 'success',
|
'class' => 'warning'
|
||||||
'show' => ['hide', 1]
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'info' => '隐藏',
|
'info' => '显示',
|
||||||
'class' => 'warning',
|
'class' => 'success'
|
||||||
'show' => ['hide', 0]
|
],
|
||||||
]
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
@ -108,13 +106,11 @@ class Menu extends Base {
|
|||||||
'rule' => [
|
'rule' => [
|
||||||
[
|
[
|
||||||
'info' => '方法类功能',
|
'info' => '方法类功能',
|
||||||
'class' => 'secondary',
|
'class' => 'secondary'
|
||||||
'show' => ['type', 0]
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'info' => '模块类功能',
|
'info' => '模块类功能',
|
||||||
'class' => 'primary',
|
'class' => 'primary'
|
||||||
'show' => ['type', 1]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -16,6 +16,17 @@
|
|||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
font-family: "Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif;
|
font-family: "Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif;
|
||||||
}
|
}
|
||||||
|
.builder-data-empty {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
.no-data {
|
||||||
|
padding: 130px 0;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
.am-text-center {
|
||||||
|
text-align: center !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{block name="myStyle"}{/block}
|
{block name="myStyle"}{/block}
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
|
@ -7,31 +7,63 @@
|
|||||||
if( tableObj.topButton ){
|
if( tableObj.topButton ){
|
||||||
tableHtml += buildTopButton( tableObj );
|
tableHtml += buildTopButton( tableObj );
|
||||||
}
|
}
|
||||||
|
tableHtml += '<table class="table table-bordered"> <tbody>';
|
||||||
if( tableObj.header ){
|
if( tableObj.header ){
|
||||||
tableHtml += buildHeader( tableObj );
|
tableHtml += buildHeader( tableObj );
|
||||||
}
|
}
|
||||||
if( tableObj.data ){
|
if( tableObj.data ){
|
||||||
tableHtml += buildDataList( tableObj );
|
tableHtml += buildDataList( tableObj );
|
||||||
}else{
|
}else{
|
||||||
tableHtml += buildEmptyTable();
|
tableHtml += buildEmptyTable( tableObj );
|
||||||
}
|
}
|
||||||
tableHtml += '</div></div>';
|
tableHtml += '</tbody></table></div></div>';
|
||||||
return tableHtml;
|
return tableHtml;
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildHeader( tableObj ) {
|
function buildHeader( tableObj ) {
|
||||||
|
var headerHtml = '<tr><th style="width: 10px"><input type="checkbox"></th>';
|
||||||
|
$.each(tableObj.header, function (index, value) {
|
||||||
|
headerHtml += '<th>'+ value.info +'</th>';
|
||||||
|
});
|
||||||
|
headerHtml += '</tr>';
|
||||||
|
return headerHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTopButton( tableObj ) {
|
function buildTopButton( tableObj ) {
|
||||||
|
var topHtml = '<div class="btn-group margin-bottom">';
|
||||||
|
if( tableObj.topButton ){
|
||||||
|
$.each(tableObj.topButton, function(index, value) {
|
||||||
|
if( value.confirm ){
|
||||||
|
value.class += ' confirm';
|
||||||
|
}
|
||||||
|
if( value.icon ){
|
||||||
|
topHtml += '<button href="'+value.href+'" type="button" class="btn '+value.class+'"><i class="'+value.icon+'"></i> '+value.info+'</button>';
|
||||||
|
}else{
|
||||||
|
topHtml += '<button href="'+value.href+'" type="button" class="btn '+value.class+'">'+value.info+'</button>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
topHtml += '</div>';
|
||||||
|
return topHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDataList( tableObj ) {
|
function buildDataList( tableObj ) {
|
||||||
|
var dataListHtml = '<tr><td><input type="checkbox"></td>';
|
||||||
|
$.each(tableObj.data, function (index, value) {
|
||||||
|
dataListHtml += '<td></td>';
|
||||||
|
});
|
||||||
|
dataListHtml += '</tr>';
|
||||||
|
return dataListHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEmptyTable() {
|
function buildEmptyTable( tableObj ) {
|
||||||
|
var emptyHtml = '<tr>';
|
||||||
|
var spanNum = tableObj.header.length + 1;
|
||||||
|
emptyHtml += '<td colspan="'+spanNum+'" class="builder-data-empty">';
|
||||||
|
emptyHtml += '<div class="am-text-center no-data" >';
|
||||||
|
emptyHtml += '<i class="fa fa-cogs"></i> 暂时没有数据<br>';
|
||||||
|
emptyHtml += '<small> 本系统由<b> 七维视觉科技有限公司 </b>开发维护</small>';
|
||||||
|
emptyHtml += '</div></td></tr>';
|
||||||
|
return emptyHtml;
|
||||||
}
|
}
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user