/** * 初始化购房补助详情对话框 */ var HouseRentingPurchaseFeesInfoDlg = { houseRentingPurchaseFeesInfoData : {}, validateFields: { talentId: {validators: {notEmpty: {message: '申报对象不能为空'}}}, email: {validators: {notEmpty: {message: '电子邮箱不能为空'}}}, houseType: {validators: {notEmpty: {message: '房产人才社区不能为空'}}}, cardType: {validators: {notEmpty: {message: '证件类型不能为空'}}}, idCard: {validators: {notEmpty: {message: '证件号码不能为空'}}}, marryStatus: {validators: {notEmpty: {message: '婚姻状态不能为空'}}}, houseMoney: { validators: { notEmpty: { message: '房产成交金额不能为空' }, regexp :{ regexp: /^([1-9][0-9]*)+(\.[0-9]{1,10})?$/, message:"房产成交金额格式不正确" } } }, } }; /** * 清除数据 */ HouseRentingPurchaseFeesInfoDlg.clearData = function() { this.houseRentingPurchaseFeesInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ HouseRentingPurchaseFeesInfoDlg.set = function(key, val) { this.houseRentingPurchaseFeesInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ HouseRentingPurchaseFeesInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ HouseRentingPurchaseFeesInfoDlg.close = function() { parent.layer.close(window.parent.HouseRentingPurchaseFees.layerIndex); } /** * 收集数据 */ HouseRentingPurchaseFeesInfoDlg.collectData = function() { this .set('id') .set('type') .set('talentId') .set('phone') .set('email') .set('marryStatus') .set('spouseName') .set('spouseSex') .set('spouseCardType') .set('spouseIdCard') .set('spouseTalentArrange') .set('spouseNativePlace') .set('spouseEntryTime') .set('spousePost') .set('spouseEnterpriseName') .set('spouseEnterpriseAddress') .set('spouseAddress') .set('spousePhone') .set('spouseEmail') .set('houseAddress') .set('houseMoney') .set('bankAddress') .set('bankAccount') .set('checkState'); } /** * 验证数据 */ HouseRentingPurchaseFeesInfoDlg.validate = function () { $('#houseRentingPurchaseFeesInfoForm').data("bootstrapValidator").resetForm(); $('#houseRentingPurchaseFeesInfoForm').bootstrapValidator('validate'); return $("#houseRentingPurchaseFeesInfoForm").data('bootstrapValidator').isValid(); } HouseRentingPurchaseFeesInfoDlg.nameChange = function(){ var talentId = $("#talentId").val(); if(Feng.isNotEmptyStr(talentId)){ var ajax = new $ax(Feng.ctxPath + "/api/houseRentingPurchaseFees/initData/"+talentId, function(data){ if(data.code == 200){ var talentInfo = data.obj; $("#sex").val(talentInfo.sex); $("#cardType").val(talentInfo.cardType); $("#idCard").val(talentInfo.idCard); $("#nativePlace").val(talentInfo.nativePlace); $("#talentArrange").val(talentInfo.talentArrange); $("#entryTime").val(talentInfo.entryTime); $("#post").val(talentInfo.post); $("#enterpriseAddress").val(talentInfo.enterpriseAddress); $("#phone").val(talentInfo.phone); $("#email").val(talentInfo.email); $("#marryStatus").val(talentInfo.marryStatus); $("#houseType").val(talentInfo.marryStatus); $("#houseAddress").val(talentInfo.applyAddress); $("#spouseName").val(talentInfo.spouseName); $("#spouseSex").val(talentInfo.spouseSex); $("#spouseCardType").val(talentInfo.spouseCardType); $("#spouseIdCard").val(talentInfo.spouseIdCard); $("#spouseNativePlace").val(talentInfo.spouseNativePlace); $("#spouseTalentArrange").val(talentInfo.spouseTalentArrange); $("#spouseEntryTime").val(talentInfo.spouseEntryTime); $("#spousePost").val(talentInfo.spousePost); $("#spouseEnterpriseName").val(talentInfo.spouseEnterpriseName); $("#spouseEnterpriseAddress").val(talentInfo.spouseEnterpriseAddress); $("#spousePhone").val(talentInfo.spousePhone); $("#spouseEmail").val(talentInfo.spouseEmail); $("#bankAddress").val(talentInfo.bankAddress); $("#bankAccount").val(talentInfo.bankAccount); var html = ""; var options = $("#cardType").html(); for (let key in data.obj.childList){ var child = data.obj.childList[key]; html = html + '
\n' + '\n' + ''+ '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '
'+ '
'; } $("#childData").empty().append(html); $("select[name='childCardType']").each(function () { $(this).val($(this).attr("value")); }) }else{ Feng.info(data.msg); } },function(data){ Feng.error("查询失败!" + data.responseJSON.message + "!"); }); ajax.start(); } } /** * 添加未成年子女 */ HouseRentingPurchaseFeesInfoDlg.addChild = function(){ var options = $("#cardType").html(); $("#childData").append( '
\n' + '\n' + ''+ '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '
'+ '
'); } /** * 删除子女信息 */ HouseRentingPurchaseFeesInfoDlg.reduceChild = function(context){ var id = $(context).parent().find("input[name='id']").val(); if(Feng.isEmptyStr(id)){ $(context).parent().remove(); if($("#childData").children().length == 0){ HouseRentingPurchaseFeesInfoDlg.addChild(); } }else{ if(!validateIsEdit())return; var operation = function () { var ajax = new $ax(Feng.ctxPath + "/api/houseRentingPurchaseFees/deleteChildren", function(data){ if(data.code == 200){ $(context).parent().remove(); Feng.success(data.msg); if($("#childData").children().length == 0){ HouseRentingPurchaseFeesInfoDlg.addChild(); } }else{ Feng.info(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set("id",id); ajax.start(); } Feng.confirm("删除后无法恢复,确认删除吗?", operation); } } /** * 提交添加 */ HouseRentingPurchaseFeesInfoDlg.addSubmit = function() { var id = $("#id").val(); if(Feng.isNotEmptyStr(id)){ HouseRentingPurchaseFeesInfoDlg.editSubmit(1); return; } this.clearData(); this.collectData(); if(!HouseRentingPurchaseFeesInfoDlg.validate()){ return ; } //提交信息 var child = new Array(); var error = ""; $("#childData .col-sm-12").each(function (index) { var id = $(this).find("input[name='id']").val(); var pId = $(this).find("input[name='pId']").val(); var childName = $(this).find("input[name='childName']").val(); var childCardType = $(this).find("select[name='childCardType']").val(); var childIdCard = $(this).find("input[name='childIdCard']").val(); if (Feng.isNotEmptyStr(id) || Feng.isNotEmptyStr(pId) || Feng.isNotEmptyStr(childName) || Feng.isNotEmptyStr(childCardType) || Feng.isNotEmptyStr(childIdCard)){ if(Feng.isEmptyStr(childName)){ error = error + "第"+ (index + 1) + "行未成年子女姓名为空;\n"; } if(Feng.isEmptyStr(childCardType)){ error = error + "第"+ (index + 1) + "行未成年子女证件类型为空;\n"; } if(Feng.isEmptyStr(childIdCard)){ error = error + "第"+ (index + 1) + "行未成年子女证件号码为空;\n"; } child.push({"id":id,"pId":pId,"name":childName,"cardType":childCardType,"idCard":childIdCard}); } }); if (Feng.isNotEmptyStr(error)){ Feng.info(error); return; } this.houseRentingPurchaseFeesInfoData['childList'] = child; var ajax = new $ax(Feng.ctxPath + "/api/houseRentingPurchaseFees/add", function(data){ if(data.code == 200){ var obj = data.obj; var childList = obj.childList; Feng.success(data.msg); $("#id").val(obj.id); $("#type").val(obj.type); $("#fileLi").removeAttr("style"); $("#checkState").val(obj.checkState); HouseRentingPurchaseFeesInfoDlg.initChildData(childList); }else{ Feng.info(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.setcontentType("application/json;charset=utf-8"); ajax.setData(JSON.stringify(this.houseRentingPurchaseFeesInfoData)); ajax.start(); } /** * 提交修改 */ HouseRentingPurchaseFeesInfoDlg.editSubmit = function(type) { this.clearData(); this.collectData(); if(!validateIsEdit())return; if(!HouseRentingPurchaseFeesInfoDlg.validate()){ return ; } //提交信息 var child = new Array(); var error = ""; $("#childData .col-sm-12").each(function (index) { var id = $(this).find("input[name='id']").val(); var pId = $(this).find("input[name='pId']").val(); var childName = $(this).find("input[name='childName']").val(); var childCardType = $(this).find("select[name='childCardType']").val(); var childIdCard = $(this).find("input[name='childIdCard']").val(); if (Feng.isNotEmptyStr(id) || Feng.isNotEmptyStr(pId) || Feng.isNotEmptyStr(childName) || Feng.isNotEmptyStr(childCardType) || Feng.isNotEmptyStr(childIdCard)){ if(Feng.isEmptyStr(childName)){ error = error + "第"+ (index + 1) + "行未成年子女姓名为空;\n"; } if(Feng.isEmptyStr(childCardType)){ error = error + "第"+ (index + 1) + "行未成年子女证件类型为空;\n"; } if(Feng.isEmptyStr(childIdCard)){ error = error + "第"+ (index + 1) + "行未成年子女证件号码为空;\n"; } child.push({"id":id,"pId":pId,"name":childName,"cardType":childCardType,"idCard":childIdCard}); } }); if (Feng.isNotEmptyStr(error)){ Feng.info(error); return; } this.houseRentingPurchaseFeesInfoData['childList'] = child; var ajax = new $ax(Feng.ctxPath + "/api/houseRentingPurchaseFees/update", function(data){ if(data.code == 200){ if(type == 1){ var childList = data.obj.childList; Feng.success(data.msg); HouseRentingPurchaseFeesInfoDlg.initChildData(childList); }else{ HouseRentingPurchaseFeesInfoDlg.submitToCheck(); } }else{ Feng.info(data.msg); } },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.setcontentType("application/json;charset=utf-8"); ajax.setData(JSON.stringify(this.houseRentingPurchaseFeesInfoData)); ajax.start(); } /** * 提交审核 */ HouseRentingPurchaseFeesInfoDlg.submitToCheck = function(){ if(!validateIsEdit())return; var operation = function() { var ajax = new $ax(Feng.ctxPath + "/api/houseRentingPurchaseFees/submitToCheck", function (data) { if(data.code==200){ Feng.success(data.msg); window.parent.HouseRentingPurchaseFees.table.refresh(); HouseRentingPurchaseFeesInfoDlg.close(); }else{ Feng.error(data.msg); } }, function (data) { Feng.error("提交审核失败!" + data.responseJSON.message + "!"); }); ajax.set("id", $("#id").val()); ajax.start(); } Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation); } /** * 校验是否显示按钮 * @param type 类型 1-上传按钮,2-修改删除按钮 * @param row * @returns {string} */ function validUploadButton(type,row,fileId){ var checkState = $("#checkState").val(); if(Feng.isEmptyStr(checkState)||checkState==1 || (checkState == 4 )){ return type == 1? "" : "" + ""; }else{ return type == 1?"":"" ; } } function validateIsEdit(){ var id = $("#id").val(); var checkState = $("#checkState").val(); if(Feng.isEmptyStr(id)){ Feng.info("请先填写基础信息并上传附件"); return false; } if(checkState != 1 && checkState != 4){ Feng.info("正在审核中或已审核完成,无法操作"); return false; } return true; } /** * 初始化子女信息 * @param list */ HouseRentingPurchaseFeesInfoDlg.initChildData = function(list){ var options = $("#cardType").html(); var html = ""; for(var key in list) { html = html + '
\n' + '\n' + '' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '
'+ '
'; } if(Feng.isEmptyStr(html)){ html = html + '
\n' + '\n' + '' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '\n' + '
\n' + '
\n' + '
'; } $("#childData").empty().append(html); $("#childData select").each(function () { $(this).val($(this).attr("value")) }) if(list == null){ HouseRentingPurchaseFeesInfoDlg.addChild(); } } $(function() { Feng.initValidatorTip("houseRentingPurchaseFeesInfoForm", HouseRentingPurchaseFeesInfoDlg.validateFields); //批量加载字典表数据 var arr = [ {"name":"cardType","code":"un_cardType"}, {"name":"talentArrange","code":"un_talentLevel"}, {"name":"houseType","code":"un_renting_houseType"}, {"name":"marryStatus","code":"un_marryStatus"}, {"name":"spouseCardType","code":"un_cardType"}, {"name":"spouseTalentArrange","code":"un_talentLevel"}]; Feng.findChildDictBatch(JSON.stringify(arr)); $("select[name='childCardType']").empty().append($("#cardType").html()); //加载时间控件 $(".date").each(function(){laydate.render({ elem: this,type: 'date',trigger: 'click' }); }); var id = $("#id").val(); if(Feng.isNotEmptyStr(id)){ $("select").each(function () {$(this).val($(this).attr("value")).trigger("change");}); $("#fileLi").removeAttr("style"); Feng.getCheckLog("logTable",{"type":CONFIG.project_renting_purchase_fees,"mainId":id,"typeFileId":"","active":1}) }else{ $("#fileLi").attr("style","pointer-events: none"); } });