作者 Karson

采用新的URL方式来实现刷新返回之前的页面

移除示例中冗余的元素
修复commonsearch中searchit不兼容select的BUG
修复jsname为空时的BUG
... ... @@ -17,6 +17,6 @@
<div class="hide layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="reset" class="btn btn-primary btn-embossed btn-close">{:__('Close')}</button>
<button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -92,9 +92,11 @@ class Backend extends Controller
!defined('IS_AJAX') && define('IS_AJAX', $this->request->isAjax());
// 非选项卡时重定向
if (!IS_AJAX && !IS_ADDTABS && !IS_DIALOG && !in_array($controllername, ['index', 'ajax']))
if (!$this->request->isPost() && !IS_AJAX && !IS_ADDTABS && !IS_DIALOG && input("ref") == 'addtabs')
{
$url = $this->request->url();
$url = preg_replace_callback("/([\?|&]+)ref=addtabs(&?)/i", function($matches) {
return $matches[2] == '&' ? $matches[1] : '';
}, $this->request->url());
$this->redirect('index/index', [], 302, ['referer' => $url]);
exit;
}
... ...
... ... @@ -89,7 +89,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
'click .btn-ip': function (e, value, row, index) {
var options = $("#table").bootstrapTable('getOptions');
//这里我们手动将数据填充到表单然后提交
$("#commonSearchContent_" + options.idTable + " form input[name='ip']").val(value);
$("#commonSearchContent_" + options.idTable + " form [name='ip']").val(value);
$("#commonSearchContent_" + options.idTable + " form").trigger('submit');
Toastr.info("执行了自定义搜索操作");
}
... ...
... ... @@ -25,7 +25,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'title', title: __('Title')},
{field: 'ip', title: __('IP')},
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
return Table.api.formatter.operate(value, row, index, table);
}
}
]
],
onLoadSuccess: function (data) {
... ...
... ... @@ -26,7 +26,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'title', title: __('Title')},
{field: 'ip', title: __('IP'), formatter: Controller.api.formatter.ip},
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
return Table.api.formatter.operate(value, row, index, table);
}
}
]
]
});
... ...
... ... @@ -28,7 +28,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'admin.nickname', title: __('Nickname'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'},
{field: 'ip', title: __('IP'), operate: '='},
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
return Table.api.formatter.operate(value, row, index, table);
}
}
]
],
});
... ... @@ -41,7 +44,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
edit: function () {
Form.api.bindevent($("form[role=form]"));
}
},
};
return Controller;
});
\ No newline at end of file
... ...
... ... @@ -266,10 +266,13 @@
});
that.$container.on("click", "." + that.options.searchClass, function () {
$("form [name='" + $(this).data("field") + "']", searchContainer).val($(this).data("value"));
$("form", searchContainer).trigger("submit");
var obj = $("form [name='" + $(this).data("field") + "']", searchContainer);
if (obj.size() > 0) {
obj.val($(this).data("value"));
$("form", searchContainer).trigger("submit");
}
});
var searchquery = getSearchQuery(this);
this.options.queryParams = function (params) {
return {
... ...
... ... @@ -174,12 +174,14 @@ require(['jquery', 'bootstrap'], function ($, undefined) {
}
});
//加载相应模块
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
console.error(e);
// 这里可捕获模块加载的错误
});
if (Config.jsname) {
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
console.error(e);
// 这里可捕获模块加载的错误
});
}
});
});
});
... ...
... ... @@ -188,12 +188,14 @@ require(['jquery', 'bootstrap'], function ($, undefined) {
}
});
//加载相应模块
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
console.error(e);
// 这里可捕获模块加载的错误
});
if (Config.jsname) {
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
console.error(e);
// 这里可捕获模块加载的错误
});
}
});
});
});
... ... @@ -7480,10 +7482,13 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
});
that.$container.on("click", "." + that.options.searchClass, function () {
$("form [name='" + $(this).data("field") + "']", searchContainer).val($(this).data("value"));
$("form", searchContainer).trigger("submit");
var obj = $("form [name='" + $(this).data("field") + "']", searchContainer);
if (obj.size() > 0) {
obj.val($(this).data("value"));
$("form", searchContainer).trigger("submit");
}
});
var searchquery = getSearchQuery(this);
this.options.queryParams = function (params) {
return {
... ... @@ -10940,6 +10945,17 @@ define('form',['jquery', 'bootstrap', 'backend', 'toastr', 'upload', 'validator'
formClass: 'n-default n-bootstrap',
msgClass: 'n-right',
stopOnError: true,
display: function (elem) {
return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
},
target: function (input) {
var $formitem = $(input).closest('.form-group'),
$msgbox = $formitem.find('span.msg-box');
if (!$msgbox.length) {
$msgbox = $('<span class="msg-box"></span>').insertAfter(input);
}
return $msgbox;
},
valid: function (ret) {
//验证通过提交表单
Form.api.submit($(ret), onBeforeSubmit, function (data) {
... ... @@ -11198,7 +11214,8 @@ $.fn.addtabs = function (options) {
document.title = title;
if (history.pushState && !$(this).data("pushstate")) {
window.history.pushState(state, title, url);
var pushurl = url.indexOf("ref=addtabs") == -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
window.history.pushState(state, title, pushurl);
}
$(this).data("pushstate", null);
_add({
... ...
... ... @@ -170,11 +170,13 @@ require(['jquery', 'bootstrap'], function ($, undefined) {
}
});
//加载相应模块
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
// 这里可捕获模块加载的错误
});
if (Config.jsname) {
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
// 这里可捕获模块加载的错误
});
}
});
});
});
... ...
... ... @@ -184,11 +184,13 @@ require(['jquery', 'bootstrap'], function ($, undefined) {
}
});
//加载相应模块
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
// 这里可捕获模块加载的错误
});
if (Config.jsname) {
require([Config.jsname], function (Controller) {
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
}, function (e) {
// 这里可捕获模块加载的错误
});
}
});
});
});
... ...