From bfb2de990eb9cdb3f1bf8dfbdab5135f78b7dc6f Mon Sep 17 00:00:00 2001
From: guoyujie <guoyujie@ng.com>
Date: 星期二, 23 十二月 2025 11:09:23 +0800
Subject: [PATCH] 提交 图片上传添加尺寸
---
north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java | 6 ++
north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue | 45 +++++++++++++++++++++-
north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java | 13 +++---
north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java | 2 +
4 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue b/north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue
index 7cb8bb5..74fe908 100644
--- a/north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue
+++ b/north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue
@@ -24,6 +24,8 @@
orderId:null,
state:null
})
+let imgWidth = ref(null)
+let imgHeight = ref(null)
const form = reactive({
format: 'png'
@@ -40,6 +42,8 @@
}
result.value = res.data
conversionResult.value = res.data.imageBase64
+ imgWidth.value = res.data.width
+ imgHeight.value = res.data.height
})
}
@@ -107,6 +111,22 @@
ElMessage.warning(t("order.msg.pleaseUploadPicture1"))
return
}
+ if(imgHeight.value ){
+ const regex = /^(0|[1-9]\d{0,2}|1000)$/
+ if(!regex.test(imgHeight.value)){
+ ElMessage.warning(`height:0~1000`)
+ return
+ }
+ }
+
+ if(imgWidth.value ){
+ const regex = /^(0|[1-9]\d{0,2}|1000)$/
+ if(!regex.test(imgWidth.value)){
+ ElMessage.warning(`width:0~1000`)
+ return
+ }
+ }
+
loadingFormats.value = true
converting.value = true
@@ -124,7 +144,9 @@
const data ={
file:fileList.value[0].raw,
- name:fileList.value[0].raw.name
+ name:fileList.value[0].raw.name,
+ width:imgWidth.value || 1000,
+ height:imgHeight.value || 700,
}
request.post(`/orderFile/updateOrderFileByOrderNumber/${props.orderId}/${props.rowIndex.orderNumber}`,data).then(res=>{
if (res.code === '200') {
@@ -244,9 +266,27 @@
{{$t("order.msg.pleaseUploadPicture10")}} <em>{{$t("order.msg.pleaseUploadPicture11")}}</em>
</div>
<template #tip>
+ <div class="el-upload__tip" style="width: 30%;margin-left: 35%">
+ <el-row>
+ <el-col :span="12">
+ <el-input
+ v-model.number="imgWidth"
+ placeholder="瀹�"/>
+ </el-col>
+ <el-col :span="12">
+ <el-input
+ v-model.number="imgHeight"
+ placeholder="楂�"/>
+ </el-col>
+ </el-row>
+ </div>
+
+
+
<div class="el-upload__tip">
{{$t("order.msg.pleaseUploadPicture12")}}
</div>
+
</template>
</el-upload>
@@ -307,7 +347,7 @@
:src="conversionResult"
:preview-src-list="[conversionResult]"
fit="contain"
- style="max-height: 600px;"
+ :style="{width: `${imgWidth}px`, height: `${imgHeight}px`}"
>
<!-- <template #error>-->
<!-- <div class="image-slot">-->
@@ -418,6 +458,7 @@
margin: 20px 0;
display: flex;
justify-content: center;
+ overflow: auto;
}
.file-info {
diff --git a/north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java b/north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java
index 1094e5b..f24ef32 100644
--- a/north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java
+++ b/north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java
@@ -22,10 +22,14 @@
public Result updateOrderFileByOrderNumber(
@RequestParam("file") MultipartFile file,
@RequestParam("name") String name,
+ @RequestParam("width") Float width,
+ @RequestParam("height") Float height,
@PathVariable String orderId,
@PathVariable String orderNumber) throws IOException {
- return Result.success(orderFileService.updateOrderFileByOrderNumber(file,name,orderId,orderNumber));
+ return Result.success(
+ orderFileService.updateOrderFileByOrderNumber(file,name,orderId,orderNumber,width,height)
+ );
}
@PostMapping("/getOrderFilePicture")
public Result getOrderFilePicture(@RequestBody List<Map<String,Object>> orderDetails) throws NoSuchFieldException {
diff --git a/north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java b/north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java
index 944651a..9b391c9 100644
--- a/north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java
+++ b/north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java
@@ -18,6 +18,8 @@
private String fileData;
private String fileJson;
private String imageBase64;
+ private Float width;
+ private Float height;
private LocalDateTime createTime;
}
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java b/north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java
index e15bb07..32b2d37 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java
@@ -53,29 +53,26 @@
return orderFiles;
}
- public Object updateOrderFileByOrderNumber(MultipartFile file,String name,String orderId,String orderNumber) throws IOException {
+ public Object updateOrderFileByOrderNumber(MultipartFile file,String name,String orderId,String orderNumber,Float width,Float height) throws IOException {
//鍒ゆ柇鏄惁瑙勫畾鐨勬牸寮忓悗缂�鍚�
if(!isAllowedFile(name)){
return null;
}
-
try (InputStream is = License.class.getResourceAsStream("/lisence.xml")) {
String base64 = null;
if(name.toLowerCase().endsWith(".dwg")){
-
License license = new License();
license.setLicense(is);
-
// 璋冪敤Image绫荤殑Load鏂规硶鏉ュ姞杞借緭鍏ョ殑DWG鏂囦欢銆�
Image image = Image.load(file.getInputStream());
// 鍒涘缓CadRasterizationOptions瀹炰緥浠ュ惎鐢–AD鏍呮牸鍖栭�夐」銆�
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
// 璁剧疆瀹藉害
- rasterizationOptions.setPageWidth(1000);
+ rasterizationOptions.setPageWidth(width);
// 璁剧疆楂樺害
- rasterizationOptions.setPageHeight(700);
+ rasterizationOptions.setPageHeight(height);
// 璋冪敤杩欎釜setEmbedBackground鏂规硶鏉ヨ缃儗鏅壊鏄惁涓嶇瓑浜庤緭鍑烘牸寮忕殑榛樿鑳屾櫙鑹�
//rasterizationOptions.setEmbedBackground(true);
// 涓虹敓鎴愮殑鍥惧儚鍒涘缓涓�涓狿ngOptions鐨勫疄渚嬶紝骞跺皢鍏跺垎閰嶇粰ImageOptionsBase绫荤殑瀹炰緥銆�
@@ -94,10 +91,12 @@
OrderFile orderFile = new OrderFile();
orderFile.setImageBase64(base64);
- orderFile.setFileName(file.getName());
+ orderFile.setFileName(name);
orderFile.setOrderId(orderId);
orderFile.setOrderNumber(orderNumber);
orderFile.setFileData(Arrays.toString(file.getBytes()));
+ orderFile.setWidth(width);
+ orderFile.setHeight(height);
OrderFile orderFileExist = orderFileMapper
.selectOne(new LambdaQueryWrapper<OrderFile>()
--
Gitblit v1.8.0