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(
        ‘<div id="div" style="padding-top:20px;padding-left:50px;">‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 客源名称 -->
                ‘<input id="ipt_gm_channelName"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>客源名称 :" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 房价方案-->
                ‘<input  id="ipt_gm_rentplanId" style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>房价方案:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- *客源组  -->
                ‘<input id="ipt_gm_sourceGroupId" style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>客源组:" labelPosition="before" labelAlign="right" labelWidth="100" />‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 联系人 -->
                ‘<input id="ipt_gm_contact"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>联系人:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 联系手机 -->
                ‘<input id="ipt_gm_mobile"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>联系手机:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 邮箱  -->
                ‘<input id="ipt_gm_email"  style="width:240px;"‘+
                    ‘label="邮箱:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 开户行 -->
                ‘<input id="ipt_gm_bankName"  style="width:240px;"‘+
                    ‘label="开户行:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 账号 -->
                ‘<input id="ipt_gm_bankAccount"  style="width:240px;"‘+
                    ‘label="账号:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 地址 -->
                ‘<input id="ipt_gm_address"  style="width:240px;"‘+
                    ‘label="通讯地址:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 状态-->
            ‘    <input id="ipt_gm_usageState" style="width:240px;" ‘+
                    ‘label="状态:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 优先级-->
                ‘<input id="ipt_gm_sortCode" style="width:240px;"‘+
                    ‘label="优先级:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
        ‘</div>‘
    );
    $(‘#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:‘邮箱格式输入不正确,如:[email protected]‘,
        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(
            ‘<div id="div" style="padding-top:20px;padding-left:50px;">‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 客源名称 -->
                ‘<input id="ipt_gmEdit_channelName"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>客源名称 :" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 房价方案-->
                ‘<input  id="ipt_gmEdit_rentplanId" style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>房价方案:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- *客源组  -->
                ‘<input id="ipt_gmEdit_sourceGroupId" style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>客源组:" labelPosition="before" labelAlign="right" labelWidth="100" />‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 联系人 -->
                ‘<input id="ipt_gmEdit_contact"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>联系人:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 联系手机 -->
                ‘<input id="ipt_gmEdit_mobile"  style="width:240px;"‘+
                    ‘label="<span style=\‘color:red;font-size: 22px;vertical-align: middle;height: 22px;display: inline;\‘>*</span>联系手机:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 邮箱  -->
                ‘<input id="ipt_gmEdit_email"  style="width:240px;"‘+
                    ‘label="邮箱:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 开户行 -->
                ‘<input id="ipt_gmEdit_bankName"  style="width:240px;"‘+
                    ‘label="开户行:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 账号 -->
                ‘<input id="ipt_gmEdit_bankAccount"  style="width:240px;"‘+
                    ‘label="账号:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 地址 -->
                ‘<input id="ipt_gmEdit_address"  style="width:240px;"‘+
                    ‘label="通讯地址:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 状态-->
            ‘    <input id="ipt_gmEdit_usageState" style="width:240px;" ‘+
                    ‘label="状态:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
            ‘<div style="margin-bottom:8px">‘+//<!-- 优先级-->
                ‘<input id="ipt_gmEdit_sortCode" style="width:240px;"‘+
                    ‘label="优先级:" labelPosition="before" labelAlign="right" labelWidth="100"/>‘+
            ‘</div>‘+
        ‘</div>‘
    );
    $(‘#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:‘邮箱格式输入不正确,如:[email protected]‘,
        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);
});
时间: 2024-11-05 21:40:07

easyui中 datagrid与pagination结合使用【记录】的相关文章

SpringMVC+easyUI中datagrid分页实现_2014.5.1

一.概述 SpringMVC: 1.是面对方法级变量的,在操作起来会比struts方便一些(structs是类级变量),具体体现在了srpingMVC的注解上面, 如@RequstMapping("/login"),而且对于返回值ModelAndView这也是一大亮点,既可以返回一个页面(View),再加上@ResponseBody注解以后就可以返回一个      模型对象(也就是一种数据结构). 2.对于方法级传入的参数操作起来也相当方便,比如本例中,在加载DataGrid时,会像后

