$(function () { $("#form-projectApplication-add").validate({ rules: { "companyInfo.company_name": { required: true }, "companyInfo.industry_code": { required: true }, "companyInfo.registration_address": { required: true }, "companyInfo.currency_unit": { required: true }, "companyInfo.registration_capital": { required: true, min: 0, max: 999999999.9999, isFloat: true, isFloat4Fn: true }, "companyInfo.legal_representative": { required: true }, "companyInfo.contact": { required: true }, "companyInfo.lr_position": { required: true }, "companyInfo.contact_position": { required: true }, "companyInfo.lr_phone": { required: true, isTel: true }, "companyInfo.contact_phone": { required: true, isTel: true }, "companyInfo.total_assets_currency_unit": { required: true }, "companyInfo.total_assets": { required: true, min: 0, max: 999999999.999999, isFloat: true, isFloat6Fn: true }, "companyInfo.fixed_assets_currency_unit": { required: true }, "companyInfo.fixed_assets": { required: true, min: 0, max: 999999999.999999, isFloat: true, isFloat6Fn: true }, "super_type_name": { required: true }, "category_id": { required: true }, "project_id": { required: true }/*, "project_id" :{ remote : { url: pagePath+"/projectApplication/canApply", type: "get", data: { name: function () { return $("#project_id").val(); } } } }*/ }, messages: { "project_id": { remote: "已经申请过该项目(互斥类),不能重复申请" } }, onkeyup: false, focusCleanup: true, success: "valid" }); }); function submit() { if (!($("#isDraft").val() == 1)) { if ($("#form-projectApplication-add").valid()) { if (!checkFile()) { return false; } } else { return false; } } /*else { //保存草稿 var validateBaseInfo = true; if ($("#project_type").val() == "" || $("#project_id").val() == "") { errorMessage('请选择项目!'); validateBaseInfo = false; } if (!validateBaseInfo) { return false; } }*/ //提交 $("#form-projectApplication-add").ajaxSubmit({ type: 'post', url: pagePath + "/company/projectMatters/save", dataType: "json", success: function (data) { if (data.success) { layer.open({ title: '提示!' , content: data.message , btn: ['确定'] , yes: function (index, layero) { layer.close(index); var index = parent.layer.getFrameIndex(window.name); if (index) { parent.location.reload(); parent.layer.close(index); } else { window.location.href = pagePath + "/home/informList/78"; //history.back(-2); } } , cancel: function () { var index = parent.layer.getFrameIndex(window.name); if (index) { parent.location.reload(); parent.layer.close(index); } else { window.location.href = pagePath + "/home/informList/78"; //history.back(-2); } return true; } }); } else { // $(form).find(":submit").attr("disabled", false); errorMessage(data.message); } }, error: function () { errorMessage('系统错误!'); } }); return false; } //弹出框 function open_dialog(title, url, w, h) { layer_show(title, pagePath + url, w, h); } //添加文件 function addFile(title, url, w, h) { layer_show(title, pagePath + url, w, h); } //添加相应name的文件 function addFileByName(url, obj) { var name = $(obj).next().attr("name"); url += "?fileIdName=" + name; layer_show('添加文件', pagePath + url, 800, 350); } function checkFile() { if ($("#fileListPre").find("input[name='fileDown.file_id']").length == 0) { errorMessage('请上传附件!'); return false; } else { var file_name = $("#fileListPre").find(".info").text(); var file_id = $("#fileListPre").find("input[name='fileDown.file_id']").val(); console.log(file_name); console.log(file_id); if ($.trim(file_name) == "" || $.trim(file_id) == "") { errorMessage('文件未上传完成!'); return false; } } return true; }