From 383777a7a30fcc9aa1d00612e58c404d7f250add Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Tue, 21 May 2024 16:55:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A8=E5=8D=95=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=85=B3=E9=94=AE=E5=AD=97=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=85=E7=A9=BA=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/tableUtil/initTableSearchUtil.js | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/web/src/main/resources/template/assets/lib/layui/customer/tableUtil/initTableSearchUtil.js b/web/src/main/resources/template/assets/lib/layui/customer/tableUtil/initTableSearchUtil.js index 7cf425273..181488ece 100644 --- a/web/src/main/resources/template/assets/lib/layui/customer/tableUtil/initTableSearchUtil.js +++ b/web/src/main/resources/template/assets/lib/layui/customer/tableUtil/initTableSearchUtil.js @@ -89,7 +89,7 @@ var initTableSearchUtil = { * @param keywordPlaceholder 关键字搜索的提示语 */ initTableKeyWordSearch: function (tableId, keywordPlaceholder) { - if (isNull(keywordPlaceholder)) { + if (isNull(keywordPlaceholder) || keywordPlaceholder == "暂不支持搜索") { return false; } var str; @@ -97,11 +97,13 @@ var initTableSearchUtil = { str = '
' + '' + '' + + '' + '
'; } else { str = '
' + '' + '' + + '' + '
'; } $(".winui-tool").append(str); @@ -133,6 +135,29 @@ var initTableSearchUtil = { $("#" + tableId + "SearchTable").click(); } }); + + // 搜索框内容变化事件 + $("body").on("input", "#" + tableId + "KeyWord", function () { + if (isNull($(this).val())) { + $(".clear-btn-keyword").hide(); + $(".search-btn-keyword").css({ + right: "8px" + }) + $(this).css({ + "padding-right": "35px" + }) + } else { + $(".clear-btn-keyword").show(); + $(".search-btn-keyword").css({ + right: "30px" + }) + $(this).css({ + "padding-right": "50px" + }) + } + }); + $("body").on("change", "#" + tableId + "KeyWord", function () { + }); }, /** @@ -571,6 +596,26 @@ var initTableSearchUtil = { } }); + // 清空搜索框 + $("body").on("click", ".clear-btn-keyword", function() { + var tableId = $(this).attr("id").replace('Clear', ''); + + $("#" + tableId + "KeyWord").val(''); + $(this).hide(); + $(".search-btn-keyword").css({ + right: "8px" + }) + $("#" + tableId + "KeyWord").css({ + "padding-right": "35px" + }) + + // 加载回调函数 + var mation = initTableSearchUtil.tableMap[tableId]; + if (typeof (mation.callback) == "function") { + mation.callback(); + } + }); + $("body").on("click", ".type-btn", function (e) { $(this).parent().find('.type-btn').removeClass("plan-select"); $(this).addClass("plan-select"); -- GitLab