var nation=["汉族","回族","阿昌","白族","保安族","布朗族","布依族","朝鲜族","达斡尔族","傣族","德昂族","侗族","东乡族","独龙族","鄂伦春族","俄罗斯族","鄂温克族","高山族","仡佬族","哈尼族","哈萨克族","赫哲族","基诺族","京族","景颇族","柯尔克孜族","拉祜族","黎族","傈僳族","珞巴族","满族","毛南族","门巴族","蒙古族","苗族","仫佬族","纳西族","怒族","普米族","羌族","撒拉族","畲族","水族","塔吉克族","塔塔尔族","土族","土家族","佤族","维吾尔族","乌兹别克族","锡伯族","瑶族","彝族","裕固族","藏族","壮族"];
$("#letteralert .close,.h-letter-modal").click(function(event){
event.preventdefault();
$(".h-letter-modal").css({display:"none"});
$("#letteralert").css({display:"none"});
});
function pagetabhtml(){
var html='';
html='\n' +
' \n' +
' 时间:'+getdate()+' \n' +
' \n' +
' \n' +
' \n' +
'
\n' +
' \n' +
' 信访人或代表人姓名* \n' +
' \n' +
' 性别 \n' +
' \n' +
' \n' +
' 男 \n' +
' 女 \n' +
' \n' +
' \n' +
' 年龄* \n' +
' \n' +
' 民族 \n' +
' \n' +
' \n';
for(var i=0;i'+nation[i]+'\n' ;
}
html+=' \n' +
' \n' +
' \n' +
' \n' +
' 身份证号* \n' +
' \n' +
' 从业状况 \n' +
' \n' +
' \n' +
' 无 \n' +
' 在职 \n' +
' 待业 \n' +
' 自由职业 \n' +
' 其他 \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' 手机号码* \n' +
' \n' +
' 户籍地* \n' +
' \n' +
' \n' +
' \n' +
' 现居住地* \n' +
' \n' +
' 问题属地* \n' +
' \n' +
' \n' +
' \n' +
' 内容分类 \n' +
' \n' +
' \n' +
' 土地承包 \n' +
' 社会保险 \n' +
' 拆迁 \n' +
' 管理 \n' +
' \n' +
' \n' +
' 集体访 \n' +
' \n' +
' 来访人数 \n' +
' \n' +
' \n' +
' \n' +
' 信访事项来源 \n' +
' 网上信访 \n' +
' \n' +
' \n' +
' \n' +
' 主要诉求 \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n' +
'\n' +
' \n' +
' 保存 清除 \n' +
' \n' +
' ';
$(".h-petition-letter>table").html(html);
$("#letterid").blur(function(){
if($(this).val().search(/^(\d{18}|\d{17}x)$/)==-1){
$("#letteralert").removeclass("alert-success").addclass("alert-danger").css({display:"block"});
$("#letteralert>span").html('请填写正确的身份证号');
$(".h-letter-modal").css({display:"block"});
}
});
$("#lettertel").blur(function(){
if($(this).val().search(/^1[3|4|5|8][0-9]\d{4,8}$/)==-1){
$("#letteralert").removeclass("alert-success").addclass("alert-danger").css({display:"block"});
$("#letteralert>span").html('请填写正确的手机号');
$(".h-letter-modal").css({display:"block"});
}
});
$(".h-letter-save").click(function(event){
event.preventdefault();
var flge=1;
var letterarr={};
if(flge){
for(var j=0;j<$(".h-petition-letter tbody tr").length;j++){
for(var k=0;k<$(".h-petition-letter tbody>tr:nth-child("+(j+1)+") td").length;k++){
var ids=$(".h-petition-letter tbody>tr:nth-child("+(j+1)+")>td:nth-child("+(k+1)+")").children();
if(ids.attr("name")){
letterarr[ids.attr("name")]=ids.val();
}
}
}
letterarr["shijian"]=$("#shijian").html();
//letterarr["isvisit"]=$(".h-petition-letter tbody input[type='checkbox']")[0].checked;
if($(".h-petition-letter tbody input[type='checkbox']")[0].checked){
letterarr["isvisit"]='是';
}else{
letterarr["isvisit"]='否';
}
if(letterarr["lettername"]==""||letterarr["letterage"]==""||letterarr["letterid"]==""||letterarr["lettertel"]==""||letterarr["lettercensue"]==""||letterarr["letteraddr"]==""||letterarr["letterissue"]==""||letterarr["lettersource"]==""){
$("#letteralert").removeclass("alert-success").addclass("alert-danger").css({display:"block"});
$("#letteralert>span").html('保存失败! 必填项不能为空!');
$(".h-letter-modal").css({display:"block"});
}else{
datalist = json.stringify({
collective:letterarr.isvisit,
living:letterarr.letteraddr,
age:letterarr.letterage,
contenttype:letterarr.letterctype,
census:letterarr.lettercensue,
appeal:letterarr.lettercont,
idcard:letterarr.letterid,
problemlcal:letterarr.letterissue,
name:letterarr.lettername,
ethnic:letterarr.letternation,
mattersource:letterarr.letterpettype,
employment:letterarr.letterpost,
sex:letterarr.lettersex,
phone:letterarr.lettertel,
time:letterarr.shijian,
visitorsnum:letterarr.visitednum
})
$.ajax({
type:"post",
url:"/pepition/addpepition/",
crossdomain: true,
datatype: "json",
//jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
//jsonpcallback:"flighthandler",//自定义的jsonp回调函数名称,默认为jquery自动生成的随机函数名,也可以写"?",jquery会自动为你处理数据
data:{datalist:datalist},
success:function(obj){
console.info(obj);
$("#letteralert").removeclass("alert-danger").addclass("alert-success").css({display:"block"});
$("#letteralert>span").html('保存成功! ');
$(".h-letter-modal").css({display:"block"});
pagetabhtml();
},
error:function(error){
console.info(error);
}
});
//$("#letteralert").removeclass("alert-danger").addclass("alert-success").css({display:"block"});
//$("#letteralert>span").html('保存成功! ');
//$(".h-letter-modal").css({display:"block"});
//pagetabhtml();
//alert("page_tab.js 149行"+letterarr);
}
}
});
$(".h-letter-clear").click(function(event){
event.preventdefault();
pagetabhtml();
});
}
pagetabhtml();
function getdate() {
var mydate = new date();
var year = mydate.getfullyear();
var month = mydate.getmonth()+1;
var day = mydate.getdate();
if(month < 10){
month = '0'+month;
}
if(day < 10){
day = '0'+day;
}
return year+'-'+month+'-'+day;
}