/** * 初始化详情对话框 */ var language =$("#language").val() var SysRedPacketRecordInfoDlg = { sysRedPacketRecordInfoData : {}, validateFields: { name: { validators: { notEmpty: { message: '红包名称不能为空' } } }, totalMoney: { validators: { notEmpty: { message: '总金额不能为空' }, regexp: { regexp: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/, message: '金额格式不正确' } } }, effective: { validators: { notEmpty: { message: '有效天数不能为空' }, regexp: { regexp: /^[1-9]\d*$/, message: '有效天数格式不正确' } } } } }; /** * 验证数据是否为空 */ SysRedPacketRecordInfoDlg.validate = function () { $('#sysRedPacketRecordInfoForm').data("bootstrapValidator").resetForm(); $('#sysRedPacketRecordInfoForm').bootstrapValidator('validate'); return $("#sysRedPacketRecordInfoForm").data('bootstrapValidator').isValid(); }; /** * 清除数据 */ SysRedPacketRecordInfoDlg.clearData = function() { this.sysRedPacketRecordInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ SysRedPacketRecordInfoDlg.set = function(key, val) { if(key=="type"){ var type=""; $('input[name="type"]:checked').each(function(){ type=$(this).val(); }); this.sysRedPacketRecordInfoData[key] = type; }else{ this.sysRedPacketRecordInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; } return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ SysRedPacketRecordInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ SysRedPacketRecordInfoDlg.close = function() { parent.layer.close(window.parent.SysRedPacketRecord.layerIndex); } /** * 收集数据 */ SysRedPacketRecordInfoDlg.collectData = function() { this .set('id') .set('money') .set('insertTime') .set('companyId') .set('name') .set('type') .set('totalMoney') .set('laveMoney') .set('startMoney') .set('endMoney') .set('effective') .set('companyType'); } /** * 提交添加 */ SysRedPacketRecordInfoDlg.addSubmit = function() { this.clearData(); this.collectData(); if ($.trim($("#name").val())=="") { Feng.error("红包名称不能为空!"); return; } if ($("#name").val().length > 15){ Feng.info("名称不能超过15个字"); return; } if ($("#totalMoney").val() > 99999999 ){ Feng.info("总金额最多不能超过8位数"); return; } var type =this.sysRedPacketRecordInfoData["type"]; var re = /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/; if (!re.test($("#totalMoney").val())) { Feng.error("请输入正确总金额数!"); return; } if(type==1){ if (!re.test($("#money").val())) { if(language==1){ Feng.error("请输入正确金额数!"); }else if(language==2){ Feng.error("Please enter the correct amount!"); }else { Feng.error("Silakan masukkan jumlah yang tepat!"); } return; } if ($("#money").val() > 999 ){ Feng.info("金额最多不能超过3位数"); return; } if(parseFloat($("#money").val())>parseFloat($("#totalMoney").val())){ Feng.info("每个红包金额不能大于总金额"); return; } }else{ if (!re.test($("#startMoney").val()) || !re.test($("#endMoney").val())) { if(language==1){ Feng.error("请输入正确金额数!"); }else if(language==2){ Feng.error("Please enter the correct amount!"); }else { Feng.error("Silakan masukkan jumlah yang tepat!"); } return; } if(parseFloat($("#endMoney").val())