From 18c509d71b6b382aa2bf846ba7c9b6d64ade1182 Mon Sep 17 00:00:00 2001
From: suerwei <18810552194@163.com>
Date: 星期二, 02 七月 2024 14:39:02 +0800
Subject: [PATCH] 加上传扫描
---
javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/TubLogController.java | 28 +++++++++
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/add.html | 41 +++++++++++++
javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/domain/TubLog.java | 15 ++++
javaweb-plus/javaweb-cms/src/main/resources/mapper/geo/TubLogMapper.xml | 6 +
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/edit.html | 43 ++++++++++++++
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/TubLog.html | 12 ++++
6 files changed, 141 insertions(+), 4 deletions(-)
diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/TubLogController.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/TubLogController.java
index 6695b35..08a07b3 100644
--- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/TubLogController.java
+++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/TubLogController.java
@@ -2,6 +2,9 @@
import java.util.List;
+import com.javaweb.common.config.Global;
+import com.javaweb.common.config.ServerConfig;
+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;
@@ -18,6 +21,8 @@
import com.javaweb.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
+
/**
* 鏉愭枡鍑哄叆搴撹褰旵ontroller
*
@@ -31,6 +36,9 @@
@Autowired
private ITubLogService tubLogService;
+
+ @Autowired
+ private ServerConfig serverConfig;
@RequiresPermissions("geo:TubLog:view")
@GetMapping()
@@ -147,4 +155,24 @@
return tubLogService.countTubLogDate(projectId);
}
+ /**
+ * 涓婁紶鍥剧墖
+ */
+ @PostMapping("/uploadTubLogFile")
+ @ResponseBody
+ public AjaxResult uploadTubLogFile(MultipartFile file){
+ try {
+ // 涓婁紶鏂囦欢璺緞
+ String filePath = Global.getUploadPath() +"/tublogfile";
+ // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+ 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/domain/TubLog.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/domain/TubLog.java
index 70582ed..8082787 100644
--- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/domain/TubLog.java
+++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/domain/TubLog.java
@@ -62,6 +62,10 @@
@Excel(name = "鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate;
+ /** 鍥剧墖/鎵弿浠惰矾寰� */
+ @Excel(name = "鍥剧墖/鎵弿浠惰矾寰�")
+ private String fileUrl;
+
/** 鍑哄叆搴撴暟閲忕粺璁� */
private Double outboundNumber;
private Double inboundNumber;
@@ -165,7 +169,16 @@
{
return unit;
}
- public void setCreateDate(Date createDate)
+
+ public String getFileUrl() {
+ return fileUrl;
+ }
+
+ public void setFileUrl(String fileUrl) {
+ this.fileUrl = fileUrl;
+ }
+
+ public void setCreateDate(Date createDate)
{
this.createDate = createDate;
}
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/mapper/geo/TubLogMapper.xml b/javaweb-plus/javaweb-cms/src/main/resources/mapper/geo/TubLogMapper.xml
index 650f94b..e4801e7 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/mapper/geo/TubLogMapper.xml
+++ b/javaweb-plus/javaweb-cms/src/main/resources/mapper/geo/TubLogMapper.xml
@@ -17,13 +17,14 @@
<result property="number" column="number" />
<result property="unit" column="unit" />
<result property="createDate" column="create_date" />
+ <result property="fileUrl" column="file_url" />
<result property="remark" column="remark" />
<result property="outboundNumber" column="outbound_number" />
<result property="inboundNumber" column="inbound_number" />
</resultMap>
<sql id="selectTubLogVo">
- select id, code, project_id, tub_name, type, outbound_date, inbound_date, opt_user, apply_user, number, unit, create_date, remark from js_tub_log
+ select id, code, project_id, tub_name, type, outbound_date, inbound_date, opt_user, apply_user, number, unit, create_date, file_url, remark from js_tub_log
</sql>
<select id="selectTubLogList" parameterType="TubLog" resultMap="TubLogResult">
@@ -93,6 +94,7 @@
<if test="number != null ">number,</if>
<if test="unit != null and unit != ''">unit,</if>
<if test="createDate != null ">create_date,</if>
+ <if test="fileUrl != null and fileUrl != ''">file_url,</if>
<if test="remark != null and remark != ''">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -107,6 +109,7 @@
<if test="number != null ">#{number},</if>
<if test="unit != null and unit != ''">#{unit},</if>
<if test="createDate != null ">#{createDate},</if>
+ <if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
<if test="remark != null and remark != ''">#{remark},</if>
</trim>
</insert>
@@ -125,6 +128,7 @@
<if test="number != null ">number = #{number},</if>
<if test="unit != null and unit != ''">unit = #{unit},</if>
<if test="createDate != null ">create_date = #{createDate},</if>
+ <if test="fileUrl != null and fileUrl != ''">file_url = #{fileUrl},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
</trim>
where id = #{id}
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/TubLog.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/TubLog.html
index 434ae3e..381b34c 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/TubLog.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/TubLog.html
@@ -109,6 +109,13 @@
field : 'unit',
title : '鏁版嵁鍗曚綅'
},
+ {
+ field : 'documentPath',
+ title : '鍥剧墖/鎵弿浠�',
+ formatter: function(value, row, index) {
+ return `<a onclick="viewTubLogFile('${row.fileUrl}')" href="#">鍥剧墖/鎵弿浠�</a>`;
+ }
+ },
{
field : 'remark',
title : '澶囨敞'
@@ -133,6 +140,11 @@
window.location.href = ctx + "common/download?fileName=" + encodeURI(filename) + "&delete=" + false;
}
+ //鏌ョ湅璇佷欢鐓х墖
+ function viewTubLogFile(path) {
+ var filepath = "/bjfw/"+path;
+ window.open(filepath)
+ }
</script>
</body>
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/add.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/add.html
index 8ce903c..a747da6 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/add.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/add.html
@@ -67,6 +67,13 @@
<textarea id="remark" name="remark" class="form-control"></textarea>
</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" />
@@ -81,6 +88,14 @@
});
function submitHandler() {
+ var result = doSubmitFile();
+ var documentFile = null;
+ if(result !=null){
+ if(result.code == web_status.SUCCESS){
+ documentFile= result.fileName;
+ }
+ }
+
let inboundDateValue = $("#inboundDateId").val();
let outboundDateValue = $("#outboundDateId").val();
if ($.common.isEmpty(inboundDateValue) && $.common.isEmpty(outboundDateValue)) {
@@ -94,11 +109,35 @@
if ($.validate.form()) {
let formData = $('#form-TubLog-add').serialize();
- let data = formData + "&projectId=" + projectId + "&code=" + code;
+ let data = formData + "&projectId=" + projectId + "&code=" + code +"&fileUrl="+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/TubLog/uploadTubLogFile",
+ data: formData,
+ cache: false,
+ contentType: false,
+ processData: false,
+ type: 'POST',
+ async:false,
+ success: function (result) {
+ data= result;
+ }
+ });
+ return data;
+ }
+
$("input[name='outboundDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/edit.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/edit.html
index d94ea29..f1e4b52 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/edit.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/TubLog/edit.html
@@ -78,6 +78,13 @@
</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" />
@@ -90,6 +97,14 @@
});
function submitHandler() {
+ var result = doSubmitFile();
+ var documentFile =null;
+ if(result !=null){
+ if(result.code == web_status.SUCCESS){
+ documentFile= result.fileName;
+ }
+ }
+
let inboundDateValue = $("#inboundDateId").val();
let outboundDateValue = $("#outboundDateId").val();
if ($.common.isEmpty(inboundDateValue) && $.common.isEmpty(outboundDateValue)) {
@@ -97,10 +112,36 @@
return;
}
if ($.validate.form()) {
- $.operate.save(prefix + "/edit", $('#form-TubLog-edit').serialize());
+ let formData = $('#form-TubLog-edit').serialize();
+ let data = formData +"&fileUrl="+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/TubLog/uploadTubLogFile",
+ data: formData,
+ cache: false,
+ contentType: false,
+ processData: false,
+ type: 'POST',
+ async:false,
+ success: function (result) {
+ data= result;
+ }
+ });
+ return data;
+ }
+
$("input[name='outboundDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
--
Gitblit v1.9.1