From 7f8e8999489606e25183b60f64527066b9d70213 Mon Sep 17 00:00:00 2001 From: Karson Date: Sat, 3 Jun 2017 23:42:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E7=94=A8=E6=96=B0=E7=9A=84URL?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=9D=A5=E5=AE=9E=E7=8E=B0=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B9=8B=E5=89=8D=E7=9A=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E7=A4=BA=E4=BE=8B=E4=B8=AD=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E5=85=83=E7=B4=A0=20=E4=BF=AE=E5=A4=8Dcommon?= =?UTF-8?q?search=E4=B8=ADsearchit=E4=B8=8D=E5=85=BC=E5=AE=B9select?= =?UTF-8?q?=E7=9A=84BUG=20=E4=BF=AE=E5=A4=8Djsname=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/example/bootstraptable/detail.html | 2 +- application/common/controller/Backend.php | 6 ++- .../js/backend/example/bootstraptable.js | 2 +- .../assets/js/backend/example/colorbadge.js | 5 ++- .../js/backend/example/controllerjump.js | 5 ++- .../js/backend/example/relationmodel.js | 7 +++- .../assets/js/bootstrap-table-commonsearch.js | 9 +++-- public/assets/js/require-backend.js | 14 ++++--- public/assets/js/require-backend.min.js | 37 ++++++++++++++----- public/assets/js/require-frontend.js | 12 +++--- public/assets/js/require-frontend.min.js | 12 +++--- 11 files changed, 74 insertions(+), 37 deletions(-) diff --git a/application/admin/view/example/bootstraptable/detail.html b/application/admin/view/example/bootstraptable/detail.html index dbb26301..83d51208 100644 --- a/application/admin/view/example/bootstraptable/detail.html +++ b/application/admin/view/example/bootstraptable/detail.html @@ -17,6 +17,6 @@ \ No newline at end of file diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 55576807..ae98465e 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -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; } diff --git a/public/assets/js/backend/example/bootstraptable.js b/public/assets/js/backend/example/bootstraptable.js index 402f1c2b..26f2fffa 100644 --- a/public/assets/js/backend/example/bootstraptable.js +++ b/public/assets/js/backend/example/bootstraptable.js @@ -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("执行了自定义搜索操作"); } diff --git a/public/assets/js/backend/example/colorbadge.js b/public/assets/js/backend/example/colorbadge.js index 960c9445..323057b1 100644 --- a/public/assets/js/backend/example/colorbadge.js +++ b/public/assets/js/backend/example/colorbadge.js @@ -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) { diff --git a/public/assets/js/backend/example/controllerjump.js b/public/assets/js/backend/example/controllerjump.js index 448ed019..650355c7 100644 --- a/public/assets/js/backend/example/controllerjump.js +++ b/public/assets/js/backend/example/controllerjump.js @@ -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); + } + } ] ] }); diff --git a/public/assets/js/backend/example/relationmodel.js b/public/assets/js/backend/example/relationmodel.js index e7a33129..87471146 100644 --- a/public/assets/js/backend/example/relationmodel.js +++ b/public/assets/js/backend/example/relationmodel.js @@ -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 diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js index 9498d685..64beebb2 100644 --- a/public/assets/js/bootstrap-table-commonsearch.js +++ b/public/assets/js/bootstrap-table-commonsearch.js @@ -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 { diff --git a/public/assets/js/require-backend.js b/public/assets/js/require-backend.js index e374b16d..98548112 100644 --- a/public/assets/js/require-backend.js +++ b/public/assets/js/require-backend.js @@ -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); + // 这里可捕获模块加载的错误 + }); + } }); }); }); diff --git a/public/assets/js/require-backend.min.js b/public/assets/js/require-backend.min.js index 72b90fc4..45dcbd54 100644 --- a/public/assets/js/require-backend.min.js +++ b/public/assets/js/require-backend.min.js @@ -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 = $('').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({ diff --git a/public/assets/js/require-frontend.js b/public/assets/js/require-frontend.js index e01d3991..4134d399 100644 --- a/public/assets/js/require-frontend.js +++ b/public/assets/js/require-frontend.js @@ -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) { + // 这里可捕获模块加载的错误 + }); + } }); }); }); diff --git a/public/assets/js/require-frontend.min.js b/public/assets/js/require-frontend.min.js index 6a65d647..71b7a700 100644 --- a/public/assets/js/require-frontend.min.js +++ b/public/assets/js/require-frontend.min.js @@ -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) { + // 这里可捕获模块加载的错误 + }); + } }); }); });