mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 完成表格样式自动适配
This commit is contained in:
parent
a48b7c4bf7
commit
802c5b5006
@ -57,18 +57,18 @@ class Menu extends Base {
|
|||||||
[
|
[
|
||||||
'info' => '编辑',
|
'info' => '编辑',
|
||||||
'href' => url('Menu/edit'),
|
'href' => url('Menu/edit'),
|
||||||
'class'=> 'success',
|
'class'=> 'btn-warning',
|
||||||
'param'=> [$this->primaryKey],
|
'param'=> [$this->primaryKey],
|
||||||
'icon' => 'check',
|
'icon' => 'fa fa-pencil',
|
||||||
'confirm' => 0,
|
'confirm' => 0,
|
||||||
'show' => ''
|
'show' => ''
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'info' => '删除',
|
'info' => '删除',
|
||||||
'href' => url('Menu/del'),
|
'href' => url('Menu/del'),
|
||||||
'class'=> 'danger',
|
'class'=> 'btn-danger',
|
||||||
'param'=> [$this->primaryKey],
|
'param'=> [$this->primaryKey],
|
||||||
'icon' => 'trash',
|
'icon' => 'fa fa-trash',
|
||||||
'confirm' => 1,
|
'confirm' => 1,
|
||||||
'show' => ''
|
'show' => ''
|
||||||
]
|
]
|
||||||
@ -109,17 +109,7 @@ class Menu extends Base {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'data' => [
|
'data' => [] //这个数据应该是从数据库中查出来
|
||||||
[
|
|
||||||
'id' => 1,
|
|
||||||
'name' => '测试',
|
|
||||||
'url' => 'ssssss',
|
|
||||||
'type' => 1,
|
|
||||||
'hide' => 1,
|
|
||||||
'level' => 3,
|
|
||||||
'sort' => 4
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
$this->result($table,200);
|
$this->result($table,200);
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,7 @@
|
|||||||
var topHtml = '<div class="btn-group margin-bottom">';
|
var topHtml = '<div class="btn-group margin-bottom">';
|
||||||
if( tableObj.topButton ){
|
if( tableObj.topButton ){
|
||||||
$.each(tableObj.topButton, function(index, value) {
|
$.each(tableObj.topButton, function(index, value) {
|
||||||
if( value.confirm ){
|
topHtml += createButton(value);
|
||||||
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>';
|
topHtml += '</div>';
|
||||||
@ -67,16 +60,21 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function buildDataList( tableObj ) {
|
function buildDataList( tableObj ) {
|
||||||
|
var paramStr;
|
||||||
var dataListHtml = '<tr><td><input type="checkbox"></td>';
|
var dataListHtml = '<tr><td><input type="checkbox"></td>';
|
||||||
$.each(tableObj.data, function (dataIndex, dataValue) {
|
$.each(tableObj.data, function (dataIndex, dataValue) {
|
||||||
$.each(tableObj.header, function (fieldIndex, fieldValue) {
|
$.each(tableObj.header, function (fieldIndex, fieldValue) {
|
||||||
var fieldName = fieldValue.field;
|
var fieldName = fieldValue.field;
|
||||||
if( fieldName == 'action' ){
|
if( fieldName == 'action' ){
|
||||||
|
dataListHtml += '<td><div class="btn-group">';
|
||||||
|
$.each(tableObj.rightButton, function(buttonIndex, buttonValue) {
|
||||||
|
dataListHtml += createButton(buttonValue, dataValue);
|
||||||
|
});
|
||||||
|
dataListHtml += '</div></td>';
|
||||||
}else{
|
}else{
|
||||||
if( tableObj.typeRule[fieldName] ){
|
if( tableObj.typeRule[fieldName] ){
|
||||||
var rule = tableObj.typeRule[fieldName];
|
var rule = tableObj.typeRule[fieldName];
|
||||||
var styleList ,detailInfo, paramStr;
|
var styleList ,detailInfo;
|
||||||
switch (rule.module){
|
switch (rule.module){
|
||||||
case 'label':
|
case 'label':
|
||||||
if( rule.rule[dataValue[fieldName]] ){
|
if( rule.rule[dataValue[fieldName]] ){
|
||||||
@ -107,6 +105,22 @@
|
|||||||
return dataListHtml;
|
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 = '<button url="'+buttonValue.href+'" data="'+paramStr+'" type="button" class="btn '+buttonValue.class+'"><i class="'+buttonValue.icon+'"></i> '+buttonValue.info+'</button>';
|
||||||
|
}else{
|
||||||
|
buttonStr = '<button url="'+buttonValue.href+'" data="'+paramStr+'" type="button" class="btn '+buttonValue.class+'">'+buttonValue.info+'</button>';
|
||||||
|
}
|
||||||
|
return buttonStr;
|
||||||
|
}
|
||||||
|
|
||||||
function prepareInfo( styleList, dataValue, fieldName ) {
|
function prepareInfo( styleList, dataValue, fieldName ) {
|
||||||
var detailInfo;
|
var detailInfo;
|
||||||
if( styleList['info'] && styleList['info'].length ){
|
if( styleList['info'] && styleList['info'].length ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user