license.js 5.31 KB

var liFun={
    init:function () {
        liFun.initTable();
    },
    initTable:function(){
        $('#licenseTable').bootstrapTable('destroy').bootstrapTable({
            striped:true,//表格显示条纹
            pagination: false, //启动分页
            pageNumber:1, //当前第几页
            pageSize: 1,  //每页显示的记录数
            pageList: [1],  //记录数可选列表
            sidePagination: 'server',//表示服务端分页
            queryParamsType: 'limit',
            method:'POST',//请求方法
            paginationPreText: '<',
            paginationNextText: '>',
            ajax:tableLoadRequest,//自定义ajax加载数据
            uniqueId:'id',
            columns: [
                {
                    field: 'issCompany',
                    title: '<span class="person-icon"> </span>授权码发行公司',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'grantType',
                    title: '<span class="type-icon"> </span>授权类型',
                    width: '10%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'grantComName',
                    title: '<span class="person-icon"> </span>授权公司',
                    width: '10%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'license',
                    title: '<span class="id-icon"> </span>License授权码',
                    width: '20%',
                    align: "left",
                    formatter:function(value,row,index){
                        var operStr ='<div style="max-width: 200px; color:#1E95CD" class="ITD-cursor-pointer ITD-hidden-nowrap LicesePop" data-toggle="tooltip" title="'+value+'"> '+value+'</div>';
                        return operStr;
                    },
                },
                {
                    field: 'iat',
                    title: '<span class="time-icon"> </span>创建时间',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'ext',
                    title: '<span class="time-icon"> </span>过期时间',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
            ],
            formatTableUnit:function(value,row,index){
                return {
                    css: {
                        "white-space":"nowrap"
                    }
                }
            },
            formatLoadingMessage:function(){
                return "数据正在加载中...";
            },

        });
    },

};
liFun.init();

documentBindFunc.on('click','#licenseAddbtn',function () {
    $('#login_error').addClass('display-none').text('');
    $('#login-licenseMsg').val('');
    $('#license_addmodel').modal('show');
});

//确定 事件 (上报license 授权码)
documentBindFunc.on('click','#addsubmit',function () {
    updateSysLicense();
});
//上报license 授权码
function updateSysLicense() {
    var licenseID=$('#login-licenseMsg').val();
    if(licenseID==null||licenseID==''||licenseID==undefined){
        $('#login_error').removeClass('display-none').text('License授权码不能为空');
        return;
    }
    var req = {
        sysCode:sysComm.sysCode,
        orgId: fn.getOrgId(),
        license: licenseID
    };
    var licenseAjax = {
        method: "post",
        url: dataUrl.util.updateSysLicenseByOrgId(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (res) {
            if (res.code == '8888') {
                $('#login-licenseMsg').val('');
                $('#license_addmodel').modal('hide');
                liFun.initTable();
            } else {
                console.log(res);
            }
        }
    };
    sysAjax(licenseAjax);
};
/**
 * 自定义table AJAX请求
 * @param {Object} params
 */
function tableLoadRequest(params){
    //设置请求参数
    var pageNum = 1;
    var req= {
        baseRequest:{
            pageNum:pageNum,
            pageSize:params.data.limit
        },
        // sysCode:sysCode,
        orgId: fn.getOrgId(),
    };
    var easyUIOps = {
        method: params.type,
        url: dataUrl.util.querySysLicense(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType:'json',
        success: function(res){
            if(res.code == '8888'){
                console.log(res.data)
                params.success(res.data);
                $('#licenseTable').bootstrapTable('insertRow',{index:1,row:{issCompany:res.data.issCompany,grantType:res.data.grantType,grantComName:res.data.grantComName,license:res.data.license,iat:res.data.iat,ext:res.data.ext}});
                /*$("[data-toggle='tooltip']").tooltip({
                    delay: {show: 500, hide: 100},
                });*/


            }else{
                console.log(res);
            }
        }
    };
    sysAjax(easyUIOps);
}