From 00a863b6f3aab1bd05bbdc143b8fa4cf72b7416d Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 18 十一月 2025 09:15:06 +0800
Subject: [PATCH] 1
---
WebTM/layuiadmin/modules/tableSelect.js | 86 +++++++++++++++++-------------------------
1 files changed, 35 insertions(+), 51 deletions(-)
diff --git a/WebTM/layuiadmin/modules/tableSelect.js b/WebTM/layuiadmin/modules/tableSelect.js
index 0c64501..6d7fa06 100644
--- a/WebTM/layuiadmin/modules/tableSelect.js
+++ b/WebTM/layuiadmin/modules/tableSelect.js
@@ -23,9 +23,10 @@
opt.searchKey = opt.searchKey || 'keyword';//鍙涓敤锛屽垎鍓�
opt.table.page = opt.table.page || false;
opt.table.height = opt.table.height || 290;
- elem.off('click').on('click', function(e) {
+ elem.off('keyup').on('keyup', function(e) {
e.stopPropagation();
- if($('div.tableSelect').length >= 1){
+ //杈撳叆瀛楃灏忎簬浜屾垨鑰呯壒娈婃寜閽笉鏄剧ず
+ if ($('div.tableSelect').length >= 1 || elem.val().length <= 2 || event.key == "F7" || event.key == "F8" || event.key == "F6") {
return false;
}
@@ -44,10 +45,15 @@
opt.table.elem = "#"+tableName;
opt.table.id = tableName;
//鑻ユ病鏈塽rl琛ㄧず涓哄墠绔垎椤�
- if (opt.table.url != undefined) {
- opt.table.where['sWhere'] = opt.sWhere
- } else {
- opt.table.data = opt.ajaxSelect(opt.sWhere);
+ //if (opt.table.url != undefined) {
+ // opt.table.where['sWhere'] = opt.sWhere
+ //} else {
+ // opt.table.data = opt.ajaxSelect(opt.sWhere);
+ //}
+ //璁╀竴娆″姞杞芥樉绀烘暟鎹�
+ //褰撳瓧绗﹂暱搴︾瓑浜�3鏃剁涓�娆″姞杞�
+ if (elem.val().length == 3) {
+ searchFirst()
}
opt.table.request={//璁剧疆椤靛弬鏁�
pageName: 'page', // 椤电爜鐨勫弬鏁板悕绉帮紝榛樿锛歱age
@@ -61,51 +67,8 @@
"data": res.data // 瑙f瀽鏁版嵁鍒楄〃
};
}
- //鐢╦ump鏇夸唬鍘熸潵琛ㄦ牸pagejump鐢ㄤ簬鏇存柊鎸夐挳閫変腑鏁伴噺姝ゅ姛鑳藉彂鐜版棤鐢ㄥ垹闄�
- //opt.table.done = function (res, curr, count, origin) {
- // this.page.jump = jump;
- //}
var tableSelect_table = table.render(opt.table);
-
- //jump鍒嗛〉瑙﹀彂鍑芥暟
- //function jump(obj, first) {
- // table.reload(tableName);
- // //鏇存柊鎸夐挳
- // updataButton(table.checkStatus(tableName).data.length)
- //}
-
- //鏇存柊閫変腑鏁伴噺
- function updataButton (n) {
- tableBox.find('.tableSelect_btn_select span').html(n==0?'':'('+n+')')
- }
-
- //鏁扮粍鍘婚噸
- function uniqueObjArray(arr, type){
- var newArr = [];
- var tArr = [];
- if(arr.length == 0){
- return arr;
- }else{
- if(type){
- for(var i=0;i<arr.length;i++){
- if(!tArr[arr[i][type]]){
- newArr.push(arr[i]);
- tArr[arr[i][type]] = true;
- }
- }
- return newArr;
- }else{
- for(var i=0;i<arr.length;i++){
- if(!tArr[arr[i]]){
- newArr.push(arr[i]);
- tArr[arr[i]] = true;
- }
- }
- return newArr;
- }
- }
- }
//FIX浣嶇疆濡備綍涓嬮潰鏀句笉涓嬫斁涓婇潰
var overHeight = (elem.offset().top + elem.outerHeight() + tableBox.outerHeight() - $(window).scrollTop()) > $(window).height();
@@ -176,7 +139,27 @@
timeout = setTimeout(() => func.apply(context, args), wait);
};
}
-
+ //鎼滅储鍑芥暟绗竴娆″姞杞�
+ function searchFirst() {
+ var searchKeyList = opt.searchKey.split(',');//鑾峰彇鏌ユ壘鐨勫叧閿瓧鎼滅储妗�
+ //鎷兼帴sql瀛楃涓�
+ var sWhereStr = " and ("
+ searchKeyList.forEach(function (value, index) {
+ if (index == 0) {
+ sWhereStr += (value + " like '%" + elem.val() + "%' ")
+ } else {
+ sWhereStr += ("or " + value + " like '%" + elem.val() + "%' ")
+ }
+ })
+ sWhereStr += ")"
+ //鍚庣鍒嗛〉鎼滅储
+ if (opt.table.where != undefined) {
+ opt.table.where['sWhere'] = opt.sWhere + sWhereStr;
+ } else {
+ var sWhere = opt.sWhere + sWhereStr;
+ opt.table.data = opt.ajaxSelect(sWhere);
+ }
+ }
//杈撳叆妗嗚緭鍏ユ墽琛�
elem.off('input').on('input', debounce(
@@ -210,7 +193,7 @@
});
}
- },200))
+ },500))
//鍙屽嚮琛岄�変腑
table.on('rowDouble('+tableName+')', function(obj){
@@ -261,6 +244,7 @@
opt.done(elem, checkStatus);
tableBox.remove();
delete table.cache[tableName];
+ $(opt.elem).blur();
}
//鐐瑰嚮鍏朵粬鍖哄煙鍏抽棴
--
Gitblit v1.9.1