$(function () { $("#form-projectMatters-edit").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 }, "project_type": { required: true }, "category_id": { required: true }, "project_id": { required: true } }, messages: {}, onkeyup: false, focusCleanup: true, success: "valid" }); }); function submit() { if (!($("#isDraft").val() == 1)) { if ($("#form-projectMatters-edit").valid()) { if($("#fileListPre").find("a[id='fileName']").length == 0){ if (!checkFile()) { return false; } } } else { return false; } } //提交 $("#form-projectMatters-edit").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/69"; //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/69"; //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; }