/** * 初始化走访小组配置详情对话框 */ var VisitGroupInfoDlg = { visitGroupInfoData : {}, validateFields: { year: { validators: { notEmpty: { message: '申报年度不能为空' } } }, name:{ validators: { notEmpty: { message: '审核小组不能为空' } } }, } }; /** * 清除数据 */ VisitGroupInfoDlg.clearData = function() { this.visitGroupInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ VisitGroupInfoDlg.set = function(key, val) { this.visitGroupInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ VisitGroupInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ VisitGroupInfoDlg.close = function() { parent.layer.close(window.parent.VisitGroup.layerIndex); } /** * 收集数据 */ VisitGroupInfoDlg.collectData = function() { this .set('id') .set('type') .set('year') .set('name'); } /** * 提交添加 */ VisitGroupInfoDlg.addSubmit = function() { this.clearData(); this.collectData(); if(Feng.isEmptyStr(this.visitGroupInfoData.name)){ Feng.info("核查小组不能为空"); return; } var talentTypeArr = new Array(); var talentTypes = ""; var errorMsg = ""; $(".child").each(function (index){ var talentType = $(this).find("[name='talentType']").val(); if(Feng.isEmptyStr(talentType)){ errorMsg = "人才标签不能为空"; return false; } if(talentTypeArr.indexOf(talentType)>=0){ errorMsg = "存在重复的人才标签"; return false; } var streets = $(this).find("[name='street']").val(); if(Feng.isEmptyStr(streets)){ errorMsg = "核查镇街不能为空"; return false; } talentTypeArr.push(talentType); talentTypes = talentTypes + talentType +"-" + streets.join(",") + ";" }); if(Feng.isNotEmptyStr(errorMsg)){ Feng.info(errorMsg); return; } this.visitGroupInfoData['talentType'] = talentTypes.substring(0,talentTypes.length-1);; if(Feng.isEmptyStr(this.visitGroupInfoData.talentType)){ Feng.error("标签镇街关系不能为空");return ; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/visitGroup/add", function(data){ if(data.code=="200"){ Feng.success(data.msg); window.parent.VisitGroup.table.refresh(); VisitGroupInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(this.visitGroupInfoData); ajax.start(); } /** * 提交修改 */ VisitGroupInfoDlg.editSubmit = function() { this.clearData(); this.collectData(); if (!this.validate()) { return; } if(Feng.isEmptyStr(this.visitGroupInfoData.talentType)){ Feng.error("核查人才标签不能为空");return ; } if(Feng.isEmptyStr(this.visitGroupInfoData.street)){ Feng.error("核查镇街不能为空");return ; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/visitGroup/update", function(data){ if(data.code=="200"){ Feng.success(data.msg); window.parent.VisitGroup.table.refresh(); VisitGroupInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.set(this.visitGroupInfoData); ajax.start(); } /** * 验证数据是否为空 */ VisitGroupInfoDlg.validate = function () { $('#visitGroupInfoForm').data("bootstrapValidator").resetForm(); $('#visitGroupInfoForm').bootstrapValidator('validate'); return $("#visitGroupInfoForm").data('bootstrapValidator').isValid(); } VisitGroupInfoDlg.insertRow = function (){ $("#childData").append("