function issignature(date){
//例如:(0123456789012345.0123456789012345.0123456789012345)
//16位的数字,中间用点分开
var code;
var strlen = date.length;
if(strlen == 0 || strlen == 16 || strlen == 33 || strlen == 50){
for (var i = 0; i < strlen; i++) {
//charAt()获取指定位置字符串,charCodeAt()返回该字符串的编码
//0的ASCII是48,9的ASCII是57
code = date.charAt(i).charCodeAt(0);
if(i<16 && (code < 48 || code > 57) )
return false;
if((i == 16 || i == 33) && code != 46)
return false;
if(i<33 && i>16 && (code < 48 || code > 57))
return false;
if(i<50 && i>33 && (code < 48 || code > 57))
return false;
}
}else{
return false;
}
return true;
}
function isDigit(date){
var $val = date;
var code;
for (var i = 0; i < $val.length; i++) {
//charAt()获取指定位置字符串,charCodeAt()返回该字符串的编码
//0的ASCII是48,9的ASCII是57
code = $val.charAt(i).charCodeAt(0);
if (code < 48 || code > 57) {
return false;
}
}
return true;
}
function mytrim(data){
return data.replace(/^\s+|\s+$/g,"");
}
function isformat(date){
//(例如:1274-A30C-CF70-4EF4-4D59)
var length = date.length;
if(length ==0 || length ==24){
var code;
for (var i = 0; i < length; i++) {
code = date.charAt(i).charCodeAt(0);
if (i == 4 || i == 9 || i == 14 || i == 19 ) {
if(code != 45)
return false;
}else{
if (code <48 || code >57 && code <63 || code > 63 && code < 65 || code > 90){
return false;
}
}
}
return true;
}else{
return false;
}
}
//用于检查数据是否为大于等于1的整数。如果是返回true,否则返回false
function checkNumber( value , object ){
if( value == '' ){
object.html("不能为空");
return false;
} else if ( !isDigit(value) ){
object.html("只能为数字");
return false;
} else if ( value < 1 ) {
object.html("必须大于0");
return false;
} else {
return true;
}
}
jQuery(document).ready(function($){
var userType = '';
$("#check-shortcode").change(function(){
if ($(this).prop("checked")){
$("#short-code-wrap").show();
} else {
$("#short-code-wrap").hide();
}
});
$("#check-bulkmac").change(function(){
if ($(this).prop("checked")){
$("#bulk-mac-wrap").show();
} else {
$("#bulk-mac-wrap").hide();
}
});
//添加 单个序列号修改链接 的消息响应
$(document).on("click",".alter-license-remark",function(){
var $this = $(this),
licenseId = $this.attr('data-id'),
licenseType = $this.attr('data-licensetype'),
licenseCount = $this.attr('data-licensecount'),
limitedDate = $this.attr('data-limiteddate'),
licenseTeacher = $this.attr("data-licenseteacher"),
licenseStudent = $this.attr("data-licensestudent"),
licenseRemark = $this.attr("data-remark"),
licenseproduct = $this.attr("data-product"),
licenseGremark = $this.attr("data-gremark"),
licenseMac = $this.attr("data-mac");
$(".alert_count").html('');
$(".alert_date").html('');
$('#message_teacher_lic_quantity').html('');
$('#message_student_lic_quantity').html('');
$(".submit_error_info").html('');
var selectContent = '';
switch(licenseType){
case '1':
if (userType == '3') {
$("#license_type_wrap td:eq(0)").html("班级授权");
$("#licenseCount td:eq(0)").html(licenseCount);
} else {
selectContent = ""
+ "";
$("#licenseType").html(selectContent);
$("#licenseCount input:text").attr('value', licenseCount);
}
$("#licenseCount").show();
$("#teacher_lic_wrap").hide();
$("#student_lic_wrap").hide();
break;
case '2':
if (userType == '3') {
$("#license_type_wrap td:eq(0)").html("终端授权 - 教师机");
} else {
selectContent = ""
+ "";
$("#licenseType").html(selectContent);
}
$("#licenseCount").hide();
$("#teacher_lic_wrap").hide();
$("#student_lic_wrap").hide();
break;
case '3':
var text = (licenseproduct == "2" || licenseproduct == "3") ? "终端授权" : "终端授权 - 学生机";
if (userType == '3') {
$("#license_type_wrap td:eq(0)").html(text);
} else {
$("#licenseType").html("");
}
$("#licenseCount").hide();
$("#teacher_lic_wrap").hide();
$("#student_lic_wrap").hide();
break;
case '8':
if (userType == '3') {
$("#license_type_wrap td:eq(0)").html("学校授权");
$("#teacher_lic_wrap td:eq(0)").html(licenseTeacher);
$("#student_lic_wrap td:eq(0)").html(licenseStudent);
} else {
$("#licenseType").html("");
$("#teacher_lic_wrap input:text").attr('value', licenseTeacher);
$("#student_lic_wrap input:text").attr('value', licenseStudent);
}
$("#licenseCount").hide();
$("#teacher_lic_wrap").show();
$("#student_lic_wrap").show();
break;
}
//limited date
if (userType == '3') {
$('#lic_limit_wrap td:eq(0)').html(limitedDate == '-1' ? "无限制" : limitedDate);
} else {
if (limitedDate == '-1'){
$("#limiteddate").attr({value: '', disabled: 'disabled'});
$("#checkbox").attr('checked', 'checked');
} else {
$("#limiteddate").removeAttr("disabled").val(limitedDate);
$("#checkbox").removeAttr('checked');
}
}
//client
$('#client_wrap').hide();
//Mac
if (userType == '3') {
$('#lic-mac').hide();
} else {
if (licenseMac && licenseMac.length > 0) {
$('#lic-mac').show();
$('#lic-mac input').val(licenseMac);
$('#lic-mac .alert_error').html('');
} else {
$('#lic-mac').hide();
}
}
//remark
$("#alter-remarktextarea").attr("value", licenseRemark);
$("#activation-type-wrap").hide();
$('#short-code-wrap').hide();
$('#bulk-mac-wrap').hide();
$(".submit_error_info").html('');
$("#ajax_submit").removeAttr("disabled");
$('.load').hide();
//license id
$("#l_id").attr("value" , licenseId);
$("#g_id").attr("value",'');
var currentTr = $(this).parent().parent();
var tdLicenseSignature = currentTr.find('.lic-signature');
var tdLicenseInfo = currentTr.find('.lic-info');
var tdLicenseDate = currentTr.find('.lic-limiteddate');
var tdLicenseRemark = currentTr.find('.lic-remark');
$("#ajax_submit").unbind().click(function(){
if (userType != '3') {
var licenseType = $("#licenseType").val();
switch( licenseType ){
case '1':
if (!checkNumber($("#count").val() , $(".alert_count"))) {
return false;
} else {
$(".alert_count").html("");
}
break;
case '8':
if(!checkNumber($("#teacher_lic_quantity").val() , $("#message_teacher_lic_quantity"))){
return false;
} else {
$("#message_teacher_lic_quantity").html("");
}
if(!checkNumber($("#student_lic_quantity").val() , $("#message_student_lic_quantity"))){
return false;
} else {
$("#message_student_lic_quantity").html("");
}
break;
}
if ( $("#checkbox").attr("checked") != 'checked' && $("#limiteddate").val() == '' ) {
$(".alert_date").html("请填写授权有效期");
return false;
} else {
$(".alert_date").html("");
}
if (licenseMac && licenseMac.length) {
$('#lic-mac .alert_error').html('');
}
}
$(".submit_error_info").html('');
$("#ajax_submit").attr("disabled", "disabled");
$('.load').css({"display": "inline-block"});
$.post("/w/index.php/Licensemake/editLicense", $('#form-dialog').serialize(), function(data){
$("#ajax_submit").removeAttr("disabled");
$('.load').css({"display": "none"});
if (data && data.status) {
switch(data.status) {
case 'ERROR':
location.reload();
return false;
case 'MAC_ERROR':
$('#lic-mac .alert_error').html(data.msg);
break;
case 'DISABLED_EDIT':
$(".submit_error_info").html("该序列号不允许被编辑");
break;
case 'OK':
$("#bgDiv_add").modal('hide');
var remark = data.msg.remark;
if (licenseGremark != undefined) {
remark += (data.msg.remark && licenseGremark ? '
' : '') + licenseGremark;
}
tdLicenseRemark.html(remark);
$this.attr("data-remark", data.msg.remark);
currentTr.css('background-color','#D9D9D9');
if (userType != '3') {
tdLicenseInfo.html(data.msg.license_msg);
tdLicenseDate.html($("#checkbox").prop("checked") ? '无限制' : $("#limiteddate").val());
$this.attr("data-licensetype", licenseType);
$this.attr("data-licensecount", $("#count").val());
$this.attr('data-limiteddate' , $("#checkbox").prop("checked") ? '-1' : $("#limiteddate").val());
$this.attr("data-licenseteacher" , $("#teacher_lic_quantity").val());
$this.attr("data-licensestudent" , $("#student_lic_quantity").val());
if (data.msg.mac) {
$this.attr("data-mac" , data.msg.mac);
tdLicenseSignature.html('预绑定Mac地址:' + data.msg.mac);
}
}
break;
}
} else {
$(".submit_error_info").html("Error!");
}
}, 'json');
});
});
$(document).on('click', '.voreturn', function(){
if( confirm("你确定要执行此操作吗?") ){
var objectParentTd = $(this).parent();
$.post("/w/index.php/Licensemake/cancelLicense",{id:$(this).data('id')},function(data){
if(data == 1){
objectParentTd.parent().find(".lic-status").html("禁用");
objectParentTd.html("");
}else{
alert('操作失败,您没有权限执行该操作!');
}
});
}
});
//添加 显示日志链接 的消息响应
$(document).on("click",".showlog a",function(){
var objectParentTr = $(this).parent().parent();
$(this).hide();
if ( $(this).html() == '+' ){
$(this).parent().children('a:eq(1)').show();
var appendContent = "
序号 | " + "授权创建时间 | " + "授权类型 | " + "详细信息 |
" + data[i].number + " | " + "" + data[i].ll_datetime + " | " + "" + data[i].ll_typename + " | " + "" + ((!data[i].ll_info)?" ":data[i].ll_info) + " | " + "
暂无数据! | |||