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)); } 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()); } } } 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); } 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; } } 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("数据上传解析中"); $.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> javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/addcopy.html
New file @@ -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("数据上传解析中"); $.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> 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,10 +95,43 @@ }); 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; } $("input[name='inSiteTime']").datetimepicker({ javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectPerson/projectPerson.html
@@ -123,9 +123,14 @@ 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>