| | |
| | | table = layui.table, |
| | | form = layui.form; |
| | | var tableSelect = function () { |
| | | this.v = '1.3.0'; |
| | | this.v = '1.4.0'; |
| | | }; |
| | | |
| | | /** |
| | |
| | | var elem = $(opt.elem); |
| | | |
| | | //é»è®¤è®¾ç½® |
| | | opt.searchKey = opt.searchKey || 'keyword'; |
| | | 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) { |
| | |
| | | } |
| | | |
| | | }) |
| | | // 鲿彿° |
| | | function debounce(func, wait) { |
| | | let timeout; |
| | | return function () { |
| | | const context = this, args = arguments; |
| | | clearTimeout(timeout); |
| | | timeout = setTimeout(() => func.apply(context, args), wait); |
| | | }; |
| | | } |
| | | |
| | | |
| | | //è¾å
¥æ¡è¾å
¥æ§è¡ |
| | | elem.off('input').on('input', function (e) { |
| | | elem.off('input').on('input', debounce( |
| | | function (e) { |
| | | // 黿¢è¡¨åæäº¤ï¼å¦æè¾å
¥æ¡å¨è¡¨åå
ï¼ |
| | | e.preventDefault(); |
| | | 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 + " and " + opt.searchKey + " like '%" + elem.val() + "%' "; |
| | | opt.table.where['sWhere'] = opt.sWhere + sWhereStr; |
| | | tableSelect_table.reload({ |
| | | where: opt.table.where, |
| | | page: { |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | var sWhere = opt.sWhere + " and " + opt.searchKey + " like '%" + elem.val() + "%' "; |
| | | var sWhere = opt.sWhere + sWhereStr; |
| | | tableSelect_table.reload({ |
| | | data: opt.ajaxSelect(sWhere) |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | },200)) |
| | | |
| | | //åå»è¡éä¸ |
| | | table.on('rowDouble('+tableName+')', function(obj){ |