123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- /*********************************************打桩 成功************************************/
- /*
- *创建jquery插件:quickgridAndSingleRecode
- */
- (function ($) {
- $.fn.quickgridAndSingleRecode = function (opt) {
- var gridAndSingleRecode=new GridAndSingleRecode(opt);
- gridAndSingleRecode.createGridAndSingleRecode(this.attr("id"));
- return gridAndSingleRecode;
-
- };
-
- })(jQuery);
- /*********************************************打桩 成功 *********************************************/
-
- /*
- *创建jquery插件:quickSingleRecode
- */
- (function($) {
- $.fn.quickSingleRecode = function(opt,grid) {
- var singleRecode=new SingleRecode(opt);
- singleRecode.createSingleRecode(this.attr("id"),grid);
- return gridAndSingleRecode;
- };
-
- })(jQuery);
- /*
- *创建jquery插件:quickPaper
- */
- (function($) {
- $.fn.quickPaper = function(opt,grid) {
- var paperObject=new PaperObject(opt,grid);
- /////////
- paperObject.createPaper(this.attr("id"));
- return paperObject;
- };
-
- })(jQuery);
- /*
- *创建jquery插件:quickPaper
- */
- (function($) {
- $.fn.quickToolBar = function(opt,grid) {
- var toolBar=new ToolBar(opt);
- toolBar.createToolBar(this.attr("id"),grid);
- return toolBar;
- };
-
- })(jQuery);
-
- /*********************************************打桩 成功 *********************************************/
- /*
- *创建SingleRecodejQuery对象
- *
- */
- function ToolBar(opt){
- var defaults = {};
- this.options=$.extend(defaults, opt);
- this.common;
- }
-
- ToolBar.prototype.createToolBar=function(con_id,grid){
- this.common=grid;
- $("#"+con_id).append("<div id='toolbar_operation' class='_operation'></div>");
- var items=this.options.items
- for(var item in items){
- $("#toolbar_operation").append("<div class='_line'></div>");
- if(items[item].line==null){
- $("#toolbar_operation").append("<div><a href='javascript:;'><span class="+items[item].iconClass+">"+items[item].text+"</span></a></div>");
- if(items[item].params==null){
- $("#toolbar_operation div:last-child").on("click",items[item].click);
- }else{
- $("#toolbar_operation div:last-child").on("click",{params:items[item].params},items[item].click);
- }
- }
- if(items[item].line==true){
- $("#toolbar_operation").append("<div class='_line'>|</div>");
- }
- }
- $("#toolBar_id").append("<div class='_ToolBar_id_change'><ul><li><a id='toolBar_singleRecode' href='javascript:;'><span class='icon_view'>单条记录视图</span></a></li>" +
- "<li><a id='toolBar_grid' href='javascript:;'><span class='icon_view'>grid表格视图</span></a></li></ul></div><div class='_clear'></div>")
-
- }
- ToolBar.prototype.bindEvent=function(onId,stateData,fn_event){
- $("#"+onId).on("click",{state:stateData},fn_event);
- }
-
-
- /*********************************************打桩 成功 *********************************************/
- /*
- *创建SingleRecodejQuery对象
- *
- */
- function SingleRecode(opt){
- var defaults = {};
- this.options=$.extend(defaults, opt);
- }
-
- SingleRecode.prototype.createSingleRecode=function(con_id,grid){
- $("#"+con_id).empty();
- for (var record in grid.records){
- var cloumnData=grid.records[record];
- $("#"+con_id).append("<ul id="+JSON.stringify(record)+"></ul>");
- var columns=grid.options.columns;
- for(var i=0;i<columns.length;i++){
- var column=columns[i];
- var record_str=JSON.stringify(record);
- var id_str = record_str.substring(1, record_str.length-1);
- if(column.hide==null){
- $("#"+id_str).append("<li ><span>"+column.display+": </span><p name='"+column.name+"' ><a href='javascript:;' title='"+cloumnData[column.name]+"'>"+cloumnData[column.name]+"</a></p></li>");
-
- }
- }
- }
- // $("#"+con_id).addClass("_form_id");
- $("#"+con_id+" ul").each(function (i){$(this).find("li").eq(0).addClass("firstLi")});
-
- }
-
- /*********************************************打桩 成功 *********************************************/
- /*
- *创建分页对象
- *
- */
- function PaperObject(opt,grid){
- var defaults = {
- pageSize:"10",
- //total:"200",
- page:"10",
- showSelect:"false",
- selectDirection:"top",
- selectData:'{"list":[{"key":10,"value":10},{"key":20,"value":20},{"key":50,"value":50},{"key":100,"value":100}]}',
- inputPosition:"center",
- showNumber:"1",
- centerPageNum:"4"
- };
- this.options = $.extend(defaults, opt);
- var papergrid=grid;
- }
- PaperObject.prototype.createPaper=function(papercon_id){
- $("#"+papercon_id).append("<div class='pageArrow _pageArrow' total='200' id='page'></div>");
- $("#page").attr(this.options);
- $("#page").render();
- // $("#page").on("pageChange",{aa:"num"},function(e,index){
- // alert(index);
- // alert(e.data.aa);
- // alert($(this).attr("pageSize"));
- // });
- // $("#page").bind("sizeChange",function(e,num){
- // alert(num);
- // });
- }
- PaperObject.prototype.bindEvent=function(gridAndSingleRecodeObject,fn_changePage){
- $("#page").on("pageChange",{gridAndSingleRecode:gridAndSingleRecodeObject},fn_changePage);
- $("#page").on("sizeChange",{gridAndSingleRecode:gridAndSingleRecodeObject},
- function(e,num){
- gridAndSingleRecodeObject.grid.setOptions({pageSize:num});
- gridAndSingleRecodeObject.grid.setOptions({page:1});
- //alert(typeof gridAndSingleRecodeObject.paper.options.page);
- gridAndSingleRecodeObject.paper.options.page=0;
- $("#page").render();
- //alert(gridAndSingleRecodeObject.paper.options.page);
- $.post(gridAndSingleRecodeObject.grid.options.url,
- {"listId" : "321","condition" :"IS_DEL=0","pager.pageNo":1, "pager.pageSize":$(this).attr("pageSize")},
- function(result){
- $("#page").attr("total",result["pager.totalRows"]);
- $("#page").render();
- gridAndSingleRecodeObject.grid.setOptions({data : result});
- gridAndSingleRecodeObject.grid.loadData();
- gridAndSingleRecodeObject.singleRecode=$("#singleRecode_id").quickSingleRecode(gridAndSingleRecodeObject.options.singleRecodeOptions,gridAndSingleRecodeObject.grid);
-
- },"json");
- //alert("pagesize:"+num);
- //alert("page:"+parseInt($(this).attr("page")));
- // e.data.gridAndSingleRecode.grid.setOptions({pageSize:num});
- // e.data.gridAndSingleRecode.grid.setOptions({page:1});
- // alert(111);
- // alert(e.data.gridAndSingleRecode.grid.options.page);
- // //alert("grid表格每页数据:"+e.data.gridAndSingleRecode.grid.options.pageSize);
- // e.data.gridAndSingleRecode.grid.loadData();
- // gridAndSingleRecodeObject.singleRecode=$("#singleRecode_id").quickSingleRecode(gridAndSingleRecodeObject.options.singleRecodeOptions,gridAndSingleRecodeObject.grid);
- //// fn_changePage({data:{gridAndSingleRecode:gridAndSingleRecodeObject}},parseInt($(this).attr("page")));
- //// $("#page").on("pageChange",{gridAndSingleRecode:gridAndSingleRecodeObject},fn_changePage({data:{gridAndSingleRecode:gridAndSingleRecodeObject}},parseInt($(this).attr("page")));
- });
-
- }
- /*********************************************打桩 成功 *********************************************/
- /*
- *创建GridAndSingleRecode对象
- *
- */
- function GridAndSingleRecode(opt){
- var defaults = {gridOptions:{},
- singleRecodeOptions:{},
- paperOpration:{},
- toolBarOprations:{}
- };
- this.options = $.extend(defaults, opt);
- this.singleRecode;
- this.grid;
- this.paper;
- this.toolBar;
- }
- //创建实例
- GridAndSingleRecode.prototype.createGridAndSingleRecode=function (con_id){
- var content_id=con_id;
- $("#"+content_id).append("<div id='toolBar_id' class='_ToolBar_id'></div><div class='_clear'></div>");
- $("#"+content_id).append("<div id='main_content' class='_main_content'></div>");
- $("#main_content").append("<div id='grid_id' class='_grid_id'></div>");
- $("#main_content").append("<div id='singleRecode_id' class='_form_id'></div>");
- $("#"+content_id).append("<div id='paper_id' class='_paper_id'></div>");
- this.grid=$("#grid_id").quiGrid(this.options.gridOptions);
- // function writeObj(obj){
- // var description = "";
- // for(var i in obj){
- // var property=obj[i];
- // description+=i+" = "+property+"\n";
- // }
- // alert(description);
- // }
- // alert(typeof this.grid.records.data);
- // alert( writeObj(this.grid.records))
- //alert( this.grid.records.data["pager.totalRows"]);
- //alert(typeof this.grid.options.data["form.paginate.totalRows"]);
- //$("#grid_id div[class='l-panel-bar']").hide();
- this.toolBar=$("#toolBar_id").quickToolBar(this.options.toolBarOptions,this.grid);
- $("#singleRecode_id").hide();
-
- this.paper=$("#paper_id").quickPaper(this.options.paperOpration,this.grid);
- this.toolBar.bindEvent("toolBar_singleRecode",{num:2,gridAndSingleRecodeParam:this},this.changeView);
- this.toolBar.bindEvent("toolBar_grid",{num:1,gridAndSingleRecodeParam:this},this.changeView);
- this.changePage(this,changePage);
- }
- //改变状态
- GridAndSingleRecode.prototype.changeView=function(event){
- if(0==event.data.state.num%2){
- event.data.state.gridAndSingleRecodeParam.singleRecode=$("#singleRecode_id").quickSingleRecode(event.data.state.gridAndSingleRecodeParam.options.singleRecodeOptions,event.data.state.gridAndSingleRecodeParam.grid);
- $("#grid_id").hide();
- $("#singleRecode_id").show();
- };
- if(1==event.data.state.num%2){
- $("#singleRecode_id").hide();
- $("#grid_id").show();
- };
- }
- GridAndSingleRecode.prototype.rendPaper=function(){
- alert("!!!!"+$("span[class='l-bar-text']").text())
- var mountStr=$("span[class='l-bar-text']").text();
- var mount=mountStr.substring(mountStr.lastIndexOf('总')+1,mountStr.lastIndexOf('条'));
- alert(parseInt(mount));
- $("#page").attr("total",parseInt(mount));
- $("#page").render();
- alert(this.paper.total);
- }
-
- //改变数据
- GridAndSingleRecode.prototype.changeData=function(){
- singleRecode=$("#singleRecode_id").quickSingleRecode(this.options.ingleRecodeOptions,grid);
- }
- GridAndSingleRecode.prototype.changePage=function(gridAndSingleRecodeObject,fn_change){
- var gridAndSingleRecode=gridAndSingleRecodeObject;
- this.paper.bindEvent(gridAndSingleRecode,fn_change);
- }
-
- function changePage(e,index){
- $.post(e.data.gridAndSingleRecode.grid.options.url,
- $.extend(e.data.gridAndSingleRecode.grid.options.params,{"pager.pageNo":index+1, "pager.pageSize":$(this).attr("pageSize")}),
- function(result){
- $("#page").attr("total",result["pager.totalRows"]);
- $("#page").render();
- e.data.gridAndSingleRecode.grid.setOptions({ data : result});
- e.data.gridAndSingleRecode.grid.loadData();
-
- e.data.gridAndSingleRecode.singleRecode=$("#singleRecode_id").quickSingleRecode(e.data.gridAndSingleRecode.options.singleRecodeOptions,e.data.gridAndSingleRecode.grid);
- },"json");
-
- }
-
-
|