From d127b647f1a2e8c1c3490af276e97c024d52f904 Mon Sep 17 00:00:00 2001 From: zmk <496160012@qq.com> Date: 星期二, 21 五月 2024 13:14:47 +0800 Subject: [PATCH] 提交代码 --- javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html | 79 ++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 47 deletions(-) diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html index 97525c4..bb22c2e 100644 --- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html +++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html @@ -79,21 +79,9 @@ <div class="form-group"> <label class="col-sm-3 control-label">涓婁紶璇佷欢锛�</label> <div class="col-sm-8"> - <form id="formId" enctype="multipart/form-data"> - <div class="select-list"> - <ul> - <li> - <input type="file" id="file" name="file"/> - </li> - <li> - <a class="btn btn-primary btn-rounded btn-sm" onclick="upload()"><i class="fa fa-upload"></i> 涓婁紶</a> - </li> - </ul> - </div> - </form> + <input type="file" name= "file" id="file"/> </div> </div> - </form> </div> @@ -108,11 +96,41 @@ }); function submitHandler() { + var result = doSubmitFile(); + var documentFile =null; + if(result !=null){ + if(result.code == web_status.SUCCESS){ + documentFile= result.fileName; + } + } if ($.validate.form()) { let formData = $('#form-projectPerson-add').serialize(); - let data = formData + "&projectId=" + projectId; + let data = formData + "&projectId=" + projectId +"&documentPath="+documentFile; $.operate.save(prefix + "/add", data); } + } + //涓婁紶鏂囦欢 + function doSubmitFile(){ + var file = $('#file').val(); + if (file == '' || file ==null){ + return null; + } + var formData = new FormData(); + formData.append("file", $('#file')[0].files[0]); + var data = null; + $.ajax({ + url: ctx + "geo/projectPerson/uploadPersonFile", + data: formData, + cache: false, + contentType: false, + processData: false, + type: 'POST', + async:false, + success: function (result) { + data= result; + } + }); + return data; } $("input[name='inSiteTime']").datetimepicker({ @@ -127,39 +145,6 @@ autoclose: true }); - function upload(){ - var file = $('#file').val(); - if (file == '' || (!$.common.endWith(file, '.png'))){ - $.modal.msgWarning("璇烽�夋嫨寰呬笂浼犵殑鏂囦欢"); - return false; - } - - var formData = new FormData(); - formData.append("file", $('#file')[0].files[0]); - formData.append("projectId", projectId); - $.modal.loading("鏁版嵁涓婁紶瑙f瀽涓�"); - - $.ajax({ - url: ctx + "geo/projectPerson/uploadImg", - data: formData, - cache: false, - contentType: false, - processData: false, - type: 'POST', - success: function (result) { - if (result.code == web_status.SUCCESS) { - $.modal.closeLoading(); - $.modal.alertSuccess(result.msg); - } else if (result.code == web_status.WARNING) { - $.modal.closeLoading(); - $.modal.alertWarning(result.msg) - } else { - $.modal.closeLoading(); - $.modal.alertError(result.msg); - } - } - }); - } </script> </body> </html> \ No newline at end of file -- Gitblit v1.9.1