| | |
| | | opt.table.height = opt.table.height || 290; |
| | | elem.off('keyup').on('keyup', function(e) { |
| | | e.stopPropagation(); |
| | | //输入字符小于二或者特殊按钮不显示 |
| | | if ($('div.tableSelect').length >= 1 || elem.val().length <= 2 || event.key == "F7" || event.key == "F8" || event.key == "F6") { |
| | | return false; |
| | | } |
| | |
| | | opt.table.elem = "#"+tableName; |
| | | opt.table.id = tableName; |
| | | //若没有url表示为前端分页 |
| | | 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', // 页码的参数名称,默认:page |
| | |
| | | "data": res.data // 解析数据列表 |
| | | }; |
| | | } |
| | | //用jump替代原来表格pagejump用于更新按钮选中数量此功能发现无用删除 |
| | | //opt.table.done = function (res, curr, count, origin) { |
| | | // this.page.jump = jump; |
| | | //} |
| | | |
| | | var tableSelect_table = table.render(opt.table); |
| | | //让一次加载显示数据 |
| | | let executed = false; |
| | | if (elem.val().length == 3 && !executed) { |
| | | executed = true; |
| | | search(); |
| | | } |
| | | //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(); |
| | |
| | | timeout = setTimeout(() => func.apply(context, args), wait); |
| | | }; |
| | | } |
| | | //搜索函数 |
| | | function search() { |
| | | //搜索函数第一次加载 |
| | | function searchFirst() { |
| | | var searchKeyList = opt.searchKey.split(',');//获取查找的关键字搜索框 |
| | | //拼接sql字符串 |
| | | var sWhereStr = " and (" |
| | |
| | | //后端分页搜索 |
| | | if (opt.table.where != undefined) { |
| | | opt.table.where['sWhere'] = opt.sWhere + sWhereStr; |
| | | tableSelect_table.reload({ |
| | | where: opt.table.where, |
| | | page: { |
| | | curr: 1 |
| | | } |
| | | }); |
| | | } else { |
| | | var sWhere = opt.sWhere + sWhereStr; |
| | | tableSelect_table.reload({ |
| | | data: opt.ajaxSelect(sWhere) |
| | | }); |
| | | opt.table.data = opt.ajaxSelect(sWhere); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | },200)) |
| | | },500)) |
| | | |
| | | //双击行选中 |
| | | table.on('rowDouble('+tableName+')', function(obj){ |