利用Aspose.Cells完成easyUI中DataGrid数据的Excel导出功能

我准备在项目中实现该功能之前,google发现大部分代码都是利用一般处理程序 HttpHandler实现的服务器端数据的Excel导出,但是这样存在的问题是ashx读取的数据一般都是数据库中视图的数据,难免会含有方便操作的 主键ID这列的记录.现在项目需要在easyUI的DataGrid中显示的数据能全部导出Excel,包括DataGrid中的中文标题,其他的统统不 要. 完成该功能所需的工具和环境:Newtonsoft.Json序列化和反序列化类库.easyUI前端UI框架.HttpHandl

EasyUI中datagrid实现显示、增加、 删除、 修改、 查询操作(后台代码C#)

2datagrid加载数据.代码如下所示 一.数据的显示 1新建HtmlPage2.html页面,引入相关文件.如下所示 <script src="easyui/js/jquery-1.8.2.min.js"></script>  <script src="easyui/js/jquery.easyui.min.js"></script>  <link href="easyui/css/themes/d

EasyUI 中 DataGrid 控件 列 如何绑定对象中的属性

EasyUI 中 DataGrid 控件 是我们经常用到的控件之一, 但是 DataGrid 控件 在绑定显示列时却不支持对象属性绑定. 模型如下: public class Manager implements java.io.Serializable { private Integer id; private Role role; private String loginName; private String password; private int status; private Da

SpringMVC+easyUI中datagrid行编辑模式(添加数据)实现_2014.5.2

一.概述 根据我们平常的习惯,一共有两种修改模式,一种是弹窗是修改,将原有的数据提取到dialog上,然后再重新提交到后台(好像easyui里面有个onAfterEdit,这个事件里面有三个参数,其中的一个参数就是发现数据是否有改变),而第二种方式就是实现行编辑模式,在原有的datagrid上添加一个空行,(本例是实现添加数据,不考虑原有数据). 二.实现 1.后台就不赘言了.直接上代码,但是我还是有个疑问,对于SpingMVC的Controller层次中的方法的**入参**,我在前台通过aja

easyui 中Datagrid 控件在列较多且无数据时,列显示不全的解决方案

在onLoadSuccess 中加入如下代码就OK啦 $('#dg3').datagrid({ onLoadSuccess:function(data){ if(data.total==0){ var dc = $(this).data('datagrid').dc; var header2Row = dc.header2.find('tr.datagrid-header-row'); dc.body2.find('table').append(header2Row.clone().css({"

easyUI中datagrid的使用

easyUI中的datagrid数据表格经常被用到,结合项目中的使用情况,总结一下datagrid使用中需要注意的一些问题.使用datagrid展示数据,需要在html.css.js中都要编写代码,html中主要是确定datagrid在网页中的位置,css来设置datagrid的样式,js填充datagrid数据. 一 html部分 示例代码如下: <div class="columntablebox" > <table id="columnTable&qu

EasyUI中DataGrid构建复合表头

在使用easyui的DataGrid控件时,构建复合表头就显得非常简单了.只需要在使用columns属性时通过数组的方式编写列名即可.如我们需要构建成一个如下的表头: Columns的代码如下: columns: [[ { field: '_id', title: '行号', fixed: true, rowspan:2 }, { field: '_j', title: '铁路局', fixed: true, colspan:2 } ], [ { field: '_id', title: '京局

easyUI 中datagrid 返回列隐藏方法

easyui的datagrid方法返回的列,有的值不需要显示可以使用hidden(属性进行隐藏) columns : [ [{ field : 'bailClass', title : '类别', width : 50, align : 'center', formatter : returnFtt },{ field : 'agencyName', title : '市场名称', width : 50, align : 'center' },{ field : 'agencyId', titl