/** * 初始化主管部门审核配置详情对话框 */ var TalentcheckpropertiesInfoDlg = { talentcheckpropertiesInfoData : {}, validateFields: { code:{ validators: { notEmpty: { message: '人才标签不能为空' } } }, companyId: { validators: { notEmpty: { message: '审核单位不能为空' } } }, enterpriseId: { validators: { notEmpty: { message: '企业不能为空' } } } } }; /** * 清除数据 */ TalentcheckpropertiesInfoDlg.clearData = function() { this.talentcheckpropertiesInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ TalentcheckpropertiesInfoDlg.set = function(key, val) { this.talentcheckpropertiesInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ TalentcheckpropertiesInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ TalentcheckpropertiesInfoDlg.close = function() { parent.layer.close(window.parent.Talentcheckproperties.layerIndex); } /** * 收集数据 */ TalentcheckpropertiesInfoDlg.collectData = function() { this .set('id') .set('code') .set('enterpriseId') .set('companyId') .set('description'); } /** * 提交添加 */ TalentcheckpropertiesInfoDlg.addSubmit = function() { this.clearData(); this.collectData(); if (!this.validate()) { return; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/add", function(data){ if(data.code==200){ Feng.success(data.msg); window.parent.Talentcheckproperties.table.refresh(); TalentcheckpropertiesInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(this.talentcheckpropertiesInfoData); ajax.start(); } /** * 提交修改 */ TalentcheckpropertiesInfoDlg.editSubmit = function() { this.clearData(); this.collectData(); if (!this.validate()) { return; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/update", function(data){ if(data.code==200){ Feng.success(data.msg); window.parent.Talentcheckproperties.table.refresh(); TalentcheckpropertiesInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.set(this.talentcheckpropertiesInfoData); ajax.start(); } /** * 验证数据是否为空 */ TalentcheckpropertiesInfoDlg.validate = function () { $('#talentcheckpropertiesForm').data("bootstrapValidator").resetForm(); $('#talentcheckpropertiesForm').bootstrapValidator('validate'); return $("#talentcheckpropertiesForm").data('bootstrapValidator').isValid(); } $(function() { Feng.initValidator("talentcheckpropertiesForm", TalentcheckpropertiesInfoDlg.validateFields); //下拉框数据动态加载 Feng.addAjaxSelect({ "id": "code", "displayCode": "code", "displayName": "name", "type": "GET", "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_jbt_talentType" }); //提交信息 var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/init", function(data){ var enterprise = data.enterprises; var company = data.companys; var eHtml,cHtml = ""; for(var key in enterprise){ eHtml = eHtml + "" } for(var key in company){ cHtml = cHtml + "" } $("#companyId").empty().append(cHtml); $("#enterpriseId").empty().append(eHtml); },function(data){ Feng.error("初始失败!" + data.responseJSON.message + "!"); }); ajax.start(); //下拉框数据回显 $("select").each(function () { $(this).val($(this).attr("selectVal")); }); });