easyui中 datagrid与pagination结合使用【记录】
/*** Js名称:客源基本管理* */ var setPageNumber = 1; var setPageSize = 10;var guestManageListData = {}; //loader var guestManageArray=[]; var guestManageLoader=function(param,success,error){if(!$.isEmptyObject(guestManageArray)){success(guestManageArray);return true;}$.ajax({url:"../channel/pglist",type:"post",dataType:"json",data:guestManageListData,success: function(data){if(data=="-3333" || data==""){success([]);return true;}guestManageArray=data;success(guestManageArray);},error:function(err){alert(err);}}); };/*搜索*/ function searchGuestManage(){var data = {};data.channelName = $('#ipt_guestName_guest_manage').textbox('getValue');data.usageState = 0;guestManageData = data;eapor.utils.defaultAjax('../channel/getChannelCount',data,gm_getPageCountCallback); }//新增 function addGuestManage(){$('#addGuestManageDiv').append(''+''+//'*客源名称 :" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*房价方案:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*客源组:" labelPosition="before" labelAlign="right" labelWidth="100" />'+''+''+//'*联系人:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*联系手机:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//''+''+''+//''+''+''+//''+''+''+//''+''+''+//' '+''+''+//''+''+'' );$('#ipt_gm_channelName').textbox({required:true,missingMessage:'客源名称不能为空!',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_rentplanId').combobox({url:'../rentplan/pglist',queryParams:{limit:9999,offset:0,rentplanName:''},valueField: 'rentplanId',textField:'rentplanName',editable:false,panelHeight: 'auto',panelMaxHeight:200,required:true,missingMessage:'房价方案不能为空!',validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_sourceGroupId').combobox({url:'../sourcegroup/pglist',queryParams:{limit:9999,offset:0,groupName:''},valueField:'sourceGroupId',textField:'sourceGroupName',editable:false,panelHeight: 'auto',panelMaxHeight:200,required:true,missingMessage:'客源组不能为空!',validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_contact').textbox({required:true,missingMessage:'联系人不能为空!',validType:"maxLength[32]",invalidMessage:'输入最大长度为32个字符',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_mobile').numberbox({required:true,missingMessage:'手机号码不能为空!',validType:'mobilephone',invalidMessage:'手机号码格式不正确,如:13700001234',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_email').textbox({validType:'email',invalidMessage:'邮箱格式输入不正确,如:123456@163.com',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_bankName').textbox({validType:'name',invalidMessage:'格式不正确,只能为中文或英文',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_bankAccount').textbox({validType:['number','length[5,30]'],delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_address').textbox({multiline:true,validType:"maxLength[64]",invalidMessage:'输入最大长度为64个字符',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gm_usageState').combobox({data:[{'id':1,'text':'使用','selected':true},{'id':2,'text':'冻结'}],valueField:'id',textField:'text',editable:false,panelHeight:'auto'});$('#ipt_gm_sortCode').numberbox({});$('#ipt_gm_sortCode').numberbox('setValue',100);var addGuestManageDiv_dialog = $('#div').dialog({title: '新增客源', width: 400, height: 480, modal: true,onClose:function(){$(this).dialog('destroy');},buttons:[{text:'确定',handler:function(){if(!$('#ipt_gm_channelName').textbox('isValid')){$('#ipt_gm_channelName').textbox('textbox').focus();return;}if(!$('#ipt_gm_rentplanId').combobox('isValid')){$('#ipt_gm_rentplanId').combobox('textbox').focus();return;}if(!$('#ipt_gm_sourceGroupId').combobox('isValid')){$('#ipt_gm_sourceGroupId').combobox('textbox').focus();return;}if(!$('#ipt_gm_contact').textbox('isValid')){$('#ipt_gm_contact').textbox('textbox').focus();return;}if(!$('#ipt_gm_mobile').numberbox('isValid')){$('#ipt_gm_mobile').numberbox('textbox').focus();return;}if(!$('#ipt_gm_email').textbox('isValid')){$('#ipt_gm_email').textbox('textbox').focus();return;}if(!$('#ipt_gm_address').textbox('isValid')){$('#ipt_gm_address').textbox('textbox').focus();return;}if(!$('#ipt_gm_bankName').textbox('isValid')){$('#ipt_gm_bankName').textbox('textbox').focus();return;}if(!$('#ipt_gm_bankAccount').textbox('isValid')){$('#ipt_gm_bankAccount').textbox('textbox').focus();return;}var data = {};data.channelName = $('#ipt_gm_channelName').textbox('getValue');data.rentplanId = $('#ipt_gm_rentplanId').combobox('getValue');data.sourceGroupId = $('#ipt_gm_sourceGroupId').combobox('getValue');data.contact = $('#ipt_gm_contact').textbox('getValue');data.mobile = $('#ipt_gm_mobile').numberbox('getValue');data.email = $('#ipt_gm_email').textbox('getValue');data.bankAccount = $('#ipt_gm_bankAccount').textbox('getValue');data.address = $('#ipt_gm_address').textbox('getValue');data.usageState = $('#ipt_gm_usageState').combobox('getValue');data.sortCode = $('#ipt_gm_sortCode').numberbox('getValue');if(data.sortCode == ""){data.sortCode = 100;}data.salerUserId = 0;data.salerUsername = "";data.telephone = "";data.credit = 1;data.creditAmount = 0;data.balance = 0;data.remark = "";console.info(data)$.ajax({type:'post',url:'../channel/add',data:data,dataType:'json',success:function(result){console.info(result);if(result==-3333){$.messager.show({title:'系统提示',msg:'您没有该操作的权限!',timeout:2000});return;}if(result== -201 || result==-111 || result == -112){$.messager.show({title:'系统提示',msg:'参数错误!',timeout:2000});return;}if(result == 0){$.messager.show({title:'系统提示',msg:'新增失败!',timeout:2000});return;}if(result>0){addGuestManageDiv_dialog.dialog('close');var data1 = {};data1.channelName = "";data1.usageState = 0;eapor.utils.defaultAjax("../channel/getChannelCount",data1,gm_getAddResultPageCountCallback);$.messager.show({title:'系统提示',msg:'新增成功!',timeout:2000});return;}$.messager.show({title:'系统提示',msg:'新增失败!',timeout:2000});}})}},{text:'取消',handler:function(){addGuestManageDiv_dialog.dialog('close');}}]}) };
//新增后同步分页总数 function gm_getAddResultPageCountCallback(result){$('#channelListPage').pagination({total:result});var data = {};data.offset = setPageSize * (setPageNumber - 1);data.limit = setPageSize;data.channelName = "";data.usageState = 0;eapor.utils.defaultAjax('../channel/pglist',data,gm_getPageListClickCallback); } //编辑btn $('#edit_gm').click(function(){var selected = $('#tab_guest_manage').datagrid('getSelected');if(selected == null){$.messager.show({title:'系统提示',msg:'请先选择客源!',timeout:2000,showType:'slide'});return;}else{if(selected.channelName == "会员" || selected.channelName == "非会员" || selected.channelName == "驿宝"){$.messager.show({title:'系统提示',msg:'该项不可编辑!请选择其他客源!',timeout:2000,showType:'slide'});return;}else{var index = -1;gm_Edit(selected,index)}} }); /*编辑*/ function gm_Edit(row,index){console.info(row);if(row.channelName == "会员" || row.channelName=="非会员"){$.messager.show({title:'系统提示',msg:'该信息为默认信息,不可编辑!',timeout:2000})return;}$('#editGuestManageDiv').append(''+''+//'*客源名称 :" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*房价方案:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*客源组:" labelPosition="before" labelAlign="right" labelWidth="100" />'+''+''+//'*联系人:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//'*联系手机:" labelPosition="before" labelAlign="right" labelWidth="100"/>'+''+''+//''+''+''+//''+''+''+//''+''+''+//''+''+''+//' '+''+''+//''+''+'');$('#ipt_gmEdit_channelName').textbox({required:true,missingMessage:'客源名称不能为空!',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_rentplanId').combobox({url:'../rentplan/pglist',queryParams:{limit:9999,offset:0,rentplanName:''},valueField: 'rentplanId',textField:'rentplanName',editable:false,panelHeight: 'auto',panelMaxHeight:200,required:true,missingMessage:'房价方案不能为空!',validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_sourceGroupId').combobox({url:'../sourcegroup/pglist',queryParams:{limit:9999,offset:0,groupName:''},valueField:'sourceGroupId',textField:'sourceGroupName',editable:false,panelHeight: 'auto',panelMaxHeight:200,required:true,missingMessage:'客源组不能为空!',validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_contact').textbox({required:true,missingMessage:'联系人不能为空!',validType:"maxLength[32]",invalidMessage:'输入最大长度为32个字符',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_mobile').numberbox({required:true,missingMessage:'手机号码不能为空!',validType:'mobilephone',invalidMessage:'手机号码格式不正确,如:13700001234',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_email').textbox({validType:'email',invalidMessage:'邮箱格式输入不正确,如:123456@163.com',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_bankName').textbox({validType:'name',invalidMessage:'格式不正确,只能为中文或英文',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_bankAccount').textbox({validType:['number','length[5,30]'],delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_address').textbox({multiline:true,validType:"maxLength[64]",invalidMessage:'输入最大长度为64个字符',delay:1000,validateOnCreate:false,validateOnBlur:true});$('#ipt_gmEdit_usageState').combobox({data:[{'id':1,'text':'使用'},{'id':2,'text':'冻结'}],valueField:'id',textField:'text',editable:false,panelHeight:'auto'});$('#ipt_gmEdit_sortCode').numberbox({});$('#ipt_gmEdit_salerUserId').combobox('setValue',row.salerUserId);$('#ipt_gmEdit_sourceGroupId').combobox('setValue',row.sourceGroupId);$('#ipt_gmEdit_channelName').textbox('setValue',row.channelName);$('#ipt_gmEdit_contact').textbox('setValue',row.contact);$('#ipt_gmEdit_mobile').numberbox('setValue',row.mobile);$('#ipt_gmEdit_email').textbox('setValue',row.email);$('#ipt_gmEdit_address').textbox('setValue',row.address);$('#ipt_gmEdit_bankAccount').textbox('setValue',row.bankAccount);$('#ipt_gmEdit_rentplanId').combobox('setValue',row.rentplanId);$('#ipt_gmEdit_sortCode').numberbox('setValue',row.sortCode);$('#ipt_gmEdit_usageState').combobox('setValue',row.usageState);$('#div').dialog({title:'编辑客源',width:400,height:480,modal: true,onClose:function(){$(this).dialog('destroy');},buttons:[{text:'确定',handler:function(){if(!$('#ipt_gmEdit_channelName').textbox('isValid')){$('#ipt_gmEdit_channelName').textbox('textbox').focus();return;}if(!$('#ipt_gmEdit_rentplanId').combobox('isValid')){$('#ipt_gmEdit_rentplanId').combobox('textbox').focus();return;}if(!$('#ipt_gmEdit_sourceGroupId').combobox('isValid')){$('#ipt_gmEdit_sourceGroupId').combobox('textbox').focus();return;}if(!$('#ipt_gmEdit_contact').textbox('isValid')){$('#ipt_gmEdit_contact').textbox('textbox').focus();return;}if(!$('#ipt_gmEdit_mobile').numberbox('isValid')){$('#ipt_gmEdit_mobile').numberbox('textbox').focus();return;}if(!$('#ipt_gmEdit_email').textbox('isValid')){$('#ipt_gmEdit_email').textbox('textbox').focus();return;}if(!$('#ipt_gmEdit_address').textbox('isValid')){$('#ipt_gmEdit_address').textbox('textbox').focus();return;}if(!$('#ipt_gmEdit_bankName').textbox('isValid')){$('#ipt_gmEdit_bankName').textbox('textbox').focus();return;}if(!$('#ipt_gmEdit_bankAccount').textbox('isValid')){$('#ipt_gmEdit_bankAccount').textbox('textbox').focus();return;}var data = {};data.channelName = $('#ipt_gmEdit_channelName').textbox('getValue');data.rentplanId = $('#ipt_gmEdit_rentplanId').combobox('getValue');data.sourceGroupId = $('#ipt_gmEdit_sourceGroupId').combobox('getValue');data.contact = $('#ipt_gmEdit_contact').textbox('getValue');data.mobile = $('#ipt_gmEdit_mobile').numberbox('getValue');data.email = $('#ipt_gmEdit_email').textbox('getValue');data.bankAccount = $('#ipt_gmEdit_bankAccount').textbox('getValue');data.address = $('#ipt_gmEdit_address').textbox('getValue');data.usageState = $('#ipt_gmEdit_usageState').combobox('getValue');data.sortCode = $('#ipt_gmEdit_sortCode').numberbox('getValue');if(data.sortCode == ""){data.sortCode = 100;}data.salerUserId = 0;data.salerUsername = "";data.telephone = "";data.credit = 1;data.creditAmount = 0;data.balance = 0;data.remark = "";data.channelId = row.channelId;console.info(data);$.ajax({type:'post',url:'../channel/edit',data:data,dataType:'json',success:function(result){console.info(result);if(result==-3333){$.messager.show({title:'系统提示',msg:'您没有该操作的权限!',timeout:2000});}else if(result== -201 || result==-111 || result == -112){$.messager.show({title:'系统提示',msg:'参数错误!',timeout:2000});}else if(result==-1){$.messager.show({title:'系统提示',msg:'客源名称已占用!请更改!',timeout:2000});}else if(result==-601){$.messager.show({title:'系统提示',msg:'银行账户输入有误!为16~19位数字!',timeout:2000});}else if(result<-1){$.messager.show({title:'系统提示',msg:'编辑失败!',timeout:2000});}else if(result>0){$('#div').dialog('close');//刷新当前页var data = {};data.offset = setPageSize * (setPageNumber - 1);data.limit = setPageSize;data.channelName = "";data.usageState = 0;eapor.utils.defaultAjax('../channel/pglist',data,gm_getPageListClickCallback);$.messager.show({title:'系统提示',msg:'编辑成功!',timeout:2000});}}})}},{text:'取消',handler:function(){$('#div').dialog('close');}}]}) } /*分页按钮*/ function gm_getPageListClickCallback(result){if(result==-3333){$.messager.show({title:'系统提示',msg:'您没有该操作的权限!',timeout:2000});}else if(result== -201 || result==-111){$.messager.show({title:'系统提示',msg:'参数错误!',timeout:2000});}else{guestManageArray= result;$('#tab_guest_manage').datagrid('options').loader = guestManageLoader;$('#tab_guest_manage').datagrid('reload');} } /*list*/ var rowSelect_guestManage=null; function gm_getPageListCallback(result){if(result==-3333){$.messager.show({title:'系统提示',msg:'您没有该操作的权限!',timeout:2000});}else if(result== -201 || result==-111){$.messager.show({title:'系统提示',msg:'参数错误!',timeout:2000});}else{ guestManageArray= result;$('#tab_guest_manage').datagrid({loader:guestManageLoader,title : '客源基本信息列表', //表格标题iconCls : 'icon-list', //表格图标nowrap : false, //是否只显示一行,即文本过多是否省略部分。fitColumns : true, //防止水平滚动scrollbarSize : 0, //去掉右侧滚动条列collapsible : false, //是否可折叠的 striped:true,//隔行变色loadMsg : "loading....",singleSelect:true,rownumbers:true,fit:true,checkOnSelect:false,onLoadSuccess:function(){$(this).parent().find(".datagrid-header-check").children('input')[0].style.visibility="hidden"; },onClickRow : function(rowIndex,rowData){ if(onlySelectedOneRowFlag==2){onlySelectedOneRowFlag=0;return;}else{onlySelectedOneRowFlag=1;}var rows = $(this).datagrid('getChecked'); var flag = true; for(var i = 0; i < rows.length; i++) { if(rowData == rows[i]){ flag = false; break; } }if(flag){$(this).datagrid('checkRow',rowIndex); $(this).datagrid('selectRow',rowIndex); rowSelect_guestManage = $(this).datagrid('getSelected');}else{$(this).datagrid('uncheckRow',rowIndex);$(this).datagrid('unselectRow',rowIndex);rowSelect_guestManage=null;}onlySelectedOneRowFlag=0;},onCheck:function(rowIndex,rowData){if(onlySelectedOneRowFlag==2){return;}if(onlySelectedOneRowFlag==1){onlySelectedOneRowFlag=0;return;}else{onlySelectedOneRowFlag=2;}if(rowData != rowjavadillselect){$(this).datagrid('checkRow',rowIndex); $(this).datagrid('selectRow',rowIndex); rowSelect_guestManage = $(this).datagrid('getSelected');}else{$(this).datagrid('uncheckRow',rowIndex);$(this).datagrid('unselectRow',rowIndex);rowSelect_guestManage=null;}onlySelectedOneRowFlag=0;},columns : [[ {field:'ck',title:'',checkbox:true}, {field:'channelName',title:'客源名称',align:'center',width:18}, {field:'rentplanName',title:'价格方案',align:'center',width:18},{field:'sourceGroupName',title:'客源组',align:'center',width:18},{field:'contact',title:'联系人',align:'center',width:18}, {field:'mobile',title:'联系手机',align:'center',width:25}, {field:'email',title:'邮箱',align:'center',width:30}, {field:'id7',title:'开户行',align:'center',width:20},{field:'bankAccount',title:'银行账号',align:'center',width:30},{field:'address',title:'通讯地址',align:'center',width:30},{field:'usageState',title:'状态',align:'center',width:10,formatter:function(value){if(value == 1){return "使用";}else if(value == 2){return "冻结";}else{return value;}}},{field:'balance',title:'余额',align:'center',width:20,hidden:true},{field:'credit',title:'能否挂帐',align:'center',width:20,formatter:function(value){if(value == 1){return "能";}if(value == 0){return "不能";}}},//0不能 1能{field:'creditAmount',title:'挂帐最大额度',align:'center',width:20,hidden:true},{field:'telephone',title:'联系座机',align:'center',width:20,hidden:true},{field:'remark',title:'备注',align:'center',width:20,hidden:true},{field:'sourceGroupId',title:'客源组Id',align:'center',width:20,hidden:true},{field:'channelId',title:'channelId',align:'center',width:20,hidden:true},{field:'createTime',title:'创建时间',align:'center',width:20,hidden:true},{field:'creator',title:'创建者',align:'center',width:20,hidden:true},{field:'hotelId',title:'宾馆lId',align:'center',width:20,hidden:true},{field:'rentplanId',title:'默认房价方案id',align:'center',width:20,hidden:true},{field:'saler',title:'销售员username',align:'center',width:20,hidden:true},{field:'sortCode',title:'排序',align:'center',width:20}]]})} } //countCallBack function gm_getPageCountCallback(result){if(result==-3333){$.messager.show({title:'系统提示',msg:'您没有该操作的权限!',timeout:2000});}else if(result== -201 || result==-111){$.messager.show({title:'系统提示',msg:'参数错误!',timeout:2000});}else{//得到分页点击记录$('#channelListPage').pagination({total:result,//loading:true,//showRefresh:,//displayMsg:'',onSelectPage:function(pageNumber, pageSize){setPageNumber = pageNumber;setPageSize = pageSize;var data = {};data.offset = pageSize * (pageNumber - 1);data.limit = pageSize;data.channelName = "";data.usageState = 0;eapor.utils.defaultAjax('../channel/pglist',data,gm_getPageListClickCallback);}});//得到显示分页记录var page = $('#channelListPage').pagination('options');var data = {};data.offset = 0;data.limit = page.pageSize;data.channelName = $('#ipt_guestName_guest_manage').textbox('getValue');data.usageState = 0;guestManageListData = data;eapor.utils.defaultAjax('../channel/pglist',data,gm_getPageListCallback);} }; //得到总记录数 $(function(){var data = {};data.channelName = "";data.usageState = 0;eapor.utils.defaultAjax("../channel/getChannelCount",data,gm_getPageCountCallback); });
转载于:https://www.cnblogs.com/ryans/p/6909564.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!