vaeThink2/public/static/admin_static/lib/jquery.bsgrid/builds/merged/grid.all.min.js

13 lines
59 KiB
JavaScript
Raw Permalink Normal View History

2020-04-01 11:45:12 +08:00
/**
* jQuery.bsgrid v1.38 by @Baishui2004
* Copyright 2014 Apache v2 License
* https://github.com/baishui2004/jquery.bsgrid
*/
String.prototype.startWith=function(a){if(a==null||a==""||this.length==0||a.length>this.length){return false}else{return this.substr(0,a.length)==a}};String.prototype.endWith=function(a){if(a==null||a==""||this.length==0||a.length>this.length){return false}else{return this.substring(this.length-a.length)==a}};String.prototype.replaceAll=function(a,b){return this.replace(new RegExp(a,"gm"),b)};function StringBuilder(){if(arguments.length){this.append.apply(this,arguments)}}StringBuilder.prototype=function(){var c=Array.prototype.join,d=Array.prototype.slice,a=/\{(\d+)\}/g,b=function(){return c.call(this,"")};return{constructor:StringBuilder,length:0,append:Array.prototype.push,appendFormat:function(e){var g=0,f=d.call(arguments,1);this.append(a.test(e)?e.replace(a,function(h,j){return f[j]}):e.replace(/\?/g,function(){return f[g++]}));return this},size:function(){return this.toString().length},toString:b,valueOf:b}}();
$.bsgrid={param:function(c,b){if(b==undefined){b=false}if(!b){return $.param(c)}var d=new StringBuilder();if(c instanceof Array){$.each(c,function(f,e){d.append("&"+e.name+"=");d.append(encodeURIComponent(encodeURIComponent(e.value)))})}else{for(var a in c){d.append("&"+a+"=");d.append(encodeURIComponent(encodeURIComponent(c[a])))}}return d.length>0?d.toString().substring(1):""},getKeysString:function(c,a){if(a==undefined){a=","}var d=new StringBuilder();if(c instanceof Array){$.each(c,function(f,e){if((d.toString()+a).indexOf(a+e.name+a)==-1){d.append(a+e.name)}})}else{for(var b in c){d.append(a+b)}}return d.length>0?d.toString().substring(1):""},forcePushPropertyInObject:function(b,a,c){if(b.hasOwnProperty(a)){b[a+"_f"]=c}else{b[a]=c}},adaptAttrOrProp:function(b,d,c){var a=parseInt($.fn.jquery.substring(0,$.fn.jquery.indexOf(".",2)).replace(".",""));if(c==undefined){if(a>=16){return b.prop(d)}else{return b.attr(d)}}else{if(a>=16){b.prop(d,c)}else{b.attr(d,c)}}},alert:function(a){alert(a)}};
(function(a){a.fn.bsgrid_paging={defaults:{loopback:false,pageSize:20,pageSizeSelect:false,pageSizeForGrid:[5,10,20,25,50,100,200,500],pageIncorrectTurnAlert:true,pagingLittleToolbar:false,pagingBtnClass:"pagingBtn",pagingMinWidth:"auto",pagingBtnShowState:{select:true,first:true,prev:true,next:true,last:true,gotoBtn:true,refresh:true}},pagingObjs:{},init:function(h,g){var d={settings:a.extend(true,{},a.fn.bsgrid_paging.defaults,g),pagingId:h,totalRowsId:h+"_totalRows",totalPagesId:h+"_totalPages",curPageId:h+"_curPage",gotoPageInputId:h+"_gotoPageInput",gotoPageId:h+"_gotoPage",refreshPageId:h+"_refreshPage",pageSizeId:h+"_pageSize",firstPageId:h+"_firstPage",prevPageId:h+"_prevPage",nextPageId:h+"_nextPage",lastPageId:h+"_lastPage",startRowId:h+"_startRow",endRowId:h+"_endRow",totalRows:0,totalPages:0,curPage:1,curPageRowsNum:0,startRow:0,endRow:0};if(g.pageSizeForGrid!=undefined){d.settings.pageSizeForGrid=g.pageSizeForGrid}var b={options:d,page:function(i){a.fn.bsgrid_paging.page(i,d)},getCurPage:function(){return a.fn.bsgrid_paging.getCurPage(d)},refreshPage:function(){a.fn.bsgrid_paging.refreshPage(d)},firstPage:function(){a.fn.bsgrid_paging.firstPage(d)},prevPage:function(){a.fn.bsgrid_paging.prevPage(d)},nextPage:function(){a.fn.bsgrid_paging.nextPage(d)},lastPage:function(){a.fn.bsgrid_paging.lastPage(d)},gotoPage:function(i){a.fn.bsgrid_paging.gotoPage(d,i)},createPagingToolbar:function(){return a.fn.bsgrid_paging.createPagingToolbar(d)},setPagingToolbarEvents:function(){a.fn.bsgrid_paging.setPagingToolbarEvents(d)},dynamicChangePagingButtonStyle:function(){a.fn.bsgrid_paging.dynamicChangePagingButtonStyle(d)},setPagingValues:function(j,i){a.fn.bsgrid_paging.setPagingValues(j,i,d)}};a.fn.bsgrid_paging.pagingObjs[h]=b;a("#"+h).append(b.createPagingToolbar());if(d.settings.pageSizeSelect){if(a.inArray(d.settings.pageSize,d.settings.pageSizeForGrid)==-1){d.settings.pageSizeForGrid.push(d.settings.pageSize)}d.settings.pageSizeForGrid.sort(function(j,i){return j-i});var f=new StringBuilder();for(var e=0;e<d.settings.pageSizeForGrid.length;e++){var c=d.settings.pageSizeForGrid[e];f.append('<option value="'+c+'">'+c+"</option>")}a("#"+d.pageSizeId).html(f.toString()).val(d.settings.pageSize)}b.setPagingToolbarEvents();return b},getPagingObj:function(c){var b=a.fn.bsgrid_paging.pagingObjs[c];return b?b:null},page:function(c,b){var d=a.fn.bsgrid.getGridObj(b.settings.gridId);d.options.settings.pageSize=b.settings.pageSize;a.fn.bsgrid.page(c,d.options)},getCurPage:function(b){var c=a("#"+b.curPageId).html();return c==""?1:c},refreshPage:function(b){a.fn.bsgrid_paging.page(a.fn.bsgrid_paging.getCurPage(b),b)},firstPage:function(b){var c=a.fn.bsgrid_paging.getCurPage(b);if(c<=1){a.fn.bsgrid_paging.incorrectTurnAlert(b,a.bsgridLanguage.isFirstPage);return}a.fn.bsgrid_paging.page(1,b)},prevPage:function(b){var c=a.fn.bsgrid_paging.getCurPage(b);if(c<=1){if(b.settings.loopback&&b.totalPages>0){a.fn.bsgrid_paging.page(b.totalPages,b);return}else{a.fn.bsgrid_paging.incorrectTurnAlert(b,a.bsgridLanguage.isFirstPage);return}}a.fn.bsgrid_paging.page(parseInt(c)-1,b)},nextPage:function(b){var c=a.fn.bsgrid_paging.getCurPage(b);if(c>=b.totalPages){if(b.settings.loopback&&c>0){a.fn.bsgrid_paging.page(1,b);return}else{a.fn.bsgrid_paging.incorrectTurnAlert(b,a.bsgridLanguage.isLastPage);return}}a.fn.bsgrid_paging.page(parseInt(c)+1,b)},lastPage:function(b){var c=a.fn.bsgrid_paging.getCurPage(b);if(c>=b.totalPages){a.fn.bsgrid_paging.incorrectTurnAlert(b,a.bsgridLanguage.isLastPage);return}a.fn.bsgrid_paging.page(b.totalPages,b)},gotoPage:function(b,c){if(c==undefined){c=a("#"+b.gotoPageInputId).val()}if(a.trim(c)==""||isNaN(c)){a.fn.bsgrid_paging.alert(a.bsgridLanguage.needInteger)}else{if(parseInt(c)<1||parseInt(c)>b.totalPages){a.fn.bsgrid_paging.alert(a.bsgridLanguage.needRange(1,b.totalPages))}else{a("#"+b.gotoPageInputId).val(c);a.fn.bsgrid_paging.page(parseInt(c),b)}}},incorrectTurnAlert:function(b,c){if(b.settings.pageIncorrectTurnAlert){a.fn.bsgrid_paging.alert(c)}},alert:function(c){try{a.bsgrid.alert(c)}catch(b){alert(c)}},c
(function($){$.fn.bsgrid={version:"1.38-preview",defaults:{dataType:"json",dataTrim:true,ajaxType:"post",localData:false,url:"",otherParames:false,autoLoad:true,pageAll:false,showPageToolbar:true,pageSize:20,pageSizeSelect:false,pageSizeForGrid:[5,10,20,25,50,100,200,500],pageIncorrectTurnAlert:true,multiSort:false,displayBlankRows:true,lineWrap:false,stripeRows:false,rowHoverColor:false,rowSelectedColor:true,pagingLittleToolbar:false,pagingToolbarAlign:"right",pagingBtnClass:"pagingBtn",displayPagingToolbarOnlyMultiPages:false,isProcessLockScreen:true,longLengthAotoSubAndTip:true,colsProperties:{align:"center",maxLength:40,indexAttr:"w_index",sortAttr:"w_sort",alignAttr:"w_align",lengthAttr:"w_length",renderAttr:"w_render",hiddenAttr:"w_hidden",tipAttr:"w_tip"},requestParamsName:{pageSize:"pageSize",curPage:"curPage",sortName:"sortName",sortOrder:"sortOrder"},beforeSend:function(options,XMLHttpRequest){},complete:function(options,XMLHttpRequest,textStatus){},processUserdata:function(userdata,options){},event:{selectRowEvent:false,unselectRowEvent:false,customRowEvents:{},customCellEvents:{}},extend:{initGridMethods:{},beforeRenderGridMethods:{},renderPerColumnMethods:{},renderPerRowMethods:{},afterRenderGridMethods:{}},additionalBeforeRenderGrid:function(parseSuccess,gridData,options){},additionalRenderPerColumn:function(record,rowIndex,colIndex,tdObj,trObj,options){},additionalRenderPerRow:function(record,rowIndex,trObj,options){},additionalAfterRenderGrid:function(parseSuccess,gridData,options){}},gridObjs:{},init:function(gridId,settings){if(!$("#"+gridId).hasClass("bsgrid")){$("#"+gridId).addClass("bsgrid")}var options={settings:$.extend(true,{},$.fn.bsgrid.defaults,settings),gridId:gridId,noPagingationId:gridId+"_no_pagination",pagingOutTabId:gridId+"_pt_outTab",pagingId:gridId+"_pt",sortName:"",sortOrder:"",otherParames:settings.otherParames,totalRows:0,totalPages:0,curPage:1,curPageRowsNum:0,startRow:0,endRow:0};if($("#"+gridId).find("thead").length==0){$("#"+gridId).prepend("<thead></thead>");$("#"+gridId).find("tr:lt("+($("#"+gridId+" tr").length-$("#"+gridId+" tfoot tr").length)+")").appendTo($("#"+gridId+" thead"))}if($("#"+gridId).find("tbody").length==0){$("#"+gridId+" thead").after("<tbody></tbody>")}if($("#"+gridId).find("tfoot").length==0){$("#"+gridId).append('<tfoot style="display: none;"></tfoot>')}options.columnsModel=$.fn.bsgrid.initColumnsModel(options);if(settings.pageSizeForGrid!=undefined){options.settings.pageSizeForGrid=settings.pageSizeForGrid}options.settings.dataType=options.settings.dataType.toLowerCase();if(options.settings.pageSizeSelect){if($.inArray(options.settings.pageSize,options.settings.pageSizeForGrid)==-1){options.settings.pageSizeForGrid.push(options.settings.pageSize)}options.settings.pageSizeForGrid.sort(function(a,b){return a-b})}var gridObj={options:options,getCondition:function(){return $.fn.bsgrid.getPageCondition(options.curPage,options)},getPageCondition:function(curPage){return $.fn.bsgrid.getPageCondition(curPage,options)},page:function(curPage){$.fn.bsgrid.page(curPage,options)},search:function(params){$.fn.bsgrid.search(options,params)},loadGridData:function(dataType,gridData){$.fn.bsgrid.loadGridData(dataType,gridData,options)},loadRowData:function(record,rowIndex,trObj){$.fn.bsgrid.loadRowData(options,record,rowIndex,trObj)},reloadLocalData:function(localData){$.fn.bsgrid.reloadLocalData(localData,options)},getPageSize:function(){return options.settings.pageSize},getTotalRows:function(){return options.totalRows},getTotalPages:function(){return options.totalPages},getCurPage:function(){return options.curPage},getCurPageRowsNum:function(){return options.curPageRowsNum},getStartRow:function(){return options.startRow},getEndRow:function(){return options.endRow},getSortName:function(){return options.sortName},getSortOrder:function(){return options.sortOrder},getRows:function(){return $.fn.bsgrid.getRows(options)},getRow:function(row){return $.fn.bsgrid.getRow(row,options)},getRowCells:function(row){return $.fn.bsgrid.getRowCells(row,options)},getColCells:function(col)
(function($){$.fn.bsgrid.defaults.extend.settings={supportGridEdit:false,supportGridEditTriggerEvent:"rowClick",supportColumnMove:false,searchConditionsContainerId:"",fixedGridHeader:false,fixedGridHeight:"320px",gridEditConfigs:{text:{build:function(edit,value,record,rowIndex,colIndex,tdObj,trObj,options){return value+'<input class="bsgrid_editgrid_edit" type="'+edit+'" value="'+value+'"/>'},val:function(formObj){return formObj.val()}},checkbox:{build:function(edit,value,record,rowIndex,colIndex,tdObj,trObj,options){return value+'<input class="bsgrid_editgrid_checkbox" type="'+edit+'" value="'+value+'"/>'},val:function(formObj){return formObj.val()}},textarea:{build:function(edit,value,record,rowIndex,colIndex,tdObj,trObj,options){return value+'<textarea class="bsgrid_editgrid_edit">'+value+"</textarea>"},val:function(formObj){return formObj.val()}}}};$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.hidden=$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.text;$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.password=$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.text;$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.radio=$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.text;$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.button=$.fn.bsgrid.defaults.extend.settings.gridEditConfigs.text;$.extend(true,$.fn.bsgrid.defaults.colsProperties,{lineNumberAttr:"w_num",checkAttr:"w_check",editAttr:"w_edit",aggAttr:"w_agg"});$.fn.bsgrid.defaults.event.customCellEditEvents={};$.fn.bsgrid.extendInitGrid={};$.fn.bsgrid.extendBeforeRenderGrid={};$.fn.bsgrid.extendRenderPerRow={};$.fn.bsgrid.extendRenderPerColumn={};$.fn.bsgrid.extendAfterRenderGrid={};$.fn.bsgrid.extendOtherMethods={};$.fn.bsgrid.extendInitGrid.initGridExtendOptions=function(gridId,options){var columnsModel=options.columnsModel;var colsProperties=options.settings.colsProperties;$.fn.bsgrid.getGridHeaderObject(options).each(function(i){columnsModel[i].lineNumber=$.trim($(this).attr(colsProperties.lineNumberAttr));columnsModel[i].check=$.trim($(this).attr(colsProperties.checkAttr));columnsModel[i].edit=$.trim($(this).attr(colsProperties.editAttr))});if($("#"+options.gridId+" tfoot tr td["+colsProperties.aggAttr+"!='']").length!=0){$("#"+options.gridId+" tfoot tr td").each(function(i){columnsModel[i].aggName="";columnsModel[i].aggIndex="";var aggInfo=$.trim($(this).attr(colsProperties.aggAttr));if(aggInfo.length!=0){var aggInfoArray=aggInfo.split(",");columnsModel[i].aggName=aggInfoArray[0].toLocaleLowerCase();columnsModel[i].aggIndex=aggInfoArray.length>1?aggInfoArray[1]:""}})}if($.fn.bsgrid.getGridHeaderObject(options).filter("["+colsProperties.lineNumberAttr+"$='line']").length!=0){options.settings.extend.afterRenderGridMethods.renderLineNumber=$.fn.bsgrid.extendAfterRenderGrid.renderLineNumber}if($.fn.bsgrid.getGridHeaderObject(options).filter("["+colsProperties.checkAttr+"='true']").length!=0){options.settings.extend.initGridMethods.initGridCheck=$.fn.bsgrid.extendInitGrid.initGridCheck;options.settings.extend.renderPerColumnMethods.renderCheck=$.fn.bsgrid.extendRenderPerColumn.renderCheck;options.settings.extend.afterRenderGridMethods.addCheckChangedEvent=$.fn.bsgrid.extendAfterRenderGrid.addCheckChangedEvent}if(options.settings.extend.settings.supportGridEdit){options.settings.extend.renderPerColumnMethods.renderForm=$.fn.bsgrid.extendRenderPerColumn.renderForm;options.settings.extend.afterRenderGridMethods.addGridEditEvent=$.fn.bsgrid.extendAfterRenderGrid.addGridEditEvent;options.settings.extend.afterRenderGridMethods.setOptionsFirstRowClone=$.fn.bsgrid.extendAfterRenderGrid.setOptionsFirstRowClone;var gridObj=$.fn.bsgrid.getGridObj(gridId);gridObj.activeGridEditMode=function(){return $.fn.bsgrid.defaults.extend.activeGridEditMode(options)};gridObj.getChangedRowsIndexs=function(){return $.fn.bsgrid.defaults.extend.getChangedRowsIndexs(options)};gridObj.getChangedRowsOldRecords=function(){return $.fn.bsgrid.defaults.extend.getChangedRowsOldRecords(options)};gridObj.getRowsChangedColumnsValue=function(){return $.fn.bsgrid.defaults.ext
(function(a){a.bsgrid_export={defaults:{url:"",exportFileName:"export",colsProperties:{width:100,align:"center",exportAttr:"w_export",indexAttr:"w_index",widthAttr:"width",alignAttr:"w_align"},colWidthPercentmultiplier:14,requestParamsName:{exportFileName:"exportFileName",colNames:"dataNames",colIndexs:"dataIndexs",colWidths:"dataLengths",colAligns:"dataAligns"}},doExport:function(h,o,d){if(o==undefined){o={}}var c={};if(d==undefined){d={}}a.extend(true,c,a.bsgrid_export.defaults,d);var n="",g="",m="",j="";for(var f=0;f<h.length;f++){if(a.trim(h.eq(f).attr(c.colsProperties.exportAttr))!="false"){n=n+","+a.trim(h.eq(f).text());g=g+","+a.trim(h.eq(f).attr(c.colsProperties.indexAttr));var l=a.trim(h.eq(f).attr(c.colsProperties.widthAttr)).toLocaleLowerCase();var e=c.colsProperties.width;if(isNaN(l)){if(l.endWith("px")){e=parseInt(l.replace("px",""))}else{if(l.endWith("%")){l=l.replace("%","");if(!isNaN(l)){e=c.colWidthPercentmultiplier*parseInt(l)}}}}m=m+","+e;var k=a.trim(h.eq(f).attr(c.colsProperties.alignAttr));if(k==""){k=c.colsProperties.align}j=j+","+k}}var b;if((typeof o).toLowerCase()=="string"||o instanceof String){b=(o.startWith("&")?o.substring(1):o)}else{b=a.bsgrid.param(o,true)}document.location.href=c.url+(c.url.indexOf("?")<0?"?":"&")+c.requestParamsName.exportFileName+"="+encodeURIComponent(encodeURIComponent(c.exportFileName))+"&"+c.requestParamsName.colNames+"="+encodeURIComponent(encodeURIComponent(n.substring(1)))+"&"+c.requestParamsName.colIndexs+"="+g.substring(1)+"&"+c.requestParamsName.colWidths+"="+m.substring(1)+"&"+c.requestParamsName.colAligns+"="+j.substring(1)+(b.length==0?"":("&"+b))}}})(jQuery);