guoyujie
3 天以前 bfb2de990eb9cdb3f1bf8dfbdab5135f78b7dc6f
提交 图片上传添加尺寸
4个文件已修改
66 ■■■■ 已修改文件
north-glass-erp/northglass-erp/src/components/sd/order/UploadPicture.vue 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/controller/sd/OrderFileController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/entity/sd/OrderFile.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/service/sd/OrderFileService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 {
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 {
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;
}
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实例以启用CAD栅格化选项。
                CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
                // 设置宽度
                rasterizationOptions.setPageWidth(1000);
                rasterizationOptions.setPageWidth(width);
                // 设置高度
                rasterizationOptions.setPageHeight(700);
                rasterizationOptions.setPageHeight(height);
                // 调用这个setEmbedBackground方法来设置背景色是否不等于输出格式的默认背景色
                //rasterizationOptions.setEmbedBackground(true);
                // 为生成的图像创建一个PngOptions的实例,并将其分配给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>()