mirror of https://gitee.com/karson/fastadmin.git
优化基类控制器Traits的方法
parent
0a164777fe
commit
481256dff3
|
|
@ -200,7 +200,10 @@ trait Backend
|
|||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
$ids = $this->request->post("ids");
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
|
|
@ -237,6 +240,10 @@ trait Backend
|
|||
*/
|
||||
public function destroy($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
|
|
@ -273,6 +280,10 @@ trait Backend
|
|||
*/
|
||||
public function restore($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
|
|
@ -307,8 +318,10 @@ trait Backend
|
|||
*/
|
||||
public function multi($ids = "")
|
||||
{
|
||||
$ids = $ids ? $ids : $this->request->param("ids");
|
||||
$ids = $this->request->param("ids");
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
if ($this->request->has('params')) {
|
||||
parse_str($this->request->post("params"), $values);
|
||||
|
|
|
|||
|
|
@ -11388,11 +11388,28 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
});
|
||||
return false;
|
||||
});
|
||||
//还原或删除
|
||||
$(document).on('click', Table.config.restoreallbtn + ',' + Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
|
||||
//全部还原
|
||||
$(document).on('click', Table.config.restoreallbtn, function () {
|
||||
var that = this;
|
||||
var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
|
||||
Fast.api.ajax(url, function () {
|
||||
Layer.closeAll();
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh');
|
||||
}, function () {
|
||||
Layer.closeAll();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
//销毁或删除
|
||||
$(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
|
||||
var that = this;
|
||||
var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
|
||||
var row = Fast.api.getrowbyindex(table, $(that).data("row-index"));
|
||||
Fast.api.ajax({
|
||||
url: url,
|
||||
data: {ids: row[options.pk]}
|
||||
}, function () {
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh');
|
||||
});
|
||||
|
|
@ -11504,7 +11521,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
var options = table.bootstrapTable('getOptions');
|
||||
var data = element ? $(element).data() : {};
|
||||
ids = ($.isArray(ids) ? ids.join(",") : ids);
|
||||
var url = typeof data.url !== "undefined" ? Table.api.replaceurl(data.url, {ids: ids}, table) : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
|
||||
options = {url: url, data: {action: action, ids: ids, params: params}};
|
||||
Fast.api.ajax(options, function (data, ret) {
|
||||
|
|
|
|||
|
|
@ -328,11 +328,28 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
});
|
||||
return false;
|
||||
});
|
||||
//还原或删除
|
||||
$(document).on('click', Table.config.restoreallbtn + ',' + Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
|
||||
//全部还原
|
||||
$(document).on('click', Table.config.restoreallbtn, function () {
|
||||
var that = this;
|
||||
var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
|
||||
Fast.api.ajax(url, function () {
|
||||
Layer.closeAll();
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh');
|
||||
}, function () {
|
||||
Layer.closeAll();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
//销毁或删除
|
||||
$(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
|
||||
var that = this;
|
||||
var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
|
||||
var row = Fast.api.getrowbyindex(table, $(that).data("row-index"));
|
||||
Fast.api.ajax({
|
||||
url: url,
|
||||
data: {ids: row[options.pk]}
|
||||
}, function () {
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh');
|
||||
});
|
||||
|
|
@ -444,7 +461,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
var options = table.bootstrapTable('getOptions');
|
||||
var data = element ? $(element).data() : {};
|
||||
ids = ($.isArray(ids) ? ids.join(",") : ids);
|
||||
var url = typeof data.url !== "undefined" ? Table.api.replaceurl(data.url, {ids: ids}, table) : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
|
||||
options = {url: url, data: {action: action, ids: ids, params: params}};
|
||||
Fast.api.ajax(options, function (data, ret) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue