<%@ page contentType="text/html;charset=UTF-8" %> <%@ include file="/WEB-INF/views/include/taglib.jsp"%> <html> <head> <title></title> <meta name="decorator" content="represent"/> <style type="text/css"> .Wdate{width:100%;} .must-fill{ color: #D7000F; display: inline-block; vertical-align: middle; margin-right: 2px; } .text-filling { color: #FFF; background-color: #D7000F; border: 1px solid #D7000F; } </style> <script type="text/javascript"> $(function(){ //返回 $("#btn-Cancel").unbind().click(function(){ window.location.href="${ctx}/cand/candidate/list?type=${candidate.type}" }) var recommendMode='${candidate.recommendMode}'; if('02'==recommendMode){ methodType(recommendMode); var objList=$.parseJSON('${nominationJson}'); for (var i = 0; i < objList.length; i++) { $("#peopleMessage").append("<input type=\"hidden\" id=\"peopleList\" name=\"peopleList\" value=\""+objList[i].voterRegisterId+"\"/>") } }else if('01'==recommendMode){ methodType(recommendMode); } var id='${candidate.id}'; if(id!=''){ $("input[name='idCardNum']").attr("disabled","true"); } }) //推荐方式 function methodType(recommendMode){ if('02'==recommendMode){ var template=$("#tmplate1").html(); $(".conent").html(null); $(".conent").append(template); }else{ var template=$("#tmplate").html(); $(".conent").html(null); $(".conent").append(template); } } function checkData(){ if($("input[name='state']").val()==''){ //状态:待确认 $("input[name='state']").val('2') } if($("input[name='regionName']").val()==""){ layer.msg("所属区域不能为空", {icon: 2,time:2000}); return false; } if($("input[name='constituencyName']").val()==""){ layer.msg("所属选区不能为空", {icon: 2,time:2000}); return false; } if($("select[name='recommendMode']").val()==""){ layer.msg("推荐方式不能为空", {icon: 2,time:2000}); return false; } if($("input[name='conName']").val()==""){ layer.msg("选区负责人不能为空", {icon: 2,time:2000}); return false; } if($("input[name='name']").val()==""){ layer.msg("候选人姓名不能为空", {icon: 2,time:2000}); return false; } var trm=$('input[name=sex]:checked').val(); if($('input[name=sex]:checked').val()==undefined || $('input[name=sex]:checked').val()==""){ layer.msg("性别不能为空不能为空", {icon: 2,time:2000}); return false; } if($("input[name='idCardNum']").val()==""){ layer.msg("身份证号不能为空", {icon: 2,time:2000}); return false; } var id='${candidate.id}'; if(''==id){ if(isIDCard()){ layer.msg("身份证号已经存在", {icon: 2,time:2000}); return false; } } /* if($("input[name='carryDate']").val()==""){ layer.msg("提名日期不能为空", {icon: 2,time:2000}); return false; } if($("input[name='birthday']").val()==""){ layer.msg("出生日期不能为空", {icon: 2,time:2000}); return false; } if($("#nation").val()==""){ layer.msg("民族不能为空", {icon: 2,time:2000}); return false; } if($("select[name='party']").val()==""){ layer.msg("政治面貌不能为空", {icon: 2,time:2000}); return false; } if($("input[name='workingHours']").val()==""){ layer.msg("参加工作时间不能为空", {icon: 2,time:2000}); return false; } if($("input[name='phone']").val()==""){ layer.msg("联系电话不能为空", {icon: 2,time:2000}); return false; } *//* else{ var checkMobile = /^1[345789]\d{9}$/; if(!checkMobile.test($("#phone").val())){ layer.msg("请正确填写手机号", {icon: 2,time:2000}); return false; } } */ /* if($("input[name='nominationRemarks']").val()==""){ layer.msg("提名推荐理由不能为空", {icon: 2,time:2000}); return false; } */ if(02==$("select[name='recommendMode']").val()){ if($("input[name='peopleList']").length<10){ layer.msg("至少选取十个联名推荐人!", {icon: 2,time:2000}); return false; } } return true; } //提交 function save(){ if(!checkData()){ return false; } // if(isIDCard()){ // layer.msg("身份证号码重复,该用户已存在!", {icon: 2,time:2000}); // return false; // }; var formData = new FormData($("#inputForm")[0]); var loadIndex; $.ajax({ type : 'POST', processData : false, contentType : false, url : '${ctx}/cand/candidate/save', data : formData, dataType: "json", beforeSend : function() { loadIndex=showLoad('正在提交,请稍等...'); }, complete: function () { layer.close(loadIndex); }, success : function(data) { if(data.success==true){ location = "${ctx}/cand/candidate/list?type=${candidate.type}"; layer.msg(data.msg, {icon: 1,time:2000}); }else{ layer.msg(data.msg, {icon: 2,time:2000}); } layer.close(loadIndex); }, error:function(){ layer.msg("请求失败", {icon: 2,time:2000}); layer.close(loadIndex); } }, 'json'); } //所属区域设置 function addressFunc(){ var addressId =$("#areaAddressId").val(); var url="${ctx}/sys/address/regionForm?id"+addressId; var title="所属区域"; var width = '350px'; var height ='400px'; layer.open({ type : 2, title :[title,'background-color:#D7000F;'], shadeClose : false, skin : 'layui-layer-lan', offset : '35px', shade : false, area : [ width, height ], content : url, btn : [ '确定', '取消' ], yes : function(index, layero) { var iframeWin = window[layero.find('iframe')[0]['name']]; var addressData = iframeWin.getAddressData(); var addressName = addressData.provinceName+('' != addressData.cityCode?addressData.cityName:''); addressName+= ('' != addressData.districtCode?addressData.districtName:''); addressName+= ('' != addressData.townCode?addressData.townName:''); $("input[name=areaGroup]").val(addressName); $("input[name=areaAddressCode]").val(addressData.townCode !=''?addressData.townCode:addressData.cityCode); layer.close(index); }, btn2 : function(index, layero) { layer.close(index); } }); } // 人员邀请 function selectUserBtn(){ if($("input[name='constituencyId']").val()==''){ layer.msg("所属选区不能为空", {icon: 2,time:2000}); return false; } layer.open({ type : 2, title :['选择人员','background-color:#D7000F;'], shadeClose : false, skin : 'layui-layer-lan', offset : '35px', shade : false, area : [ '1000px', '550px' ], content : '${ctx}/cand/candidate/selectUserIndex?constituencyId='+$("input[name='constituencyId']").val()+'&nameList='+getTableData().nameList, btn : [ '保存', '取消' ], yes : function(index, layero) { var iframeWin=window[layero.find('iframe')[0]['name']]; var json=iframeWin.getData(); appendData(json); layer.closeAll(); }, btn2 : function(index, layero) { layer.close(index); } }); } // 追加页面信息 function appendData(obj){ var idList=obj.idList; var resultList = getTableData().idList; if(idList.length==0){ return false; } if(resultList.length>0){ for (var i=0;i<idList.length;i++) { if(resultList.indexOf(idList[i])>-1){ idList.splice(i,1); i--; } } } if(idList.length==0){ return false; } $.ajax({ type : 'POST', url : '${ctx}/cand/candidate/appendData', data : {"idList":idList,"id":obj.constituencyId}, dataType: "json", beforeSend : function() { loadIndex=showLoad('正在提交,请稍等...'); }, complete: function () { layer.close(loadIndex); }, success : function(data) { if(data.success==true){ layer.msg(data.msg, {icon: 1,time:2000}); $.each(data.obj,function(index,value){ $("#peopleMessage").append("<input type=\"hidden\" id=\"peopleList\" name=\"peopleList\" value=\""+value.id+"\"/>") }); addData(data.obj); }else{ layer.msg(data.msg, {icon: 2,time:2000}); } }, error:function(){ layer.msg("请求失败", {icon: 2,time:2000}); } }, 'json'); } // 添加数据 function addData(obj){ var rowCount = $("#listTable tr").length; if(obj.length>0){ for(var i=0;i<obj.length;i++){ var voterRegister=obj[i]; $("#listTable").append("<tr id=\""+voterRegister.id+"\">"+ "<th scope=\"row\">"+ "<div class=\"checkbox checkbox-danger\">"+ "<input type=\"checkbox\" name=\"check\" onclick=\"trCheck()\" value=\""+voterRegister.id+"\" class=\"styled\"/>"+ "<label class=\"checkbox-inline\"></label>"+ "</div>"+ "</th>"+ "<td>"+((rowCount++)+1)+"</td>"+ "<td>"+voterRegister.name+"</td>"+ "<td>"+getDictLabel(${fns:toJson(fns:getDictList('sex'))},voterRegister.sex)+"</td>"+ "<td>"+voterRegister.birthday+"</td>"+ "<td>"+""/* getDictLabel(${fns:toJson(fns:getDictList('political'))},voterRegister.party) */+"</td>"+ "<td>"+voterRegister.workingName+"</td>"+ "</tr>"); } } } // 删除数据 function deleteData(){ $("#delType").val("1"); var list = $("#listTable input[name='check']:checked"); if(list.length==0){ layer.msg("请至少选择一条数据", {icon: 2,time:2000}); return false; } for(var i=0;i<list.length;i++){ $("#listTable tr[id='"+$(list[i]).val()+"']").remove();// 删除数据 $("#peopleMessage input[name='peopleList'][value='"+$(list[i]).val()+"']").remove(); } sortData(); layer.msg("操作成功", {icon: 1,time:2000}); } // 重新排序 function sortData(){ var rowCount = $("#listTable tr").length; for(var i=0;i<rowCount;i++){ var tr= $("#listTable tr").eq(i).find("td").eq(0).text(i+1); } } //全选 function selectCheck(obj){ $("input[name='check']").attr("checked",$(obj).attr("checked")=='checked'?true:false); } //反选、计算 function trCheck(){ if($("input[name='check']").length== $("input[name='check']:checked").length){ $("input[name='all-check']").attr("checked",true) } if( $("input[name='check']").length== $("input[name='check']:not(:checked)").length){ $("input[name='all-check']").attr("checked",false) } } // 获取人员信息 function getTableData(){ var trList = $("#listTable").children("tr"); var idList=[]; var nameList=[]; for(var i=0;i<trList.length;i++){ var id= trList.eq(i).attr("id"); var name= trList.eq(i).find("td").eq(1).text(); idList.push(id); nameList.push(name); } var data={}; data.idList=idList; data.nameList=nameList; return data; } //判断身份证号是否存在 function isIDCard(){ var result=false; var idCardNum = $("input[name='idCardNum']").val(); var type ='${candidate.type}'; var loadIndex; $.ajax({ type : 'POST', async:false, url : '${ctx}/cand/candidate/isIDCard', data : {"idCardNum":idCardNum,"type":type}, dataType: "json", // beforeSend : function() { // loadIndex=showLoad('正在查询,请稍等...'); // }, complete: function () { layer.close(loadIndex); }, success : function(data) { if(data.success==true){ result=true; }else{ result=false; } layer.close(loadIndex); }, error:function(){ layer.msg("请求失败", {icon: 2,time:2000}); layer.close(loadIndex); } }, 'json'); return result; } //信息自动录入 function autoCandidate(){ var result=false; // 身份证号 var idNumber=$("input[name='idCardNum']").val(); if(idNumber==""){ layer.msg("身份证号不能为空 ", {icon: 2,time:2000}); return false; } var loadIndex; $.ajax({ type : 'POST', url : '${ctx}/voter/voterRegister/automaticEntry', data : {"idNumber":idNumber}, dataType: "json", beforeSend : function() { loadIndex=showLoad('正在查询,请稍等...'); }, complete: function () { layer.close(loadIndex); }, success : function(data) { if(data.success==true){ layer.msg("信息获取成功 ", {icon: 1,time:2000}); var voterRegister = data.obj; var candidate=new Object(); $("input[name='constituencyId']").val(voterRegister.workingId); // 所属选区 $("input[name='constituencyName']").val(voterRegister.workingName);// 所属选区 $("input[name='name']").val(voterRegister.name); // 姓名 $("input[name='birthday']").val(getMyDate(voterRegister.birthday)); // 出生日期 $("#nation").val([''+voterRegister.nation+'']).trigger('change'); // 民族 $("#cultureDegree").val([''+voterRegister.education+'']).trigger('change');// 文化程度 $("input[name='phone']").val(voterRegister.phone);// 联系电话 $("input[name='sex'][value='"+voterRegister.sex+"']").prop("checked",'checked'); // 性别 }else{ layer.msg("信息获取失败,请手动输入 ", {icon: 2,time:2000}); } layer.close(loadIndex); }, error:function(){ layer.msg("请求失败", {icon: 2,time:2000}); layer.close(loadIndex); } }, 'json'); return result; } </script> </head> <body> <div id="jerichotab" class="jericho_container"> <form action="" method="post" id="inputForm" class="form-horizontal"> <input type="hidden" name="id" value="${candidate.id }"/> <input type="hidden" name="type" value="${candidate.type }"/> <input type="hidden" name="state" value="${candidate.state }"/> <div style="display: none;" id="peopleMessage"></div> <div class="form_btn_area"> <ul> <li><input type="button" class="jointly btn btn_red" value="提交" onclick="save();"></li> <li><input id="btn-Cancel" type="button" class="btn btn_default" value="返回"></li> </ul> </div> <div class="cont_area"> <div class="container-fluid base_msg"> <div class="col-md-12"> <div class="base_msg_area"> <!-- 左侧表单 --> <div class="col-md-6"> <div class="form_left"> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> <span class="must-fill">*</span>所属区域: </label> <div class="form_input col-sm-8"> <sys:treeselect id="region" name="regionId" value="${candidate.regionId}" labelName="regionName" labelValue="${candidate.regionName}" title="区域" url="/constituency/workingGroup/treeData" cssClass="" notAllowSelectParent="false"/> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> <span class="must-fill">*</span>推荐方式: </label> <div class="form_input col-sm-8"> <select name="recommendMode" class="form-select col-sm-9 padding-none w100" onchange="methodType(this.value);"> <option value="">请选择</option> <c:forEach items="${fns:getDictList('nominate_type')}" var="dict"> <option value="${dict.value }" <c:if test="${null !=candidate.recommendMode && candidate.recommendMode eq dict.value }">selected = "selected"</c:if> >${dict.label }</option> </c:forEach> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> <span class="must-fill">*</span>选区负责人: </label> <div class="form_input col-sm-8"> <input type="text" name="conName" class="form-control" value="${candidate.conName }" placeholder="请填写"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> <span class="must-fill">*</span>性别: </label> <div class="form_input col-sm-8"> <div class="radio-width"> <div class="radio radio-danger"> <input class="radio-template" type="radio" name="sex" value="1" id="man" <c:if test="${null !=candidate.sex && candidate.sex eq 1 }">checked= "checked" </c:if> > <label class="radio-inline" for="man">男</label> </div> <div class="radio radio-danger"> <input class="radio-template" type="radio" name="sex" value="2" id="women" <c:if test="${null !=candidate.sex && candidate.sex eq 2 }">checked= "checked" </c:if> > <label class="radio-inline" for="women">女</label> </div> </div> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> <span class="must-fill">*</span>身份证号: </label> <div class="form_input col-sm-8"> <input type="text" name="idCardNum" class="form-control" value="${candidate.idCardNum }" placeholder="请填写" style="width:75%"> <input type="button" class="btn text-filling" value="一键录入" onclick="autoCandidate()" style="width:23%"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> 民族: </label> <div class="form_input col-sm-8"> <select id="nation" name="nation" class="form-select col-sm-9 padding-none w100" > <option value="">请选择</option> <c:forEach items="${fns:getDictList('rep_nation')}" var="dict"> <option value="${dict.value }" <c:if test="${null !=candidate.nation && candidate.nation eq dict.value }">selected = "selected"</c:if> >${dict.label }</option> </c:forEach> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-2 msg_label padding-none"> 参加工作时间: </label> <div class="form_input col-sm-8"> <input type="text" name="workingHours" class="Wdate" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" nullable="false" star="false" palce="right" value="<fmt:formatDate value="${candidate.workingHours}" pattern="yyyy-MM-dd"/>" placeholder="请选择"> </div> </div> <div class="form-group "> <label class="control-label col-sm-2 msg_label padding-none"> 政治面貌:</label> <div class="form_input col-sm-8"> <select name="party" class="form-select col-sm-12 padding-none"> <option value=''>请选择</option> <c:forEach items="${fns:getDictList('political')}" var="politicalDict"> <option value="${politicalDict.value}" <c:if test="${null != candidate.party && candidate.party eq politicalDict.value}">selected = "selected"</c:if>>${politicalDict.label}</option> </c:forEach> </select> </div> </div> </div> </div> <!-- 右侧表单 --> <div class="col-md-6"> <div class="form_right"> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> <span class="must-fill">*</span>所属选区: </label> <div class="form_input col-sm-8"> <sys:treeselect id="parent" name="constituencyId" value="${candidate.constituencyId}" labelName="constituencyName" labelValue="${candidate.constituencyName}" title="所属选区" url="/constituency/constituency/treeData" cssClass="" allowClear="true"/> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 提名日期: </label> <div class="form_input col-sm-8"> <input type="text" name="carryDate" class="Wdate" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" nullable="false" star="false" palce="right" value="<fmt:formatDate value="${candidate.carryDate}" pattern="yyyy-MM-dd"/>" placeholder="请选择"> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> <span class="must-fill">*</span>候选人姓名: </label> <div class="form_input col-sm-8"> <input type="text" name="name" class="form-control" value="${candidate.name }" placeholder="请填写"> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 出生日期: </label> <div class="form_input col-sm-8"> <input type="text" name="birthday" class="Wdate" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" nullable="false" star="false" palce="right" value="<fmt:formatDate value="${candidate.birthday}" pattern="yyyy-MM-dd"/>" placeholder="请选择"> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 联系电话: </label> <div class="form_input col-sm-8"> <input type="text" name="phone" class="form-control" value="${candidate.phone }" placeholder="请填写"> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 文化程度: </label> <div class="form_input col-sm-8"> <select id="cultureDegree" name="cultureDegree" class="form-select col-sm-9 padding-none w100" > <option value="">请选择</option> <c:forEach items="${fns:getDictList('education')}" var="dict"> <option value="${dict.value }" <c:if test="${null !=candidate.cultureDegree && candidate.cultureDegree eq dict.value }">selected = "selected"</c:if> >${dict.label }</option> </c:forEach> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 职称: </label> <div class="form_input col-sm-8"> <input type="text" name="technicalTitle" class="form-control" value="${candidate.technicalTitle }" placeholder="请填写"> </div> </div> <div class="form-group"> <label class="control-label col-sm-3 msg_label"> 代表构成: </label> <div class="form_input col-sm-8"> <select name="composition" class="form-select col-sm-9 padding-none w100"> <option value="">请选择</option> <c:forEach items="${fns:getDictList('representative_category')}" var="dict"> <option value="${dict.value }" <c:if test="${null !=candidate.composition && candidate.composition eq dict.value }">selected = "selected"</c:if>>${dict.label }</option> </c:forEach> </select> </div> </div> </div> </div> <!-- 整行 --> <div class="col-sm-12"> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 工作单位及职务职称: </label> <div class="form_input col-sm-11 w87"> <input type="text" name="unitposition" class="form-control" value="${candidate.unitposition }"> </div> </div> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 工作简历: </label> <div class="col-sm-9 vitae"> <textarea class="bianji-textarea-l col-sm-12" name="workResume" id="resume" style="min-height: 220px;">${candidate.workResume }</textarea> </div> </div> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 工作表现: </label> <div class="col-sm-9 vitae"> <textarea class="bianji-textarea-l col-sm-12" name="majorShow" id="resume" style="min-height: 220px;">${candidate.majorShow }</textarea> </div> </div> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 提名推荐理由: </label> <%-- <div class="form_input col-sm-11 w87"> <input type="text" name="nominationRemarks" class="form-control" value="${candidate.nominationRemarks }"> </div> --%> <div class="col-sm-9 vitae"> <textarea class="bianji-textarea-l col-sm-12" name="nominationRemarks" id="resume" style="min-height: 220px;">${candidate.nominationRemarks }</textarea> </div> </div> </div> <div class="conent"></div> </div> </div> </div> </div> </form> </div> <script type="text/tmplate" id="tmplate1"> <div class="col-sm-12"> <div class="sc_censusInv"> <ul> <a class="next_page" style='cursor:pointer' href="javascript:void(0);" onclick="selectUserBtn()">选取人员</a> </ul> </div> <div class="col-sm-12 attendance"> <a class="deleteInv_btn" style='cursor:pointer' onclick="deleteData()">删除</a> <div class="table-responsive"> <table class="table table-bordered"> <thead> <tr> <th> <div class="checkbox checkbox-danger"> <input type="checkbox" name="all-check" onclick="selectCheck(this)" class="styled"/> <label class="checkbox-inline"></label> </div> </th> <th>序号</th> <th>姓名</th> <th>性别</th> <th>出生年月</th> <th>政治面貌</th> <th>所在选区</th> </tr> </thead> <tbody id="listTable"> <c:forEach var="list" items="${candidate.nominationRecommends}" varStatus="index"> <tr id="${list.voterRegisterId}"> <th scope="row"> <div class="checkbox checkbox-danger"> <input type="checkbox" name="check" onclick="trCheck()" value="${list.voterRegisterId}" class="styled"/> <label class="checkbox-inline"></label> </div> </th> <td>${index.index+1}</td> <td>${list.name}</td> <td>${fns:getDictLabels(list.sex,"sex","")}</td> <td><fmt:formatDate value="${list.birthday}" pattern="yyyy-MM-dd"/></td> <td>${fns:getDictLabels(list.party,"political","")}</td> <td>${list.constituencyName}</td> </tr> </c:forEach> </tbody> </table> </div> <div class="pagination">${page}</div> </div> </div> </script> <script type="text/tmplate" id="tmplate"> <div class="col-sm-12"> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 提名推荐的政党团体名称: </label> <div class="form_input col-sm-11 w87"> <input type="text" name="nominationGroup" class="form-control" value="${candidate.nominationGroup }"> </div> </div> <div class="form-group"> <label class="control-label col-sm-1 msg_label padding-none"> 选举委员会意见: </label> <div class="form_input col-sm-11 w87"> <input type="text" name="committeeOpinion" class="form-control" value="${candidate.committeeOpinion }"> </div> </div> </div> </script> <script type="text/javascript"> </script> </body> </html>
trigger() 方法触发被选元素的指定事件类型。
经试验$("input[name='nation']").val([''+voterRegister.nation+'']).trigger('change');不起作用;
$("#nation").val([''+voterRegister.nation+'']).trigger('change');则可以。不知道为什么?