新增Table.api.formatter.buttons方法

优化管理员列表和分组列表显示
btn-dialog,btn-addtabs,btn-ajax的URL新增{ids}可替换为表格选中项
禁用分类管理下的排序
新增Trace开启的情况下Ajax不打印trace信息
优化新增、编辑按钮,可动态传参到Layer弹窗
pull/9/head
Karson 2017-08-17 23:41:58 +08:00
parent 6b4cb9c52a
commit 07a16a6797
14 changed files with 131 additions and 43 deletions

View File

@ -34,13 +34,10 @@ class Ajax extends Backend
public function lang() public function lang()
{ {
header('Content-Type: application/javascript'); header('Content-Type: application/javascript');
$callback = $this->request->get('callback');
$controllername = input("controllername"); $controllername = input("controllername");
//默认只加载了控制器对应的语言名,你还根据控制器名来加载额外的语言包 //默认只加载了控制器对应的语言名,你还根据控制器名来加载额外的语言包
$this->loadlang($controllername); $this->loadlang($controllername);
//强制输出JSON Object return jsonp(Lang::get(), 200, [], ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]);
$result = 'define(' . json_encode(Lang::get(), JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . ');';
return $result;
} }
/** /**

View File

@ -43,6 +43,7 @@ class Admin extends Backend
} }
$this->childrenIds = array_keys($groupdata); $this->childrenIds = array_keys($groupdata);
$this->view->assign('groupdata', $groupdata); $this->view->assign('groupdata', $groupdata);
$this->assignconfig("admin", ['id' => $this->auth->id]);
} }
/** /**
@ -59,7 +60,7 @@ class Admin extends Backend
->field('uid,group_id') ->field('uid,group_id')
->where('group_id', 'in', $this->childrenIds) ->where('group_id', 'in', $this->childrenIds)
->select(); ->select();
$adminGroupName = []; $adminGroupName = [];
foreach ($authGroupList as $k => $v) foreach ($authGroupList as $k => $v)
{ {

View File

@ -32,12 +32,14 @@ class Group extends Backend
// 取出所有分组 // 取出所有分组
$grouplist = model('AuthGroup')->all(['status' => 'normal']); $grouplist = model('AuthGroup')->all(['status' => 'normal']);
$objlist = []; $objlist = [];
$group_ids = [];
foreach ($groups as $K => $v) foreach ($groups as $K => $v)
{ {
// 取出包含自己的所有子节点 // 取出包含自己的所有子节点
$childrenlist = Tree::instance()->init($grouplist)->getChildren($v['id'], TRUE); $childrenlist = Tree::instance()->init($grouplist)->getChildren($v['id'], TRUE);
$obj = Tree::instance()->init($childrenlist)->getTreeArray($v['pid']); $obj = Tree::instance()->init($childrenlist)->getTreeArray($v['pid']);
$objlist = array_merge($objlist, Tree::instance()->getTreeList($obj)); $objlist = array_merge($objlist, Tree::instance()->getTreeList($obj));
$group_ids[] = (int) $v['group_id'];
} }
$groupdata = []; $groupdata = [];
@ -46,6 +48,7 @@ class Group extends Backend
$groupdata[$v['id']] = $v['name']; $groupdata[$v['id']] = $v['name'];
} }
$this->groupdata = $groupdata; $this->groupdata = $groupdata;
$this->assignconfig("admin", ['id' => $this->auth->id, 'group_ids' => $group_ids]);
$this->childrenIds = array_keys($groupdata); $this->childrenIds = array_keys($groupdata);
$this->view->assign('groupdata', $groupdata); $this->view->assign('groupdata', $groupdata);
} }
@ -280,7 +283,7 @@ class Group extends Backend
$state = array('selected' => in_array($v['id'], $current_rule_ids) && !in_array($v['id'], $hasChildrens)); $state = array('selected' => in_array($v['id'], $current_rule_ids) && !in_array($v['id'], $hasChildrens));
$nodelist[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => $v['title'], 'type' => 'menu', 'state' => $state); $nodelist[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => $v['title'], 'type' => 'menu', 'state' => $state);
} }
$this->success('',null,$nodelist); $this->success('', null, $nodelist);
} }
else else
{ {

View File

@ -7,10 +7,10 @@ use think\Config;
class Common class Common
{ {
public function run(&$params) public function run(&$request)
{ {
// 如果修改了index.php入口地址则需要手动修改cdnurl的值 // 如果修改了index.php入口地址则需要手动修改cdnurl的值
$cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $params->root()); $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $request->root());
// 如果未设置__CDN__则自动匹配得出 // 如果未设置__CDN__则自动匹配得出
if (!Config::get('view_replace_str.__CDN__')) if (!Config::get('view_replace_str.__CDN__'))
{ {
@ -36,6 +36,11 @@ class Common
// 如果是开发模式修改异常页的模板 // 如果是开发模式修改异常页的模板
Config::set('exception_tmpl', APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'think_exception.tpl'); Config::set('exception_tmpl', APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'think_exception.tpl');
} }
// 如果是trace模式且Ajax的情况下关闭trace
if (Config::get('app_trace') && $request->isAjax())
{
Config::set('app_trace', false);
}
} }
} }

View File

@ -596,7 +596,7 @@ table.table-template {
box-shadow: 1px 1px 50px rgba(0, 0, 0, 0.3) !important; box-shadow: 1px 1px 50px rgba(0, 0, 0, 0.3) !important;
} }
.layui-layer-fast.layui-layer-iframe { .layui-layer-fast.layui-layer-iframe {
overflow: hidden!important; overflow: visible;
} }
.layui-layer-fast .layui-layer-moves { .layui-layer-fast .layui-layer-moves {
-webkit-box-sizing: content-box; -webkit-box-sizing: content-box;
@ -607,6 +607,7 @@ table.table-template {
text-align: center!important; text-align: center!important;
padding: 10px!important; padding: 10px!important;
background: #ecf0f1; background: #ecf0f1;
overflow: hidden;
} }
.layui-layer-fast .layui-layer-btn a { .layui-layer-fast .layui-layer-btn a {
background-color: #95a5a6!important; background-color: #95a5a6!important;

File diff suppressed because one or more lines are too long

View File

@ -63,11 +63,24 @@ define(['fast', 'moment'], function (Fast, Moment) {
} }
} }
}, },
replaceids: function (elem, url) {
//如果有需要替换ids的
if (url.indexOf("{ids}") > -1) {
var ids = 0;
var tableId = $(elem).data("table-id");
if (tableId && $(tableId).size() > 0 && $(tableId).data("bootstrap.table")) {
var Table = require("table");
ids = Table.api.selectedids($(tableId)).join(",");
}
url = url.replace(/\{ids\}/g, ids);
}
return url;
}
}, },
init: function () { init: function () {
//公共代码 //公共代码
//添加ios-fix兼容iOS下的iframe //添加ios-fix兼容iOS下的iframe
if(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){ if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
$("html").addClass("ios-fix"); $("html").addClass("ios-fix");
} }
//配置Toastr的参数 //配置Toastr的参数
@ -75,28 +88,32 @@ define(['fast', 'moment'], function (Fast, Moment) {
//点击包含.btn-dialog的元素时弹出dialog //点击包含.btn-dialog的元素时弹出dialog
$(document).on('click', '.btn-dialog,.dialogit', function (e) { $(document).on('click', '.btn-dialog,.dialogit', function (e) {
e.preventDefault(); e.preventDefault();
var options = $(this).data(); var options = $(this).data() || {};
options = options ? options : {}; Backend.api.open(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr('title'), options);
Backend.api.open(Backend.api.fixurl($(this).attr('href')), $(this).attr('title'), options);
}); });
//点击包含.btn-addtabs的元素时事件 //点击包含.btn-addtabs的元素时新增选项卡
$(document).on('click', '.btn-addtabs,.addtabsit', function (e) { $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
e.preventDefault(); e.preventDefault();
Backend.api.addtabs($(this).attr("href"), $(this).attr("title")); Backend.api.addtabs(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr("title"));
}); });
//点击包含.btn-ajax的元素时事件 //点击包含.btn-ajax的元素时发送Ajax请求
$(document).on('click', '.btn-ajax,.ajaxit', function (e) { $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
e.preventDefault(); e.preventDefault();
var options = $(this).data(); var options = $(this).data();
if (typeof options.url === 'undefined' && $(this).attr("href")) { if (typeof options.url === 'undefined' && $(this).attr("href")) {
options.url = $(this).attr("href"); options.url = $(this).attr("href");
} }
options.url = Backend.api.replaceids(this, options.url);
Backend.api.ajax(options); Backend.api.ajax(options);
}); });
//修复含有fixed-footer类的body边距 //修复含有fixed-footer类的body边距
if ($(".fixed-footer").size() > 0) { if ($(".fixed-footer").size() > 0) {
$(document.body).css("padding-bottom", $(".fixed-footer").height()); $(document.body).css("padding-bottom", $(".fixed-footer").height());
} }
//修复不在iframe时layer-footer隐藏的问题
if ($(".layer-footer").size() > 0 && self === top) {
$(".layer-footer").show();
}
} }
}; };
Backend.api = $.extend(Fast.api, Backend.api); Backend.api = $.extend(Fast.api, Backend.api);

View File

@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'status', title: __("Status"), formatter: Table.api.formatter.status}, {field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime}, {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
if(row.id == 1){ if(row.id == Config.admin.id){
return ''; return '';
} }
return Table.api.formatter.operate.call(this, value, row, index); return Table.api.formatter.operate.call(this, value, row, index);

View File

@ -32,7 +32,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
events: Table.api.events.operate, events: Table.api.events.operate,
buttons: [{ buttons: [{
name: 'detail', name: 'detail',
text: 'Detail', text: __('Detail'),
icon: 'fa fa-list', icon: 'fa fa-list',
classname: 'btn btn-info btn-xs btn-detail btn-dialog', classname: 'btn btn-info btn-xs btn-detail btn-dialog',
url: 'auth/adminlog/detail' url: 'auth/adminlog/detail'

View File

@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function (
{field: 'name', title: __('Name'), align: 'left'}, {field: 'name', title: __('Name'), align: 'left'},
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, {field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
if (row.id == 1) { if (Config.admin.group_ids.indexOf(parseInt(row.id)) > -1) {
return ''; return '';
} }
return Table.api.formatter.operate.call(this, value, row, index); return Table.api.formatter.operate.call(this, value, row, index);

View File

@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit_url: 'category/edit', edit_url: 'category/edit',
del_url: 'category/del', del_url: 'category/del',
multi_url: 'category/multi', multi_url: 'category/multi',
dragsort_url: '',
table: 'category', table: 'category',
} }
}); });
@ -33,7 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'nickname', title: __('Nickname')}, {field: 'nickname', title: __('Nickname')},
{field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag}, {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag},
{field: 'image', title: __('Image'), operate: false, formatter: Table.api.formatter.image}, {field: 'image', title: __('Image'), operate: false, formatter: Table.api.formatter.image},
{field: 'weigh', title: __('Weigh'), operate: false}, {field: 'weigh', title: __('Weigh')},
{field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status}, {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
] ]

View File

@ -6774,11 +6774,24 @@ define('backend',['fast', 'moment'], function (Fast, Moment) {
} }
} }
}, },
replaceids: function (elem, url) {
//如果有需要替换ids的
if (url.indexOf("{ids}") > -1) {
var ids = 0;
var tableId = $(elem).data("table-id");
if (tableId && $(tableId).size() > 0 && $(tableId).data("bootstrap.table")) {
var Table = require("table");
ids = Table.api.selectedids($(tableId)).join(",");
}
url = url.replace(/\{ids\}/g, ids);
}
return url;
}
}, },
init: function () { init: function () {
//公共代码 //公共代码
//添加ios-fix兼容iOS下的iframe //添加ios-fix兼容iOS下的iframe
if(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){ if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
$("html").addClass("ios-fix"); $("html").addClass("ios-fix");
} }
//配置Toastr的参数 //配置Toastr的参数
@ -6786,28 +6799,32 @@ define('backend',['fast', 'moment'], function (Fast, Moment) {
//点击包含.btn-dialog的元素时弹出dialog //点击包含.btn-dialog的元素时弹出dialog
$(document).on('click', '.btn-dialog,.dialogit', function (e) { $(document).on('click', '.btn-dialog,.dialogit', function (e) {
e.preventDefault(); e.preventDefault();
var options = $(this).data(); var options = $(this).data() || {};
options = options ? options : {}; Backend.api.open(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr('title'), options);
Backend.api.open(Backend.api.fixurl($(this).attr('href')), $(this).attr('title'), options);
}); });
//点击包含.btn-addtabs的元素时事件 //点击包含.btn-addtabs的元素时新增选项卡
$(document).on('click', '.btn-addtabs,.addtabsit', function (e) { $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
e.preventDefault(); e.preventDefault();
Backend.api.addtabs($(this).attr("href"), $(this).attr("title")); Backend.api.addtabs(Backend.api.replaceids(this, $(this).attr('href')), $(this).attr("title"));
}); });
//点击包含.btn-ajax的元素时事件 //点击包含.btn-ajax的元素时发送Ajax请求
$(document).on('click', '.btn-ajax,.ajaxit', function (e) { $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
e.preventDefault(); e.preventDefault();
var options = $(this).data(); var options = $(this).data();
if (typeof options.url === 'undefined' && $(this).attr("href")) { if (typeof options.url === 'undefined' && $(this).attr("href")) {
options.url = $(this).attr("href"); options.url = $(this).attr("href");
} }
options.url = Backend.api.replaceids(this, options.url);
Backend.api.ajax(options); Backend.api.ajax(options);
}); });
//修复含有fixed-footer类的body边距 //修复含有fixed-footer类的body边距
if ($(".fixed-footer").size() > 0) { if ($(".fixed-footer").size() > 0) {
$(document.body).css("padding-bottom", $(".fixed-footer").height()); $(document.body).css("padding-bottom", $(".fixed-footer").height());
} }
//修复不在iframe时layer-footer隐藏的问题
if ($(".layer-footer").size() > 0 && self === top) {
$(".layer-footer").show();
}
} }
}; };
Backend.api = $.extend(Fast.api, Backend.api); Backend.api = $.extend(Fast.api, Backend.api);
@ -7858,14 +7875,14 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
// 添加按钮事件 // 添加按钮事件
$(toolbar).on('click', Table.config.addbtn, function () { $(toolbar).on('click', Table.config.addbtn, function () {
var ids = Table.api.selectedids(table); var ids = Table.api.selectedids(table);
Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add')); Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add'), $(this).data() || {});
}); });
// 批量编辑按钮事件 // 批量编辑按钮事件
$(toolbar).on('click', Table.config.editbtn, function () { $(toolbar).on('click', Table.config.editbtn, function () {
var ids = Table.api.selectedids(table); var ids = Table.api.selectedids(table);
//循环弹出多个编辑框 //循环弹出多个编辑框
$.each(ids, function (i, j) { $.each(ids, function (i, j) {
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit'), $(this).data() || {});
}); });
}); });
// 批量操作按钮事件 // 批量操作按钮事件
@ -7929,7 +7946,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
}); });
$(table).on("click", "[data-id].btn-edit", function (e) { $(table).on("click", "[data-id].btn-edit", function (e) {
e.preventDefault(); e.preventDefault();
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit'), $(this).data() || {});
}); });
$(table).on("click", "[data-id].btn-del", function (e) { $(table).on("click", "[data-id].btn-del", function (e) {
e.preventDefault(); e.preventDefault();
@ -7966,7 +7983,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
'click .btn-editone': function (e, value, row, index) { 'click .btn-editone': function (e, value, row, index) {
e.stopPropagation(); e.stopPropagation();
var options = $(this).closest('table').bootstrapTable('getOptions'); var options = $(this).closest('table').bootstrapTable('getOptions');
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit'), $(this).data() || {});
}, },
'click .btn-delone': function (e, value, row, index) { 'click .btn-delone': function (e, value, row, index) {
e.stopPropagation(); e.stopPropagation();
@ -8085,11 +8102,33 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') { if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
return true; return true;
} }
if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
return true;
}
var attr = table.data("operate-" + j.name); var attr = table.data("operate-" + j.name);
if (typeof attr === 'undefined' || attr) { if (typeof attr === 'undefined' || attr) {
if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) { //自动加上ids
return true; j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
} url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;';
classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one';
icon = j.icon ? j.icon : '';
text = j.text ? j.text : '';
title = j.title ? j.title : text;
html.push('<a href="' + url + '" class="' + classname + '" title="' + title + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>');
}
});
return html.join(' ');
},
buttons: function (value, row, index) {
var table = this.table;
// 操作配置
var options = table ? table.bootstrapTable('getOptions') : {};
// 默认按钮组
var buttons = $.extend([], this.buttons || []);
var html = [];
$.each(buttons, function (i, j) {
var attr = table.data("buttons-" + j.name);
if (typeof attr === 'undefined' || attr) {
//自动加上ids //自动加上ids
j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : ''; j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;'; url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;';

View File

@ -153,14 +153,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
// 添加按钮事件 // 添加按钮事件
$(toolbar).on('click', Table.config.addbtn, function () { $(toolbar).on('click', Table.config.addbtn, function () {
var ids = Table.api.selectedids(table); var ids = Table.api.selectedids(table);
Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add')); Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add'), $(this).data() || {});
}); });
// 批量编辑按钮事件 // 批量编辑按钮事件
$(toolbar).on('click', Table.config.editbtn, function () { $(toolbar).on('click', Table.config.editbtn, function () {
var ids = Table.api.selectedids(table); var ids = Table.api.selectedids(table);
//循环弹出多个编辑框 //循环弹出多个编辑框
$.each(ids, function (i, j) { $.each(ids, function (i, j) {
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit'), $(this).data() || {});
}); });
}); });
// 批量操作按钮事件 // 批量操作按钮事件
@ -224,7 +224,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}); });
$(table).on("click", "[data-id].btn-edit", function (e) { $(table).on("click", "[data-id].btn-edit", function (e) {
e.preventDefault(); e.preventDefault();
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit'), $(this).data() || {});
}); });
$(table).on("click", "[data-id].btn-del", function (e) { $(table).on("click", "[data-id].btn-del", function (e) {
e.preventDefault(); e.preventDefault();
@ -261,7 +261,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
'click .btn-editone': function (e, value, row, index) { 'click .btn-editone': function (e, value, row, index) {
e.stopPropagation(); e.stopPropagation();
var options = $(this).closest('table').bootstrapTable('getOptions'); var options = $(this).closest('table').bootstrapTable('getOptions');
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit')); Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit'), $(this).data() || {});
}, },
'click .btn-delone': function (e, value, row, index) { 'click .btn-delone': function (e, value, row, index) {
e.stopPropagation(); e.stopPropagation();
@ -380,11 +380,33 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') { if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
return true; return true;
} }
if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
return true;
}
var attr = table.data("operate-" + j.name); var attr = table.data("operate-" + j.name);
if (typeof attr === 'undefined' || attr) { if (typeof attr === 'undefined' || attr) {
if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) { //自动加上ids
return true; j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
} url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;';
classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one';
icon = j.icon ? j.icon : '';
text = j.text ? j.text : '';
title = j.title ? j.title : text;
html.push('<a href="' + url + '" class="' + classname + '" title="' + title + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>');
}
});
return html.join(' ');
},
buttons: function (value, row, index) {
var table = this.table;
// 操作配置
var options = table ? table.bootstrapTable('getOptions') : {};
// 默认按钮组
var buttons = $.extend([], this.buttons || []);
var html = [];
$.each(buttons, function (i, j) {
var attr = table.data("buttons-" + j.name);
if (typeof attr === 'undefined' || attr) {
//自动加上ids //自动加上ids
j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : ''; j.url = j.url ? j.url + (j.url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;'; url = j.url ? Fast.api.fixurl(j.url) : 'javascript:;';

View File

@ -621,7 +621,8 @@ table.table-template{
box-shadow: 1px 1px 50px rgba(0,0,0,.3)!important; box-shadow: 1px 1px 50px rgba(0,0,0,.3)!important;
} }
&.layui-layer-iframe { &.layui-layer-iframe {
overflow:hidden!important; //overflow:hidden!important;
overflow:visible;
} }
.layui-layer-moves{ .layui-layer-moves{
.box-sizing(content-box); .box-sizing(content-box);
@ -631,6 +632,7 @@ table.table-template{
text-align: center!important; text-align: center!important;
padding: 10px!important; padding: 10px!important;
background: #ecf0f1; background: #ecf0f1;
overflow:hidden;
a { a {
background-color: #95a5a6!important; background-color: #95a5a6!important;
border-color: #95a5a6!important; border-color: #95a5a6!important;