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/addcopy.html | 165 +++++++++++++++++++++++ javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectPersonServiceImpl.java | 21 --- javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java | 35 +++- javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/edit.html | 45 ++++++ javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/HolePersonController.java | 1 javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html | 18 ++ javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/IProjectPersonService.java | 4 javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/add.html | 79 ++++------ 8 files changed, 282 insertions(+), 86 deletions(-) diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/HolePersonController.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/HolePersonController.java index cd0c283..02129cf 100644 --- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/HolePersonController.java +++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/HolePersonController.java @@ -88,6 +88,7 @@ @ResponseBody public AjaxResult addSave(HolePerson holePerson) { + return toAjax(holePersonService.insertHolePerson(holePerson)); } diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java index 17d7c24..58e2edf 100644 --- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java +++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java @@ -2,15 +2,15 @@ import java.util.List; +import com.javaweb.common.config.Global; +import com.javaweb.common.config.ServerConfig; +import com.javaweb.common.utils.IdGenerate; +import com.javaweb.common.utils.file.FileUploadUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.javaweb.common.annotation.Log; import com.javaweb.common.enums.BusinessType; import com.javaweb.geo.domain.ProjectPerson; @@ -37,6 +37,9 @@ @Autowired private IProjectPersonService projectPersonService; + + @Autowired + private ServerConfig serverConfig; @RequiresPermissions("geo:projectPerson:view") @GetMapping() @@ -87,6 +90,7 @@ @PostMapping("/add") @ResponseBody public AjaxResult addSave(ProjectPerson projectPerson) { + return toAjax(projectPersonService.insertProjectPerson(projectPerson)); } @@ -125,9 +129,24 @@ /** * 涓婁紶鍥剧墖 */ - @PostMapping("/uploadImg") + @PostMapping("/uploadPersonFile") @ResponseBody - public AjaxResult uploadImg(MultipartFile file, HttpServletRequest request){ - return projectPersonService.uploadImg(file,request); + public AjaxResult uploadPersonFile(MultipartFile file, HttpServletRequest request){ + try + { + // 涓婁紶鏂囦欢璺緞 + String filePath = Global.getUploadPath() +"/personfile"; + // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + ajax.put("url", url); + return ajax; + } + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); + } } } diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/IProjectPersonService.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/IProjectPersonService.java index 297c38c..cf1642a 100644 --- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/IProjectPersonService.java +++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/IProjectPersonService.java @@ -63,8 +63,4 @@ */ public int deleteProjectPersonById(String ids); - /** - * 涓婁紶鍥剧墖 - */ - AjaxResult uploadImg(MultipartFile file, HttpServletRequest request); } diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectPersonServiceImpl.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectPersonServiceImpl.java index ae68ff0..ea8a0d4 100644 --- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectPersonServiceImpl.java +++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectPersonServiceImpl.java @@ -104,25 +104,4 @@ return projectPersonMapper.deleteProjectPersonById(ids); } - /** - * 涓婁紶鍥剧墖 - */ - @Override - public AjaxResult uploadImg(MultipartFile file, HttpServletRequest request) { - String originalFilename = file.getOriginalFilename(); - //浼犲叆鐨勯捇瀛旂殑id - String projectId = request.getParameter("projectId"); - - //鑾峰彇鍚庣紑.zip 淇濆瓨鐨勬枃浠跺悕 - String substring = originalFilename.substring(originalFilename.lastIndexOf(".")); - String UID = IdGenerate.nextId(); - String dFileName = UID + substring; - - - - - - - return null; - } } 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 diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/addcopy.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/addcopy.html new file mode 100644 index 0000000..97525c4 --- /dev/null +++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/addcopy.html @@ -0,0 +1,165 @@ +<!DOCTYPE html> +<html lang="zh" xmlns:th="http://www.thymeleaf.org" > +<head> + <th:block th:include="include :: header('鏂板椤圭洰浜哄憳')" /> + <th:block th:include="include :: datetimepicker-css" /> +</head> +<body class="white-bg"> + <div class="wrapper wrapper-content animated fadeInRight ibox-content"> + <form class="form-horizontal m" id="form-projectPerson-add"> + <div class="form-group"> + <label class="col-sm-3 control-label">浜哄憳鍚嶇О锛�</label> + <div class="col-sm-8"> + <input name="name" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">绫诲瀷锛�</label> + <div class="col-sm-8"> + <select name="type" class="form-control m-b" th:with="type=${@dict.getType('project_person_type')}"> + <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> + </select> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">鎵嬫満鍙凤細</label> + <div class="col-sm-8"> + <input name="phone" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">韬唤璇佸彿锛�</label> + <div class="col-sm-8"> + <input name="idCard" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">浜哄憳鍒嗙粍锛�</label> + <div class="col-sm-8"> + <input name="personGroup" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">鑱岃矗锛�</label> + <div class="col-sm-8"> + <input name="responsibility" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">杩涘満鏃堕棿锛�</label> + <div class="col-sm-8"> + <div class="input-group date"> + <span class="input-group-addon"><i class="fa fa-calendar"></i></span> + <input name="inSiteTime" class="form-control" placeholder="yyyy-MM-dd" type="text"> + </div> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">鍑哄満鏃堕棿锛�</label> + <div class="col-sm-8"> + <div class="input-group date"> + <span class="input-group-addon"><i class="fa fa-calendar"></i></span> + <input name="outSiteTime" class="form-control" placeholder="yyyy-MM-dd" type="text"> + </div> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">璇佷欢绫诲瀷锛�</label> + <div class="col-sm-8"> + <input name="documentType" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label class="col-sm-3 control-label">璇佷欢缂栧彿锛�</label> + <div class="col-sm-8"> + <input name="documentCode" class="form-control" type="text"> + </div> + </div> + + <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> + </div> + </div> + + + </form> + </div> + <th:block th:include="include :: footer" /> + <th:block th:include="include :: datetimepicker-js" /> + <script th:inline="javascript"> + var prefix = ctx + "geo/projectPerson" + var projectId = [[${projectId}]]; + + $("#form-projectPerson-add").validate({ + focusCleanup: true + }); + + function submitHandler() { + if ($.validate.form()) { + let formData = $('#form-projectPerson-add').serialize(); + let data = formData + "&projectId=" + projectId; + $.operate.save(prefix + "/add", data); + } + } + + $("input[name='inSiteTime']").datetimepicker({ + format: "yyyy-mm-dd", + minView: "month", + autoclose: true + }); + + $("input[name='outSiteTime']").datetimepicker({ + format: "yyyy-mm-dd", + minView: "month", + 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 diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/edit.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/edit.html index 482bb42..a14508e 100644 --- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/edit.html +++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/edit.html @@ -76,6 +76,14 @@ <input name="documentCode" th:field="*{documentCode}" class="form-control" type="text"> </div> </div> + <div class="form-group"> + <label class="col-sm-3 control-label">涓婁紶璇佷欢锛�</label> + <div class="col-sm-8"> + + <input type="file" name= "file" id="file"/> + + </div> + </div> </form> </div> <th:block th:include="include :: footer" /> @@ -87,9 +95,42 @@ }); function submitHandler() { - if ($.validate.form()) { - $.operate.save(prefix + "/edit", $('#form-projectPerson-edit').serialize()); + 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-edit').serialize(); + let data = formData +"&documentPath="+documentFile; + $.operate.save(prefix + "/edit",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; } diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html index fe78dd4..e2af5b1 100644 --- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html +++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html @@ -122,10 +122,15 @@ title : '璇佷欢缂栧彿', visible: false }, - { - field : 'remark', - title : '澶囨敞' - }, + { + field : 'documentPath', + title : '璇佷欢鐓х墖', + formatter: function(value, row, index) { + return `<a onclick="viewUserFile('${row.documentPath}')" href="#">璇佷欢鐓�</a>`; + } + + }, + { title: '鎿嶄綔', align: 'center', @@ -139,6 +144,11 @@ }; $.table.init(options); }); + //鏌ョ湅璇佷欢鐓х墖 + function viewUserFile(path) { + var filepath = "/bjfw/"+path; + window.open(filepath) + } </script> </body> </html> \ No newline at end of file -- Gitblit v1.9.1