{% extends "data_edit.html" %}
{% load i18n %}
{% block form %}
{% if request.user|HasPerm:"iaccess.add_accwiegandfmt" or request.user|HasPerm:"iaccess.change_accwiegandfmt" %}
{% autoescape off %}
| {% trans "偶校验(e)" %} |
{% trans "奇校验(o)" %} |
{% trans "CID(c)" %} |
{% trans "设备代码(f)" %} |
{% trans "区位码(s)" %} |
{% trans "厂商代码(m)" %} |
| {% trans "起始位" %} |
{% trans "长度" %} |
{% trans "起始位" %} |
{% trans "长度" %} |
{% trans "起始位" %} |
{% trans "长度" %} |
{% trans "起始位" %} |
{% trans "长度" %} |
{% trans "起始位" %} |
{% trans "长度" %} |
{% trans "起始位" %} |
{% trans "长度" %} |
{{ form.even_parity_start|field_as_td_h_special }}
{{ form.even_parity_count|field_as_td_h_special }}
{{ form.odd_parity_start|field_as_td_h_special }}
{{ form.odd_parity_count|field_as_td_h_special }}
{{ form.cid_start|field_as_td_h_special }}
{{ form.cid_count|field_as_td_h_special }}
{{ form.facility_code_start|field_as_td_h_special }}
{{ form.facility_code_count|field_as_td_h_special }}
{{ form.site_code_start|field_as_td_h_special }}
{{ form.site_code_count|field_as_td_h_special }}
{{ form.manufactory_code_start|field_as_td_h_special }}
{{ form.manufactory_code_count|field_as_td_h_special }}
|
|
{{ form.before_fmt.as_widget }} |
|
{{ form.after_fmt.as_widget }} |
|
Testing wiegand card format
| {% trans '时间' %} |
{% trans '设备' %} |
{% trans '事件点' %} |
{% trans '事件描述' %} |
{% trans '卡号' %} |
{% trans '人员编号(姓名)' %} |
{% trans '状态' %} |
{% trans '验证方式' %} |
|
|
|
{% if form.non_field_errors %}
| {{ form.non_field_errors }} |
{% endif %}
{% endautoescape %}
{% endif %}
{% endblock %}
{% block addjs %}
// if($("#id_model_pk").val() > 0)
// {
// $("#idWGTestDiv").show();
// }
//新增默认韦根格式
if($("#id_model_pk").val() == "None" || $("#id_model_pk").val() > 10)
{
//$("#tr_default_fmt").hide();
}
else
{
$("#id_wiegand_name").attr("readonly", "true");//名称不让更改
$("#id_wiegand_count").attr("readonly", "true");//总位数不让更改
}
// 限制只能是数字
$("#id_wiegand_count").attr("maxlength", "2");
$("#id_first_p").attr("maxlength", "2");
$("#id_second_p").attr("maxlength", "2");
$("#id_first_p").attr("class", "wZBaseIntegerField");
$("#id_second_p").attr("class", "wZBaseIntegerField");
$("#tb_wiegand_mode_1").find("input").each(function(){
$(this).attr("class", "wZBaseIntegerField");
$(this).attr("maxlength", "2");
});
// 调整长度
$("#id_before_fmt").attr("style", "width:550px");
$("#id_after_fmt").attr("style", "width:550px");
$("input[name^='wiegand_mode']").each(function(){
if($(this).attr("checked"))
{
if($(this).val() == 1)
{
$("#wgMode1").click();
mode_2_readonly();
}
else
{
$("#wgMode2").click();
mode_1_readonly();
}
}
});
$("input[name^='wgMode']").click(function(){
if($(this).val() == 1)
{
$("#id_wiegand_mode_0").click();
mode_2_readonly();
}
else
{
$("#id_wiegand_mode_1").click();
mode_1_readonly();
}
});
function mode_1_readonly()
{
$("#id_table_mode_1").find("input").each(function(){
$(this).attr("readonly", "readonly");
});
$(".id_tr_mode_1").find("input").each(function(){
$(this).attr("readonly", "readonly");
});
$("#id_table_mode_2").find("input").each(function(){
$(this).removeAttr("readonly");
});
}
function mode_2_readonly()
{
$("#id_table_mode_2").find("input").each(function(){
$(this).attr("readonly", "readonly");
});
$("#id_table_mode_1").find("input").each(function(){
$(this).removeAttr("readonly");
});
$(".id_tr_mode_1").find("input").each(function(){
$(this).removeAttr("readonly");
});
}
var before_submit = function(){
return dataValid();
}
var wgMode = "";
function dataValid()
{
wgMode = "";
$("input[name^='wgMode']").each(function(){
if($(this).attr("checked"))
{
wgMode = $(this).val();
}
});
if(wgMode == 1)
{
// 模式一暂不做判断,后续需要补充
}
else
{
if($("#id_before_fmt").val().length != $("#id_wiegand_count").val())
{
$("#id_info").html("").append('- {% trans "卡校验格式长度必须等于总位数!" %}
');
return false;
}
if($("#id_after_fmt").val().length != $("#id_wiegand_count").val())
{
$("#id_info").html("").append('- {% trans "奇偶校验格式长度必须等于总位数!" %}
');
return false;
}
}
return true;
}
$("#idWGTest").click(function(){
if($("#id_wiegand_count").val() == "" || $("#id_wiegand_name").val() == "")
{
$("#OK").click();
return false;
}
if(dataValid())
{
var data = {};
data["wgMode"] = wgMode;
$("#id_edit_form").find("input[type='text']").each(function(){
data[$(this).attr("name")] = $(this).val();
});
// 从后台生成韦根格式字符串
$.ajax({
url:"/{{request.surl}}iaccess/opWgFmtData/",
type: "POST",
data: data,
dataType: "json",
async: true,
success:function(datas)
{
$("#id_wgfmtStr").val(datas.wgfmtStr);
wgfmt_test_fun();
}
});
}
});
//----------------以下是韦根测试
var id_doors = [];
var stop_post = null;
var log_id = -1;
var time_now = "";
var disabled_select_door = false;
function wgfmt_test_fun()
{
$("#idTestDiv").show();
id_doors = [];
stop_post = null;
log_id = -1;
time_now = "";
disabled_select_door = false;
$("#id_show_devices").html("");
$("#rt_content").html("");
show_device();// 加载设备-门树形菜单
}
function show_device()
{
if($("#id_door").html() == null)
{
$.ajax({
url: "/{{request.surls}}iaccess/GetData/?func=get_doors_tree&filter=wgFmt",
dataType: "html",
success: function(data_html)
{
document.getElementById("id_show_devices").innerHTML = data_html;
$("#id_door").find("ul").each(function(){
$(this).attr("style","display:none");
})
$("#id_door .filetree").treeview();
check_root("id_door");
check_selected("id_door");
$("#id_door").find("p").click(function(){
get_child(this);
});
$("#id_door").css({padding:"0px",height:"auto"});
$("#id_show_devices").css({width:$("#id_door").width()});
$("#id_door").find("ul").each(function(){
$(this).attr("style","");
})
$($("#id_door").find("ul")[0]).attr("style","height: 220px; overflow: auto;")
data_html = null;
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert(gettext("服务器处理数据失败,请重试!错误码:-625"));
}
});
}
$("#id_door").attr("class","");
}
function get_child(tag)
{
if($(tag).attr("class")=="t s" && $(tag).find("input").length!=0)//为最后一级标签时
{
var id_s = $(tag).find("input")[0].id.split("_")[1];
id_doors.push(id_s);
}
else if($(tag).attr("class")=="t u" && $(tag).find("input").length != 0)
{
var id_d = $(tag).find("input")[0].id.split("_")[1];
var index = get_index(id_d,id_doors,false);
id_doors.splice(index, 1);
}
else if($(tag).find("input").length==0)//为父标签时
{
$($(tag).next()).find("p").each(function(){
get_child(this);
});
}
}
function get_index(num, array, is_emp)
{
for(var i=0;i'+ret_list[i][1]+' | '
+ ''+ret_list[i][2]+' | '
+ ''+ret_list[i][3]+' | '
+ ''+ret_list[i][4]+' | '
+ ''+ret_list[i][5]+' | '
+ ''+ret_list[i][6]+' | '
+ ''+ret_list[i][7]+' | '
+ ''+ret_list[i][8]+' | ';
}
$("#rt_content").prepend(rtlisthtml);
if($("#rt_content tr").length > 5)
{
$("#rt_content").find("tr:gt(5)").remove();
}
}
});
}
{% endblock %}