/** * 初始化人才津贴配置详情对话框 */ var AmountStandardInfoDlg = { amountStandardInfoData : {}, validateFields: { type: { validators: { notEmpty: { message: '人才类型不能为空' } } }, allowanceType: { validators: { notEmpty: { message: '津贴类型不能为空' } } }, talentArrange: { validators: { notEmpty: { message: '人才层次不能为空' } } }, money: { validators: { notEmpty: { message: '津贴类型不能为空' }, regexp :{ regexp: /^\d+$/, message:"只能输入数字" } } } } }; /** * 清除数据 */ AmountStandardInfoDlg.clearData = function() { this.amountStandardInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ AmountStandardInfoDlg.set = function(key, val) { this.amountStandardInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ AmountStandardInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ AmountStandardInfoDlg.close = function() { parent.layer.close(window.parent.AmountStandard.layerIndex); } /** * 收集数据 */ AmountStandardInfoDlg.collectData = function() { this .set('id') .set('type') .set('allowanceType') .set('talentArrange') .set('money') .set('description'); } /** * 验证数据是否为空 */ AmountStandardInfoDlg.validate = function () { $('#amountForm').data("bootstrapValidator").resetForm(); $('#amountForm').bootstrapValidator('validate'); return $("#amountForm").data('bootstrapValidator').isValid(); } /** * 提交添加 */ AmountStandardInfoDlg.addSubmit = function() { this.clearData(); this.collectData(); if (!this.validate()) { return; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/amountStandard/add", function(data){ if(data.code=="200"){ Feng.success(data.msg); window.parent.AmountStandard.table.refresh(); AmountStandardInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(this.amountStandardInfoData); ajax.start(); } /** * 提交修改 */ AmountStandardInfoDlg.editSubmit = function() { this.clearData(); this.collectData(); if (!this.validate()) { return; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/amountStandard/update", function(data){ Feng.success(data.msg); window.parent.AmountStandard.table.refresh(); AmountStandardInfoDlg.close(); },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.set(this.amountStandardInfoData); ajax.start(); } $(function() { Feng.initValidator("amountForm", AmountStandardInfoDlg.validateFields); //下拉框数据动态加载 Feng.addAjaxSelect({ "id": "talentArrange", "displayCode": "code", "displayName": "name", "type": "GET", "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_talentLevel" }); //下拉框数据回显 $("select").each(function () { $(this).val($(this).attr("selectVal")); }); });